优化订单支付

This commit is contained in:
yml
2026-06-08 23:56:25 +08:00
parent 870ea72996
commit a2a0489158
20 changed files with 884 additions and 5 deletions
@@ -31,6 +31,34 @@ func TestApplyEntryRoundsMoneyBeforeComparing(t *testing.T) {
}
}
func TestApplyEntryKeepsWalletMoneyAtJiaoPrecision(t *testing.T) {
account := model.WalletAccount{
UserID: 8,
AvailableBalance: 0,
}
entry := Entry{
UserID: 8,
Direction: "in",
Amount: 2.30,
BalanceType: "available",
}
balanceAfter, err := applyEntry(&account, entry)
if err != nil {
t.Fatalf("applyEntry() error = %v", err)
}
if balanceAfter != 2.3 {
t.Fatalf("balanceAfter = %v, want 2.3", balanceAfter)
}
if account.AvailableBalance != 2.3 {
t.Fatalf("AvailableBalance = %v, want 2.3", account.AvailableBalance)
}
if rounded := roundWalletMoney(2.36); rounded != 2.4 {
t.Fatalf("roundWalletMoney(2.36) = %v, want 2.4", rounded)
}
}
func TestNewLedgerNoUsesReadableFormat(t *testing.T) {
ledgerNo, err := newLedgerNo()
if err != nil {