diff --git a/internal/biz/cmb.go b/internal/biz/cmb.go index a7cb78d..b6cb869 100644 --- a/internal/biz/cmb.go +++ b/internal/biz/cmb.go @@ -20,23 +20,25 @@ func (v *VoucherBiz) CmbOrder(ctx context.Context, req *bo.OrderCreateReqBo) (or err = lock.NewMutex(v.rdb.Rdb, c.TTL).Lock(bizCtx, c.Key, func(bizCtx context.Context) error { - order, err := v.OrderRepo.GetByOutBizNo(bizCtx, vo.OrderTypeCmb, req.OutBizNo) + if req.ProductNo != "001" { + order, err := v.OrderRepo.GetByOutBizNo(bizCtx, vo.OrderTypeCmb, req.OutBizNo) - if err != nil && !err2.IsDbNotFound(err) { - return err - } - - if order != nil { - - if order.Status.IsFail() { - - if err = v.orderRetry(bizCtx, order); err != nil { - return err - } + if err != nil && !err2.IsDbNotFound(err) { + return err } - orderNo = order.OrderNo - return nil + if order != nil { + + if order.Status.IsFail() { + + if err = v.orderRetry(bizCtx, order); err != nil { + return err + } + } + + orderNo = order.OrderNo + return nil + } } product, err := v.ProductRepo.GetByProductNo(bizCtx, req.ProductNo) @@ -48,7 +50,7 @@ func (v *VoucherBiz) CmbOrder(ctx context.Context, req *bo.OrderCreateReqBo) (or return err2.ErrorCmbProductNotSupported("只支持微信") } - order, err = v.order(bizCtx, req, product) + order, err := v.order(bizCtx, req, product) if err != nil { return err } diff --git a/internal/data/repoimpl/order.go b/internal/data/repoimpl/order.go index ab8083a..8463968 100644 --- a/internal/data/repoimpl/order.go +++ b/internal/data/repoimpl/order.go @@ -75,6 +75,10 @@ func (p *OrderRepoImpl) Create(ctx context.Context, req *bo.OrderBo) (*bo.OrderB UpdateTime: &now, } + if req.ProductNo == "001" { + req.VoucherNo = req.OrderNo + } + tx := p.DB(ctx).Create(info) if tx.Error != nil { return nil, fmt.Errorf("create db fail %w", tx.Error)