From 8e2419c870e2db07b1106148f80373093d7cd235 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Sat, 7 Nov 2026 21:15:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(order):=20=E5=BE=85=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8F=90=E7=A4=BA=E8=A2=AB=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E7=9A=84=E6=9C=AA=E7=BB=91=E5=AE=9A=E5=95=86=E5=93=81=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 拉单提示「成功 9 单」但列表只显示 3 单,实际是明细商品未采集/未绑定的订单被 默认过滤(exclude_unbound=1)掉了,界面上看不到任何线索,容易误判为漏拉。 - service/orderStatus.list:exclude_unbound=1 时额外统计未过滤总数,返回 hiddenUnbound - controller/orderStatus.index:输出 hidden_unbound - contract.orderStatusPage:补 hidden_unbound 字段 - 前端 StatusPanel:工具栏显示「另有 N 单未显示」(hover 说明原因),点击即切到「含未绑定」 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- backend/app/contract/index.js | 5 ++++- backend/app/controller/orderStatus.js | 8 +++++-- backend/app/service/orderStatus.js | 27 +++++++++++++++--------- frontend/src/api/orderStatus.ts | 12 +++++++---- frontend/src/views/Order/StatusPanel.vue | 26 ++++++++++++++++++++++- 5 files changed, 60 insertions(+), 18 deletions(-) diff --git a/backend/app/contract/index.js b/backend/app/contract/index.js index a5932d3..0534b82 100644 --- a/backend/app/contract/index.js +++ b/backend/app/contract/index.js @@ -2511,7 +2511,10 @@ module.exports = { archived_at: { type: 'string', description: '归档时间(仅历史表)' }, transferred_at: { type: 'string', description: '转入历史时间(仅历史表)' }, }, - orderStatusPage: buildPage('orderStatusItem', '订单列表'), + orderStatusPage: { + ...buildPage('orderStatusItem', '订单列表'), + hidden_unbound: { type: 'integer', description: '因「含未绑定商品」被隐藏的订单数(exclude_unbound=1 时返回)' }, + }, orderStatusListResponse: buildListResponse('orderStatusPage'), /** 新建订单(含发货单口径:可直接带 items 创建明细) */ createOrderStatusRequest: { diff --git a/backend/app/controller/orderStatus.js b/backend/app/controller/orderStatus.js index 3d99b8f..54d6602 100644 --- a/backend/app/controller/orderStatus.js +++ b/backend/app/controller/orderStatus.js @@ -79,8 +79,12 @@ class OrderStatusController extends Controller { const { ctx } = this; const { page, pageSize, offset, limit } = parsePagination(ctx.query); try { - const { list, total } = await ctx.service.orderStatus.list({ ...ctx.query, offset, limit }); - ctx.body = { code: 0, message: 'success', data: buildPageResult(list, total, { page, pageSize }) }; + const { list, total, hiddenUnbound } = await ctx.service.orderStatus.list({ ...ctx.query, offset, limit }); + ctx.body = { + code: 0, + message: 'success', + data: { ...buildPageResult(list, total, { page, pageSize }), hidden_unbound: hiddenUnbound || 0 }, + }; } catch (err) { this._fail(ctx, err, '查询订单列表失败'); } diff --git a/backend/app/service/orderStatus.js b/backend/app/service/orderStatus.js index 4305c92..b3d3040 100644 --- a/backend/app/service/orderStatus.js +++ b/backend/app/service/orderStatus.js @@ -454,25 +454,32 @@ class OrderStatusService extends Service { // exclude_unbound=1:排除「有未绑定系统商品的明细」的订单(订单页默认只看已解析订单) // 用 EXISTS 子查询而非 IN 列表,避免未绑定订单很多时拼接超长参数 - if (String(p.exclude_unbound) === '1') { - where[Op.and].push( - ctx.app.Sequelize.literal( - 'NOT EXISTS (SELECT 1 FROM order_status_items oi WHERE oi.order_id = `' + Model.tableName + '`.id ' + - `AND oi.principal_id = ${principalId} AND oi.parse_status = 2)` - ) - ); - } + const excludeUnbound = String(p.exclude_unbound) === '1'; + const unboundClause = ctx.app.Sequelize.literal( + 'NOT EXISTS (SELECT 1 FROM order_status_items oi WHERE oi.order_id = `' + Model.tableName + '`.id ' + + `AND oi.principal_id = ${principalId} AND oi.parse_status = 2)` + ); + const whereWithUnbound = excludeUnbound + ? { ...where, [Op.and]: [ ...where[Op.and], unboundClause ] } + : where; const { count, rows } = await Model.findAndCountAll({ - where, + where: whereWithUnbound, offset: p.offset, limit: p.limit, order: [[ 'id', 'DESC' ]], }); + // 「因商品未绑定被隐藏」的订单数:前端据此提示「另有 N 单未显示」,避免看起来像漏拉 + let hiddenUnbound = 0; + if (excludeUnbound) { + const totalWithUnbound = await Model.count({ where }); + hiddenUnbound = Math.max(0, Number(totalWithUnbound) - Number(count)); + } + const list = rows.map(row => row.get({ plain: true })); await this._attachListMeta(list, principalId, status); - return { list, total: count }; + return { list, total: count, hiddenUnbound }; } /** diff --git a/frontend/src/api/orderStatus.ts b/frontend/src/api/orderStatus.ts index e181a80..797ed6a 100644 --- a/frontend/src/api/orderStatus.ts +++ b/frontend/src/api/orderStatus.ts @@ -294,10 +294,14 @@ export interface OrderStatusArchiveResult { /** 订单列表(按 status 定位状态表;principal_id 由请求拦截器注入) */ export function getOrderStatusList(params: OrderStatusQuery) { - return get<{ list: OrderStatusItem[]; total: number; page: number; pageSize: number }>( - '/order-status/list', - params as unknown as object, - ) + return get<{ + list: OrderStatusItem[] + total: number + page: number + pageSize: number + /** 因商品未绑定被隐藏的订单数(仅 exclude_unbound=1 时返回) */ + hidden_unbound?: number + }>('/order-status/list', params as unknown as object) } /** 筛选项数据源:状态枚举 + 当前主体下的店铺/仓库 + 归档阈值 */ diff --git a/frontend/src/views/Order/StatusPanel.vue b/frontend/src/views/Order/StatusPanel.vue index a28bad5..3157422 100644 --- a/frontend/src/views/Order/StatusPanel.vue +++ b/frontend/src/views/Order/StatusPanel.vue @@ -143,12 +143,24 @@ async function retryOneExternalSend(row: OrderStatusItem) { /** 「含未绑定商品订单」开关(默认关闭:不显示含未绑定商品的订单) */ const showUnboundOrders = ref(false) +/** 因商品未绑定被隐藏的订单数(后端 hidden_unbound),用于提示「不是没拉到,是没显示」 */ +const hiddenUnbound = ref(0) function onUnboundSwitchChange() { query.page = 1 search() } +/** 只在「待审核 + 仅已绑定」视图下提示被隐藏的数量 */ +const showHiddenUnboundHint = computed( + () => props.status === 'pending' && !showUnboundOrders.value && hiddenUnbound.value > 0, +) + +function onShowUnboundClick() { + showUnboundOrders.value = true + onUnboundSwitchChange() +} + const { loading, list, total, elapsed, fetchList, search, handlePageChange, handleSizeChange } = useListPage({ query, @@ -181,7 +193,10 @@ const { loading, list, total, elapsed, fetchList, search, handlePageChange, hand const sendStatus = isDeliveryException.value ? '2,3' : query.external_send_status if (sendStatus) params.external_send_status = sendStatus } - return getOrderStatusList(params as never) + return getOrderStatusList(params as never).then(res => { + hiddenUnbound.value = Number(res?.hidden_unbound) || 0 + return res + }) }, }) @@ -846,6 +861,15 @@ onBeforeUnmount(() => { 已选 {{ selectedIds.length }} 条
+ + + 另有 {{ hiddenUnbound }} 单未显示 + +