All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m17s
为支付宝、Stripe、Epay和CryptoSaaS支付逻辑添加金额转换的日志记录 将支付请求参数提取为变量并添加日志记录 优化代码结构,提高可读性和可维护性
26 lines
846 B
Go
26 lines
846 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
)
|
|
|
|
func main() {
|
|
price := int64(300 * 7)
|
|
discountPercent := 95.19
|
|
discount := discountPercent / 100.0
|
|
amount := int64(math.Round(float64(price) * discount))
|
|
fmt.Printf("price_cents=%d discount=%.4f amount_cents=%d amount=%.2f\n", price, discount, amount, float64(amount)/100.0)
|
|
|
|
couponPercent := 10.0
|
|
coupon := int64(math.Round(float64(amount) * (couponPercent / 100.0)))
|
|
amount -= coupon
|
|
fmt.Printf("coupon_percent=%.2f coupon_cents=%d amount_cents=%d amount=%.2f\n", couponPercent, coupon, amount, float64(amount)/100.0)
|
|
|
|
feePercent := 5.0
|
|
fee := int64(math.Round(float64(amount) * (feePercent / 100.0)))
|
|
total := amount + fee
|
|
fmt.Printf("fee_percent=%.2f fee_cents=%d total_cents=%d total=%.2f\n", feePercent, fee, total, float64(total)/100.0)
|
|
}
|
|
|