feat: 为折扣计算函数 getDiscount 引入新用户判断逻辑以支持新用户专属折扣。
Build docker and publish / build (20.15.1) (push) Successful in 7m37s
Build docker and publish / build (20.15.1) (push) Successful in 7m37s
This commit is contained in:
@@ -129,10 +129,11 @@ func (l *PurchaseLogic) Purchase(req *types.PurchaseOrderRequest) (resp *types.P
|
||||
}
|
||||
|
||||
var discount float64 = 1
|
||||
isNewUserForDiscount := time.Since(u.CreatedAt) <= 24*time.Hour
|
||||
if sub.Discount != "" {
|
||||
var dis []types.SubscribeDiscount
|
||||
_ = json.Unmarshal([]byte(sub.Discount), &dis)
|
||||
discount = getDiscount(dis, req.Quantity)
|
||||
discount = getDiscount(dis, req.Quantity, isNewUserForDiscount)
|
||||
}
|
||||
price := sub.UnitPrice * req.Quantity
|
||||
// discount amount
|
||||
|
||||
Reference in New Issue
Block a user