package timeslicequery import ( "context" "github.com/go-kratos/kratos/v2/log" "voucher/internal/biz/bo" ) func (v *Query) wechatQuery(ctx context.Context, order *bo.OrderBo, notifyNum *int) error { status, err := v.wechatCpnRepo.Query(ctx, order) if err != nil { return err } if status.IsUse() { return v.queryUsed(ctx, order, notifyNum) } else if status.IsExpired() { return v.queryExpired(ctx, order) } return nil } func (v *Query) queryUsed(ctx context.Context, order *bo.OrderBo, notifyNum *int) error { *notifyNum += 1 if order.Status.IsUse() { return v.notify(ctx, order) } if err := v.orderRepo.Used(ctx, order.ID); err != nil { return err } return v.notify(ctx, order) } func (v *Query) queryExpired(ctx context.Context, order *bo.OrderBo) error { if order.Status.IsExpired() { log.Warnf("券状态已是已过期,忽略不处理,orderNo:%s", order.OrderNo) return nil } if err := v.orderRepo.Expired(ctx, order.ID); err != nil { return err } return nil // 过期不做通知 } func (v *Query) notify(ctx context.Context, order *bo.OrderBo) error { order, err := v.orderRepo.GetByID(ctx, order.ID) if err != nil { return err } if _, err = v.cmb.Notify(ctx, order); err != nil { return err } return nil }