"fix(order): 修复优惠券使用限制检查逻辑,增加数量有效性验证"
This commit is contained in:
parent
617768a4a1
commit
565eb8cbbf
@ -63,7 +63,7 @@ func (l *PreCreateOrderLogic) PreCreateOrder(req *types.PurchaseOrderRequest) (r
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "find coupon error: %v", err.Error())
|
||||
}
|
||||
if couponInfo.Count <= couponInfo.UsedCount {
|
||||
if couponInfo.Count > 0 && couponInfo.Count <= couponInfo.UsedCount {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.CouponAlreadyUsed), "coupon used")
|
||||
}
|
||||
var count int64
|
||||
@ -76,7 +76,7 @@ func (l *PreCreateOrderLogic) PreCreateOrder(req *types.PurchaseOrderRequest) (r
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "find coupon error: %v", err.Error())
|
||||
}
|
||||
|
||||
if count >= couponInfo.UserLimit {
|
||||
if couponInfo.UserLimit > 0 && count >= couponInfo.UserLimit {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.CouponInsufficientUsage), "coupon limit exceeded")
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user