货币体系: 全平台统一使用积分(POINT)替代人民币(CNY)

后端:
- 模型 currency 默认值 CNY→POINT (MerchantProduct/WalletAccount/FulfillmentOrder)
- DashboardStats TotalSales/TotalFees 从 float64 改为 int64,去掉 /100.0 转换
- 上游 OpenOrderQuery.Amount 从 float64 改为 int64,直接返回积分整数
- 钱包/商品创建时 currency 默认 POINT

前端:
- 去掉 centsToYuan/yuanToCents 转换函数,金额直接用整数积分
- money() 显示从 ¥X.XX 改为 X 积分
- 商品售价/成本表单字段名改回 price_amount/cost_amount,precision 改 0
- 钱包调整表单 amount_yuan→amount,precision 改 0
- 手续费固定金额表单 precision 改 0,label 改积分
- 币种选项 CNY→POINT
- Dashboard 成交金额/手续费 suffix 元→积分,去掉 precision

数据库:
- 新增迁移 004: currency 默认值 CNY→POINT,存量数据更新
This commit is contained in:
yml2213
2026-07-30 14:30:34 +08:00
parent bafe41a3ea
commit 0de0ad9e9d
9 changed files with 52 additions and 69 deletions
+13 -27
View File
@@ -212,11 +212,11 @@ export default function MerchantCenter() {
setEditingProduct(null)
productForm.resetFields()
productForm.setFieldsValue({
currency: 'CNY',
currency: 'POINT',
stock: -1,
status: 'active',
price_yuan: 0,
cost_yuan: 0,
price_amount: 0,
cost_amount: 0,
})
setProductOpen(true)
}
@@ -225,8 +225,6 @@ export default function MerchantCenter() {
setEditingProduct(record)
productForm.setFieldsValue({
...record,
price_yuan: centsToYuan(record.price_amount),
cost_yuan: centsToYuan(record.cost_amount),
})
setProductOpen(true)
}
@@ -236,11 +234,7 @@ export default function MerchantCenter() {
try {
const payload = {
...values,
price_amount: yuanToCents(values.price_yuan),
cost_amount: yuanToCents(values.cost_yuan),
}
delete payload.price_yuan
delete payload.cost_yuan
if (editingProduct) {
await merchantApi.updateProduct(editingProduct.id, payload)
message.success('商品已更新')
@@ -259,7 +253,7 @@ export default function MerchantCenter() {
const values = await walletForm.validateFields()
try {
const walletData = await merchantApi.adjustWallet({
amount: yuanToCents(values.amount_yuan),
amount: values.amount,
idempotency_key: values.idempotency_key,
note: values.note,
})
@@ -497,7 +491,7 @@ export default function MerchantCenter() {
<Descriptions size="small" bordered column={3} style={{ flex: 1 }}>
<Descriptions.Item label="可用余额">{money(wallet?.available_balance ?? 0)}</Descriptions.Item>
<Descriptions.Item label="冻结余额">{money(wallet?.frozen_balance ?? 0)}</Descriptions.Item>
<Descriptions.Item label="币种">{wallet?.currency || 'CNY'}</Descriptions.Item>
<Descriptions.Item label="币种">{wallet?.currency || 'POINT'}</Descriptions.Item>
</Descriptions>
{canFinance && (
<Button
@@ -604,14 +598,14 @@ export default function MerchantCenter() {
</Form.Item>
</Space>
<Space size="middle" style={{ width: '100%' }}>
<Form.Item name="price_yuan" label="售价" rules={[{ required: true }]} style={{ width: 180 }}>
<InputNumber min={0} precision={2} style={{ width: '100%' }} />
<Form.Item name="price_amount" label="售价(积分)" rules={[{ required: true }]} style={{ width: 180 }}>
<InputNumber min={0} precision={0} style={{ width: '100%' }} />
</Form.Item>
<Form.Item name="cost_yuan" label="成本" style={{ width: 180 }}>
<InputNumber min={0} precision={2} style={{ width: '100%' }} />
<Form.Item name="cost_amount" label="成本(积分)" style={{ width: 180 }}>
<InputNumber min={0} precision={0} style={{ width: '100%' }} />
</Form.Item>
<Form.Item name="currency" label="币种" style={{ width: 180 }}>
<Select options={[{ value: 'CNY', label: 'CNY' }]} />
<Select options={[{ value: 'POINT', label: 'POINT(积分)' }]} />
</Form.Item>
</Space>
<Space size="middle" style={{ width: '100%' }}>
@@ -635,8 +629,8 @@ export default function MerchantCenter() {
<Modal title="钱包调整" open={walletOpen} onOk={submitWalletAdjust} onCancel={() => setWalletOpen(false)} destroyOnClose>
<Form form={walletForm} layout="vertical" style={{ marginTop: 16 }}>
<Form.Item name="amount_yuan" label="调整金额" rules={[{ required: true }]}>
<InputNumber precision={2} style={{ width: '100%' }} placeholder="正数充值,负数扣减" />
<Form.Item name="amount" label="调整积分" rules={[{ required: true }]}>
<InputNumber precision={0} style={{ width: '100%' }} placeholder="正数充值,负数扣减" />
</Form.Item>
<Form.Item name="idempotency_key" label="幂等键" rules={[{ required: true }]}>
<Input />
@@ -734,14 +728,6 @@ function SecretBlock({ appKey, secret }: { appKey?: string; secret: string }) {
)
}
function yuanToCents(value?: number | null) {
return Math.round(Number(value || 0) * 100)
}
function centsToYuan(value?: number | null) {
return Number(((value || 0) / 100).toFixed(2))
}
function featuresToList(features?: string) {
const list = (features || '')
.split(/[,\s]+/)
@@ -768,7 +754,7 @@ function resolveEnabledTab(current: string, features?: string) {
}
function money(value?: number | null) {
return `¥${centsToYuan(value).toFixed(2)}`
return `${Number(value || 0)} 积分`
}
function moneyWithSign(value?: number | null) {