From 5bc5bf77dd6cb5631b75b10855d926ac0f41ccff Mon Sep 17 00:00:00 2001 From: ziming Date: Mon, 28 Apr 2025 17:43:48 +0800 Subject: [PATCH] syn notice --- internal/biz/order.go | 19 +++++++++++++++++++ internal/server/http.go | 1 + internal/service/cmb.go | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/internal/biz/order.go b/internal/biz/order.go index 268a5d0..206a896 100644 --- a/internal/biz/order.go +++ b/internal/biz/order.go @@ -265,3 +265,22 @@ func (v *VoucherBiz) UpdateOrderStatus(ctx context.Context, orderId uint64, stat return fmt.Errorf("notice 未知券状态,orderId:%d,statuText:%s", orderId, status.GetText()) } + +func (v *VoucherBiz) QueryOrder(ctx context.Context, orderNo string) (string, error) { + + order, err3 := v.OrderRepo.GetByOrderNo(ctx, orderNo) + if err3 != nil { + return "", err3 + } + + if order == nil || order.ID == 0 { + return "", fmt.Errorf("订单不存在:%s", orderNo) + } + + status, err := v.WechatCpnRepo.Query(ctx, order) + if err != nil { + return "", err + } + + return fmt.Sprintf("orderNo:%s,订单状态:%s,微信查询返回状态:%s", orderNo, order.Status.GetText(), status.GetText()), nil +} diff --git a/internal/server/http.go b/internal/server/http.go index adcfbb3..f47951d 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -37,6 +37,7 @@ func NewHTTPServer( }) srv.Route("/voucher/").GET("notifyRetry/{id}", cmb.NotifyRetry) + srv.Route("/voucher/").GET("query/{order_no}", cmb.QueryOrder) v1.RegisterCmbHTTPServer(srv, cmb) diff --git a/internal/service/cmb.go b/internal/service/cmb.go index 54bea42..2a3043f 100644 --- a/internal/service/cmb.go +++ b/internal/service/cmb.go @@ -6,6 +6,7 @@ import ( "github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/transport/http" "github.com/robfig/cron" + http2 "net/http" "strconv" v1 "voucher/api/v1" "voucher/internal/biz" @@ -72,3 +73,20 @@ func (this *CmbService) NotifyRetry(ctx http.Context) error { return this.VoucherBiz.PushNotifyRetryDelayMQ(ctx, 1, orderNotifyId) } + +func (this *CmbService) QueryOrder(ctx http.Context) error { + + orderNo := ctx.Vars().Get("order_no") + if orderNo == "" { + return fmt.Errorf("orderNo is empty") + } + + str, err := this.VoucherBiz.QueryOrder(ctx, orderNo) + if err != nil { + return err + } + + return ctx.JSON(http2.StatusOK, map[string]interface{}{ + "data": str, + }) +}