From 408a929b33b50da6a1962abdb5f55f5259310e26 Mon Sep 17 00:00:00 2001 From: ziming Date: Mon, 15 Dec 2025 10:42:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E7=AC=94=E7=AB=8B=E5=87=8F=E9=87=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/biz/bo/multi_notify_data_bo.go | 1 + internal/biz/multi.go | 11 ++++++----- internal/biz/wechat_notify.go | 2 +- internal/data/model/multi_notify_data.gen.go | 1 + internal/data/repoimpl/multi_notify_data.go | 1 + internal/service/qixing.go | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/internal/biz/bo/multi_notify_data_bo.go b/internal/biz/bo/multi_notify_data_bo.go index 6779bde..d558e4e 100644 --- a/internal/biz/bo/multi_notify_data_bo.go +++ b/internal/biz/bo/multi_notify_data_bo.go @@ -6,6 +6,7 @@ import "time" type MultiNotifyDataBo struct { ID int64 Source string + IP string NotifyID string OrderNo string OutBizNo string diff --git a/internal/biz/multi.go b/internal/biz/multi.go index c094b97..6e71181 100644 --- a/internal/biz/multi.go +++ b/internal/biz/multi.go @@ -51,7 +51,7 @@ func NewMultiBiz( } } -func (biz *MultiBiz) Notify(ctx context.Context, source string, req *bo.WechatVoucherNotifyBo) error { +func (biz *MultiBiz) Notify(ctx context.Context, ip, source string, req *bo.WechatVoucherNotifyBo) error { cl := vo.MultiNotifyLockKey.BuildCache([]string{ source, @@ -66,7 +66,7 @@ func (biz *MultiBiz) Notify(ctx context.Context, source string, req *bo.WechatVo return err } - if err = biz.Run(ctx, source, req, order); err != nil { + if err = biz.Run(ctx, ip, source, req, order); err != nil { return err } @@ -85,7 +85,7 @@ func (biz *MultiBiz) order(ctx context.Context, req *bo.WechatVoucherNotifyBo) ( return order, nil } -func (biz *MultiBiz) Run(ctx context.Context, source string, req *bo.WechatVoucherNotifyBo, order *bo.OrderBo) error { +func (biz *MultiBiz) Run(ctx context.Context, ip, source string, req *bo.WechatVoucherNotifyBo, order *bo.OrderBo) error { if order.ActivityId == "" { return fmt.Errorf("批次活动ID为空,不是多笔立减金,请检查") @@ -102,7 +102,7 @@ func (biz *MultiBiz) Run(ctx context.Context, source string, req *bo.WechatVouch return nil } } else { - mnd, err = biz.mndCreate(ctx, source, req, order) + mnd, err = biz.mndCreate(ctx, ip, source, req, order) if err != nil { return fmt.Errorf("创建通知数据错误 error: %v", err) } @@ -151,7 +151,7 @@ func (biz *MultiBiz) run(ctx context.Context, req *bo.WechatVoucherNotifyBo, mnd return biz.Request(ctx, mnd, nl, order) } -func (biz *MultiBiz) mndCreate(ctx context.Context, source string, req *bo.WechatVoucherNotifyBo, order *bo.OrderBo) (*bo.MultiNotifyDataBo, error) { +func (biz *MultiBiz) mndCreate(ctx context.Context, ip, source string, req *bo.WechatVoucherNotifyBo, order *bo.OrderBo) (*bo.MultiNotifyDataBo, error) { originalData, err := req.Str() if err != nil { @@ -160,6 +160,7 @@ func (biz *MultiBiz) mndCreate(ctx context.Context, source string, req *bo.Wecha return biz.MultiNotifyDataRepo.Create(ctx, &bo.MultiNotifyDataBo{ Source: source, + IP: ip, NotifyID: req.ID, OrderNo: order.OrderNo, OutBizNo: order.OutBizNo, diff --git a/internal/biz/wechat_notify.go b/internal/biz/wechat_notify.go index 6fd7c74..be88e76 100644 --- a/internal/biz/wechat_notify.go +++ b/internal/biz/wechat_notify.go @@ -23,7 +23,7 @@ func (this *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, re } if order.ActivityId != "" { - return this.MultiBiz.Run(ctx, "lsxd_"+order.MerchantNo, req, order) + return this.MultiBiz.Run(ctx, "127.0.0.1", "lsxd_"+req.PlainText.StockCreatorMchid, req, order) } if req.PlainText.Status.IsSended() { diff --git a/internal/data/model/multi_notify_data.gen.go b/internal/data/model/multi_notify_data.gen.go index 84ba3f2..bffbf9b 100644 --- a/internal/data/model/multi_notify_data.gen.go +++ b/internal/data/model/multi_notify_data.gen.go @@ -13,6 +13,7 @@ const TableNameMultiNotifyDatum = "multi_notify_data" // MultiNotifyDatum mapped from table type MultiNotifyDatum struct { ID int64 `gorm:"column:id;primaryKey" json:"id"` + IP string `gorm:"column:ip;not null;comment:ip" json:"ip"` // ip Source string `gorm:"column:source;not null;comment:来源" json:"source"` // 来源 NotifyID string `gorm:"column:notify_id;not null;comment:回调通知id" json:"notify_id"` // 回调通知id OrderNo string `gorm:"column:order_no;not null;comment:订单号" json:"order_no"` // 订单号 diff --git a/internal/data/repoimpl/multi_notify_data.go b/internal/data/repoimpl/multi_notify_data.go index 2febea8..83a5acd 100644 --- a/internal/data/repoimpl/multi_notify_data.go +++ b/internal/data/repoimpl/multi_notify_data.go @@ -50,6 +50,7 @@ func (p *MultiNotifyDataRepoImpl) Create(ctx context.Context, req *bo.MultiNotif info := &model.MultiNotifyDatum{ Source: req.Source, + IP: req.IP, NotifyID: req.NotifyID, OrderNo: req.OrderNo, OutBizNo: req.OutBizNo, diff --git a/internal/service/qixing.go b/internal/service/qixing.go index cbaa499..134c9c5 100644 --- a/internal/service/qixing.go +++ b/internal/service/qixing.go @@ -79,7 +79,7 @@ func (srv *TripartiteService) QiXingNotify(ctx http.Context) error { return srv.ResponseErr(ctx, fmt.Sprintf("validate wxNotifyData error: %v", err)) } - err = srv.multiBiz.Notify(ctx, "qixing_"+wxNotifyData.PlainText.StockCreatorMchid, wxNotifyData) + err = srv.multiBiz.Notify(ctx, ip, "qixing_"+wxNotifyData.PlainText.StockCreatorMchid, wxNotifyData) if err != nil { log.Errorf("qixing notify run err ip:%s,error:%v,body:%s", ip, err, string(bodyBytes)) return srv.ResponseErr(ctx, err.Error())