mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
feat: 新增拼多多订单页
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
-- 拼多多:占位菜单改为目录,并增加「订单」子菜单;补齐权限(存量库可能未跑过 OAuth/同步迁移的权限段)
|
||||
|
||||
-- 0) 权限(幂等)
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 3600, (SELECT id FROM `sys_permission` WHERE `code` = 'MODULE:ecom' LIMIT 1),
|
||||
'biz:pdd', '拼多多', 'module', 1, '拼多多对接', 360
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'biz:pdd');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 3601, (SELECT id FROM `sys_permission` WHERE `code` = 'biz:pdd' LIMIT 1),
|
||||
'biz:pdd:auth:manage', '拼多多授权管理', 'api', 1, '生成授权链接/管理授权', 361
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'biz:pdd:auth:manage');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 3602, (SELECT id FROM `sys_permission` WHERE `code` = 'biz:pdd' LIMIT 1),
|
||||
'biz:pdd:shop:read', '拼多多店铺查看', 'api', 1, '', 362
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'biz:pdd:shop:read');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 3603, (SELECT id FROM `sys_permission` WHERE `code` = 'biz:pdd' LIMIT 1),
|
||||
'biz:pdd:shop:manage', '拼多多店铺管理', 'api', 1, '', 363
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'biz:pdd:shop:manage');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 3604, (SELECT id FROM `sys_permission` WHERE `code` = 'biz:pdd' LIMIT 1),
|
||||
'biz:pdd:order:sync', '拼多多订单同步', 'api', 1, '手动/定时同步拼多多订单', 364
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'biz:pdd:order:sync');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 3605, (SELECT id FROM `sys_permission` WHERE `code` = 'biz:pdd' LIMIT 1),
|
||||
'biz:pdd:order:read', '拼多多订单查看', 'api', 1, '', 365
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'biz:pdd:order:read');
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `code`, `name`, `type`, `status`, `remark`, `sort_order`)
|
||||
SELECT 3606, (SELECT id FROM `sys_permission` WHERE `code` = 'biz:pdd' LIMIT 1),
|
||||
'biz:pdd:order:manage', '拼多多订单管理', 'api', 1, '', 366
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `code` = 'biz:pdd:order:manage');
|
||||
|
||||
-- 1) 拼多多改为 catalog,补齐路由前缀
|
||||
UPDATE `sys_menu`
|
||||
SET `type` = 'catalog',
|
||||
`path` = '/pdd',
|
||||
`component` = '',
|
||||
`redirect` = NULL,
|
||||
`order` = 0
|
||||
WHERE `name` = '拼多多';
|
||||
|
||||
-- 2) 订单子菜单
|
||||
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||
SELECT 12032,
|
||||
(SELECT id FROM `sys_menu` WHERE `name` = '拼多多' LIMIT 1),
|
||||
0,
|
||||
'拼多多订单',
|
||||
'订单',
|
||||
'/pdd/order',
|
||||
'/ecommerce/pdd/order/index',
|
||||
'',
|
||||
'lucide:shopping-bag',
|
||||
'menu',
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '拼多多订单' OR `path` = '/pdd/order');
|
||||
|
||||
-- 3) 菜单挂权限
|
||||
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id
|
||||
FROM `sys_menu` m
|
||||
JOIN `sys_permission` p ON p.code IN ('biz:pdd:order:read', 'biz:pdd:order:manage', 'biz:pdd:order:sync')
|
||||
WHERE m.name = '拼多多订单' OR m.path = '/pdd/order';
|
||||
|
||||
-- 4) 已开通「拼多多」的公司自动开通子菜单
|
||||
INSERT IGNORE INTO `org_company_menu` (`company_id`, `menu_id`, `status`)
|
||||
SELECT cm.company_id, child.id, 1
|
||||
FROM `org_company_menu` cm
|
||||
JOIN `sys_menu` parent ON parent.id = cm.menu_id AND parent.name = '拼多多'
|
||||
JOIN `sys_menu` child ON child.name = '拼多多订单'
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM `org_company_menu` x
|
||||
WHERE x.company_id = cm.company_id AND x.menu_id = child.id
|
||||
);
|
||||
|
||||
-- 5) 已开通拼多多菜单的公司,补齐拼多多权限
|
||||
INSERT IGNORE INTO `org_company_permission` (`company_id`, `permission_id`)
|
||||
SELECT DISTINCT cm.company_id, p.id
|
||||
FROM `org_company_menu` cm
|
||||
JOIN `sys_menu` m ON m.id = cm.menu_id AND m.name = '拼多多'
|
||||
JOIN `sys_permission` p ON p.code IN (
|
||||
'biz:pdd', 'biz:pdd:order:read', 'biz:pdd:order:manage', 'biz:pdd:order:sync',
|
||||
'biz:pdd:auth:manage', 'biz:pdd:shop:read', 'biz:pdd:shop:manage'
|
||||
)
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM `org_company_permission` x
|
||||
WHERE x.company_id = cm.company_id AND x.permission_id = p.id
|
||||
);
|
||||
+6
@@ -35,4 +35,10 @@ public class PddOrderFilterDTO {
|
||||
|
||||
@Schema(description = "支付时间-结束")
|
||||
private LocalDateTime payTimeEnd;
|
||||
|
||||
@Schema(description = "成交时间-开始")
|
||||
private LocalDateTime confirmTimeStart;
|
||||
|
||||
@Schema(description = "成交时间-结束")
|
||||
private LocalDateTime confirmTimeEnd;
|
||||
}
|
||||
|
||||
+8
-2
@@ -131,7 +131,7 @@ public class PddOrderServiceImpl extends ServiceImpl<PddOrderMapper, PddOrderPO>
|
||||
wrapper.eq(PddOrderPO::getShopId, filter.getShopId());
|
||||
}
|
||||
if (filter.getOrderSn() != null && !filter.getOrderSn().isEmpty()) {
|
||||
wrapper.eq(PddOrderPO::getOrderSn, filter.getOrderSn());
|
||||
wrapper.like(PddOrderPO::getOrderSn, filter.getOrderSn().trim());
|
||||
}
|
||||
if (filter.getOrderStatus() != null) {
|
||||
wrapper.eq(PddOrderPO::getOrderStatus, filter.getOrderStatus());
|
||||
@@ -154,8 +154,14 @@ public class PddOrderServiceImpl extends ServiceImpl<PddOrderMapper, PddOrderPO>
|
||||
if (filter.getPayTimeEnd() != null) {
|
||||
wrapper.le(PddOrderPO::getPayTime, filter.getPayTimeEnd());
|
||||
}
|
||||
if (filter.getConfirmTimeStart() != null) {
|
||||
wrapper.ge(PddOrderPO::getConfirmTime, filter.getConfirmTimeStart());
|
||||
}
|
||||
if (filter.getConfirmTimeEnd() != null) {
|
||||
wrapper.le(PddOrderPO::getConfirmTime, filter.getConfirmTimeEnd());
|
||||
}
|
||||
|
||||
wrapper.orderByDesc(PddOrderPO::getCreatedTime);
|
||||
wrapper.orderByDesc(PddOrderPO::getConfirmTime).orderByDesc(PddOrderPO::getId);
|
||||
|
||||
IPage<PddOrderPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
IPage<PddOrderPO> result = this.page(page, wrapper);
|
||||
|
||||
@@ -390,9 +390,13 @@ SELECT 12020, NULL, 0, '月度目标', '月度目标', 'shop/monthly-target', '/
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '月度目标');
|
||||
|
||||
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||
SELECT 12030, NULL, 0, '拼多多', '拼多多', '', '', '', 'arcticons:pinduoduo', 'menu', 1, 1, 0, 0
|
||||
SELECT 12030, NULL, 0, '拼多多', '拼多多', '/pdd', '', '', 'arcticons:pinduoduo', 'catalog', 1, 1, 0, 0
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '拼多多');
|
||||
|
||||
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||
SELECT 12032, (SELECT id FROM `sys_menu` WHERE `name` = '拼多多' LIMIT 1), 0, '拼多多订单', '订单', '/pdd/order', '/ecommerce/pdd/order/index', '', 'lucide:shopping-bag', 'menu', 1, 1, 0, 1
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '拼多多订单');
|
||||
|
||||
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||
SELECT 12031, NULL, 0, '淘宝', '淘宝', '', '', '', 'ri:taobao-fill', 'menu', 1, 1, 0, 0
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '淘宝');
|
||||
@@ -533,6 +537,9 @@ SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code = 'org:pos
|
||||
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code LIKE 'ecom:order:%' WHERE m.name = '订单管理';
|
||||
|
||||
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code IN ('biz:pdd:order:read', 'biz:pdd:order:manage', 'biz:pdd:order:sync') WHERE m.name = '拼多多订单';
|
||||
|
||||
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||
SELECT m.id, p.id FROM `sys_menu` m JOIN `sys_permission` p ON p.code LIKE 'ecom:product:%' WHERE m.name = '商品管理';
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { PddOrderDTO, PddOrderVO } from './types';
|
||||
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/** 分页查询拼多多订单 */
|
||||
export async function getPddOrderPageApi(
|
||||
params: PageQueryDTO<PddOrderDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<PddOrderVO.Info>>(
|
||||
'/ec/pdd/order/list',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/** 拼多多订单详情(含明细) */
|
||||
export async function getPddOrderDetailApi(id: number) {
|
||||
return requestClient.get<PddOrderVO.Info>(`/ec/pdd/order/detail/${id}`);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 拼多多订单 DTO
|
||||
*/
|
||||
export namespace PddOrderDTO {
|
||||
export interface Filters {
|
||||
shopId?: number;
|
||||
orderSn?: string;
|
||||
orderStatus?: number;
|
||||
refundStatus?: number;
|
||||
afterSalesStatus?: number;
|
||||
createdTimeStart?: string;
|
||||
createdTimeEnd?: string;
|
||||
payTimeStart?: string;
|
||||
payTimeEnd?: string;
|
||||
confirmTimeStart?: string;
|
||||
confirmTimeEnd?: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* 拼多多订单 VO
|
||||
*/
|
||||
export namespace PddOrderVO {
|
||||
export interface Item {
|
||||
id: number;
|
||||
orderId: number;
|
||||
orderSn: string;
|
||||
goodsId?: string;
|
||||
skuId?: string;
|
||||
goodsName?: string;
|
||||
goodsSpec?: string;
|
||||
goodsImg?: string;
|
||||
goodsCount?: number;
|
||||
goodsPrice?: number;
|
||||
outerGoodsId?: string;
|
||||
outerId?: string;
|
||||
}
|
||||
|
||||
export interface Info {
|
||||
id: number;
|
||||
companyId: number;
|
||||
shopId: number;
|
||||
pddAuthId?: number;
|
||||
orderSn: string;
|
||||
orderStatus?: number;
|
||||
refundStatus?: number;
|
||||
afterSalesStatus?: number;
|
||||
confirmStatus?: number;
|
||||
payAmount?: number;
|
||||
goodsAmount?: number;
|
||||
discountAmount?: number;
|
||||
postage?: number;
|
||||
platformDiscount?: number;
|
||||
sellerDiscount?: number;
|
||||
logisticsId?: number;
|
||||
trackingNumber?: string;
|
||||
createdTime?: string;
|
||||
payTime?: string;
|
||||
confirmTime?: string;
|
||||
shippingTime?: string;
|
||||
receiveTime?: string;
|
||||
province?: string;
|
||||
city?: string;
|
||||
town?: string;
|
||||
receiverNameMask?: string;
|
||||
receiverPhoneMask?: string;
|
||||
receiverAddressMask?: string;
|
||||
buyerMemo?: string;
|
||||
remark?: string;
|
||||
tradeType?: number;
|
||||
isPreSale?: number;
|
||||
groupStatus?: number;
|
||||
lastSyncTime?: string;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
items?: Item[];
|
||||
}
|
||||
}
|
||||
+242
@@ -0,0 +1,242 @@
|
||||
<script lang="ts" setup>
|
||||
import type { PddOrderVO } from '#/api/ecommerce/pdd/order';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import {
|
||||
Descriptions,
|
||||
DescriptionsItem,
|
||||
Drawer,
|
||||
Image,
|
||||
Table,
|
||||
Tag,
|
||||
message,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { getPddOrderDetailApi } from '#/api/ecommerce/pdd/order';
|
||||
|
||||
defineOptions({ name: 'PddOrderDetailDrawer' });
|
||||
|
||||
const ORDER_STATUS_MAP: Record<number, { color: string; text: string }> = {
|
||||
1: { text: '待发货', color: 'orange' },
|
||||
2: { text: '已发货待签收', color: 'blue' },
|
||||
3: { text: '已签收', color: 'green' },
|
||||
};
|
||||
|
||||
const REFUND_STATUS_MAP: Record<number, { color: string; text: string }> = {
|
||||
1: { text: '无售后/已关闭', color: 'default' },
|
||||
2: { text: '售后处理中', color: 'processing' },
|
||||
3: { text: '退款中', color: 'warning' },
|
||||
4: { text: '退款成功', color: 'error' },
|
||||
};
|
||||
|
||||
const openFlag = ref(false);
|
||||
const loading = ref(false);
|
||||
const shopName = ref('');
|
||||
const detail = ref<null | PddOrderVO.Info>(null);
|
||||
|
||||
const itemColumns = [
|
||||
{
|
||||
title: '商品',
|
||||
key: 'goods',
|
||||
dataIndex: 'goodsName',
|
||||
},
|
||||
{
|
||||
title: '规格',
|
||||
dataIndex: 'goodsSpec',
|
||||
key: 'goodsSpec',
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '数量',
|
||||
dataIndex: 'goodsCount',
|
||||
key: 'goodsCount',
|
||||
width: 70,
|
||||
},
|
||||
{
|
||||
title: '单价',
|
||||
key: 'goodsPrice',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: 'SKU',
|
||||
dataIndex: 'skuId',
|
||||
key: 'skuId',
|
||||
ellipsis: true,
|
||||
},
|
||||
];
|
||||
|
||||
const moneyFields = computed(() => [
|
||||
{ label: '实付', value: detail.value?.payAmount },
|
||||
{ label: '商品金额', value: detail.value?.goodsAmount },
|
||||
{ label: '折扣', value: detail.value?.discountAmount },
|
||||
{ label: '邮费', value: detail.value?.postage },
|
||||
{ label: '平台优惠', value: detail.value?.platformDiscount },
|
||||
{ label: '商家优惠', value: detail.value?.sellerDiscount },
|
||||
]);
|
||||
|
||||
function money(v?: null | number) {
|
||||
if (v == null || Number.isNaN(Number(v))) return '-';
|
||||
return `¥${Number(v).toFixed(2)}`;
|
||||
}
|
||||
|
||||
function statusText(
|
||||
map: Record<number, { color: string; text: string }>,
|
||||
status?: null | number,
|
||||
) {
|
||||
if (status == null) return { text: '-', color: 'default' };
|
||||
return map[status] ?? { text: String(status), color: 'default' };
|
||||
}
|
||||
|
||||
async function open(id: number, shopLabel?: string) {
|
||||
openFlag.value = true;
|
||||
shopName.value = shopLabel || '';
|
||||
loading.value = true;
|
||||
detail.value = null;
|
||||
try {
|
||||
detail.value = await getPddOrderDetailApi(id);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.error('加载订单详情失败');
|
||||
openFlag.value = false;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
openFlag.value = false;
|
||||
}
|
||||
|
||||
defineExpose({ open, close });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Drawer
|
||||
v-model:open="openFlag"
|
||||
title="拼多多订单详情"
|
||||
width="720"
|
||||
destroy-on-close
|
||||
:loading="loading"
|
||||
>
|
||||
<template v-if="detail">
|
||||
<Descriptions bordered :column="2" size="small" class="mb-4">
|
||||
<DescriptionsItem label="订单号" :span="2">
|
||||
{{ detail.orderSn }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="店铺">
|
||||
{{ shopName || `店铺#${detail.shopId}` }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="运单号">
|
||||
{{ detail.trackingNumber || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="订单状态">
|
||||
<Tag :color="statusText(ORDER_STATUS_MAP, detail.orderStatus).color">
|
||||
{{ statusText(ORDER_STATUS_MAP, detail.orderStatus).text }}
|
||||
</Tag>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="退款状态">
|
||||
<Tag
|
||||
:color="statusText(REFUND_STATUS_MAP, detail.refundStatus).color"
|
||||
>
|
||||
{{ statusText(REFUND_STATUS_MAP, detail.refundStatus).text }}
|
||||
</Tag>
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="成交时间">
|
||||
{{ detail.confirmTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="支付时间">
|
||||
{{ detail.payTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="下单时间">
|
||||
{{ detail.createdTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="发货时间">
|
||||
{{ detail.shippingTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="签收时间">
|
||||
{{ detail.receiveTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="最近同步">
|
||||
{{ detail.lastSyncTime || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem
|
||||
v-for="item in moneyFields"
|
||||
:key="item.label"
|
||||
:label="item.label"
|
||||
>
|
||||
{{ money(item.value) }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="收件人">
|
||||
{{ detail.receiverNameMask || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="手机">
|
||||
{{ detail.receiverPhoneMask || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="地区" :span="2">
|
||||
{{
|
||||
[detail.province, detail.city, detail.town]
|
||||
.filter(Boolean)
|
||||
.join(' / ') || '-'
|
||||
}}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="地址" :span="2">
|
||||
{{ detail.receiverAddressMask || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="买家留言" :span="2">
|
||||
{{ detail.buyerMemo || '-' }}
|
||||
</DescriptionsItem>
|
||||
<DescriptionsItem label="商家备注" :span="2">
|
||||
{{ detail.remark || '-' }}
|
||||
</DescriptionsItem>
|
||||
</Descriptions>
|
||||
|
||||
<div class="mb-2 font-medium">商品明细</div>
|
||||
<Table
|
||||
:columns="itemColumns"
|
||||
:data-source="detail.items || []"
|
||||
:pagination="false"
|
||||
row-key="id"
|
||||
size="small"
|
||||
bordered
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'goods'">
|
||||
<div class="goods-row">
|
||||
<Image
|
||||
v-if="record.goodsImg"
|
||||
:src="record.goodsImg"
|
||||
:width="36"
|
||||
:height="36"
|
||||
/>
|
||||
<span>{{ record.goodsName || '-' }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'goodsPrice'">
|
||||
{{ money(record.goodsPrice) }}
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</template>
|
||||
</Drawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.mb-4 {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.mb-2 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.font-medium {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.goods-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,472 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { PlatformVO } from '#/api/ecommerce/platform/types';
|
||||
import type { PddOrderDTO, PddOrderVO } from '#/api/ecommerce/pdd/order';
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { Button, Image, Space, Tag, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getPddOrderPageApi } from '#/api/ecommerce/pdd/order';
|
||||
import { getActivePlatformsApi } from '#/api/ecommerce/platform';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
import PddOrderDetailDrawer from './components/PddOrderDetailDrawer.vue';
|
||||
|
||||
defineOptions({ name: 'PddOrderManagement' });
|
||||
|
||||
const PLATFORM_CODE_PDD = 'pdd';
|
||||
|
||||
const ORDER_STATUS_MAP: Record<number, { color: string; text: string }> = {
|
||||
1: { text: '待发货', color: 'orange' },
|
||||
2: { text: '已发货待签收', color: 'blue' },
|
||||
3: { text: '已签收', color: 'green' },
|
||||
};
|
||||
|
||||
const REFUND_STATUS_MAP: Record<number, { color: string; text: string }> = {
|
||||
1: { text: '无售后/已关闭', color: 'default' },
|
||||
2: { text: '售后处理中', color: 'processing' },
|
||||
3: { text: '退款中', color: 'warning' },
|
||||
4: { text: '退款成功', color: 'error' },
|
||||
};
|
||||
|
||||
const loading = ref(false);
|
||||
const detailDrawerRef = ref<InstanceType<typeof PddOrderDetailDrawer>>();
|
||||
const shopOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const shopNameById = ref<Record<number, string>>({});
|
||||
|
||||
const DEFAULT_LIST_DAYS = 7;
|
||||
|
||||
function buildDefaultConfirmRange() {
|
||||
const end = dayjs().endOf('day');
|
||||
const start = dayjs()
|
||||
.subtract(DEFAULT_LIST_DAYS - 1, 'day')
|
||||
.startOf('day');
|
||||
return {
|
||||
start: start.format('YYYY-MM-DD HH:mm:ss'),
|
||||
end: end.format('YYYY-MM-DD HH:mm:ss'),
|
||||
range: [start, end] as [dayjs.Dayjs, dayjs.Dayjs],
|
||||
};
|
||||
}
|
||||
|
||||
const defaultConfirm = buildDefaultConfirmRange();
|
||||
|
||||
const searchForm = ref({
|
||||
orderSn: '',
|
||||
shopId: undefined as number | undefined,
|
||||
orderStatus: undefined as number | undefined,
|
||||
refundStatus: undefined as number | undefined,
|
||||
confirmTimeStart: defaultConfirm.start as string | undefined,
|
||||
confirmTimeEnd: defaultConfirm.end as string | undefined,
|
||||
});
|
||||
|
||||
function money(v?: null | number) {
|
||||
if (v == null || Number.isNaN(Number(v))) return '-';
|
||||
return `¥${Number(v).toFixed(2)}`;
|
||||
}
|
||||
|
||||
function orderStatusTag(status?: null | number) {
|
||||
if (status == null) return { text: '-', color: 'default' };
|
||||
return ORDER_STATUS_MAP[status] ?? { text: String(status), color: 'default' };
|
||||
}
|
||||
|
||||
function refundStatusTag(status?: null | number) {
|
||||
if (status == null) return { text: '-', color: 'default' };
|
||||
return REFUND_STATUS_MAP[status] ?? { text: String(status), color: 'default' };
|
||||
}
|
||||
|
||||
function regionText(row: PddOrderVO.Info) {
|
||||
return [row.province, row.city, row.town].filter(Boolean).join(' / ') || '-';
|
||||
}
|
||||
|
||||
async function loadPddShops() {
|
||||
try {
|
||||
const platforms = await getActivePlatformsApi();
|
||||
const pddPlatformIds = new Set(
|
||||
platforms
|
||||
.filter((p: PlatformVO.Info) => p.platformCode === PLATFORM_CODE_PDD)
|
||||
.map((p: PlatformVO.Info) => p.id),
|
||||
);
|
||||
const data = await getShopPageApi({
|
||||
page: 1,
|
||||
pageSize: 500,
|
||||
filters: {} as ShopDTO.Filters,
|
||||
});
|
||||
const list = (data.records ?? []).filter(
|
||||
(s: ShopVO.Info) =>
|
||||
(s.platformId != null && pddPlatformIds.has(s.platformId)) ||
|
||||
!!s.pddShop ||
|
||||
!!s.externalShopId,
|
||||
);
|
||||
shopOptions.value = list.map((s) => ({ label: s.name, value: s.id }));
|
||||
const map: Record<number, string> = {};
|
||||
for (const s of list) map[s.id] = s.name;
|
||||
shopNameById.value = map;
|
||||
|
||||
await gridApi.formApi?.updateSchema([
|
||||
{
|
||||
fieldName: 'shopId',
|
||||
componentProps: { options: shopOptions.value },
|
||||
},
|
||||
]);
|
||||
} catch {
|
||||
message.error('获取店铺列表失败');
|
||||
}
|
||||
}
|
||||
|
||||
const gridOptions: VxeGridProps<PddOrderVO.Info> = {
|
||||
columns: [
|
||||
{ type: 'seq' as const, width: 56, title: '序号' },
|
||||
{
|
||||
field: 'orderSn',
|
||||
title: '订单号',
|
||||
minWidth: 180,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
title: '店铺',
|
||||
minWidth: 120,
|
||||
showOverflow: 'tooltip' as const,
|
||||
slots: { default: 'shopName' },
|
||||
},
|
||||
{
|
||||
title: '商品',
|
||||
minWidth: 220,
|
||||
showOverflow: false,
|
||||
slots: { default: 'goods' },
|
||||
},
|
||||
{
|
||||
title: '实付',
|
||||
width: 100,
|
||||
slots: { default: 'payAmount' },
|
||||
},
|
||||
{
|
||||
title: '订单状态',
|
||||
width: 120,
|
||||
slots: { default: 'orderStatus' },
|
||||
},
|
||||
{
|
||||
title: '退款状态',
|
||||
width: 120,
|
||||
slots: { default: 'refundStatus' },
|
||||
},
|
||||
{
|
||||
field: 'confirmTime',
|
||||
title: '成交时间',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
field: 'payTime',
|
||||
title: '支付时间',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
title: '收件地区',
|
||||
minWidth: 140,
|
||||
showOverflow: 'tooltip' as const,
|
||||
slots: { default: 'region' },
|
||||
},
|
||||
{
|
||||
field: 'lastSyncTime',
|
||||
title: '最近同步',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 100,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: { isHover: true, height: 72 },
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
toolbarConfig: {
|
||||
custom: true,
|
||||
refresh: true,
|
||||
zoom: true,
|
||||
},
|
||||
data: [],
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
layouts: [
|
||||
'PrevJump',
|
||||
'PrevPage',
|
||||
'Number',
|
||||
'NextPage',
|
||||
'NextJump',
|
||||
'Sizes',
|
||||
'FullJump',
|
||||
'Total',
|
||||
] as (
|
||||
| 'FullJump'
|
||||
| 'NextJump'
|
||||
| 'NextPage'
|
||||
| 'Number'
|
||||
| 'PrevJump'
|
||||
| 'PrevPage'
|
||||
| 'Sizes'
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<PddOrderDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
orderSn: searchForm.value.orderSn || undefined,
|
||||
shopId: searchForm.value.shopId,
|
||||
orderStatus: searchForm.value.orderStatus,
|
||||
refundStatus: searchForm.value.refundStatus,
|
||||
confirmTimeStart: searchForm.value.confirmTimeStart,
|
||||
confirmTimeEnd: searchForm.value.confirmTimeEnd,
|
||||
},
|
||||
};
|
||||
const data = await getPddOrderPageApi(params);
|
||||
return {
|
||||
items: data.records,
|
||||
total: data.total,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.error('获取拼多多订单失败');
|
||||
return { items: [], total: 0 };
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '订单号(模糊,回车搜索)',
|
||||
allowClear: true,
|
||||
onChange: (e: any) => {
|
||||
searchForm.value.orderSn = e?.target?.value ?? '';
|
||||
},
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'orderSn',
|
||||
label: '订单号',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '全部店铺',
|
||||
options: shopOptions.value,
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
optionFilterProp: 'label',
|
||||
onChange: (val: number | undefined) => {
|
||||
searchForm.value.shopId = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'shopId',
|
||||
label: '店铺',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '全部',
|
||||
allowClear: true,
|
||||
options: Object.entries(ORDER_STATUS_MAP).map(([value, meta]) => ({
|
||||
label: meta.text,
|
||||
value: Number(value),
|
||||
})),
|
||||
onChange: (val: number | undefined) => {
|
||||
searchForm.value.orderStatus = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'orderStatus',
|
||||
label: '订单状态',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '全部',
|
||||
allowClear: true,
|
||||
options: Object.entries(REFUND_STATUS_MAP).map(([value, meta]) => ({
|
||||
label: meta.text,
|
||||
value: Number(value),
|
||||
})),
|
||||
onChange: (val: number | undefined) => {
|
||||
searchForm.value.refundStatus = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'refundStatus',
|
||||
label: '退款状态',
|
||||
},
|
||||
{
|
||||
component: 'RangePicker',
|
||||
defaultValue: defaultConfirm.range,
|
||||
componentProps: {
|
||||
placeholder: ['成交开始时间', '成交结束时间'],
|
||||
allowClear: true,
|
||||
showTime: { format: 'HH:mm:ss' },
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
style: { width: '100%' },
|
||||
onChange: (val: any) => {
|
||||
if (!val || !val[0] || !val[1]) {
|
||||
searchForm.value.confirmTimeStart = undefined;
|
||||
searchForm.value.confirmTimeEnd = undefined;
|
||||
return;
|
||||
}
|
||||
searchForm.value.confirmTimeStart = dayjs(val[0]).format(
|
||||
'YYYY-MM-DD HH:mm:ss',
|
||||
);
|
||||
searchForm.value.confirmTimeEnd = dayjs(val[1]).format(
|
||||
'YYYY-MM-DD HH:mm:ss',
|
||||
);
|
||||
},
|
||||
},
|
||||
fieldName: 'confirmTimeRange',
|
||||
label: '成交时间',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: false,
|
||||
collapsedRows: 2,
|
||||
}));
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '拼多多订单',
|
||||
});
|
||||
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
function openDetail(row: PddOrderVO.Info) {
|
||||
detailDrawerRef.value?.open(row.id, shopNameById.value[row.shopId]);
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadPddShops();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<Grid class="pdd-order-grid">
|
||||
<template #shopName="{ row }">
|
||||
{{ shopNameById[row.shopId] || `店铺#${row.shopId}` }}
|
||||
</template>
|
||||
|
||||
<template #goods="{ row }">
|
||||
<div class="goods-cell">
|
||||
<template v-if="row.items?.length">
|
||||
<Image
|
||||
v-if="row.items[0]?.goodsImg"
|
||||
:src="row.items[0].goodsImg"
|
||||
:width="40"
|
||||
:height="40"
|
||||
class="goods-img"
|
||||
/>
|
||||
<div class="goods-meta">
|
||||
<div class="goods-name" :title="row.items[0]?.goodsName">
|
||||
{{ row.items[0]?.goodsName || '-' }}
|
||||
</div>
|
||||
<div class="goods-spec">
|
||||
{{ row.items[0]?.goodsSpec || '' }}
|
||||
<span v-if="row.items.length > 1">
|
||||
等 {{ row.items.length }} 件
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<span v-else>-</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #payAmount="{ row }">
|
||||
{{ money(row.payAmount) }}
|
||||
</template>
|
||||
|
||||
<template #orderStatus="{ row }">
|
||||
<Tag :color="orderStatusTag(row.orderStatus).color">
|
||||
{{ orderStatusTag(row.orderStatus).text }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
<template #refundStatus="{ row }">
|
||||
<Tag :color="refundStatusTag(row.refundStatus).color">
|
||||
{{ refundStatusTag(row.refundStatus).text }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
<template #region="{ row }">
|
||||
{{ regionText(row) }}
|
||||
</template>
|
||||
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<Button type="link" size="small" @click="openDetail(row)">
|
||||
详情
|
||||
</Button>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<PddOrderDetailDrawer ref="detailDrawerRef" />
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.goods-cell {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
min-height: 48px;
|
||||
}
|
||||
|
||||
.goods-img {
|
||||
flex-shrink: 0;
|
||||
overflow: hidden;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.goods-meta {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.goods-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.goods-spec {
|
||||
color: #8c8c8c;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
:deep(.pdd-order-grid .vxe-body--column) {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user