优化价格计算精度,将价格除法结果的小数位数从2位调整为4位,以提高价格处理的准确性。

This commit is contained in:
wood chen 2025-04-15 11:18:34 +08:00
parent 7963ac8294
commit 9b4cee8e0f

View File

@ -51,12 +51,12 @@ func GetPriceRates(c *gin.Context) {
if price.Currency == "USD" {
// 如果是美元除以2
inputRate = round(price.InputPrice/2, 2)
outputRate = round(price.OutputPrice/2, 2)
inputRate = round(price.InputPrice/2, 4)
outputRate = round(price.OutputPrice/2, 4)
} else {
// 如果是人民币或其他货币除以14
inputRate = round(price.InputPrice/14, 2)
outputRate = round(price.OutputPrice/14, 2)
inputRate = round(price.InputPrice/14, 4)
outputRate = round(price.OutputPrice/14, 4)
}
// 创建当前价格的PriceRate