refactor(distribution): 重写分销迁移并落地利润百分比分成与货架比例
将 000064-000078 合并为 064/065/066,默认规则改为收号 35%、卖出 40%、服务费 25%。 货架调价改为增加分站 1 元兑换哈夫币比例。sql-guard 仅保护 main 已发布迁移。
This commit is contained in:
@@ -33,7 +33,7 @@ export default function Accounts() {
|
||||
// Markup modal state
|
||||
const [markupModalVisible, setMarkupModalVisible] = useState(false)
|
||||
const [targetAccount, setTargetAccount] = useState<AccountDisplay | null>(null)
|
||||
const [markupYuan, setMarkupYuan] = useState<number>(0)
|
||||
const [markupRatio, setMarkupRatio] = useState<number>(0)
|
||||
const [markupSaving, setMarkupSaving] = useState(false)
|
||||
|
||||
async function load(site?: number, statusFilter?: string) {
|
||||
@@ -122,30 +122,29 @@ export default function Accounts() {
|
||||
function handleOpenMarkup(item?: AccountDisplay) {
|
||||
if (item) {
|
||||
setTargetAccount(item)
|
||||
setMarkupYuan((item.markup_amount_cent ?? 0) / 100)
|
||||
setMarkupRatio(item.shelf_ratio_delta ?? 0)
|
||||
} else {
|
||||
if (selectedRowKeys.length === 0) {
|
||||
message.warning('请先勾选需要批量加价的账号商品')
|
||||
return
|
||||
}
|
||||
setTargetAccount(null)
|
||||
setMarkupYuan(0)
|
||||
setMarkupRatio(0)
|
||||
}
|
||||
setMarkupModalVisible(true)
|
||||
}
|
||||
|
||||
async function handleSaveMarkup() {
|
||||
if (!siteID) return
|
||||
const markupCent = Math.round(markupYuan * 100)
|
||||
if (markupCent < 0) {
|
||||
message.error('加价金额不能小于0')
|
||||
if (markupRatio < 0) {
|
||||
message.error('加价比例不能小于0')
|
||||
return
|
||||
}
|
||||
setMarkupSaving(true)
|
||||
try {
|
||||
if (targetAccount) {
|
||||
await updateAccountMarkup(targetAccount.id, markupCent)
|
||||
message.success('商品加价设置成功!')
|
||||
await updateAccountMarkup(targetAccount.id, markupRatio)
|
||||
message.success('商品加价比例设置成功')
|
||||
} else {
|
||||
const listingIDs = items
|
||||
.filter((it) => selectedRowKeys.includes(it.id))
|
||||
@@ -154,7 +153,7 @@ export default function Accounts() {
|
||||
message.warning('请先勾选要加价的商品')
|
||||
return
|
||||
}
|
||||
await batchUpdateAccountMarkup(siteID, listingIDs, markupCent)
|
||||
await batchUpdateAccountMarkup(siteID, listingIDs, markupRatio)
|
||||
message.success(`已成功为选中的 ${listingIDs.length} 个商品批量设置加价!`)
|
||||
setSelectedRowKeys([])
|
||||
}
|
||||
@@ -340,8 +339,7 @@ export default function Accounts() {
|
||||
render: (_: unknown, row: AccountDisplay) => (
|
||||
<div>
|
||||
<Typography.Text strong style={{ color: '#cf1322' }}>
|
||||
{formatMoney(row.price_cent)}
|
||||
<span style={{ fontSize: 12, fontWeight: 'normal', color: '#888' }}> /小时</span>
|
||||
{formatMoney(row.site_price_cent || row.price_cent)}
|
||||
</Typography.Text>
|
||||
<div style={{ fontSize: 12, color: '#666' }}>
|
||||
押金: {formatMoney(row.deposit_amount_cent)}
|
||||
@@ -350,14 +348,14 @@ export default function Accounts() {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '自主加价',
|
||||
dataIndex: 'markup_amount_cent',
|
||||
title: '加价比例',
|
||||
dataIndex: 'shelf_ratio_delta',
|
||||
width: 120,
|
||||
render: (v: number | undefined) => {
|
||||
if (v && v > 0) {
|
||||
return (
|
||||
<Tag color="gold" style={{ fontWeight: 'bold' }}>
|
||||
+{formatMoney(v)}
|
||||
+{v}
|
||||
</Tag>
|
||||
)
|
||||
}
|
||||
@@ -422,28 +420,29 @@ export default function Accounts() {
|
||||
>
|
||||
<Space direction="vertical" style={{ width: '100%', padding: '12px 0' }}>
|
||||
<Typography.Paragraph type="secondary" style={{ marginBottom: 8 }}>
|
||||
自主加价金额将直接叠加在分销前台展示的每小时租金上,该部分溢价产生的收益将在成单结算时归当前分销商所有。
|
||||
加价是增加该站账号「1 元兑换哈夫币」的比例,不是叠加人民币。比例越大,同样币数售价越低。
|
||||
</Typography.Paragraph>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
|
||||
<Typography.Text strong>每小时加价金额:</Typography.Text>
|
||||
<Typography.Text strong>增加兑换比例:</Typography.Text>
|
||||
<InputNumber
|
||||
min={0}
|
||||
max={1000}
|
||||
precision={2}
|
||||
max={100}
|
||||
precision={1}
|
||||
style={{ width: 180 }}
|
||||
value={markupYuan}
|
||||
onChange={(val) => setMarkupYuan(val ?? 0)}
|
||||
addonAfter="元/小时"
|
||||
placeholder="0.00"
|
||||
value={markupRatio}
|
||||
onChange={(val) => setMarkupRatio(val ?? 0)}
|
||||
addonAfter="比例"
|
||||
placeholder="0"
|
||||
/>
|
||||
</div>
|
||||
{markupYuan > 0 && targetAccount && (
|
||||
{targetAccount && (
|
||||
<div style={{ marginTop: 8, padding: '8px 12px', background: '#f6ffed', borderRadius: 4, border: '1px solid #b7eb8f', fontSize: 12 }}>
|
||||
原租金 {formatMoney(targetAccount.price_cent)}/时 ➔ 分销前台标价为{' '}
|
||||
主站比例 {targetAccount.base_ratio || '-'} → 分站{' '}
|
||||
{((targetAccount.base_ratio || 0) + markupRatio).toFixed(1)},标价{' '}
|
||||
<strong style={{ color: '#cf1322' }}>
|
||||
¥{(((targetAccount.price_cent ?? 0) + Math.round(markupYuan * 100)) / 100).toFixed(2)}
|
||||
{formatMoney(targetAccount.site_price_cent || targetAccount.price_cent)}
|
||||
</strong>
|
||||
/时
|
||||
(保存后按新比例重算)
|
||||
</div>
|
||||
)}
|
||||
</Space>
|
||||
|
||||
Reference in New Issue
Block a user