This commit is contained in:
李子铭 2025-03-04 14:54:41 +08:00
parent 064d9b10b7
commit f840cbf0ae
4 changed files with 8 additions and 38 deletions

View File

@ -12,7 +12,7 @@ import (
"voucher/internal/pkg/uid" "voucher/internal/pkg/uid"
) )
func (v *Cmb) CmbOrder(ctx context.Context, req *bo.OrderCreateReqBo) (reps *bo.OrderCreateRepBo, err error) { func (v *Cmb) Order(ctx context.Context, req *bo.OrderCreateReqBo) (reps *bo.OrderCreateRepBo, err error) {
err = lock.NewMutex(v.rdb.Rdb, time.Second*30).Lock(ctx, fmt.Sprintf("cmb_order_%s", req.OutBizNo), func(ctx context.Context) error { err = lock.NewMutex(v.rdb.Rdb, time.Second*30).Lock(ctx, fmt.Sprintf("cmb_order_%s", req.OutBizNo), func(ctx context.Context) error {
@ -63,7 +63,7 @@ func (v *Cmb) CmbOrder(ctx context.Context, req *bo.OrderCreateReqBo) (reps *bo.
return return
} }
func (v *Cmb) CmbQuery(ctx context.Context, req *bo.OrderCreateReqBo) (reps *bo.OrderCreateRepBo, err error) { func (v *Cmb) Query(ctx context.Context, req *bo.OrderCreateReqBo) (reps *bo.OrderCreateRepBo, err error) {
err = lock.NewMutex(v.rdb.Rdb, time.Second*30).Lock(ctx, fmt.Sprintf("cmb_order_%s", req.OutBizNo), func(ctx context.Context) error { err = lock.NewMutex(v.rdb.Rdb, time.Second*30).Lock(ctx, fmt.Sprintf("cmb_order_%s", req.OutBizNo), func(ctx context.Context) error {
@ -73,6 +73,6 @@ func (v *Cmb) CmbQuery(ctx context.Context, req *bo.OrderCreateReqBo) (reps *bo.
return return
} }
func (v *Cmb) CmbNotify(ctx context.Context, order *bo.OrderBo) (err error) { func (v *Cmb) Notify(ctx context.Context, order *bo.OrderBo) (err error) {
return return
} }

View File

@ -1,34 +0,0 @@
package service
import (
"github.com/go-kratos/kratos/v2/transport/http"
http2 "net/http"
)
// BaseService order 公共方法
type BaseService struct {
}
type BaseResponse struct {
Code int `json:"code"`
Data interface{} `json:"data"`
Message string `json:"message"`
}
// ResponseOK 返回 json 成功
func (b *BaseService) ResponseOK(ctx http.Context, data interface{}) error {
return ctx.JSON(http2.StatusOK, &BaseResponse{
Code: http2.StatusOK,
Data: data,
Message: "",
})
}
// ResponseError 返回 json 错误
func (b *BaseService) ResponseError(ctx http.Context, error string) error {
return ctx.JSON(http2.StatusOK, &BaseResponse{
Code: 4001,
Data: nil,
Message: error,
})
}

View File

@ -27,7 +27,7 @@ func (s *VoucherService) CmbOrder(ctx http.Context) error {
AccountType: vo.OrderAccountTypeOpenId, AccountType: vo.OrderAccountTypeOpenId,
} }
boRep, err := s.VoucherBiz.CmbOrder(ctx, boReq) boRep, err := s.Cmb.Order(ctx, boReq)
if err != nil { if err != nil {
return err return err
} }

View File

@ -2,20 +2,24 @@ package service
import ( import (
"voucher/internal/biz" "voucher/internal/biz"
"voucher/internal/biz/cmb"
"voucher/internal/conf" "voucher/internal/conf"
) )
type VoucherService struct { type VoucherService struct {
bc *conf.Bootstrap bc *conf.Bootstrap
VoucherBiz *biz.VoucherBiz VoucherBiz *biz.VoucherBiz
Cmb *cmb.Cmb
} }
func NewVoucherService( func NewVoucherService(
bc *conf.Bootstrap, bc *conf.Bootstrap,
VoucherBiz *biz.VoucherBiz, VoucherBiz *biz.VoucherBiz,
Cmb *cmb.Cmb,
) *VoucherService { ) *VoucherService {
return &VoucherService{ return &VoucherService{
bc: bc, bc: bc,
VoucherBiz: VoucherBiz, VoucherBiz: VoucherBiz,
Cmb: Cmb,
} }
} }