From 654540ba65c370f35a425c2cfb64e8affec2008d Mon Sep 17 00:00:00 2001 From: ziming Date: Mon, 15 Dec 2025 15:03:31 +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 --- api/v1/cmb_cpn.proto | 27 ++++++++++++++++++ internal/biz/bo/multi_notify_log_bo.go | 7 +++-- internal/biz/multi.go | 33 +++++++++++++--------- internal/biz/vo/cmb.go | 3 +- internal/data/repoimpl/multi_notify_log.go | 2 +- internal/pkg/cmb/sm2_test.go | 2 +- 6 files changed, 56 insertions(+), 18 deletions(-) diff --git a/api/v1/cmb_cpn.proto b/api/v1/cmb_cpn.proto index ae03540..db0e675 100644 --- a/api/v1/cmb_cpn.proto +++ b/api/v1/cmb_cpn.proto @@ -210,6 +210,7 @@ message CmbNotifyRequest { string ext = 13 [json_name = "ext"]; string attach = 14 [json_name = "attach"]; } + message CmbNotifyReply { // 接口调用返回码,1000 成功,1001 失败 string respCode = 1 [json_name = "respCode"]; @@ -217,6 +218,32 @@ message CmbNotifyReply { string respMsg = 2 [json_name = "respMsg"]; } +message CmbMultiNotifyRequest { + // cmb业务号 + string transactionId = 1 [json_name = "transactionId"]; + // 活动编号 + string activityId = 2 [json_name = "activityId"]; + // 微信券id + string couponId = 3 [json_name = "couponId"]; + // 券领取时间 + string acquiredDate = 4 [json_name = "acquiredDate"]; + // 券状态0:可使用,1:已使用 + string status = 5 [json_name = "status"]; + // 券核销时间 格式:yyyy-MM-dd HH:mm:ss.sss + string transDate = 6 [json_name = "transDate"]; + // 券核销金额,单位-分 + string transAmount = 7 [json_name = "transAmount"]; + // 券核销支付单号,微信支付系统生成的订单号 + string orderId = 8 [json_name = "orderId"]; + // 优惠券券码 codeNo + string ticket = 9 [json_name = "ticket"]; + // 发码机构号,固定值,掌上生活优惠券系统提供 + string orgNo = 10 [json_name = "orgNo"]; + // 500 标识位 + string attach = 12 [json_name = "attach"]; + // 扩展字段 + string ext = 11 [json_name = "ext"]; +} message EncryptBodyRequest { string encryptBody = 1 [json_name = "encryptBody"]; diff --git a/internal/biz/bo/multi_notify_log_bo.go b/internal/biz/bo/multi_notify_log_bo.go index 487ab23..1fb27c9 100644 --- a/internal/biz/bo/multi_notify_log_bo.go +++ b/internal/biz/bo/multi_notify_log_bo.go @@ -1,6 +1,9 @@ package bo -import "time" +import ( + "time" + "voucher/internal/biz/vo" +) // MultiNotifyLogBo 领域实体Bo结构,字段和模型字段保持一致 type MultiNotifyLogBo struct { @@ -12,7 +15,7 @@ type MultiNotifyLogBo struct { ActivityNo string StockID string EventType string - Status string + Status vo.WechatVoucherStatus ConsumeAmount int32 ConsumeTime *time.Time TransactionID string diff --git a/internal/biz/multi.go b/internal/biz/multi.go index 6e71181..20332ea 100644 --- a/internal/biz/multi.go +++ b/internal/biz/multi.go @@ -184,7 +184,7 @@ func (biz *MultiBiz) nlCreate(ctx context.Context, req *bo.WechatVoucherNotifyBo ActivityNo: order.ProductNo, StockID: mnd.StockID, EventType: mnd.EventType, - Status: req.PlainText.Status.GetValue(), + Status: req.PlainText.Status, ConsumeAmount: mnd.ConsumeAmount, ConsumeTime: mnd.ConsumeTime, TransactionID: req.PlainText.ConsumeInformation.TransactionID, @@ -193,10 +193,12 @@ func (biz *MultiBiz) nlCreate(ctx context.Context, req *bo.WechatVoucherNotifyBo OrderCreateTime: order.CreateTime, CouponCreateTime: &req.PlainText.CreateTime, } + request, err := biz.GetRequest(ctx, nl, order) if err != nil { return nil, err } + b, _ := json.Marshal(request) nl.Request = string(b) @@ -205,18 +207,23 @@ func (biz *MultiBiz) nlCreate(ctx context.Context, req *bo.WechatVoucherNotifyBo func (biz *MultiBiz) bizContent(nl *bo.MultiNotifyLogBo, order *bo.OrderBo) (string, error) { - req := &v1.CmbNotifyRequest{ // 待确定 - Ticket: nl.OrderNo, // 券订单号,lsxd订单号 - TransDate: "", // 核销时间,验券时间,格式yyyy-mm-dd hh:mm:ss.sss - Status: "1", // 状态:1-核销成功 - OrgNo: biz.bc.Cmb.OrgNo, // cmb固定值 - Attach: order.Attach, // cmb拓展参数 - Ext: "", + req := &v1.CmbMultiNotifyRequest{ + TransactionId: nl.OutBizNo, // cmb业务号 + ActivityId: nl.ActivityNo, // 批次活动号 + CouponId: nl.CouponID, // 微信券券号 + AcquiredDate: order.ReceiveSuccessTime.Format("2006-01-02 15:04:05.000"), // 券领取时间 + Status: "0", // 券状态 0:可使用,1:已使用 + TransDate: nl.ConsumeTime.Format("2006-01-02 15:04:05.000"), // 核销时间,验券时间,格式yyyy-mm-dd hh:mm:ss.sss + TransAmount: fmt.Sprintf("%d", nl.ConsumeAmount), + OrderId: nl.TransactionID, // 券核销支付单号 + Ticket: nl.OrderNo, // 券订单号,lsxd订单号 + OrgNo: biz.bc.Cmb.OrgNo, // cmb固定值 + Attach: order.Attach, // cmb拓展参数 + Ext: "", } - if nl.ConsumeTime != nil { - req.TransDate = nl.ConsumeTime.Format("2006-01-02 15:04:05.000") - } else { - req.TransDate = nl.CreateTime.Format("2006-01-02 15:04:05.000") + + if nl.Status.IsUsed() { + req.Status = "1" } bizJsonBytes, err := json.Marshal(req) @@ -235,7 +242,7 @@ func (biz *MultiBiz) GetRequest(ctx context.Context, nl *bo.MultiNotifyLogBo, or } request, err := biz.CmbMixRepo.GetRequest(ctx, &bo.CmbRequestBo{ - FuncName: vo.CmbNotifyFuncName, // 待确定 + FuncName: vo.CmbNotifyFuncNameUpdateCodeStatusForMulti, BizContent: bizContent, }) if err != nil { diff --git a/internal/biz/vo/cmb.go b/internal/biz/vo/cmb.go index d89d0b1..3b22bbf 100644 --- a/internal/biz/vo/cmb.go +++ b/internal/biz/vo/cmb.go @@ -5,7 +5,8 @@ type CmbFuncName string const ( // CmbNotifyFuncName . 券状态回调通知方法 - CmbNotifyFuncName CmbFuncName = "updateCodeStatus.json" + CmbNotifyFuncName CmbFuncName = "updateCodeStatus.json" + CmbNotifyFuncNameUpdateCodeStatusForMulti CmbFuncName = "updateCodeStatusForMulti.json" ) func (s CmbFuncName) GetValue() string { diff --git a/internal/data/repoimpl/multi_notify_log.go b/internal/data/repoimpl/multi_notify_log.go index 4a4ccc9..a1d08ea 100644 --- a/internal/data/repoimpl/multi_notify_log.go +++ b/internal/data/repoimpl/multi_notify_log.go @@ -41,7 +41,7 @@ func (p *MultiNotifyLogRepoImpl) Create(ctx context.Context, req *bo.MultiNotify ActivityNo: req.ActivityNo, StockID: req.StockID, EventType: req.EventType, - Status: req.Status, + Status: req.Status.GetValue(), ConsumeAmount: req.ConsumeAmount, ConsumeTime: req.ConsumeTime, TransactionID: req.TransactionID, diff --git a/internal/pkg/cmb/sm2_test.go b/internal/pkg/cmb/sm2_test.go index 511443f..6ba2dc8 100644 --- a/internal/pkg/cmb/sm2_test.go +++ b/internal/pkg/cmb/sm2_test.go @@ -186,7 +186,7 @@ func TestVerifyBody(t *testing.T) { } func TestDecryptBody(t *testing.T) { - //priKey := "f6a8d2f412e289686aba6a0f33cad1a64367d0ba012046ee0fbbefd3ffd675bd" + //priKey := "f6a8d2f412e289686aba6a0f33cad1a64367d0ba012046ee0fbbefd3ffd675bd" // 测试 priKey := "8d39ff3d2559258c163f4510f082727f51531e1953ab203d5ab1ea4a6d94fd73" //content := "BAdcIauIjNx3LsrplpJiZoljE4hCiGHra6ulhgG1qL0tKcAeenX+Z9VaHfXLSdkji1fYBpdZiiI35R0vFtnXPXJCJdHsGbfbae+PzNznYQS3KM8/90Y/FIWzSoszfUiF6fAuv8I6v9kQuqHUTidHeHyICDoyvJ0nhbNyUyg85bAKd6TmkVX1MgXLQ81m|5KfR/5UkpVBEQv1dx+iJbojOykNRuDV8Gsy3QOIlRI+cZvafRRPUUG6eeixnPMumhOvyZwsSG/OBeg0U/lSlAepg12tXWcQ601wjgyLaKN1iMvb1DCtfnJFAm8EWAc2SLH3NQuyhxGe/jgCXvj0wGphh4vBUzm8la8i8Aij0BI5lfgU5OzglkKDln6zHN3vBHDqOurEh18eU6z1bfvNnDpzdwEcygcEIH/6lGiqVnGH+C2+QpcKeCnj5qKGFiuSC"