timeSliceQueryPush

This commit is contained in:
ziming 2025-06-12 14:30:49 +08:00
parent 32c3b6c7a8
commit 21bb6f53eb
4 changed files with 13 additions and 12 deletions

View File

@ -93,6 +93,8 @@ func (v *VoucherBiz) timeSliceQuery(ctx context.Context, startTime, endTime time
end := start.Add(duration) // 计算每次请求的结束时间
if end.After(endTime) {
end = endTime
} else {
end = end.Add(-1 * time.Second)
}
req := &bo.FindInBatchesUseBo{
@ -150,8 +152,7 @@ func (v *VoucherBiz) notice(ctx context.Context, order *bo.OrderBo) error {
}
if order.Status == status {
//log.Warnf("notice 券状态未改变:%s忽略不处理,orderNo:%s", order.Status.GetText(), order.OrderNo)
return nil
return nil // 券状态未改变,忽略不处理
}
event, err := status.GetOrderNotifyEvent()
@ -176,9 +177,8 @@ func (v *VoucherBiz) notice(ctx context.Context, order *bo.OrderBo) error {
func (v *VoucherBiz) cmbNotice(ctx context.Context, order *bo.OrderBo, orderNotify *bo.OrderNotifyBo) error {
if !orderNotify.Event.CanNotify() {
//log.Warnf("notice 券状态:%s忽略不通知,orderNo:%s", orderNotify.Event.GetText(), order.OrderNo)
return nil
if orderNotify.Event.CanNotify() {
return nil // 不可通知,忽略
}
request, err := v.Cmb.NotifyRequest(ctx, order, orderNotify)
@ -188,11 +188,11 @@ func (v *VoucherBiz) cmbNotice(ctx context.Context, order *bo.OrderBo, orderNoti
reply, err := v.CmbMixRepo.Request(ctx, request, order.NotifyUrl)
if err != nil {
return fmt.Errorf("订单定时通知,orderNo:%s,outBizNo:%s,%s", order.OrderNo, order.OutBizNo, err.Error())
return fmt.Errorf("订单定时通知,orderNo:%s,outBizNo:%s,err:%s", order.OrderNo, order.OutBizNo, err.Error())
}
if reply.RespCode != vo.CmbResponseStatusSuccess.GetValue() {
return errors.New("订单定时通知,招行返回" + reply.RespMsg)
return errors.New("订单定时通知,招行返回错误:" + reply.RespMsg)
}
return nil

View File

@ -40,7 +40,7 @@ func (s OrderNotifyEvent) IsExpired() bool {
}
func (s OrderNotifyEvent) CanNotify() bool {
return s.IsSendDEd() || s.IsUsed() || s.IsExpired()
return s.IsSendDEd() || s.IsUsed()
}
var OrderNotifyEventMapCmbStatus = map[OrderNotifyEvent]CmbStatus{

View File

@ -98,13 +98,13 @@ func (p *OrderRepoImpl) FindIngInBatches(ctx context.Context, fun func(ctx conte
return nil
}
func (p *OrderRepoImpl) FindInBatches(ctx context.Context, w *bo.FindInBatchesUseBo, fun func(ctx context.Context, rows []*bo.OrderBo) error) error {
func (p *OrderRepoImpl) FindInBatches(ctx context.Context, req *bo.FindInBatchesUseBo, fun func(ctx context.Context, rows []*bo.OrderBo) error) error {
var results = make([]*model.Order, 0)
result := p.DB(ctx).
Where("status IN (?)", []uint8{vo.OrderStatusSuccess.GetValue(), vo.OrderStatusUse.GetValue()}).
Where("receive_success_time BETWEEN ? AND ?", w.StartTime, w.EndTime).
Where("receive_success_time BETWEEN ? AND ?", req.StartTime, req.EndTime).
FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error {
// tx.RowsAffected 提供当前批处理中记录的计数the count of records in the current batch
// 'batch' 变量表示当前批号the current batch number

View File

@ -72,7 +72,9 @@ func (s *VoucherService) CronOrderNotice(ctx context.Context) error {
}
func (s *VoucherService) OrderNotice(ctx context.Context) {
start := time.Now()
log.Errorf("订单定时通知,执行开始: %v", start.Format(time.DateTime))
if err := s.VoucherBiz.Notice(ctx); err != nil {
log.Errorf("订单定时通知,执行失败: %v", err)
@ -81,11 +83,10 @@ func (s *VoucherService) OrderNotice(ctx context.Context) {
end := time.Now()
elapsed := end.Sub(start)
log.Warnf("订单定时通知,开始执行时间%s,执行结束时间%s,代码块执行耗时: %s", start.Format(time.DateTime), end.Format(time.DateTime), elapsed)
return
}
func (j *VoucherService) GetNotifyRetryConfig() *mq.ConsumerConfig {
elm, ok := j.bc.RocketMQ.EventMap["notifyRetry"]
if !ok {
return nil