fix:携程分销商管理页面添加用户手机号以及退订和核销按钮
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import type { ProColumns } from '@ant-design/pro-components';
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import { Popconfirm, Space } from 'antd';
|
||||||
import { CtripDistOrderStatusTag, ConsumeStatusTag, RefundStatusTag } from './Tags';
|
import { CtripDistOrderStatusTag, ConsumeStatusTag, RefundStatusTag } from './Tags';
|
||||||
|
|
||||||
export interface CtripDistOrderItem {
|
export interface CtripDistOrderItem {
|
||||||
@@ -11,6 +12,7 @@ export interface CtripDistOrderItem {
|
|||||||
ctripPackageId?: number;
|
ctripPackageId?: number;
|
||||||
ctripResourceId?: number;
|
ctripResourceId?: number;
|
||||||
distributorOrderId?: string;
|
distributorOrderId?: string;
|
||||||
|
mobile?: string;
|
||||||
orderAmount?: number | string;
|
orderAmount?: number | string;
|
||||||
currency?: string;
|
currency?: string;
|
||||||
ctripOrderStatus?: string;
|
ctripOrderStatus?: string;
|
||||||
@@ -26,19 +28,32 @@ export interface CtripDistOrderItem {
|
|||||||
updateTime?: string;
|
updateTime?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ColumnActions = {
|
||||||
|
onCancel?: (record: CtripDistOrderItem) => Promise<void>;
|
||||||
|
onConsume?: (record: CtripDistOrderItem) => Promise<void>;
|
||||||
|
};
|
||||||
|
|
||||||
const formatAmount = (amount: any): string => {
|
const formatAmount = (amount: any): string => {
|
||||||
if (amount === undefined || amount === null || amount === '') return '-';
|
if (amount === undefined || amount === null || amount === '') return '-';
|
||||||
const num = parseFloat(String(amount));
|
const num = parseFloat(String(amount));
|
||||||
return isNaN(num) ? '-' : num.toFixed(2);
|
return isNaN(num) ? '-' : num.toFixed(2);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const buildCtripDistOrderColumns = (): ProColumns<CtripDistOrderItem>[] => [
|
const canOperate = (record: CtripDistOrderItem) =>
|
||||||
|
record.consumeStatus === 0
|
||||||
|
&& record.refundStatus === 0
|
||||||
|
&& record.ctripOrderStatus === 'CONFIRMED'
|
||||||
|
&& !!record.orderNo
|
||||||
|
&& !!record.ctripOrderId;
|
||||||
|
|
||||||
|
export const buildCtripDistOrderColumns = (actions: ColumnActions = {}): ProColumns<CtripDistOrderItem>[] => [
|
||||||
{ dataIndex: 'index', valueType: 'indexBorder', width: 56 },
|
{ dataIndex: 'index', valueType: 'indexBorder', width: 56 },
|
||||||
{ title: 'ID', dataIndex: 'id', width: 80 },
|
{ title: 'ID', dataIndex: 'id', width: 80 },
|
||||||
{ title: '本地订单号', dataIndex: 'orderNo', width: 200, copyable: true, ellipsis: true },
|
{ title: '本地订单号', dataIndex: 'orderNo', width: 200, copyable: true, ellipsis: true },
|
||||||
{ title: '分销商订单号', dataIndex: 'distributorOrderId', width: 200, copyable: true, ellipsis: true },
|
{ title: '分销商订单号', dataIndex: 'distributorOrderId', width: 200, copyable: true, ellipsis: true },
|
||||||
{ title: '携程订单ID', dataIndex: 'ctripOrderId', width: 160, copyable: true, ellipsis: true },
|
{ title: '携程订单ID', dataIndex: 'ctripOrderId', width: 160, copyable: true, ellipsis: true },
|
||||||
{ title: '携程产品ID', dataIndex: 'ctripProductId', width: 140 },
|
{ title: '携程产品ID', dataIndex: 'ctripProductId', width: 140 },
|
||||||
|
{ title: '手机号', dataIndex: 'mobile', width: 140, copyable: true, ellipsis: true },
|
||||||
{
|
{
|
||||||
title: '订单金额',
|
title: '订单金额',
|
||||||
dataIndex: 'orderAmount',
|
dataIndex: 'orderAmount',
|
||||||
@@ -80,4 +95,32 @@ export const buildCtripDistOrderColumns = (): ProColumns<CtripDistOrderItem>[] =
|
|||||||
{ title: '备注', dataIndex: 'remark', width: 150, ellipsis: true },
|
{ title: '备注', dataIndex: 'remark', width: 150, ellipsis: true },
|
||||||
{ title: '创建时间', dataIndex: 'createTime', width: 180, valueType: 'dateTime' },
|
{ title: '创建时间', dataIndex: 'createTime', width: 180, valueType: 'dateTime' },
|
||||||
{ title: '更新时间', dataIndex: 'updateTime', width: 180, valueType: 'dateTime' },
|
{ title: '更新时间', dataIndex: 'updateTime', width: 180, valueType: 'dateTime' },
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
valueType: 'option',
|
||||||
|
key: 'action',
|
||||||
|
width: 160,
|
||||||
|
fixed: 'right',
|
||||||
|
render: (_, record) => {
|
||||||
|
if (!canOperate(record)) {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Space size="small">
|
||||||
|
<Popconfirm
|
||||||
|
title="确认退订该分销订单?"
|
||||||
|
onConfirm={() => actions.onCancel?.(record)}
|
||||||
|
>
|
||||||
|
<a>退订</a>
|
||||||
|
</Popconfirm>
|
||||||
|
<Popconfirm
|
||||||
|
title="确认核销该分销订单?"
|
||||||
|
onConfirm={() => actions.onConsume?.(record)}
|
||||||
|
>
|
||||||
|
<a>核销</a>
|
||||||
|
</Popconfirm>
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { useRef, useMemo, useState } from 'react';
|
import React, { useRef, useMemo, useState } from 'react';
|
||||||
import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
|
import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
|
||||||
import type { ActionType } from '@ant-design/pro-components';
|
import type { ActionType } from '@ant-design/pro-components';
|
||||||
|
import { message } from 'antd';
|
||||||
import { ordersApi } from '@/services/orders';
|
import { ordersApi } from '@/services/orders';
|
||||||
import { GlassCard, SearchBarPlus } from '@/components/ui';
|
import { GlassCard, SearchBarPlus } from '@/components/ui';
|
||||||
import {
|
import {
|
||||||
@@ -10,6 +11,9 @@ import {
|
|||||||
} from './components/constants';
|
} from './components/constants';
|
||||||
import { buildCtripDistOrderColumns, CtripDistOrderItem } from './components/buildColumns';
|
import { buildCtripDistOrderColumns, CtripDistOrderItem } from './components/buildColumns';
|
||||||
|
|
||||||
|
const getResponseCode = (res: any) => res?.resp_code ?? res?.code;
|
||||||
|
const getResponseMessage = (res: any) => res?.resp_msg ?? res?.msg ?? res?.message;
|
||||||
|
|
||||||
const CtripDistOrderPage: React.FC = () => {
|
const CtripDistOrderPage: React.FC = () => {
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
const [searchParams, setSearchParams] = useState<Record<string, any>>({});
|
const [searchParams, setSearchParams] = useState<Record<string, any>>({});
|
||||||
@@ -19,7 +23,56 @@ const CtripDistOrderPage: React.FC = () => {
|
|||||||
actionRef.current?.reset?.();
|
actionRef.current?.reset?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = useMemo(() => buildCtripDistOrderColumns(), []);
|
const reloadTable = () => actionRef.current?.reload?.();
|
||||||
|
|
||||||
|
const handleCancel = async (record: CtripDistOrderItem) => {
|
||||||
|
const orderNo = record.orderNo;
|
||||||
|
if (!orderNo) {
|
||||||
|
message.error('订单号不存在,无法退订');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const hide = message.loading('正在提交退订...');
|
||||||
|
try {
|
||||||
|
const res = await ordersApi.ctripDistOrderCancel(orderNo);
|
||||||
|
const code = getResponseCode(res);
|
||||||
|
if (typeof code === 'number' && code !== 0) {
|
||||||
|
throw new Error(getResponseMessage(res) || '退订失败');
|
||||||
|
}
|
||||||
|
message.success(getResponseMessage(res) || '退订成功');
|
||||||
|
reloadTable();
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error?.message || '退订失败');
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleConsume = async (record: CtripDistOrderItem) => {
|
||||||
|
const ctripOrderId = record.ctripOrderId;
|
||||||
|
if (!ctripOrderId) {
|
||||||
|
message.error('携程订单ID不存在,无法核销');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const hide = message.loading('正在提交核销...');
|
||||||
|
try {
|
||||||
|
const res = await ordersApi.ctripDistOrderConsume(ctripOrderId);
|
||||||
|
const code = getResponseCode(res);
|
||||||
|
if (typeof code === 'number' && code !== 0) {
|
||||||
|
throw new Error(getResponseMessage(res) || '核销失败');
|
||||||
|
}
|
||||||
|
message.success(getResponseMessage(res) || '核销成功');
|
||||||
|
reloadTable();
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error?.message || '核销失败');
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const columns = useMemo(
|
||||||
|
() => buildCtripDistOrderColumns({ onCancel: handleCancel, onConsume: handleConsume }),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer header={{ title: '携程分销订单管理' }}>
|
<PageContainer header={{ title: '携程分销订单管理' }}>
|
||||||
@@ -66,7 +119,7 @@ const CtripDistOrderPage: React.FC = () => {
|
|||||||
columns={columns}
|
columns={columns}
|
||||||
search={false}
|
search={false}
|
||||||
pagination={{ showSizeChanger: true, showQuickJumper: true, defaultPageSize: 20 }}
|
pagination={{ showSizeChanger: true, showQuickJumper: true, defaultPageSize: 20 }}
|
||||||
scroll={{ x: 2200 }}
|
scroll={{ x: 2360 }}
|
||||||
/>
|
/>
|
||||||
</GlassCard>
|
</GlassCard>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
|
|||||||
@@ -642,6 +642,19 @@ export const ordersApi = {
|
|||||||
const data = (res as any)?.data;
|
const data = (res as any)?.data;
|
||||||
return { data: data?.data || [], total: data?.count || 0 };
|
return { data: data?.data || [], total: data?.count || 0 };
|
||||||
},
|
},
|
||||||
|
ctripDistOrderCancel: async (orderNo: string, reason?: string) => {
|
||||||
|
const res = await request(`/api-coupon/ctrip/dist/order/cancel/${orderNo}`, {
|
||||||
|
method: 'POST',
|
||||||
|
params: reason ? { reason } : undefined,
|
||||||
|
});
|
||||||
|
return res as any;
|
||||||
|
},
|
||||||
|
ctripDistOrderConsume: async (ctripOrderId: number) => {
|
||||||
|
const res = await request(`/api-coupon/ctrip/dist/order/consume/${ctripOrderId}`, {
|
||||||
|
method: 'POST',
|
||||||
|
});
|
||||||
|
return res as any;
|
||||||
|
},
|
||||||
|
|
||||||
// ==================== 订单状态超时监控配置 ====================
|
// ==================== 订单状态超时监控配置 ====================
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user