diff --git a/internal/biz/warning_budget.go b/internal/biz/warning_budget.go index f2fc2d2..b8e3f7c 100644 --- a/internal/biz/warning_budget.go +++ b/internal/biz/warning_budget.go @@ -98,8 +98,16 @@ func (this *VoucherBiz) cronWarningBudget(ctx context.Context) error { return this.ProductRepo.FindWarningBudget(ctx, func(ctx context.Context, rows []*bo.ProductBo) error { + exist := make(map[string]bool, 0) for _, row := range rows { + _, ok := exist[row.ProductNo] + if ok { + log.Warnf("预警查询,微信批次号%s忽略处理", row.BatchNo) + continue + } + exist[row.ProductNo] = true + if err := this.WarningBudget(ctx, row); err != nil { log.Context(ctx).Errorf("预警查询,处理失败: %s", err) } diff --git a/internal/data/repoimpl/product.go b/internal/data/repoimpl/product.go index d3b377f..a2fb78e 100644 --- a/internal/data/repoimpl/product.go +++ b/internal/data/repoimpl/product.go @@ -37,7 +37,6 @@ func (r *ProductRepoImpl) FindWarningBudget(ctx context.Context, fun func(ctx co nowTime := time.Now().Format(time.DateTime) result := r.db.DB(ctx). - Select("DISTINCT batch_no, product.*"). Where("start_time < ?", nowTime). Where("end_time > ?", nowTime). Where("warning_budget > 0").