From 5256a965d77f119f2ef0e198c8c261271ecd96cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Sat, 8 Mar 2025 16:15:00 +0800 Subject: [PATCH] cmb --- internal/biz/wechat_notify_consume.go | 6 ++++++ internal/server/wechat_notify_consumer.go | 4 ++-- internal/service/wechat_notify_consume.go | 10 ++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/biz/wechat_notify_consume.go b/internal/biz/wechat_notify_consume.go index 4b7d9bf..e884876 100644 --- a/internal/biz/wechat_notify_consume.go +++ b/internal/biz/wechat_notify_consume.go @@ -20,6 +20,10 @@ func (j *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, req * return nil } + //req.PlainText.StockCreatorMchid = "1676203838" + //req.PlainText.StockID = "20215869" + //req.PlainText.CouponID = "96059179220" + orderWechat, err := j.OrderWechatRepo.GetByMSCId(ctx, req.PlainText.StockCreatorMchid, req.PlainText.StockID, req.PlainText.CouponID) if err != nil { return err @@ -43,6 +47,7 @@ func (j *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, req * func (v *VoucherBiz) wechatVoucherUsed(ctx context.Context, orderWechat *bo.OrderWechatBo) error { if orderWechat.Status.IsUse() { + log.Warnf("券状态已是已使用,忽略不处理,orderNo:%s", orderWechat.OrderNo) return nil } @@ -60,6 +65,7 @@ func (v *VoucherBiz) wechatVoucherUsed(ctx context.Context, orderWechat *bo.Orde func (j *VoucherBiz) wechatVoucherExpired(ctx context.Context, orderWechat *bo.OrderWechatBo) error { if orderWechat.Status.IsExpired() { + log.Warnf("券状态已是已过期,忽略不处理,orderNo:%s", orderWechat.OrderNo) return nil } diff --git a/internal/server/wechat_notify_consumer.go b/internal/server/wechat_notify_consumer.go index dd19e32..7337b34 100644 --- a/internal/server/wechat_notify_consumer.go +++ b/internal/server/wechat_notify_consumer.go @@ -77,10 +77,10 @@ func (w *WechatNotifyConsumer) consumeMessages(ctx context.Context, mqConsumer m var handles []string for _, v := range resp.Messages { handles = append(handles, v.ReceiptHandle) - log.Warnf("接收消息成功 wechat notify messageTag:%s, message: %s", v.MessageTag, v.MessageBody) + log.Warnf("微信回调消费接收消息成功 messageTag:%s, message: %s", v.MessageTag, v.MessageBody) if err := w.voucherService.WechatNotifyConsumer(ctx, v.MessageTag, v.MessageBody); err != nil { - log.Errorf("wechat notify messageTag:%s, err:%+v", v.MessageTag, err) + log.Errorf("微信回调消费处理失败err:%+v", err) } } diff --git a/internal/service/wechat_notify_consume.go b/internal/service/wechat_notify_consume.go index 6c161ae..73af37d 100644 --- a/internal/service/wechat_notify_consume.go +++ b/internal/service/wechat_notify_consume.go @@ -3,8 +3,6 @@ package service import ( "context" "encoding/json" - "fmt" - "github.com/go-kratos/kratos/v2/log" "voucher/internal/biz/bo" ) @@ -13,12 +11,8 @@ func (j *VoucherService) WechatNotifyConsumer(ctx context.Context, tag, msg stri var x *bo.WechatVoucherNotifyBo if err := json.Unmarshal([]byte(msg), &x); err != nil { - return fmt.Errorf("consume msg json.Unmarshal error:%s", err.Error()) + return err } - if err := j.VoucherBiz.WechatNotifyConsumer(ctx, tag, x); err != nil { - log.Errorf("WechatNotifyConsumer error:%s", err.Error()) - } - - return nil + return j.VoucherBiz.WechatNotifyConsumer(ctx, tag, x) }