商户订单
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
import { Tag, Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
|
||||
import type IMerchantWithdrawal from '@/domain/iMerchantWithdrawal';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
const Table: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const columns: XinTableColumn<IMerchantWithdrawal>[] = [
|
||||
{
|
||||
title: t('merchant.withdrawal.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('merchant.withdrawal.withdraw_no'),
|
||||
dataIndex: 'withdraw_no',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.withdrawal.merchant_id'),
|
||||
dataIndex: 'merchant_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.withdrawal.amount'),
|
||||
dataIndex: 'amount',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
render: (value: number) => `¥${value ?? '0.00'}`,
|
||||
},
|
||||
{
|
||||
title: t('merchant.withdrawal.channel'),
|
||||
dataIndex: 'channel',
|
||||
valueType: 'select',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 'wechat', label: t('merchant.withdrawal.channel.wechat') },
|
||||
{ value: 'alipay', label: t('merchant.withdrawal.channel.alipay') },
|
||||
{ value: 'bank', label: t('merchant.withdrawal.channel.bank') },
|
||||
],
|
||||
},
|
||||
render: (value: string) => {
|
||||
const colorMap: Record<string, string> = { wechat: 'green', alipay: 'blue', bank: 'orange' };
|
||||
const labelMap: Record<string, string> = {
|
||||
wechat: t('merchant.withdrawal.channel.wechat'),
|
||||
alipay: t('merchant.withdrawal.channel.alipay'),
|
||||
bank: t('merchant.withdrawal.channel.bank'),
|
||||
};
|
||||
return <Tag color={colorMap[value] ?? 'default'}>{labelMap[value] ?? value}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.withdrawal.channel.wechat'), value: 'wechat' },
|
||||
{ text: t('merchant.withdrawal.channel.alipay'), value: 'alipay' },
|
||||
{ text: t('merchant.withdrawal.channel.bank'), value: 'bank' },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.withdrawal.status'),
|
||||
dataIndex: 'status',
|
||||
valueType: 'select',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.withdrawal.status.0') },
|
||||
{ value: 1, label: t('merchant.withdrawal.status.1') },
|
||||
{ value: 2, label: t('merchant.withdrawal.status.2') },
|
||||
{ value: 3, label: t('merchant.withdrawal.status.3') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
const colorMap: Record<number, string> = { 0: 'warning', 1: 'processing', 2: 'success', 3: 'error' };
|
||||
const labelMap: Record<number, string> = {
|
||||
0: t('merchant.withdrawal.status.0'),
|
||||
1: t('merchant.withdrawal.status.1'),
|
||||
2: t('merchant.withdrawal.status.2'),
|
||||
3: t('merchant.withdrawal.status.3'),
|
||||
};
|
||||
return <Tag color={colorMap[value] ?? 'default'}>{labelMap[value] ?? '-'}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.withdrawal.status.0'), value: 0 },
|
||||
{ text: t('merchant.withdrawal.status.1'), value: 1 },
|
||||
{ text: t('merchant.withdrawal.status.2'), value: 2 },
|
||||
{ text: t('merchant.withdrawal.status.3'), value: 3 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.withdrawal.remark'),
|
||||
dataIndex: 'remark',
|
||||
valueType: 'text',
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.withdrawal.processed_at'),
|
||||
dataIndex: 'processed_at',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '-'),
|
||||
},
|
||||
{
|
||||
title: t('merchant.withdrawal.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IMerchantWithdrawal> = {
|
||||
api: '/merchant/withdrawal',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'merchant.withdrawal',
|
||||
addShow: false,
|
||||
scroll: { x: 1200 },
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
rowProps: { gutter: [30, 0] },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: { width: 800 },
|
||||
cardProps: { variant: 'borderless' },
|
||||
pagination: { size: 'small', style: { marginBottom: 0 } },
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('merchant.withdrawal.page.title')}</Title>
|
||||
<Text type="secondary">{t('merchant.withdrawal.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IMerchantWithdrawal> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
@@ -0,0 +1,161 @@
|
||||
import { Tag, Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
|
||||
import type IOrderPayment from '@/domain/iOrderPayment';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
const Table: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const columns: XinTableColumn<IOrderPayment>[] = [
|
||||
{
|
||||
title: t('merchant.order_payment.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('merchant.order_payment.payment_no'),
|
||||
dataIndex: 'payment_no',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.order_payment.order_id'),
|
||||
dataIndex: 'order_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.order_payment.user_id'),
|
||||
dataIndex: 'user_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.order_payment.amount'),
|
||||
dataIndex: 'amount',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
render: (value: number) => `¥${value ?? '0.00'}`,
|
||||
},
|
||||
{
|
||||
title: t('merchant.order_payment.pay_type'),
|
||||
dataIndex: 'pay_type',
|
||||
valueType: 'select',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.order_payment.pay_type.0') },
|
||||
{ value: 1, label: t('merchant.order_payment.pay_type.1') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
const colorMap: Record<number, string> = { 0: 'default', 1: 'blue' };
|
||||
const labelMap: Record<number, string> = {
|
||||
0: t('merchant.order_payment.pay_type.0'),
|
||||
1: t('merchant.order_payment.pay_type.1'),
|
||||
};
|
||||
return <Tag color={colorMap[value] ?? 'default'}>{labelMap[value] ?? '-'}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.order_payment.pay_type.0'), value: 0 },
|
||||
{ text: t('merchant.order_payment.pay_type.1'), value: 1 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.order_payment.status'),
|
||||
dataIndex: 'status',
|
||||
valueType: 'select',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.order_payment.status.0') },
|
||||
{ value: 1, label: t('merchant.order_payment.status.1') },
|
||||
{ value: 2, label: t('merchant.order_payment.status.2') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
const colorMap: Record<number, string> = { 0: 'warning', 1: 'success', 2: 'default' };
|
||||
const labelMap: Record<number, string> = {
|
||||
0: t('merchant.order_payment.status.0'),
|
||||
1: t('merchant.order_payment.status.1'),
|
||||
2: t('merchant.order_payment.status.2'),
|
||||
};
|
||||
return <Tag color={colorMap[value] ?? 'default'}>{labelMap[value] ?? '-'}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.order_payment.status.0'), value: 0 },
|
||||
{ text: t('merchant.order_payment.status.1'), value: 1 },
|
||||
{ text: t('merchant.order_payment.status.2'), value: 2 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.order_payment.paid_at'),
|
||||
dataIndex: 'paid_at',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '-'),
|
||||
},
|
||||
{
|
||||
title: t('merchant.order_payment.refund_at'),
|
||||
dataIndex: 'refund_at',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '-'),
|
||||
},
|
||||
{
|
||||
title: t('merchant.order_payment.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IOrderPayment> = {
|
||||
api: '/merchant/order-payment',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'merchant.order_payment',
|
||||
addShow: false,
|
||||
editShow: false,
|
||||
scroll: { x: 1200 },
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
rowProps: { gutter: [30, 0] },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: { width: 800 },
|
||||
cardProps: { variant: 'borderless' },
|
||||
pagination: { size: 'small', style: { marginBottom: 0 } },
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('merchant.order_payment.page.title')}</Title>
|
||||
<Text type="secondary">{t('merchant.order_payment.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IOrderPayment> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
Reference in New Issue
Block a user