fix(portal): 修复折扣计算中浮点数精度问题
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m13s
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m13s
This commit is contained in:
parent
81086eea52
commit
83cb35add6
@ -10,8 +10,8 @@ func getDiscount(discounts []types.SubscribeDiscount, inputMonths int64) float64
|
||||
var finalDiscount int64 = 100
|
||||
|
||||
for _, discount := range discounts {
|
||||
if inputMonths >= discount.Quantity && discount.Discount < finalDiscount {
|
||||
finalDiscount = discount.Discount
|
||||
if inputMonths >= discount.Quantity && int64(discount.Discount*100) < finalDiscount {
|
||||
finalDiscount = int64(discount.Discount * 100)
|
||||
}
|
||||
}
|
||||
return float64(finalDiscount) / float64(100)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user