feat: improve application access and money precision

This commit is contained in:
hectorzhao
2026-07-16 17:54:05 +08:00
parent 9d5c507007
commit faa716b8d0
49 changed files with 1699 additions and 489 deletions
@@ -0,0 +1,41 @@
-- Monetary values were historically stored as integer cents. The platform now
-- stores integer units of 0.0001 yuan. Convert existing values by 100 while
-- widening columns to bigint so balances and report aggregates do not inherit
-- PostgreSQL integer's ~214,748 yuan ceiling at the new scale.
ALTER TABLE "TenantAccount"
ALTER COLUMN "balanceCents" TYPE BIGINT USING ("balanceCents"::BIGINT * 100),
ALTER COLUMN "creditCents" TYPE BIGINT USING ("creditCents"::BIGINT * 100);
ALTER TABLE "AccountTransaction"
ALTER COLUMN "amountCents" TYPE BIGINT USING ("amountCents"::BIGINT * 100),
ALTER COLUMN "balanceAfter" TYPE BIGINT USING ("balanceAfter"::BIGINT * 100);
ALTER TABLE "BillingRule"
ALTER COLUMN "unitPrice" TYPE BIGINT USING ("unitPrice"::BIGINT * 100);
ALTER TABLE "RechargeOrder"
ALTER COLUMN "amountCents" TYPE BIGINT USING ("amountCents"::BIGINT * 100);
ALTER TABLE "SmsBillingRecord"
ALTER COLUMN "unitPrice" TYPE BIGINT USING ("unitPrice"::BIGINT * 100),
ALTER COLUMN "amountCents" TYPE BIGINT USING ("amountCents"::BIGINT * 100);
ALTER TABLE "SmsApplication"
ALTER COLUMN "customerUnitPrice" TYPE BIGINT USING ("customerUnitPrice"::BIGINT * 100);
ALTER TABLE "SmsChannel"
ALTER COLUMN "unitPrice" TYPE BIGINT USING ("unitPrice"::BIGINT * 100);
ALTER TABLE "SmsMessageRecord"
ALTER COLUMN "unitPrice" TYPE BIGINT USING ("unitPrice"::BIGINT * 100),
ALTER COLUMN "amountCents" TYPE BIGINT USING ("amountCents"::BIGINT * 100);
ALTER TABLE "SmsSubmitRecord"
ALTER COLUMN "costUnitPrice" TYPE BIGINT USING ("costUnitPrice"::BIGINT * 100),
ALTER COLUMN "costAmountCents" TYPE BIGINT USING ("costAmountCents"::BIGINT * 100);
ALTER TABLE "DailyProfitReport"
ALTER COLUMN "revenueCents" TYPE BIGINT USING ("revenueCents"::BIGINT * 100),
ALTER COLUMN "costCents" TYPE BIGINT USING ("costCents"::BIGINT * 100),
ALTER COLUMN "profitCents" TYPE BIGINT USING ("profitCents"::BIGINT * 100);