query
This commit is contained in:
parent
d094dbd5ff
commit
68b95dc87c
|
|
@ -118,12 +118,7 @@ func (v *VoucherBiz) expired(ctx context.Context, order *bo.OrderBo) error {
|
|||
|
||||
func (v *VoucherBiz) notify(ctx context.Context, order *bo.OrderBo) error {
|
||||
|
||||
if order.Type.IsCmb() {
|
||||
|
||||
return v.cmbNotify(ctx, order.ID)
|
||||
}
|
||||
|
||||
return fmt.Errorf("未知渠道订单类型:%s", order.Type.GetText())
|
||||
return v.cmbNotify(ctx, order.ID)
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) cmbNotify(ctx context.Context, orderId uint64) error {
|
||||
|
|
|
|||
|
|
@ -63,31 +63,32 @@ func (v *VoucherBiz) WechatQuery(ctx context.Context, msg string) error {
|
|||
|
||||
n := 0
|
||||
num := 0
|
||||
notifyNum := 0
|
||||
err := v.OrderRepo.FinSucByStockIdInBatches(ctx, req, func(ctx context.Context, rows []*bo.OrderBo) error {
|
||||
|
||||
n += 1
|
||||
for _, order := range rows {
|
||||
|
||||
num += 1
|
||||
if err := v.wechatQuery(ctx, order); err != nil {
|
||||
if err := v.wechatQuery(ctx, order, ¬ifyNum); err != nil {
|
||||
log.Errorf("微信查询券订单状态发生错误,msg:%s,orderNo:%s,couponId:%s,appId:%s,openId:%s,err:%v",
|
||||
msg, order.OrderNo, order.VoucherNo, order.AppID, order.Account, err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
log.Warnf("微信券查询处理第:%d组,已执行条数:%d,执行开始时间:%s,已耗时:%s", n, num, startStr, time.Now().Sub(start).String())
|
||||
log.Warnf("微信券查询处理第:%d组,已执行条数:%d,核销通知条数:%d,执行开始时间:%s,已耗时:%s", n, num, notifyNum, startStr, time.Now().Sub(start).String())
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
log.Warnf("微信券查询处理耗时:%s,处理%d组,处理%d单,msg:%s", time.Now().Sub(start).String(), n, num, msg)
|
||||
fmt.Printf("微信券查询处理耗时:%s,处理%d组,处理%d单,msg:%s", time.Now().Sub(start).String(), n, num, msg)
|
||||
log.Warnf("微信券查询处理耗时:%s,处理%d组,处理%d单,核销通知条数:%d,msg:%s", time.Now().Sub(start).String(), n, num, notifyNum, msg)
|
||||
fmt.Printf("微信券查询处理耗时:%s,处理%d组,处理%d单,核销通知条数:%d,msg:%s", time.Now().Sub(start).String(), n, num, notifyNum, msg)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) wechatQuery(ctx context.Context, order *bo.OrderBo) error {
|
||||
func (v *VoucherBiz) wechatQuery(ctx context.Context, order *bo.OrderBo, notifyNum *int) error {
|
||||
|
||||
status, err := v.WechatCpnRepo.Query(ctx, order)
|
||||
if err != nil {
|
||||
|
|
@ -95,7 +96,7 @@ func (v *VoucherBiz) wechatQuery(ctx context.Context, order *bo.OrderBo) error {
|
|||
}
|
||||
|
||||
if status.IsUse() {
|
||||
return v.queryUsed(ctx, order)
|
||||
return v.queryUsed(ctx, order, notifyNum)
|
||||
} else if status.IsExpired() {
|
||||
return v.expired(ctx, order)
|
||||
}
|
||||
|
|
@ -103,11 +104,12 @@ func (v *VoucherBiz) wechatQuery(ctx context.Context, order *bo.OrderBo) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) queryUsed(ctx context.Context, order *bo.OrderBo) error {
|
||||
func (v *VoucherBiz) queryUsed(ctx context.Context, order *bo.OrderBo, notifyNum *int) error {
|
||||
|
||||
*notifyNum += 1
|
||||
|
||||
if order.Status.IsUse() {
|
||||
log.Warnf("券状态已是已使用,忽略不处理,orderNo:%s", order.OrderNo)
|
||||
return nil
|
||||
return v.notify(ctx, order)
|
||||
}
|
||||
|
||||
if err := v.OrderRepo.Used(ctx, order.ID); err != nil {
|
||||
|
|
|
|||
|
|
@ -25,3 +25,19 @@ func TestNoticeTime(t *testing.T) {
|
|||
|
||||
t.Logf("startTime:%s,endTime:%s", startTime, endTime)
|
||||
}
|
||||
|
||||
func TestNum(t *testing.T) {
|
||||
useNum := 0
|
||||
used(&useNum)
|
||||
t.Log(useNum)
|
||||
}
|
||||
|
||||
func used(useNum *int) {
|
||||
queryUsed(useNum)
|
||||
queryUsed(useNum)
|
||||
*useNum += 1
|
||||
}
|
||||
|
||||
func queryUsed(useNum *int) {
|
||||
*useNum += 1
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue