zksu
/
WEB
forked from yoone/WEB
1
0
Fork 0

feat(订单): 增加订单导出功能并扩展API类型定义

扩展订单列表API的类型定义,增加时间范围查询参数和分组选项
修改订单导出功能,直接返回CSV文件流供下载
为订单详情添加更多字段类型定义,包括支付时间、客户IP等
This commit is contained in:
tikkhun 2025-12-31 14:56:46 +08:00
parent 6f35c2aee5
commit 6d97ecbcc7
2 changed files with 303 additions and 211 deletions

View File

@ -76,6 +76,7 @@ import {
} from 'antd';
import React, { useMemo, useRef, useState } from 'react';
import RelatedOrders from '../../Subscription/Orders/RelatedOrders';
import { request } from '@umijs/max';
const ListPage: React.FC = () => {
const actionRef = useRef<ActionType>();
@ -504,15 +505,25 @@ const ListPage: React.FC = () => {
title="批量导出"
description="确认导出选中的订单吗?"
onConfirm={async () => {
console.log(selectedRowKeys);
try {
const { success, message: errMsg } =
await ordercontrollerExportorder({
const res = await request('/order/order/export', {
method: 'GET',
params: {
ids: selectedRowKeys,
});
if (!success) {
throw new Error(errMsg);
}
});
if (res?.success && res?.data?.csv) {
const blob = new Blob([res.data.csv], { type: 'text/csv;charset=utf-8;' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'customers.csv';
a.click();
URL.revokeObjectURL(url);
} else {
message.error(res.message || '导出失败');
}
message.success('导出成功');
actionRef.current?.reload();
setSelectedRowKeys([]);
} catch (error: any) {
@ -616,36 +627,36 @@ const Detail: React.FC<{
)
? []
: [
<Divider type="vertical" />,
<Button
type="primary"
onClick={async () => {
try {
if (!record.siteId || !record.externalOrderId) {
message.error('站点ID或外部订单ID不存在');
return;
}
const {
success,
message: errMsg,
data,
} = await ordercontrollerSyncorderbyid({
siteId: record.siteId,
orderId: record.externalOrderId,
});
if (!success) {
throw new Error(errMsg);
}
showSyncResult(data as SyncResultData, '订单');
tableRef.current?.reload();
} catch (error: any) {
message.error(error?.message || '同步失败');
<Divider type="vertical" />,
<Button
type="primary"
onClick={async () => {
try {
if (!record.siteId || !record.externalOrderId) {
message.error('站点ID或外部订单ID不存在');
return;
}
}}
>
</Button>,
]),
const {
success,
message: errMsg,
data,
} = await ordercontrollerSyncorderbyid({
siteId: record.siteId,
orderId: record.externalOrderId,
});
if (!success) {
throw new Error(errMsg);
}
showSyncResult(data as SyncResultData, '订单');
tableRef.current?.reload();
} catch (error: any) {
message.error(error?.message || '同步失败');
}
}}
>
</Button>,
]),
// ...(['processing', 'pending_reshipment'].includes(record.orderStatus)
// ? [
// <Divider type="vertical" />,
@ -664,152 +675,152 @@ const Detail: React.FC<{
'pending_refund',
].includes(record.orderStatus)
? [
<Divider type="vertical" />,
<Popconfirm
title="转至售后"
description="确认转至售后?"
onConfirm={async () => {
try {
if (!record.id) {
message.error('订单ID不存在');
return;
}
const { success, message: errMsg } =
await ordercontrollerChangestatus(
{
id: record.id,
},
{
status: 'after_sale_pending',
},
);
if (!success) {
throw new Error(errMsg);
}
tableRef.current?.reload();
} catch (error: any) {
message.error(error.message);
<Divider type="vertical" />,
<Popconfirm
title="转至售后"
description="确认转至售后?"
onConfirm={async () => {
try {
if (!record.id) {
message.error('订单ID不存在');
return;
}
}}
>
<Button type="primary" ghost>
</Button>
</Popconfirm>,
]
const { success, message: errMsg } =
await ordercontrollerChangestatus(
{
id: record.id,
},
{
status: 'after_sale_pending',
},
);
if (!success) {
throw new Error(errMsg);
}
tableRef.current?.reload();
} catch (error: any) {
message.error(error.message);
}
}}
>
<Button type="primary" ghost>
</Button>
</Popconfirm>,
]
: []),
...(record.orderStatus === 'after_sale_pending'
? [
<Divider type="vertical" />,
<Popconfirm
title="转至取消"
description="确认转至取消?"
onConfirm={async () => {
try {
if (!record.id) {
message.error('订单ID不存在');
return;
}
const { success, message: errMsg } =
await ordercontrollerCancelorder({
<Divider type="vertical" />,
<Popconfirm
title="转至取消"
description="确认转至取消?"
onConfirm={async () => {
try {
if (!record.id) {
message.error('订单ID不存在');
return;
}
const { success, message: errMsg } =
await ordercontrollerCancelorder({
id: record.id,
});
if (!success) {
throw new Error(errMsg);
}
tableRef.current?.reload();
} catch (error: any) {
message.error(error.message);
}
}}
>
<Button type="primary" ghost>
</Button>
</Popconfirm>,
<Divider type="vertical" />,
<Popconfirm
title="转至退款"
description="确认转至退款?"
onConfirm={async () => {
try {
if (!record.id) {
message.error('订单ID不存在');
return;
}
const { success, message: errMsg } =
await ordercontrollerRefundorder({
id: record.id,
});
if (!success) {
throw new Error(errMsg);
}
tableRef.current?.reload();
} catch (error: any) {
message.error(error.message);
}
}}
>
<Button type="primary" ghost>
退
</Button>
</Popconfirm>,
<Divider type="vertical" />,
<Popconfirm
title="转至完成"
description="确认转至完成?"
onConfirm={async () => {
try {
if (!record.id) {
message.error('订单ID不存在');
return;
}
const { success, message: errMsg } =
await ordercontrollerCompletedorder({
id: record.id,
});
if (!success) {
throw new Error(errMsg);
}
tableRef.current?.reload();
} catch (error: any) {
message.error(error.message);
}
}}
>
<Button type="primary" ghost>
</Button>
</Popconfirm>,
<Divider type="vertical" />,
<Popconfirm
title="转至待补发"
description="确认转至待补发?"
onConfirm={async () => {
try {
const { success, message: errMsg } =
await ordercontrollerChangestatus(
{
id: record.id,
});
if (!success) {
throw new Error(errMsg);
}
tableRef.current?.reload();
} catch (error: any) {
message.error(error.message);
},
{
status: 'pending_reshipment',
},
);
if (!success) {
throw new Error(errMsg);
}
}}
>
<Button type="primary" ghost>
</Button>
</Popconfirm>,
<Divider type="vertical" />,
<Popconfirm
title="转至退款"
description="确认转至退款?"
onConfirm={async () => {
try {
if (!record.id) {
message.error('订单ID不存在');
return;
}
const { success, message: errMsg } =
await ordercontrollerRefundorder({
id: record.id,
});
if (!success) {
throw new Error(errMsg);
}
tableRef.current?.reload();
} catch (error: any) {
message.error(error.message);
}
}}
>
<Button type="primary" ghost>
退
</Button>
</Popconfirm>,
<Divider type="vertical" />,
<Popconfirm
title="转至完成"
description="确认转至完成?"
onConfirm={async () => {
try {
if (!record.id) {
message.error('订单ID不存在');
return;
}
const { success, message: errMsg } =
await ordercontrollerCompletedorder({
id: record.id,
});
if (!success) {
throw new Error(errMsg);
}
tableRef.current?.reload();
} catch (error: any) {
message.error(error.message);
}
}}
>
<Button type="primary" ghost>
</Button>
</Popconfirm>,
<Divider type="vertical" />,
<Popconfirm
title="转至待补发"
description="确认转至待补发?"
onConfirm={async () => {
try {
const { success, message: errMsg } =
await ordercontrollerChangestatus(
{
id: record.id,
},
{
status: 'pending_reshipment',
},
);
if (!success) {
throw new Error(errMsg);
}
tableRef.current?.reload();
} catch (error: any) {
message.error(error.message);
}
}}
>
<Button type="primary" ghost>
</Button>
</Popconfirm>,
]
tableRef.current?.reload();
} catch (error: any) {
message.error(error.message);
}
}}
>
<Button type="primary" ghost>
</Button>
</Popconfirm>,
]
: []),
]}
>
@ -1071,31 +1082,31 @@ const Detail: React.FC<{
}
actions={
v.state === 'waiting-for-scheduling' ||
v.state === 'waiting-for-transit'
v.state === 'waiting-for-transit'
? [
<Popconfirm
title="取消运单"
description="确认取消运单?"
onConfirm={async () => {
try {
const { success, message: errMsg } =
await logisticscontrollerDelshipment({
id: v.id,
});
if (!success) {
throw new Error(errMsg);
}
tableRef.current?.reload();
initRequest();
} catch (error: any) {
message.error(error.message);
<Popconfirm
title="取消运单"
description="确认取消运单?"
onConfirm={async () => {
try {
const { success, message: errMsg } =
await logisticscontrollerDelshipment({
id: v.id,
});
if (!success) {
throw new Error(errMsg);
}
}}
>
<DeleteFilled />
</Popconfirm>,
]
tableRef.current?.reload();
initRequest();
} catch (error: any) {
message.error(error.message);
}
}}
>
<DeleteFilled />
</Popconfirm>,
]
: []
}
>
@ -1483,16 +1494,16 @@ const Shipping: React.FC<{
<ProFormList
label="发货产品"
name="sales"
// rules={[
// {
// required: true,
// message: '至少需要一个商品',
// validator: (_, value) =>
// value && value.length > 0
// ? Promise.resolve()
// : Promise.reject('至少需要一个商品'),
// },
// ]}
// rules={[
// {
// required: true,
// message: '至少需要一个商品',
// validator: (_, value) =>
// value && value.length > 0
// ? Promise.resolve()
// : Promise.reject('至少需要一个商品'),
// },
// ]}
>
<ProForm.Group>
<ProFormSelect
@ -1917,7 +1928,7 @@ const Shipping: React.FC<{
name="description"
placeholder="请输入描述"
width="lg"
// rules={[{ required: true, message: '请输入描述' }]}
// rules={[{ required: true, message: '请输入描述' }]}
/>
</ProForm.Group>
</ProFormList>

View File

@ -452,7 +452,7 @@ declare namespace API {
/** 站点ID */
site_id?: number;
/** 原始ID */
origin_id?: number;
origin_id?: string;
/** 站点创建时间 */
site_created_at?: string;
/** 站点更新时间 */
@ -988,6 +988,7 @@ declare namespace API {
purchaseType?: 'all' | 'first_purchase' | 'repeat_purchase';
orderType?: 'all' | 'cpc' | 'non_cpc';
brand?: 'all' | 'zyn' | 'yoone' | 'zolt';
grouping?: 'day' | 'week' | 'month';
};
type OrderStatusCountDTO = {
@ -1156,6 +1157,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1669,6 +1674,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1683,6 +1692,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1697,6 +1710,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1711,6 +1728,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1725,6 +1746,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1739,6 +1764,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1758,6 +1787,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1778,6 +1811,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1796,6 +1833,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1820,6 +1861,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1844,6 +1889,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1858,6 +1907,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1872,6 +1925,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -1891,6 +1948,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -2398,6 +2459,8 @@ declare namespace API {
email?: string;
/** 电话 */
phone?: string;
/** 配送方式 */
method_title?: string;
};
type UnifiedCategoryDTO = {
@ -2535,6 +2598,8 @@ declare namespace API {
status?: string;
/** 货币 */
currency?: string;
/** 货币符号 */
currency_symbol?: string;
/** 总金额 */
total?: string;
/** 客户ID */
@ -2543,6 +2608,8 @@ declare namespace API {
customer_name?: string;
/** 客户邮箱 */
email?: string;
/** 客户邮箱 */
customer_email?: string;
/** 订单项(具体的商品) */
line_items?: UnifiedOrderLineItemDTO[];
/** 销售项(兼容前端) */
@ -2573,6 +2640,16 @@ declare namespace API {
coupon_lines?: UnifiedCouponLineDTO[];
/** 物流追踪信息 */
tracking?: UnifiedOrderTrackingDTO[];
/** 支付时间 */
date_paid?: string;
/** 客户IP地址 */
customer_ip_address?: string;
/** UTM来源 */
utm_source?: string;
/** 设备类型 */
device_type?: string;
/** 来源类型 */
source_type?: string;
};
type UnifiedOrderLineItemDTO = {
@ -2801,6 +2878,10 @@ declare namespace API {
page?: number;
/** 每页数量 */
per_page?: number;
/** 查询时间范围开始 */
after?: string;
/** 查询时间范围结束 */
before?: string;
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
@ -2916,7 +2997,7 @@ declare namespace API {
/** 站点ID */
site_id?: number;
/** 原始ID */
origin_id?: number;
origin_id?: string;
/** 邮箱 */
email?: string;
/** 名字 */