first commit
This commit is contained in:
15
pkg/lzkit/lzUtils/utils.go
Normal file
15
pkg/lzkit/lzUtils/utils.go
Normal file
@@ -0,0 +1,15 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user