fix(支付): 修复金额计算精度问题
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 6m45s
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 6m45s
在epayPayment和CryptoSaaSPayment方法中,对转换后的金额进行四舍五入保留两位小数处理,确保支付金额精度准确
This commit is contained in:
parent
9987bd43fa
commit
6fba1d683a
@ -271,10 +271,11 @@ func (l *PurchaseCheckoutLogic) epayPayment(config *payment.Payment, info *order
|
|||||||
client := epay.NewClient(epayConfig.Pid, epayConfig.Url, epayConfig.Key, epayConfig.Type)
|
client := epay.NewClient(epayConfig.Pid, epayConfig.Url, epayConfig.Key, epayConfig.Type)
|
||||||
|
|
||||||
// Convert order amount to CNY using current exchange rate
|
// Convert order amount to CNY using current exchange rate
|
||||||
amount, err := l.queryExchangeRate("CNY", info.Amount)
|
amount, err := l.queryExchangeRate("CNY", info.Amount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
amount = math.Round(amount*100) / 100
|
||||||
|
|
||||||
// Build notification URL for payment status callbacks
|
// Build notification URL for payment status callbacks
|
||||||
notifyUrl := ""
|
notifyUrl := ""
|
||||||
@ -313,10 +314,11 @@ func (l *PurchaseCheckoutLogic) CryptoSaaSPayment(config *payment.Payment, info
|
|||||||
client := epay.NewClient(epayConfig.AccountID, epayConfig.Endpoint, epayConfig.SecretKey, epayConfig.Type)
|
client := epay.NewClient(epayConfig.AccountID, epayConfig.Endpoint, epayConfig.SecretKey, epayConfig.Type)
|
||||||
|
|
||||||
// Convert order amount to CNY using current exchange rate
|
// Convert order amount to CNY using current exchange rate
|
||||||
amount, err := l.queryExchangeRate("CNY", info.Amount)
|
amount, err := l.queryExchangeRate("CNY", info.Amount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
amount = math.Round(amount*100) / 100
|
||||||
|
|
||||||
// Build notification URL for payment status callbacks
|
// Build notification URL for payment status callbacks
|
||||||
notifyUrl := ""
|
notifyUrl := ""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user