diff --git a/internal/biz/multi.go b/internal/biz/multi.go index 7fef2f0..f88489e 100644 --- a/internal/biz/multi.go +++ b/internal/biz/multi.go @@ -7,6 +7,7 @@ import ( "fmt" "github.com/go-kratos/kratos/v2/log" "gorm.io/gorm" + "time" v1 "voucher/api/v1" "voucher/internal/biz/bo" "voucher/internal/biz/cmb" @@ -178,6 +179,11 @@ func (biz *MultiBiz) bizContent(nl *bo.MultiNotifyLogBo) (string, error) { //Attach: nl.Attach, Ext: "", } + if nl.ConsumeTime != nil { + req.TransDate = nl.ConsumeTime.Format("2006-01-02 15:04:05.000") + } else { + req.TransDate = time.Now().Format("2006-01-02 15:04:05.000") + } bizJsonBytes, err := json.Marshal(req) if err != nil { @@ -208,7 +214,11 @@ func (biz *MultiBiz) GetRequest(ctx context.Context, nl *bo.MultiNotifyLogBo) (* func (biz *MultiBiz) Request(ctx context.Context, mmd *bo.MultiNotifyDataBo, nl *bo.MultiNotifyLogBo) error { if nl.RequestURL == "" { - return biz.notifyFail(ctx, nl, "回调通知招行地址为空") + if err := biz.notifyFail(ctx, nl, "回调通知招行地址为空"); err != nil { + return err + } + // 回调通知地址为空,不反回错误,不做再次通知处理 + return nil } request, err := biz.GetRequest(ctx, nl) @@ -225,7 +235,7 @@ func (biz *MultiBiz) Request(ctx context.Context, mmd *bo.MultiNotifyDataBo, nl } if err = biz.CmbMixRepo.VerifyResponse(ctx, reply); err != nil { - errMsg := fmt.Sprintf("回调通知招行返回验证结果发生错误,rep:%+v error:%s", reply, err.Error()) + errMsg := fmt.Sprintf("回调通知招行返回验证结果发生错误,resp:%+v error:%s", reply, err.Error()) if err2 := biz.notifyFail(ctx, nl, errMsg); err2 != nil { return err2 } diff --git a/internal/biz/wechat_notify.go b/internal/biz/wechat_notify.go index c939be8..6fd7c74 100644 --- a/internal/biz/wechat_notify.go +++ b/internal/biz/wechat_notify.go @@ -37,7 +37,6 @@ func (this *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, re } else if req.PlainText.Status.IsExpired() { return this.expired(ctx, order) - } return fmt.Errorf("未知通知类型:%s", req.PlainText.Status.GetText()) diff --git a/internal/data/repoimpl/multi_notify_data.go b/internal/data/repoimpl/multi_notify_data.go index 95ff99a..4cbe272 100644 --- a/internal/data/repoimpl/multi_notify_data.go +++ b/internal/data/repoimpl/multi_notify_data.go @@ -113,9 +113,7 @@ func (p *MultiNotifyDataRepoImpl) AddNoticeNum(ctx context.Context, id int64) er "update_time": &now, } - tx := p.DB(ctx). - Where("id = ?", id). - Updates(u) + tx := p.DB(ctx).Where("id = ?", id).Updates(u) if tx.Error != nil { return tx.Error diff --git a/internal/pkg/helper/utils_test.go b/internal/pkg/helper/utils_test.go index d09f8d6..04142a2 100644 --- a/internal/pkg/helper/utils_test.go +++ b/internal/pkg/helper/utils_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" "time" - "voucher/internal/biz/do" + "voucher/internal/biz/bo" ) func TestHashMod(t *testing.T) { @@ -82,7 +82,7 @@ func TestLength(t *testing.T) { s := len(jsonStr) t.Log(s) - var notify do.CouponNotification + var notify bo.WechatVoucherNotifyBo err := json.Unmarshal([]byte(jsonStr), ¬ify) if err != nil { panic(err) diff --git a/internal/server/http.go b/internal/server/http.go index 2758dd4..b65e518 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -37,7 +37,7 @@ func NewHTTPServer( return ctx.String(http2.StatusOK, "pong") }) - // 启星 /voucher/qiXing/v1/notify + // 启星(启星-蓝色兄弟立减金代配) /voucher/qiXing/v1/notify srv.Route("/voucher/").POST("qiXing/v1/notify", tripartiteService.QiXingNotify) // 订单通知重试 -- 不健全