From 107ed2cae0a0e05351e6217202734ddbc9b57726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Fri, 14 Mar 2025 14:36:27 +0800 Subject: [PATCH] notice --- internal/biz/order.go | 5 +++++ internal/biz/order_notice.go | 7 ++++--- internal/data/repoimpl/order.go | 2 +- internal/data/wechatrepoimpl/cpn.go | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/biz/order.go b/internal/biz/order.go index d69f49f..3678cab 100644 --- a/internal/biz/order.go +++ b/internal/biz/order.go @@ -262,10 +262,15 @@ func (v *VoucherBiz) Query(ctx context.Context, order *bo.OrderBo) error { func (v *VoucherBiz) UpdateOrderStatus(ctx context.Context, orderId uint64, status vo.OrderStatus) error { if status.IsSuccess() { + return v.OrderRepo.Available(ctx, orderId) + } else if status.IsUse() { + return v.OrderRepo.Used(ctx, orderId) + } else if status.IsExpired() { + return v.OrderRepo.Expired(ctx, orderId) } diff --git a/internal/biz/order_notice.go b/internal/biz/order_notice.go index 513e2f2..85bf662 100644 --- a/internal/biz/order_notice.go +++ b/internal/biz/order_notice.go @@ -2,7 +2,6 @@ package biz import ( "context" - "encoding/json" "fmt" "github.com/go-kratos/kratos/v2/log" "github.com/redis/go-redis/v9" @@ -40,9 +39,12 @@ func (v *VoucherBiz) OrderNotice(ctx context.Context) error { for _, order := range rows { if order.Type.IsCmb() { + if err := v.cmbOrderNotice(ctx, order); err != nil { + log.Errorf("cmbOrderNotice err:%v", err) return err } + } } @@ -133,8 +135,7 @@ func (v *VoucherBiz) cmbOrderNotice(ctx context.Context, order *bo.OrderBo) erro } if reply.RespCode != vo.CmbResponseStatusSuccess.GetValue() { - replyJson, _ := json.Marshal(reply) - return fmt.Errorf("callback notify cmb error,orderNo:%s,resp:%s", order.OrderNo, string(replyJson)) + return fmt.Errorf(reply.RespMsg) } return nil diff --git a/internal/data/repoimpl/order.go b/internal/data/repoimpl/order.go index 7a43665..e45918a 100644 --- a/internal/data/repoimpl/order.go +++ b/internal/data/repoimpl/order.go @@ -33,8 +33,8 @@ func (p *OrderRepoImpl) FindInBatches(ctx context.Context, w *bo.FindInBatchesUs db := p.db.DB(ctx) - db.Where("status = ?", vo.OrderStatusUse) db.Where("type = ?", w.Type) + db.Where("status = ?", vo.OrderStatusUse) db.Where("last_use_time >= ?", w.StartTime) db.Where("last_use_time <= ?", w.EndTime) diff --git a/internal/data/wechatrepoimpl/cpn.go b/internal/data/wechatrepoimpl/cpn.go index d9fc363..38e8543 100644 --- a/internal/data/wechatrepoimpl/cpn.go +++ b/internal/data/wechatrepoimpl/cpn.go @@ -111,6 +111,7 @@ func (c *CpnRepoImpl) Query(ctx context.Context, orderWechat *bo.OrderBo) (vo.Or } if result.Response.StatusCode != CodeSuccess { + return 0, fmt.Errorf("微信返回错误 Response StatusCode[%s]", result.Response.StatusCode) }