Files
SupplierSystem/miniprogram/utils/constants.js
T
Ubuntu 1350c097bc
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s
feat(小程序): 订单列表/详情跟随散客录单(状态「待扣除」+ 一键「确认扣除并完结」)
改前(真 HTTP,本地 BR002 实测):散客单(哨兵客户 __RETAIL__)order_status=30 在
GET /api/mobile/orders/management-list 返回 next_status=40 / advance_label=确认备货
⇒ 小程序显示「待备货」并给出「确认备货」,点了走 advanceOrderWorkflow(30→40) 推进「待验收」;
而散客单不生成验收(ensureInspectionsForOrder 已按散客拦掉)⇒ 死路,只能回网页端救。
且小程序侧没有「一键完结」接口(miniprogram 目录搜 散客/__RETAIL__/待扣除/确认扣除 = 0 命中)。

改后:
- 列表/详情新增 is_retail;散客行的 next_status / advance_label 一律置 null
- 新增 POST /mobile/orders/retail-confirm → 与 Web 同源调 confirmRetailOrderComplete
  (不另写扣库逻辑;未挂分公司时与 Web 同口径 operating_branch_required)
- POST /mobile/orders/advance 对散客单 409 retail_order_not_advanceable
  (纵深防御:旧版小程序缓存了按钮也挡得住)
- 小程序:状态显示改「待扣除」、列表行与详情按钮改「确认扣除并完结」;
  非散客单的标签与推进按钮逐字不变

真跑验证(本地 BR002,改后):
- 列表:is_retail=true / next_status=null / advance_label=null
- 推进:HTTP 409 retail_order_not_advanceable
- 一键完结:HTTP 200 {order_status:90, deducted:true, outbound_types:["retail_out"]};
  inventory_logs 2 行 retail_out(30→28、5→4);验证后已清理(测试单 0 行、可用量回补 30/5)
- 后端全量 vitest:26 文件 / 33 用例失败 = 与基线一致,失败文件名无新增;npx tsc --noEmit 0 错误
- 设计门禁 run-all.sh --verify:通过 8 / 未通过 1(check-ai-cost 既有红)/ 未执行 1(verify-facts)=基线

文案:两处界面文字**逐字复用 Web 已批准用词**(待扣除 / 确认扣除并完结),无新增小字。
⚠️ 小程序需用微信开发者工具重新上传版本才对现场生效(本提交只改仓库代码)。

设计:docs/design/20261015-小程序订单列表与详情跟随散客录单(待扣除·一键完结).md
2026-10-15 11:47:17 +08:00

133 lines
3.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const ROLE_OPTIONS = [
{ value: 'admin', label: '管理员', hint: '管理员/超级管理员账号' },
{ value: 'operator', label: '运营', hint: '运营角色或订单管理权限账号' },
{ value: 'purchaser', label: '采购员', hint: '使用采购员账号登录' },
{ value: 'supplier', label: '供应商', hint: '使用供应商管理中创建的账号' },
{ value: 'warehouse', label: '仓管员', hint: '到货验收、加工与验收' },
{ value: 'picker', label: '分拣员', hint: '分拣复核、提交出库' },
{ value: 'order_entry', label: '录单员', hint: '使用录单权限账号登录' },
{ value: 'delivery', label: '配送员', hint: '配送任务、验货上车' },
];
const ROLE_LABELS = {
admin: '管理员',
operator: '运营',
purchaser: '采购员',
supplier: '供应商',
warehouse: '仓管员',
inspector: '检验人员',
picker: '分拣员',
order_entry: '录单员',
delivery: '配送员',
};
const SESSION_KEY = 'canteen.mp.session';
/** 录单常用加工方式(与 Web processingMethods 对齐) */
const PROCESSING_METHOD_OPTIONS = [
'原材料',
'净菜',
'切配',
'熟食',
'砍',
'去皮',
'切片',
'切块',
'切丝',
'切段',
'切丁',
'清洗',
'洗净',
'打包',
'分装',
'剁碎',
'去根',
'去叶',
];
const ORDER_STATUS_LABELS = {
20: '待分配',
30: '待备货',
40: '待验收',
41: '拒收待处理',
45: '待分拣',
50: '待配送',
60: '配送中',
90: '已完成',
};
/**
* 散客录单(哨兵客户 `__RETAIL__`)在**未完成**时的状态名。
* 它没有备货/验收/分拣/配送(全额库存抵扣 + 一键完结)⇒ 显示「待备货」是错的。
* 文案与 Web 端**逐字同词**(开发者定稿),不新增说法。
*/
const RETAIL_PENDING_DEDUCT_LABEL = '待扣除';
/** 订单完成状态(状态链 20→30→40→45→50→60→**90** 的终点,与 Web `ORDER_COMPLETED_STATUS` 同值) */
const ORDER_COMPLETED_STATUS = 90;
/**
* 解析订单状态显示名。
* · 散客录单且未完成 ⇒ 「待扣除」(Web 同款)
* · 其余(含已完成的散客单)逐字沿用 `ORDER_STATUS_LABELS`,不改既有表现
* 设计:docs/design/20261015-小程序订单列表与详情跟随散客录单(待扣除·一键完结).md
*/
function resolveOrderStatusLabel(status, isRetail) {
const code = Number(status);
if (isRetail === true && Number.isFinite(code) && code < ORDER_COMPLETED_STATUS) {
return RETAIL_PENDING_DEDUCT_LABEL;
}
return ORDER_STATUS_LABELS[status] || (status === null || status === undefined ? '' : String(status));
}
const ORDER_ADVANCE_LABELS = {
20: '确认分配',
30: '确认备货',
40: '确认验收',
45: '分拣出库',
50: '开始配送',
60: '完成配送',
};
const DELIVERY_TIME_SLOT_LABELS = {
morning: '上午',
afternoon: '下午',
evening: '晚上',
noon: '中午',
all: '全天',
custom: '自定义',
};
function deliveryTimeSlotLabel(value) {
const key = String(value || '').trim().toLowerCase();
if (!key) return '';
return DELIVERY_TIME_SLOT_LABELS[key] || value;
}
function displayCustomerDeliveryDeadline(raw) {
const trimmed = String(raw || '').trim();
if (!trimmed) return '';
const m = trimmed.match(/^(\d{1,2})[::](\d{2})(?::\d{2})?$/);
if (!m) return trimmed;
const hour = Number(m[1]);
const minute = Number(m[2]);
if (!Number.isInteger(hour) || !Number.isInteger(minute)) return trimmed;
if (hour < 0 || hour > 23 || minute < 0 || minute > 59) return trimmed;
return `${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}`;
}
module.exports = {
ROLE_OPTIONS,
ROLE_LABELS,
SESSION_KEY,
PROCESSING_METHOD_OPTIONS,
ORDER_STATUS_LABELS,
ORDER_ADVANCE_LABELS,
ORDER_COMPLETED_STATUS,
RETAIL_PENDING_DEDUCT_LABEL,
resolveOrderStatusLabel,
DELIVERY_TIME_SLOT_LABELS,
deliveryTimeSlotLabel,
displayCustomerDeliveryDeadline,
};