635351f539
来源:luoguang/monkey-ai weiyuan@bfdfb339 的 web/(经 sync/main-weiyuan-web-bfdfb339 同步)
同步基准:总仓库 a2ca13cb = 本仓库初始导入 d8f3aee2
冲突处理原则:保留 ui-optimization 的 UI(样式/结构/组件),嫁接 weiyuan 的功能逻辑。
- i18n:按键三方合并;ours 的「令牌→密钥」改名键上移植 theirs 的术语修订
- task-logs / OrgLogs:ours 已手工移植同一功能(6ad95e2),保留 ours
- 删除:OrgCreate(theirs 下线 /org/create)、旧 image 组件与 VideoRegenerateModal(theirs 体验中心重写)、
OrgAvatarSection / PricingBentoPage / CommissionConsole(ours 重构中已移除)
- 测试:users-pagination 的 i18next mock 补 t();theirs 新增文件补 license header
244 lines
7.8 KiB
React
244 lines
7.8 KiB
React
/*
|
|
Copyright (C) 2025 QuantumNous
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as
|
|
published by the Free Software Foundation, either version 3 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
For commercial licensing, please contact support@quantumnous.com
|
|
*/
|
|
import TableEmpty from '../../components/common/table/TableEmpty';
|
|
import TableToolbar from '../../components/common/table/TableToolbar';
|
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
import {
|
|
Banner,
|
|
Button,
|
|
Card,
|
|
Descriptions,
|
|
Modal,
|
|
Table,
|
|
Tag,
|
|
Typography,
|
|
} from '@/components/ui';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { RefreshCw } from 'lucide-react';
|
|
import { API, showError, showSuccess } from '../../helpers';
|
|
|
|
const { Text } = Typography;
|
|
const uToYuan = (u) =>
|
|
u === undefined || u === null ? '-' : (u / 1e6).toFixed(2);
|
|
|
|
/** 我的提成(内部销售自助对账,v2.0 六章:次月对账、3 工作日申诉期) */
|
|
export default function MyCommission() {
|
|
const { t } = useTranslation();
|
|
const [bills, setBills] = useState([]);
|
|
const [detail, setDetail] = useState(null);
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const load = useCallback(async () => {
|
|
setLoading(true);
|
|
try {
|
|
const res = await API.get('/api/sales/commission/bills');
|
|
if (res.data.success) setBills(res.data.data || []);
|
|
else showError(res.data.message);
|
|
} catch (error) {
|
|
showError(error.message);
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
load();
|
|
}, [load]);
|
|
|
|
const openDetail = async (bill) => {
|
|
const res = await API.get(`/api/sales/commission/bills/${bill.id}/items`);
|
|
if (res.data.success) setDetail(res.data.data);
|
|
else showError(res.data.message);
|
|
};
|
|
|
|
const confirm = async (billId) => {
|
|
const res = await API.post(`/api/sales/commission/bills/${billId}/confirm`);
|
|
if (res.data.success) {
|
|
showSuccess(t('对账单已确认'));
|
|
setDetail(null);
|
|
load();
|
|
} else showError(res.data.message);
|
|
};
|
|
|
|
return (
|
|
// mt-[60px]:顶栏 fixed 定位需自行让位(跑马灯由 PageLayout 占位补偿)
|
|
<div className='console-content'>
|
|
<Card>
|
|
<Banner
|
|
type='info'
|
|
closeIcon={null}
|
|
style={{ margin: '8px 0' }}
|
|
description={t(
|
|
'对账单于次月发出;如有异议请在 3 个工作日内联系管理员,逾期视为确认。当期发放 70%,余 30% 随回款到账释放',
|
|
)}
|
|
/>
|
|
<TableToolbar title={t('提成列表')}>
|
|
<Button
|
|
icon={<RefreshCw size={16} />}
|
|
onClick={load}
|
|
loading={loading}
|
|
>
|
|
{t('刷新')}
|
|
</Button>
|
|
</TableToolbar>
|
|
<Table
|
|
loading={loading}
|
|
columns={[
|
|
{ title: t('月份'), dataIndex: 'month' },
|
|
{ title: t('毛利(元)'), dataIndex: 'gp_uyuan', render: uToYuan },
|
|
{
|
|
title: t('个人(元)'),
|
|
dataIndex: 'personal_uyuan',
|
|
render: uToYuan,
|
|
},
|
|
{
|
|
title: t('续费(元)'),
|
|
dataIndex: 'renewal_uyuan',
|
|
render: uToYuan,
|
|
},
|
|
{ title: t('管理(元)'), dataIndex: 'mgmt_uyuan', render: uToYuan },
|
|
{ title: t('专项(元)'), dataIndex: 'bonus_uyuan', render: uToYuan },
|
|
{ title: t('当期发(元)'), dataIndex: 'immediate_yuan' },
|
|
{
|
|
title: t('回款留存(元)'),
|
|
render: (r) => (
|
|
<span>
|
|
{r.holdback_yuan}{' '}
|
|
{r.holdback_released && (
|
|
<Tag color='green'>{t('已释放')}</Tag>
|
|
)}
|
|
</span>
|
|
),
|
|
},
|
|
{
|
|
title: t('状态'),
|
|
dataIndex: 'status',
|
|
render: (v) => (
|
|
<Tag color={v === 'pending_confirm' ? 'orange' : 'green'}>
|
|
{v === 'pending_confirm' ? t('待确认') : t('已确认')}
|
|
</Tag>
|
|
),
|
|
},
|
|
{
|
|
title: '',
|
|
render: (r) => (
|
|
<span className='flex gap-2'>
|
|
<Button size='small' onClick={() => openDetail(r)}>
|
|
{t('明细')}
|
|
</Button>
|
|
{r.status === 'pending_confirm' && (
|
|
<Button
|
|
size='small'
|
|
type='primary'
|
|
onClick={() => confirm(r.id)}
|
|
>
|
|
{t('确认')}
|
|
</Button>
|
|
)}
|
|
</span>
|
|
),
|
|
},
|
|
]}
|
|
dataSource={bills}
|
|
rowKey='id'
|
|
pagination={false}
|
|
scroll={{ x: 'max-content' }}
|
|
empty={<TableEmpty />}
|
|
/>
|
|
<Modal
|
|
title={
|
|
detail
|
|
? t('{{month}} 月提成明细', { month: detail.bill.month })
|
|
: ''
|
|
}
|
|
visible={!!detail}
|
|
onCancel={() => setDetail(null)}
|
|
width={760}
|
|
footer={null}
|
|
>
|
|
{detail && (
|
|
<>
|
|
<Descriptions
|
|
row
|
|
size='small'
|
|
data={[
|
|
{
|
|
key: t('合计(元)'),
|
|
value: uToYuan(detail.bill.total_uyuan),
|
|
},
|
|
{
|
|
key: t('调整(元)'),
|
|
value: uToYuan(detail.bill.offset_uyuan),
|
|
},
|
|
{
|
|
key: t('期初结转(元)'),
|
|
value: uToYuan(detail.bill.carry_in_uyuan),
|
|
},
|
|
{ key: t('方案版本'), value: detail.bill.plan_version },
|
|
]}
|
|
/>
|
|
<Table
|
|
style={{ marginTop: 8 }}
|
|
columns={[
|
|
{ title: t('客户名称'), dataIndex: 'customer_name' },
|
|
{
|
|
title: t('净消耗(元)'),
|
|
dataIndex: 'net_uyuan',
|
|
render: uToYuan,
|
|
},
|
|
{
|
|
title: t('毛利(元)'),
|
|
dataIndex: 'gp_uyuan',
|
|
render: uToYuan,
|
|
},
|
|
{
|
|
title: t('客户属性'),
|
|
render: (r) =>
|
|
r.is_stock ? (
|
|
<Tag color='blue'>{t('存量(续费叠加)')}</Tag>
|
|
) : r.is_new_first ? (
|
|
<Tag color='green'>{t('新客首月')}</Tag>
|
|
) : (
|
|
'-'
|
|
),
|
|
},
|
|
{
|
|
title: t('续费提成(元)'),
|
|
dataIndex: 'renewal_uyuan',
|
|
render: uToYuan,
|
|
},
|
|
]}
|
|
dataSource={detail.items}
|
|
rowKey='id'
|
|
pagination={false}
|
|
size='small'
|
|
/>
|
|
<Text type='tertiary' size='small'>
|
|
{t(
|
|
'毛利 = 净消耗 − 底层成本(v2.0 二章口径);提成按实际毛利据实计算',
|
|
)}
|
|
</Text>
|
|
</>
|
|
)}
|
|
</Modal>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|