feat: add configurable payment amount precision

- add system.amount_precision setting with 2-6 validation
This commit is contained in:
line-6000
2026-05-11 17:11:43 +08:00
parent 1c805ed061
commit 8d2ddbd045
178 changed files with 532 additions and 273 deletions
+19
View File
@@ -119,6 +119,25 @@ func GetSettingBool(key string, fallback bool) bool {
return b
}
const (
DefaultAmountPrecision = 2
MinAmountPrecision = 2
MaxAmountPrecision = 6
)
// NormalizeAmountPrecision clamps external precision values to the supported
// range used by order creation and transaction matching.
func NormalizeAmountPrecision(precision int) int {
if precision < MinAmountPrecision || precision > MaxAmountPrecision {
return DefaultAmountPrecision
}
return precision
}
func GetAmountPrecision() int {
return NormalizeAmountPrecision(GetSettingInt(mdb.SettingKeyAmountPrecision, DefaultAmountPrecision))
}
// SetSetting upserts a setting row and refreshes the cache entry.
func SetSetting(group, key, value, valueType string) error {
if valueType == "" {