This commit is contained in:
ziming 2025-05-21 11:05:16 +08:00
parent f4872bfe74
commit 4de408c547
1 changed files with 34 additions and 24 deletions

View File

@ -34,7 +34,27 @@ func (v *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, req *
return err return err
} }
if req.PlainText.ConsumeInformation.ConsumeTime != "" { if err = v.useLog(ctx, order, req); err != nil {
return err
}
return v.wxToBBUse(ctx, order, req)
} else if req.PlainText.Status.IsExpired() {
return v.expired(ctx, order)
} else {
return fmt.Errorf("未知通知类型:%s", req.PlainText.Status.GetText())
}
})
}
func (v *VoucherBiz) useLog(ctx context.Context, order *bo.OrderBo, req *bo.WechatVoucherNotifyBo) error {
if req.PlainText.ConsumeInformation.ConsumeTime == "" {
return nil
}
useTime, err2 := time.Parse(time.RFC3339, req.PlainText.ConsumeInformation.ConsumeTime) useTime, err2 := time.Parse(time.RFC3339, req.PlainText.ConsumeInformation.ConsumeTime)
if err2 != nil { if err2 != nil {
@ -48,7 +68,7 @@ func (v *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, req *
} }
if useLog == nil { if useLog == nil {
_, err = v.UseLogRepo.Create(ctx, &bo.UseLogBo{ _, err := v.UseLogRepo.Create(ctx, &bo.UseLogBo{
OrderNo: order.OrderNo, OrderNo: order.OrderNo,
Amount: req.PlainText.ConsumeInformation.ConsumeAmount, Amount: req.PlainText.ConsumeInformation.ConsumeAmount,
Type: vo.UseLogTypeUsed, Type: vo.UseLogTypeUsed,
@ -58,18 +78,8 @@ func (v *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, req *
return err return err
} }
} }
}
return v.wxToBBUse(ctx, order, req) return nil
} else if req.PlainText.Status.IsExpired() {
return v.expired(ctx, order)
} else {
return fmt.Errorf("未知通知类型:%s", req.PlainText.Status.GetText())
}
})
} }
func (v *VoucherBiz) used(ctx context.Context, order *bo.OrderBo) error { func (v *VoucherBiz) used(ctx context.Context, order *bo.OrderBo) error {