server/internal/logic/public/order/getDiscount.go
Chang lue Tsen c8de30f78c fix(order): improve code quality and fix critical bugs in order processing logic
- Fix inconsistent logging calls across all order logic files
- Fix critical gift amount deduction logic bug in renewal process
- Fix variable shadowing errors in database transactions
- Add comprehensive Go-standard documentation comments
- Improve log prefix consistency for better debugging
- Remove redundant discount validation code
2025-07-24 03:06:44 +09:00

16 lines
395 B
Go

package order
import "github.com/perfect-panel/server/internal/types"
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
}
}
return float64(finalDiscount) / float64(100)
}