fix(分润管理):前端功能实现,统计功能实现
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
import { PageContainer, ProTable } from '@ant-design/pro-components';
|
||||
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||
import { Button, message, Space, Tag, Typography, Modal } from 'antd';
|
||||
import React, { useRef } from 'react';
|
||||
import { profitSharingList, executeProfitSharing } from '@/services/orders/api';
|
||||
import { history } from 'umi';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
const STATUS_MAP = {
|
||||
0: { text: '待分账', color: 'default' },
|
||||
1: { text: '分账中', color: 'processing' },
|
||||
2: { text: '分账成功', color: 'success' },
|
||||
3: { text: '分账失败', color: 'error' },
|
||||
};
|
||||
|
||||
const ProfitSharingList: React.FC = () => {
|
||||
const actionRef = useRef<ActionType>();
|
||||
|
||||
const handleExecute = async (orderNo: string) => {
|
||||
Modal.confirm({
|
||||
title: '确认执行分账',
|
||||
content: '是否确认为该订单执行分账操作?',
|
||||
onOk: async () => {
|
||||
try {
|
||||
const result = await executeProfitSharing(orderNo);
|
||||
if (result.resp_code === 0) {
|
||||
message.success('分账执行成功');
|
||||
actionRef.current?.reload();
|
||||
} else {
|
||||
message.error(result.resp_msg || '分账执行失败');
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('分账执行失败');
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handleRequest = async (params: any) => {
|
||||
const { current, pageSize, ...rest } = params;
|
||||
const result = await profitSharingList({
|
||||
page: current,
|
||||
limit: pageSize,
|
||||
...rest,
|
||||
});
|
||||
|
||||
return {
|
||||
data: result.data,
|
||||
success: result.resp_code === 0,
|
||||
total: result.total,
|
||||
};
|
||||
};
|
||||
|
||||
const columns: ProColumns<ORDERS.ProfitSharing>[] = [
|
||||
{
|
||||
title: '订单编号',
|
||||
dataIndex: 'orderNo',
|
||||
width: 200,
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: '微信支付订单号',
|
||||
dataIndex: 'transactionId',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '订单总额',
|
||||
dataIndex: 'totalAmount',
|
||||
width: 120,
|
||||
render: (val) => `¥${(Number(val) / 100).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
title: '平台分账',
|
||||
dataIndex: 'platformAmount',
|
||||
width: 120,
|
||||
render: (val) => `¥${(Number(val) / 100).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
title: '二维码分账',
|
||||
dataIndex: 'qrCodeAmount',
|
||||
width: 120,
|
||||
render: (val) => `¥${(Number(val) / 100).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
title: '实际分账金额',
|
||||
dataIndex: 'receiverAmount',
|
||||
width: 120,
|
||||
render: (val) => (val ? `¥${(Number(val) / 100).toFixed(2)}` : '-'),
|
||||
},
|
||||
{
|
||||
title: '分账状态',
|
||||
dataIndex: 'status',
|
||||
width: 100,
|
||||
valueEnum: STATUS_MAP,
|
||||
},
|
||||
{
|
||||
title: '分账账号',
|
||||
dataIndex: 'payeeAccount',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '账号类型',
|
||||
dataIndex: 'payeeType',
|
||||
width: 120,
|
||||
valueEnum: {
|
||||
'MERCHANT_ID': { text: '商户ID' },
|
||||
'PERSONAL_OPENID': { text: '个人openid' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
width: 180,
|
||||
valueType: 'dateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
<Link onClick={() => history.push(`/orders/profit-sharing/detail/${record.orderNo}`)}>
|
||||
详情
|
||||
</Link>
|
||||
{record.status === 3 && record.retryTimes < 3 && (
|
||||
<Link onClick={() => handleExecute(record.orderNo)}>
|
||||
重试分账
|
||||
</Link>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
<ProTable<ORDERS.ProfitSharing>
|
||||
actionRef={actionRef}
|
||||
columns={columns}
|
||||
scroll={{ x: 1800 }}
|
||||
request={handleRequest}
|
||||
rowKey="id"
|
||||
search={{
|
||||
labelWidth: 120,
|
||||
}}
|
||||
pagination={{
|
||||
pageSize: 10,
|
||||
showQuickJumper: true,
|
||||
showSizeChanger: true,
|
||||
}}
|
||||
dateFormatter="string"
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProfitSharingList;
|
||||
Reference in New Issue
Block a user