feat(distribution): 重构分销后台为SaaS商户工作台并全面商业化优化
- 商品货架 (Accounts.tsx): 支持期望售价/固定金额/百分比多模式实时联动加价与批量调价,高亮100%独享溢价 - 订单中心 (Orders.tsx): 透传账号游戏租客信息,新增收益对账抽屉透明拆解底价、手续费、分成与自主溢价 - 结算与规则 (Settlements.tsx & Rules.tsx): 纠正角色倒错,商户视角展现周期对账单与分成合作政策 - 店铺装修 (SiteSettings.tsx): 废除手写JSON,提供横幅/公告/页脚可视化列表编辑器与前台实时模拟器 - 数据大盘 (Dashboard.tsx): 对齐最新订单字段,大字展示分销商净收益 - 后端数据层 (dto.go, repository.go, handler.go): 聚合计算分销商订单收益,支持商品与租客搜索
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Card, Table, Typography, Space, Select, Tag, message } from 'antd'
|
||||
import { useEffect, useState, useCallback } from 'react'
|
||||
import { Card, Table, Typography, Space, Select, Tag, message, Row, Col, Divider, Alert, Button } from 'antd'
|
||||
import {
|
||||
SafetyCertificateOutlined,
|
||||
DollarCircleOutlined,
|
||||
ThunderboltOutlined,
|
||||
CheckCircleOutlined,
|
||||
LockOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import { listRules, listSites, updateRuleStatus, getMe, type Rule, type Site } from '../api'
|
||||
import { useMember } from '../MemberContext'
|
||||
|
||||
const MODE_LABELS: Record<string, string> = {
|
||||
two_party_distributor_receive: '两方-分销收号',
|
||||
two_party_platform_receive: '两方-分销卖出',
|
||||
three_party: '三方',
|
||||
two_party_distributor_receive: '分销收号模式 (主站售出 / 散户在本站上传)',
|
||||
two_party_platform_receive: '分销卖号模式 (分站售出 / 主站共享号源池)',
|
||||
three_party: '分销跨站协同模式 (分站A收号 + 分站B卖出)',
|
||||
site_self_sell: '分站自收自卖模式',
|
||||
}
|
||||
|
||||
export default function Rules() {
|
||||
@@ -16,16 +24,16 @@ export default function Rules() {
|
||||
const [rules, setRules] = useState<Rule[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
async function load(site?: number) {
|
||||
const load = useCallback(async (site?: number) => {
|
||||
setLoading(true)
|
||||
try {
|
||||
setRules(await listRules(site))
|
||||
} catch {
|
||||
message.error('规则加载失败')
|
||||
message.error('分成规则加载失败')
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
async function init() {
|
||||
@@ -56,7 +64,7 @@ export default function Rules() {
|
||||
}
|
||||
}
|
||||
void init()
|
||||
}, [member])
|
||||
}, [member, load])
|
||||
|
||||
async function toggleStatus(rule: Rule) {
|
||||
const next = rule.status === 'active' ? 'disabled' : 'active'
|
||||
@@ -69,57 +77,231 @@ export default function Rules() {
|
||||
}
|
||||
}
|
||||
|
||||
const isSuperadmin = member?.is_superadmin
|
||||
|
||||
return (
|
||||
<Space direction="vertical" className="page">
|
||||
<Typography.Title level={3}>比例与税费规则</Typography.Title>
|
||||
<Space>
|
||||
{member?.is_superadmin && sites.length > 1 && (
|
||||
<Space direction="vertical" className="page" style={{ width: '100%' }} size="middle">
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<div>
|
||||
<Typography.Title level={3} style={{ marginBottom: 4 }}>
|
||||
{isSuperadmin ? '分成规则配置与管理' : '分销商合作协议与分成政策'}
|
||||
</Typography.Title>
|
||||
<Typography.Text type="secondary">
|
||||
{isSuperadmin
|
||||
? '主站超管可维护各交易模式的分账比例、服务费与税费政策'
|
||||
: '查看当前分销站签约的收益权益、分成政策与资金结算恒等式说明'}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
{isSuperadmin && sites.length > 1 && (
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="分销网站"
|
||||
style={{ width: 200 }}
|
||||
placeholder="切换分销网站"
|
||||
style={{ width: 220 }}
|
||||
value={siteID}
|
||||
options={sites.map((site) => ({ label: site.site_name, value: site.id }))}
|
||||
options={sites.map((site) => ({ label: `${site.site_name} (${site.site_code})`, value: site.id }))}
|
||||
onChange={(value) => {
|
||||
setSiteID(value)
|
||||
void load(value)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Space>
|
||||
<Card>
|
||||
</div>
|
||||
|
||||
{/* 4 Core Rights Cards */}
|
||||
<Card title="分销商核心权益与收益构成">
|
||||
<Row gutter={[16, 16]}>
|
||||
<Col xs={24} md={6}>
|
||||
<div
|
||||
style={{
|
||||
background: '#f6ffed',
|
||||
border: '1px solid #b7eb8f',
|
||||
borderRadius: 8,
|
||||
padding: '16px',
|
||||
height: '100%',
|
||||
}}
|
||||
>
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<ThunderboltOutlined style={{ color: '#52c41a', fontSize: 20 }} />
|
||||
<Typography.Text strong style={{ fontSize: 16, color: '#389e0d' }}>
|
||||
自主加价 100% 独享
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<Typography.Text type="secondary" style={{ fontSize: 13 }}>
|
||||
分销站在主站基准价上自行上浮的全部溢价差额,<strong>100% 独立结算至商户账户</strong>,主站不参与任何分润抽成。
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
</div>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} md={6}>
|
||||
<div
|
||||
style={{
|
||||
background: '#e6f4ff',
|
||||
border: '1px solid #91caff',
|
||||
borderRadius: 8,
|
||||
padding: '16px',
|
||||
height: '100%',
|
||||
}}
|
||||
>
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<DollarCircleOutlined style={{ color: '#1677ff', fontSize: 20 }} />
|
||||
<Typography.Text strong style={{ fontSize: 16, color: '#0958d9' }}>
|
||||
卖号分成 40%
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<Typography.Text type="secondary" style={{ fontSize: 13 }}>
|
||||
租客通过本分销站点租赁主站共享号源池账号,获得扣除号主底价及通道费后的<strong>主站提价利润池 40% 分成</strong>。
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
</div>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} md={6}>
|
||||
<div
|
||||
style={{
|
||||
background: '#f9f0ff',
|
||||
border: '1px solid #d3adf7',
|
||||
borderRadius: 8,
|
||||
padding: '16px',
|
||||
height: '100%',
|
||||
}}
|
||||
>
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<SafetyCertificateOutlined style={{ color: '#722ed1', fontSize: 20 }} />
|
||||
<Typography.Text strong style={{ fontSize: 16, color: '#531dab' }}>
|
||||
收号分成 35%
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<Typography.Text type="secondary" style={{ fontSize: 13 }}>
|
||||
散户号主通过本站上传账号并上架,在全网产生租赁订单后,本站长期享受该账号产生的<strong>主站提价利润 35% 分成</strong>。
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
</div>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} md={6}>
|
||||
<div
|
||||
style={{
|
||||
background: '#fffbe6',
|
||||
border: '1px solid #ffe58f',
|
||||
borderRadius: 8,
|
||||
padding: '16px',
|
||||
height: '100%',
|
||||
}}
|
||||
>
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<CheckCircleOutlined style={{ color: '#fa8c16', fontSize: 20 }} />
|
||||
<Typography.Text strong style={{ fontSize: 16, color: '#d46b08' }}>
|
||||
底价与结算保障
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<Typography.Text type="secondary" style={{ fontSize: 13 }}>
|
||||
号主本金 100% 刚兑保障,支付通道手续费固定为 0.5%,订单履约验收后系统自动打款至商户钱包。
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
{/* Rules Table */}
|
||||
<Card title="当前生效的交易分账规则版本">
|
||||
<Table
|
||||
rowKey="id"
|
||||
loading={loading}
|
||||
dataSource={rules}
|
||||
pagination={false}
|
||||
columns={[
|
||||
{ title: '模式', dataIndex: 'mode', render: (v: string) => MODE_LABELS[v] ?? v },
|
||||
{ title: '版本', dataIndex: 'version' },
|
||||
{ title: '状态', dataIndex: 'status', render: (v: string) => <Tag color={v === 'active' ? 'green' : 'default'}>{v}</Tag> },
|
||||
{
|
||||
title: '比例',
|
||||
render: (_: unknown, r: Rule) => {
|
||||
const parts: string[] = []
|
||||
if (r.distributor_receive_ratio > 0) parts.push(`分销收 ${r.distributor_receive_ratio}%`)
|
||||
if (r.platform_sell_ratio > 0) parts.push(`主站卖 ${r.platform_sell_ratio}%`)
|
||||
if (r.distributor_sell_ratio > 0) parts.push(`分销卖 ${r.distributor_sell_ratio}%`)
|
||||
if (r.platform_receive_ratio > 0) parts.push(`主站收 ${r.platform_receive_ratio}%`)
|
||||
if (r.distributor_a_ratio > 0) parts.push(`分销A ${r.distributor_a_ratio}%`)
|
||||
if (r.distributor_b_ratio > 0) parts.push(`分销B ${r.distributor_b_ratio}%`)
|
||||
return parts.join(' / ') || '-'
|
||||
},
|
||||
},
|
||||
{ title: '服务费', render: (_: unknown, r: Rule) => `${r.service_fee_value}%` },
|
||||
{ title: '手续费', dataIndex: 'payment_fee_bps', render: (v: number) => `${v / 100}%` },
|
||||
{ title: '税费', render: (_: unknown, r: Rule) => (r.tax_enabled ? `${r.tax_rate_bps / 100}%` : '关闭') },
|
||||
{ title: '生效时间', dataIndex: 'effective_from' },
|
||||
{
|
||||
title: '操作',
|
||||
render: (_: unknown, r: Rule) => (
|
||||
<a onClick={() => toggleStatus(r)}>{r.status === 'active' ? '停用' : '启用'}</a>
|
||||
title: '业务交易模式',
|
||||
dataIndex: 'mode',
|
||||
render: (v: string) => (
|
||||
<div>
|
||||
<strong>{MODE_LABELS[v] ?? v}</strong>
|
||||
<div style={{ fontSize: 11, color: '#8c8c8c' }}>模式标识: {v}</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '版本号',
|
||||
dataIndex: 'version',
|
||||
width: 90,
|
||||
render: (v: number) => <Tag color="blue">v{v}</Tag>,
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
width: 100,
|
||||
render: (v: string) => (
|
||||
<Tag color={v === 'active' ? 'success' : 'default'}>
|
||||
{v === 'active' ? '生效中' : '已停用'}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '分成权益比例',
|
||||
render: (_: unknown, r: Rule) => {
|
||||
const parts: string[] = []
|
||||
if (r.distributor_receive_ratio > 0) parts.push(`分销收号: ${r.distributor_receive_ratio}%`)
|
||||
if (r.distributor_sell_ratio > 0) parts.push(`分销卖出: ${r.distributor_sell_ratio}%`)
|
||||
if (r.platform_receive_ratio > 0) parts.push(`主站收号: ${r.platform_receive_ratio}%`)
|
||||
if (r.platform_sell_ratio > 0) parts.push(`主站卖出: ${r.platform_sell_ratio}%`)
|
||||
if (r.distributor_a_ratio > 0) parts.push(`分销A: ${r.distributor_a_ratio}%`)
|
||||
if (r.distributor_b_ratio > 0) parts.push(`分销B: ${r.distributor_b_ratio}%`)
|
||||
return (
|
||||
<Space direction="vertical" size={2}>
|
||||
{parts.map((p, idx) => (
|
||||
<Tag color="cyan" key={idx}>
|
||||
{p}
|
||||
</Tag>
|
||||
))}
|
||||
</Space>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '平台服务费',
|
||||
width: 110,
|
||||
render: (_: unknown, r: Rule) => <span>{r.service_fee_value}%</span>,
|
||||
},
|
||||
{
|
||||
title: '通道手续费',
|
||||
width: 110,
|
||||
dataIndex: 'payment_fee_bps',
|
||||
render: (v: number) => <span>{(v / 100).toFixed(2)}%</span>,
|
||||
},
|
||||
{
|
||||
title: '生效时间',
|
||||
dataIndex: 'effective_from',
|
||||
width: 160,
|
||||
render: (v: string) => (
|
||||
<span style={{ fontSize: 12, color: '#595959' }}>
|
||||
{v ? new Date(v).toLocaleString('zh-CN', { hour12: false }) : '-'}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
...(isSuperadmin
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 100,
|
||||
render: (_: unknown, r: Rule) => (
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
danger={r.status === 'active'}
|
||||
onClick={() => void toggleStatus(r)}
|
||||
>
|
||||
{r.status === 'active' ? '停用' : '启用'}
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user