From fb4b094aedbb84751eaabb013d79875e426e1688 Mon Sep 17 00:00:00 2001 From: ziming Date: Fri, 16 May 2025 17:53:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=8E=E9=99=A9=E5=88=A4=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/bo/wechat_notify_register_tag_bo.go | 7 +++++-- internal/biz/order.go | 21 +++++++++---------- .../repoimpl/wechat_notify_register_tag.go | 6 ++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/internal/biz/bo/wechat_notify_register_tag_bo.go b/internal/biz/bo/wechat_notify_register_tag_bo.go index 68a58e2..22531d6 100644 --- a/internal/biz/bo/wechat_notify_register_tag_bo.go +++ b/internal/biz/bo/wechat_notify_register_tag_bo.go @@ -1,6 +1,9 @@ package bo -import "time" +import ( + "time" + "voucher/internal/biz/vo" +) // WechatNotifyRegisterTagBo 领域实体Bo结构,字段和模型字段保持一致 type WechatNotifyRegisterTagBo struct { @@ -8,7 +11,7 @@ type WechatNotifyRegisterTagBo struct { StockID string StockCreatorMchID string Tag string - Status uint8 + Status vo.WechatNotifyRegisterTagStatus Remark string CreateTime *time.Time UpdateTime *time.Time diff --git a/internal/biz/order.go b/internal/biz/order.go index 40e1a79..2f1deaa 100644 --- a/internal/biz/order.go +++ b/internal/biz/order.go @@ -106,17 +106,18 @@ func (v *VoucherBiz) registerNotifyTag(ctx context.Context, stockCreatorMchID, s } if wechatNotifyTag != nil { - if wechatNotifyTag.Tag != v.bc.WechatNotifyMQ.Tag { return fmt.Errorf("tag不一致,请检查tag配置:%s", wechatNotifyTag.Tag) } - return v.setCache(ctx, c, wechatNotifyTag) - } - - wechatNotifyTag, err3 = v.createWechatNotifyRegisterTag(ctx, stockCreatorMchID, stockID) - if err3 != nil { - return err3 + if wechatNotifyTag.Status.IsSuccess() { + return v.setCache(ctx, c, wechatNotifyTag) + } + } else { + wechatNotifyTag, err3 = v.createWechatNotifyRegisterTag(ctx, stockCreatorMchID, stockID) + if err3 != nil { + return err3 + } } if err = v.WechatCpnRepo.RegisterNotifyTag(ctx, stockID); err != nil { @@ -150,12 +151,10 @@ func (v *VoucherBiz) setCache(ctx context.Context, c *vo.Cache, wechatNotifyTag } func (v *VoucherBiz) ing(ctx context.Context, id uint64) error { - return v.OrderRepo.Ing(ctx, id) } func (v *VoucherBiz) success(ctx context.Context, order *bo.OrderBo, voucherNo string) error { - return v.OrderRepo.Success(ctx, order.ID, voucherNo) } @@ -164,8 +163,8 @@ func (v *VoucherBiz) fail(ctx context.Context, order *bo.OrderBo, remark string) if err := v.OrderRepo.Fail(ctx, order.ID, remark); err != nil { return err } - - return v.alarm(ctx, order, remark) + return nil + //return v.alarm(ctx, order, remark) } func (v *VoucherBiz) alarm(ctx context.Context, order *bo.OrderBo, errMsg string) error { diff --git a/internal/data/repoimpl/wechat_notify_register_tag.go b/internal/data/repoimpl/wechat_notify_register_tag.go index 10a5feb..d26e6f7 100644 --- a/internal/data/repoimpl/wechat_notify_register_tag.go +++ b/internal/data/repoimpl/wechat_notify_register_tag.go @@ -71,8 +71,7 @@ func (p *WechatNotifyRegisterTagRepoImpl) Success(ctx context.Context, id int32) res := p.DB(ctx). Where(model.WechatNotifyRegisterTag{ - ID: id, - Status: vo.WechatNotifyRegisterTagStatusWait.GetValue(), + ID: id, }). Updates(model.WechatNotifyRegisterTag{ Status: vo.WechatNotifyRegisterTagStatusSuccess.GetValue(), @@ -99,8 +98,7 @@ func (p *WechatNotifyRegisterTagRepoImpl) Fail(ctx context.Context, id int32, re res := p.DB(ctx). Where(model.WechatNotifyRegisterTag{ - ID: id, - Status: vo.WechatNotifyRegisterTagStatusWait.GetValue(), + ID: id, }). Updates(model.WechatNotifyRegisterTag{ Status: vo.WechatNotifyRegisterTagStatusFail.GetValue(),