fix(admin): 主站分销管理按最新分成与释放口径改展示

规则页按模式展示收号/卖出/服务费,通道费标明主站承担;订单改为释放状态筛选;结算区分自动与人工批次。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yml2213
2026-09-10 17:36:49 +08:00
co-authored by Cursor
parent 647fdc0b4a
commit e621722218
10 changed files with 677 additions and 138 deletions
@@ -0,0 +1,112 @@
import type { DistributionRule } from '@/features/admin/api/adminDistribution'
export const DISTRIBUTION_MODES = [
{
value: 'two_party_distributor_receive',
label: '两方 · 分站收号',
hint: '主站下单,货在分站',
},
{
value: 'two_party_platform_receive',
label: '两方 · 分站卖出',
hint: '分站卖主站货',
},
{
value: 'three_party',
label: '三方分账',
hint: '分站卖另一分站的货',
},
] as const
const MODE_LABELS: Record<string, string> = Object.fromEntries(
DISTRIBUTION_MODES.map(item => [item.value, item.label])
)
const PARTY_ROLE_LABELS: Record<string, string> = {
distributor_receive: '分站收号',
platform_sell: '主站卖出',
platform_receive: '主站收号',
distributor_sell: '分站卖出',
distributor_a: '收号站',
distributor_b: '卖出站',
}
export function distributionModeLabel(mode?: string) {
if (!mode) return '-'
return MODE_LABELS[mode] || mode
}
export function distributionPartyRoleLabel(role?: string) {
if (!role) return '-'
return PARTY_ROLE_LABELS[role] || role
}
export function formatRatioPercent(value?: number) {
const n = Number(value || 0)
return `${n.toFixed(n % 1 === 0 ? 0 : 1)}%`
}
export function formatPaymentFeeBps(bps?: number) {
return `${Number(bps || 0) / 100}%`
}
export function ruleSplitParts(rule: DistributionRule) {
switch (rule.mode) {
case 'two_party_distributor_receive':
return [
{ label: '分站收号', value: formatRatioPercent(rule.distributor_receive_ratio) },
{ label: '主站卖出', value: formatRatioPercent(rule.platform_sell_ratio) },
]
case 'two_party_platform_receive':
return [
{ label: '主站收号', value: formatRatioPercent(rule.platform_receive_ratio) },
{ label: '分站卖出', value: formatRatioPercent(rule.distributor_sell_ratio) },
]
case 'three_party':
return [
{ label: '收号站', value: formatRatioPercent(rule.distributor_a_ratio) },
{ label: '卖出站', value: formatRatioPercent(rule.distributor_b_ratio) },
]
default:
return []
}
}
export function formatServiceFee(
rule: Pick<DistributionRule, 'service_fee_value' | 'service_fee_unit'>
) {
if (rule.service_fee_unit === 'fixed_amount') {
return `${Number(rule.service_fee_value || 0).toFixed(2)} 元/单`
}
return formatRatioPercent(rule.service_fee_value)
}
export function settlementBatchKind(batchNo?: string) {
if (batchNo?.startsWith('DA')) {
return { label: '自动释放', type: 'success' as const }
}
if (batchNo?.startsWith('DS')) {
return { label: '人工批次', type: 'warning' as const }
}
return { label: '结算批次', type: 'info' as const }
}
export function distributorReleaseLabel(row: {
distributor_settlement_status?: string
release_at?: string
}) {
if (row.distributor_settlement_status === 'settled') {
return { label: '已释放入账', type: 'success' as const }
}
if (row.distributor_settlement_status === 'pending' && row.release_at) {
const date = new Date(row.release_at)
const text = Number.isNaN(date.getTime())
? '待释放'
: `待释放 ${date.toLocaleDateString('zh-CN', { month: 'numeric', day: 'numeric' })}`
return { label: text, type: 'warning' as const }
}
if (row.distributor_settlement_status === 'pending') {
return { label: '待释放', type: 'info' as const }
}
return { label: '未进入释放', type: 'info' as const }
}