From 0c1243419eb9e99b1a0483eea944b207e33cd6d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Fri, 7 Mar 2025 11:29:26 +0800 Subject: [PATCH] cmb --- configs/config.yaml | 2 +- internal/biz/cmb/consume.go | 4 ++-- internal/biz/repo/wechat_notify_register_tag.go | 2 +- internal/data/repoimpl/order.go | 1 + internal/data/repoimpl/product.go | 1 + internal/data/repoimpl/wechat_notify_register_tag.go | 5 +++-- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/configs/config.yaml b/configs/config.yaml index d1262b7..02dd14b 100644 --- a/configs/config.yaml +++ b/configs/config.yaml @@ -21,7 +21,7 @@ data: poolSize: 5 #连接池大小,不配置,或配置为0表示不启用连接池 minIdleConns: 2 #最小空闲连接数 connMaxIdleTime: 30s #每个连接最大空闲时间,如果超过了这个时间会被关闭 - db: 1 + db: 3 rocketMQ: addr: "http://rmq-cn-nwy3fn4ex09.cn-chengdu.rmq.aliyuncs.com:8080" diff --git a/internal/biz/cmb/consume.go b/internal/biz/cmb/consume.go index 25c7e44..83bc22c 100644 --- a/internal/biz/cmb/consume.go +++ b/internal/biz/cmb/consume.go @@ -30,7 +30,7 @@ func (v *Cmb) OrderConsume(ctx context.Context, order *bo.OrderBo) (outRequestNo return } - if err = v.registerNotifyTag(ctx, orderWechat.StockID); err != nil { + if err = v.registerNotifyTag(ctx, orderWechat.StockCreatorMchid, orderWechat.StockID); err != nil { return outRequestNo, err } @@ -46,7 +46,7 @@ func (v *Cmb) OrderConsume(ctx context.Context, order *bo.OrderBo) (outRequestNo return orderWechat.OutRequestNo, err } -func (v *Cmb) registerNotifyTag(ctx context.Context, stockID string) error { +func (v *Cmb) registerNotifyTag(ctx context.Context, stockCreatorMchID, stockID string) error { if err := v.WechatCpnRepo.RegisterNotifyTag(ctx, stockID); err != nil { return err diff --git a/internal/biz/repo/wechat_notify_register_tag.go b/internal/biz/repo/wechat_notify_register_tag.go index b7a3da8..5f07fe5 100644 --- a/internal/biz/repo/wechat_notify_register_tag.go +++ b/internal/biz/repo/wechat_notify_register_tag.go @@ -6,7 +6,7 @@ import ( ) type WechatNotifyRegisterTagRepo interface { - GetByStockIdAndMchId(ctx context.Context, stockId, stockCreatorMchID string) (*bo.WechatNotifyRegisterTagBo, error) + GetByStockIdAndMchId(ctx context.Context, stockCreatorMchID, stockId string) (*bo.WechatNotifyRegisterTagBo, error) Create(ctx context.Context, req *bo.WechatNotifyRegisterTagBo) (*bo.WechatNotifyRegisterTagBo, error) Success(ctx context.Context, id int32) error Fail(ctx context.Context, id int32, remark string) error diff --git a/internal/data/repoimpl/order.go b/internal/data/repoimpl/order.go index 193b6ee..58c9947 100644 --- a/internal/data/repoimpl/order.go +++ b/internal/data/repoimpl/order.go @@ -60,6 +60,7 @@ func (p *OrderRepoImpl) GetByOutBizNo(ctx context.Context, outBizNo string) (*bo if tx.Error != nil { return nil, tx.Error } + if tx.RowsAffected == 0 { return nil, gorm.ErrRecordNotFound } diff --git a/internal/data/repoimpl/product.go b/internal/data/repoimpl/product.go index ebb8e18..b57b60f 100644 --- a/internal/data/repoimpl/product.go +++ b/internal/data/repoimpl/product.go @@ -32,6 +32,7 @@ func (r *ProductRepoImpl) GetByPNO(ctx context.Context, PNO string) (*bo.Product if tx.Error != nil { return nil, tx.Error } + if tx.RowsAffected == 0 { return nil, gorm.ErrRecordNotFound } diff --git a/internal/data/repoimpl/wechat_notify_register_tag.go b/internal/data/repoimpl/wechat_notify_register_tag.go index 2306ea2..37082cb 100644 --- a/internal/data/repoimpl/wechat_notify_register_tag.go +++ b/internal/data/repoimpl/wechat_notify_register_tag.go @@ -27,14 +27,15 @@ func (p *WechatNotifyRegisterTagRepoImpl) DB(ctx context.Context) *gorm.DB { return p.db.DB(ctx).Model(model.WechatNotifyRegisterTag{}) } -func (p *WechatNotifyRegisterTagRepoImpl) GetByStockIdAndMchId(ctx context.Context, stockId, stockCreatorMchID string) (*bo.WechatNotifyRegisterTagBo, error) { +func (p *WechatNotifyRegisterTagRepoImpl) GetByStockIdAndMchId(ctx context.Context, stockCreatorMchID, stockId string) (*bo.WechatNotifyRegisterTagBo, error) { info := &model.WechatNotifyRegisterTag{} - tx := p.DB(ctx).Where(model.WechatNotifyRegisterTag{StockID: stockId, StockCreatorMchID: stockCreatorMchID}).Find(&info) + tx := p.DB(ctx).Where(model.WechatNotifyRegisterTag{StockCreatorMchID: stockCreatorMchID, StockID: stockId}).Find(&info) if tx.Error != nil { return nil, tx.Error } + if tx.RowsAffected == 0 { return nil, gorm.ErrRecordNotFound }