多笔立减
This commit is contained in:
parent
9e39917583
commit
21163dc79a
|
|
@ -2,44 +2,43 @@ package biz
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"voucher/internal/biz/bo"
|
|
||||||
"voucher/internal/biz/vo"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *VoucherBiz) OrderRetry(ctx context.Context, outBizNos []string) error {
|
func (this *VoucherBiz) OrderRetry(ctx context.Context, outBizNos []string) error {
|
||||||
|
|
||||||
if len(outBizNos) > 0 {
|
|
||||||
|
|
||||||
for _, outBizNo := range outBizNos {
|
|
||||||
|
|
||||||
order, err := this.OrderRepo.GetByOutBizNo(ctx, vo.OrderTypeCmb, outBizNo)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf(fmt.Sprintf("获取订单%s异常:%v", outBizNo, err))
|
|
||||||
}
|
|
||||||
|
|
||||||
if !order.Status.IsIng() {
|
|
||||||
return fmt.Errorf(fmt.Sprintf("订单%s状态异常:%s", order.OrderNo, order.Status))
|
|
||||||
}
|
|
||||||
|
|
||||||
if err4 := this.orderRetry(ctx, order); err4 != nil {
|
|
||||||
return err4
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
|
||||||
|
|
||||||
return this.OrderRepo.FindIngInBatches(ctx, func(ctx context.Context, rows []*bo.OrderBo) error {
|
//if len(outBizNos) > 0 {
|
||||||
|
//
|
||||||
for _, order := range rows {
|
// for _, outBizNo := range outBizNos {
|
||||||
|
//
|
||||||
if err4 := this.orderRetry(ctx, order); err4 != nil {
|
// order, err := this.OrderRepo.GetByOutBizNo(ctx, vo.OrderTypeCmb, outBizNo)
|
||||||
return err4
|
// if err != nil {
|
||||||
}
|
// return fmt.Errorf(fmt.Sprintf("获取订单%s异常:%v", outBizNo, err))
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return nil
|
// if !order.Status.IsIng() {
|
||||||
})
|
// return fmt.Errorf(fmt.Sprintf("订单%s状态异常:%s", order.OrderNo, order.Status))
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if err4 := this.orderRetry(ctx, order); err4 != nil {
|
||||||
|
// return err4
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return nil
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//return this.OrderRepo.FindIngInBatches(ctx, func(ctx context.Context, rows []*bo.OrderBo) error {
|
||||||
|
//
|
||||||
|
// for _, order := range rows {
|
||||||
|
//
|
||||||
|
// if err4 := this.orderRetry(ctx, order); err4 != nil {
|
||||||
|
// return err4
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return nil
|
||||||
|
//})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,6 @@ package biz
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-kratos/kratos/v2/log"
|
|
||||||
"time"
|
|
||||||
"voucher/internal/biz/bo"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *VoucherBiz) PushWechatRetry(ctx context.Context, batchNo string) error {
|
func (this *VoucherBiz) PushWechatRetry(ctx context.Context, batchNo string) error {
|
||||||
|
|
@ -30,35 +27,36 @@ func (this *VoucherBiz) PushWechatRetry(ctx context.Context, batchNo string) err
|
||||||
|
|
||||||
func (this *VoucherBiz) WechatRetry(ctx context.Context, batchNo string) error {
|
func (this *VoucherBiz) WechatRetry(ctx context.Context, batchNo string) error {
|
||||||
|
|
||||||
start := time.Now()
|
|
||||||
log.Warnf("失败订单重试开始:%s,batchNo:%s", start.String(), batchNo)
|
|
||||||
fmt.Printf("失败订单重试开始:%s,batchNo:%s", start.String(), batchNo)
|
|
||||||
|
|
||||||
num := 0
|
|
||||||
err := this.OrderRepo.FinFailByStockIdInBatches(ctx, batchNo, func(ctx context.Context, rows []*bo.OrderBo) error {
|
|
||||||
|
|
||||||
if len(rows) == 0 {
|
|
||||||
log.Infof("微信查询券订单状态,batchNo[%s],已处理[%d]单,无订单,结束执行", batchNo, num)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
//start := time.Now()
|
||||||
|
//log.Warnf("失败订单重试开始:%s,batchNo:%s", start.String(), batchNo)
|
||||||
for _, order := range rows {
|
//fmt.Printf("失败订单重试开始:%s,batchNo:%s", start.String(), batchNo)
|
||||||
|
//
|
||||||
num += 1
|
//num := 0
|
||||||
if err := this.orderRetry(ctx, order); err != nil {
|
//err := this.OrderRepo.FinFailByStockIdInBatches(ctx, batchNo, func(ctx context.Context, rows []*bo.OrderBo) error {
|
||||||
log.Errorf("失败订单重试发生错误,batchNo:%s,orderNo:%s,appId:%s,openId:%s,err:%v",
|
//
|
||||||
batchNo, order.OrderNo, order.AppID, order.Account, err)
|
// if len(rows) == 0 {
|
||||||
}
|
// log.Infof("微信查询券订单状态,batchNo[%s],已处理[%d]单,无订单,结束执行", batchNo, num)
|
||||||
|
// return nil
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
time.Sleep(1 * time.Second)
|
// for _, order := range rows {
|
||||||
|
//
|
||||||
return nil
|
// num += 1
|
||||||
})
|
// if err := this.orderRetry(ctx, order); err != nil {
|
||||||
|
// log.Errorf("失败订单重试发生错误,batchNo:%s,orderNo:%s,appId:%s,openId:%s,err:%v",
|
||||||
log.Warnf("微信券查询处理耗时:%s,batchNo:%s,处理%d单", time.Now().Sub(start).String(), batchNo, num)
|
// batchNo, order.OrderNo, order.AppID, order.Account, err)
|
||||||
fmt.Printf("微信券查询处理耗时:%s,batchNo:%s,处理%d单", time.Now().Sub(start).String(), batchNo, num)
|
// }
|
||||||
|
//
|
||||||
return err
|
// }
|
||||||
|
//
|
||||||
|
// time.Sleep(1 * time.Second)
|
||||||
|
//
|
||||||
|
// return nil
|
||||||
|
//})
|
||||||
|
//
|
||||||
|
//log.Warnf("微信券查询处理耗时:%s,batchNo:%s,处理%d单", time.Now().Sub(start).String(), batchNo, num)
|
||||||
|
//fmt.Printf("微信券查询处理耗时:%s,batchNo:%s,处理%d单", time.Now().Sub(start).String(), batchNo, num)
|
||||||
|
//
|
||||||
|
//return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,44 +2,43 @@ package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"github.com/go-kratos/kratos/v2/log"
|
|
||||||
"voucher/internal/pkg/rdsmq"
|
"voucher/internal/pkg/rdsmq"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *VoucherService) GetWechatRetryConfig() *rdsmq.ConsumeConfig {
|
func (s *VoucherService) GetWechatRetryConfig() *rdsmq.ConsumeConfig {
|
||||||
|
|
||||||
queue := s.bc.RdsMQ.GetWechatRetry()
|
|
||||||
if queue == nil {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
//queue := s.bc.RdsMQ.GetWechatRetry()
|
||||||
|
//if queue == nil {
|
||||||
if !queue.GetIsOpen() {
|
// return nil
|
||||||
log.Warn(fmt.Sprintf("[%s]RdsMQ is not open", queue.Name))
|
//}
|
||||||
return nil
|
//
|
||||||
}
|
//if !queue.GetIsOpen() {
|
||||||
|
// log.Warn(fmt.Sprintf("[%s]RdsMQ is not open", queue.Name))
|
||||||
return &rdsmq.ConsumeConfig{
|
// return nil
|
||||||
Rdb: s.rdb.Rdb,
|
//}
|
||||||
QueueName: queue.Name,
|
//
|
||||||
NumWorkers: queue.NumWorkers,
|
//return &rdsmq.ConsumeConfig{
|
||||||
WaitTime: queue.GetWaitTime().AsDuration(),
|
// Rdb: s.rdb.Rdb,
|
||||||
RetryNum: queue.RetryNum,
|
// QueueName: queue.Name,
|
||||||
Fn: s.HandleWechatRetry,
|
// NumWorkers: queue.NumWorkers,
|
||||||
Logger: s.logHelper,
|
// WaitTime: queue.GetWaitTime().AsDuration(),
|
||||||
}
|
// RetryNum: queue.RetryNum,
|
||||||
|
// Fn: s.HandleWechatRetry,
|
||||||
|
// Logger: s.logHelper,
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *VoucherService) HandleWechatRetry(ctx context.Context, batchNo string) error {
|
func (s *VoucherService) HandleWechatRetry(ctx context.Context, batchNo string) error {
|
||||||
|
|
||||||
if batchNo == "" {
|
//if batchNo == "" {
|
||||||
s.logHelper.Errorf("RdsMQ keySend error: batchNo is empty")
|
// s.logHelper.Errorf("RdsMQ keySend error: batchNo is empty")
|
||||||
return nil
|
// return nil
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
if err := s.VoucherBiz.WechatRetry(ctx, batchNo); err != nil {
|
//if err := s.VoucherBiz.WechatRetry(ctx, batchNo); err != nil {
|
||||||
s.logHelper.Error(err)
|
// s.logHelper.Error(err)
|
||||||
}
|
//}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue