满足压测处理

This commit is contained in:
李子铭 2025-03-21 14:44:24 +08:00
parent 1a8343cda8
commit 6dd9cfbbee
2 changed files with 21 additions and 15 deletions

View File

@ -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 { 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) { if err != nil && !err2.IsDbNotFound(err) {
return err return err
}
if order != nil {
if order.Status.IsFail() {
if err = v.orderRetry(bizCtx, order); err != nil {
return err
}
} }
orderNo = order.OrderNo if order != nil {
return 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) 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("只支持微信") return err2.ErrorCmbProductNotSupported("只支持微信")
} }
order, err = v.order(bizCtx, req, product) order, err := v.order(bizCtx, req, product)
if err != nil { if err != nil {
return err return err
} }

View File

@ -75,6 +75,10 @@ func (p *OrderRepoImpl) Create(ctx context.Context, req *bo.OrderBo) (*bo.OrderB
UpdateTime: &now, UpdateTime: &now,
} }
if req.ProductNo == "001" {
req.VoucherNo = req.OrderNo
}
tx := p.DB(ctx).Create(info) tx := p.DB(ctx).Create(info)
if tx.Error != nil { if tx.Error != nil {
return nil, fmt.Errorf("create db fail %w", tx.Error) return nil, fmt.Errorf("create db fail %w", tx.Error)