tydata-server/pkg/lzkit/lzUtils/utils.go
2025-01-10 00:09:25 +08:00

16 lines
488 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package lzUtils
import "fmt"
// ToWechatAmount 将金额从元转换为微信支付 SDK 需要的分int64 类型)
func ToWechatAmount(amount float64) int64 {
// 将金额从元转换为分,并四舍五入
return int64(amount*100 + 0.5)
}
// ToAlipayAmount 将金额从元转换为支付宝支付 SDK 需要的字符串格式,保留两位小数
func ToAlipayAmount(amount float64) string {
// 格式化为字符串,保留两位小数
return fmt.Sprintf("%.2f", amount)
}