From 95ddba2332d30fb22bbb85aa13cdff12774df201 Mon Sep 17 00:00:00 2001 From: EUForest Date: Fri, 21 Nov 2025 17:40:03 +0800 Subject: [PATCH] update: Added support for floating-point calculations for discounts --- internal/logic/public/order/getDiscount.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/logic/public/order/getDiscount.go b/internal/logic/public/order/getDiscount.go index 34c16a9..01f1035 100644 --- a/internal/logic/public/order/getDiscount.go +++ b/internal/logic/public/order/getDiscount.go @@ -3,7 +3,7 @@ package order import "github.com/perfect-panel/server/internal/types" 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 { @@ -11,5 +11,5 @@ func getDiscount(discounts []types.SubscribeDiscount, inputMonths int64) float64 } } - return float64(finalDiscount) / float64(100) + return finalDiscount / float64(100) }