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:
@@ -6,10 +6,13 @@ import (
|
||||
"github.com/perfect-panel/server/internal/types"
|
||||
)
|
||||
|
||||
func getDiscount(discounts []types.SubscribeDiscount, inputMonths int64) float64 {
|
||||
func getDiscount(discounts []types.SubscribeDiscount, inputMonths int64, isNewUser bool) float64 {
|
||||
var finalDiscount float64 = 100
|
||||
|
||||
for _, discount := range discounts {
|
||||
if discount.NewUserOnly && !isNewUser {
|
||||
continue
|
||||
}
|
||||
if inputMonths >= discount.Quantity && discount.Discount < finalDiscount {
|
||||
finalDiscount = discount.Discount
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user