update: Added support for floating-point calculations for discounts

This commit is contained in:
EUForest
2025-11-21 17:39:57 +08:00
parent ff2d3f85f3
commit c1efb23354
3 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -7,14 +7,14 @@ import (
)
func getDiscount(discounts []types.SubscribeDiscount, inputMonths int64) float64 {
var finalDiscount int64 = 100
var finalDiscount float64 = 100
for _, discount := range discounts {
if inputMonths >= discount.Quantity && discount.Discount < finalDiscount {
finalDiscount = discount.Discount
}
}
return float64(finalDiscount) / float64(100)
return finalDiscount / float64(100)
}
func calculateCoupon(amount int64, couponInfo *coupon.Coupon) int64 {