Merge branch 'pro' into pre

# Conflicts:
#	internal/server/http.go
#	internal/service/cmb.go
This commit is contained in:
ziming 2025-05-06 09:42:12 +08:00
commit c209c645f7
4 changed files with 36 additions and 8 deletions

1
go.sum
View File

@ -133,7 +133,6 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=

View File

@ -268,7 +268,7 @@ func (s *CmbMixRepoImpl) Request(ctx context.Context, req *v1.CmbRequest, uri st
r := uri + "?" + uv.Encode()
_, bodyBytes, err := request.Post(ctx, r, nil, request.WithHeaders(h))
_, bodyBytes, err := request.Post(ctx, r, nil, request.WithHeaders(h), request.WithTimeout(time.Second*20))
if err != nil {
log.Errorf("请求掌上生活报错,url:%s,err:%v", r, err)
return nil, err

View File

@ -39,8 +39,6 @@ func NewHTTPServer(
srv.Route("/voucher/").GET("notifyRetry/{id}", cmb.NotifyRetry)
srv.Route("/voucher/").GET("queryOrder/{order_no}", cmb.QueryOrder)
srv.HandleFunc("/voucher/queryByOrderNo/{order_no}", cmb.QueryByOrderNo)
v1.RegisterCmbHTTPServer(srv, cmb)
return srv

View File

@ -2,9 +2,12 @@ package service
import (
"context"
"fmt"
"github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/transport/http"
"github.com/robfig/cron"
"html/template"
http2 "net/http"
"strconv"
v1 "voucher/api/v1"
"voucher/internal/biz"
"voucher/internal/biz/bo"
@ -22,7 +25,6 @@ type CmbService struct {
VoucherBiz *biz.VoucherBiz
CmbMixRepo mixrepos.CmbMixRepo
WechatCpnRepo wechatrepo.WechatCpnRepo
tmpl *template.Template
}
func NewCmbService(
@ -31,7 +33,6 @@ func NewCmbService(
VoucherBiz *biz.VoucherBiz,
CmbMixRepo mixrepos.CmbMixRepo,
WechatCpnRepo wechatrepo.WechatCpnRepo,
tmpl *template.Template,
) *CmbService {
return &CmbService{
bc: bc,
@ -39,7 +40,6 @@ func NewCmbService(
VoucherBiz: VoucherBiz,
CmbMixRepo: CmbMixRepo,
WechatCpnRepo: WechatCpnRepo,
tmpl: tmpl,
}
}
@ -59,3 +59,34 @@ func (c *CmbService) GetResponse(ctx context.Context, replyBizContent []byte) (*
return reply, nil
}
func (this *CmbService) NotifyRetry(ctx http.Context) error {
id := ctx.Vars().Get("id")
if id == "" {
return fmt.Errorf("id is empty")
}
orderNotifyId, err := strconv.ParseUint(id, 10, 64)
if err != nil {
return err
}
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,
})
}