cmb
This commit is contained in:
parent
d61cd68faa
commit
d6a70119ce
|
|
@ -29,6 +29,7 @@ type OrderCreateReqBo struct {
|
|||
ProductNo string
|
||||
Account string
|
||||
AppID string
|
||||
Type vo.OrderType
|
||||
AccountType vo.OrderAccountType
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ func (v *VoucherBiz) CmbOrder(ctx context.Context, req *bo.OrderCreateReqBo) (or
|
|||
|
||||
err = lock.NewMutex(v.rdb.Rdb, c.TTL).Lock(ctx, c.Key, func(ctx context.Context) error {
|
||||
|
||||
order, err := v.OrderRepo.GetByOutBizNo(ctx, req.AppID, req.OutBizNo)
|
||||
order, err := v.OrderRepo.GetByOutBizNo(ctx, vo.OrderTypeCmb, req.AppID, req.OutBizNo)
|
||||
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -3,10 +3,11 @@ package repo
|
|||
import (
|
||||
"context"
|
||||
"voucher/internal/biz/bo"
|
||||
"voucher/internal/biz/vo"
|
||||
)
|
||||
|
||||
type OrderRepo interface {
|
||||
GetByOutBizNo(ctx context.Context, appId, outBizNo string) (*bo.OrderBo, error)
|
||||
GetByOutBizNo(ctx context.Context, t vo.OrderType, appId, outBizNo string) (*bo.OrderBo, error)
|
||||
GetByOrderNo(ctx context.Context, orderNo string) (*bo.OrderBo, error)
|
||||
Create(ctx context.Context, req *bo.OrderBo) (*bo.OrderBo, error)
|
||||
GetByID(ctx context.Context, id uint64) (*bo.OrderBo, error)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ func (p *OrderRepoImpl) Create(ctx context.Context, req *bo.OrderBo) (*bo.OrderB
|
|||
Account: req.Account,
|
||||
AccountType: req.AccountType.GetValue(),
|
||||
Status: vo.OrderStatusWait.GetValue(),
|
||||
Type: req.Type.GetValue(),
|
||||
AppID: req.AppID,
|
||||
MerchantNo: req.MerchantNo,
|
||||
Channel: req.Channel.GetValue(),
|
||||
|
|
@ -52,10 +53,10 @@ func (p *OrderRepoImpl) Create(ctx context.Context, req *bo.OrderBo) (*bo.OrderB
|
|||
return p.ToBo(info), nil
|
||||
}
|
||||
|
||||
func (p *OrderRepoImpl) GetByOutBizNo(ctx context.Context, appId, outBizNo string) (*bo.OrderBo, error) {
|
||||
func (p *OrderRepoImpl) GetByOutBizNo(ctx context.Context, t vo.OrderType, appId, outBizNo string) (*bo.OrderBo, error) {
|
||||
info := &model.Order{}
|
||||
|
||||
tx := p.DB(ctx).Where(model.Order{AppID: appId, OutBizNo: outBizNo}).Find(&info)
|
||||
tx := p.DB(ctx).Where(model.Order{Type: t.GetValue(), AppID: appId, OutBizNo: outBizNo}).Find(&info)
|
||||
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ func (s *VoucherService) cmbOrder(ctx http.Context) (string, error) {
|
|||
Account: bizContent.CmbUid,
|
||||
AppID: bizContent.AppId,
|
||||
AccountType: vo.OrderAccountTypeOpenId,
|
||||
Type: vo.OrderTypeCmb,
|
||||
}
|
||||
|
||||
orderNo, err := s.VoucherBiz.CmbOrder(ctx, boReq)
|
||||
|
|
|
|||
Loading…
Reference in New Issue