refactor(money): 统一金额分为纯整数工具
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
"hfb_sys/backend/internal/modules/rentergrowth"
|
||||
"hfb_sys/backend/pkg/money"
|
||||
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
@@ -486,23 +485,32 @@ func readOrderSnapshotAssetNumber(raw datatypes.JSON, key string) float64 {
|
||||
return readJSONNumber(snapshot[key])
|
||||
}
|
||||
|
||||
// roundMoney 使用统一的角精度(0.1元)
|
||||
// roundMoney 是订单历史链路的角精度兼容实现;新金额链路应直接使用整数分。
|
||||
func roundMoney(value float64) float64 {
|
||||
return money.Round(value)
|
||||
if value <= 0 || math.IsNaN(value) || math.IsInf(value, 0) {
|
||||
return 0
|
||||
}
|
||||
return math.Round(value*10) / 10
|
||||
}
|
||||
|
||||
func roundQuantity(value float64) float64 {
|
||||
return math.Round(value*100) / 100
|
||||
}
|
||||
|
||||
// minMoney 返回较小金额(角精度)
|
||||
// minMoney 返回较小金额(角精度兼容)。
|
||||
func minMoney(a float64, b float64) float64 {
|
||||
return money.Min(a, b)
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// maxMoney 返回较大金额(角精度)
|
||||
// maxMoney 返回较大金额(角精度兼容)。
|
||||
func maxMoney(a float64, b float64) float64 {
|
||||
return money.Max(a, b)
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func minCent(a int64, b int64) int64 {
|
||||
|
||||
Reference in New Issue
Block a user