Compare commits
10 Commits
591a69d35e
...
9327611552
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9327611552 | ||
|
|
29e7b6ae70 | ||
|
|
d18da89925 | ||
|
|
864351977b | ||
|
|
ac4222c49a | ||
|
|
110d0685ee | ||
|
|
943a20f582 | ||
|
|
aaadce25af | ||
|
|
c5c16a12a2 | ||
|
|
3817948b35 |
29
app/lib/lock_guard.js
Normal file
29
app/lib/lock_guard.js
Normal file
@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* 订单锁定状态共享定义。
|
||||
*
|
||||
* wms_order_delivery.lock_status 枚举(order_delivery.js / order_delivery_factory.js)实际取值为:
|
||||
* none / warehouse / store。
|
||||
*
|
||||
* 业务约定:锁定状态只要不是 'none'(即被仓库或货主锁定的订单),一律视为"已锁定",
|
||||
* 禁止继续执行仓储作业(分配储位/分配快递/抓取波次/自动加团等),
|
||||
* 已锁定订单一律跳过。
|
||||
*/
|
||||
const LOCK_STATUS_NONE = 'none';
|
||||
|
||||
/**
|
||||
* 判断订单锁定状态是否属于"已锁定"。
|
||||
* 空值/NULL 归一化为 none 处理;除此之外任何非 none 状态(含 warehouse/store)均视为已锁定。
|
||||
* @param {*} status 锁定状态值。
|
||||
* @return {boolean} 是否已锁定。
|
||||
*/
|
||||
function isLockedOrderStatus(status) {
|
||||
const normalizedStatus = String(status || '').trim() || LOCK_STATUS_NONE;
|
||||
return normalizedStatus !== LOCK_STATUS_NONE;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
LOCK_STATUS_NONE,
|
||||
isLockedOrderStatus,
|
||||
};
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
module.exports = app => {
|
||||
const { Sequelize, model } = app;
|
||||
const { STRING, BIGINT, DECIMAL, INTEGER, JSON } = Sequelize;
|
||||
const { STRING, BIGINT, DECIMAL, INTEGER, JSON, TEXT } = Sequelize;
|
||||
|
||||
const OrderItems = model.define('wms_order_items', {
|
||||
id: {
|
||||
@ -28,7 +28,7 @@ module.exports = app => {
|
||||
comment: '零售价格',
|
||||
},
|
||||
ext_code: {
|
||||
type: STRING(50),
|
||||
type: TEXT,
|
||||
allowNull: true,
|
||||
comment: '外部编码',
|
||||
},
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
const MainService = require('../../main');
|
||||
const { parseWhereConditions } = require('../../../lib/query_condition_parser');
|
||||
const { isInterceptedOrderStatus } = require('../../../lib/intercept_guard');
|
||||
const { isLockedOrderStatus } = require('../../../lib/lock_guard');
|
||||
|
||||
const DEFAULT_PAGE_SIZE = 20;
|
||||
const MAX_PAGE_SIZE = 500;
|
||||
@ -208,6 +209,16 @@ class OrderBaseService extends MainService {
|
||||
return isInterceptedOrderStatus(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断订单锁定状态是否属于"已锁定"(lock_status != none)。
|
||||
*
|
||||
* @param {*} status 锁定状态值。
|
||||
* @return {boolean} 是否已锁定。
|
||||
*/
|
||||
isLockedOrderStatus(status = '') {
|
||||
return isLockedOrderStatus(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 断言订单未进入拦截流程,否则抛出阻断异常。
|
||||
*
|
||||
@ -567,6 +578,17 @@ class OrderBaseService extends MainService {
|
||||
return Number.isNaN(numericVersion) ? strategyVersion : numericVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* 规范化订单锁定状态展示值。
|
||||
* none 返回 N,其余状态(warehouse/store 等)一律返回 Y。
|
||||
* @param {*} lockStatus 锁定状态值。
|
||||
* @return {string} Y 或 N。
|
||||
*/
|
||||
normalizeLockStatusFlag(lockStatus) {
|
||||
const normalizedStatus = String(lockStatus || '').trim() || 'none';
|
||||
return normalizedStatus === 'none' ? 'N' : 'Y';
|
||||
}
|
||||
|
||||
/**
|
||||
* 规范订单列表单行输出,保证重量类型直接返回中文。
|
||||
* @param {Object} order 订单列表行数据。
|
||||
@ -585,6 +607,7 @@ class OrderBaseService extends MainService {
|
||||
wave_strategy_version: this.normalizeWaveStrategyVersion(order.wave_strategy_version),
|
||||
wave_scan_result: this.normalizeWaveScanResult(order.wave_scan_result),
|
||||
create_channel: this.formatCreateChannelLabel(order.create_channel),
|
||||
lock_status: this.normalizeLockStatusFlag(order.lock_status),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -5048,7 +5048,7 @@ ${numbered}`;
|
||||
|
||||
return {
|
||||
businessType: 'order',
|
||||
businessId: logWarehouseId,
|
||||
businessId: orderId,
|
||||
operationCode: 'ORDER_LOCK',
|
||||
operator,
|
||||
extras: {
|
||||
@ -5557,7 +5557,7 @@ ${numbered}`;
|
||||
|
||||
return {
|
||||
businessType: 'order',
|
||||
businessId: logWarehouseId,
|
||||
businessId: orderId,
|
||||
operationCode: 'ORDER_UNLOCK',
|
||||
operator,
|
||||
extras: {
|
||||
|
||||
@ -290,8 +290,12 @@ class RecheckOrderService extends OrderBaseService {
|
||||
});
|
||||
|
||||
const totalOrders = mergedList.length;
|
||||
const reviewedCount = mergedList.filter(o => o.recheck_status === 'fin').length;
|
||||
const unreviewedCount = totalOrders - reviewedCount;
|
||||
// 复核统计仅计非拦截订单(拦截订单保留在 list 中按单提示)
|
||||
const reviewableOrders = mergedList.filter(
|
||||
o => !this.isInterceptedOrderStatus(o.intercept_status)
|
||||
);
|
||||
const reviewedCount = reviewableOrders.filter(o => o.recheck_status === 'fin').length;
|
||||
const unreviewedCount = reviewableOrders.length - reviewedCount;
|
||||
const waveType = scanViews.find(v => Number(v.wave_type || 0) > 0)?.wave_type || 0;
|
||||
const pickerInfo = await this.getPickerInfoByTaskId(taskId, warehouseId);
|
||||
|
||||
@ -451,8 +455,12 @@ class RecheckOrderService extends OrderBaseService {
|
||||
});
|
||||
|
||||
const totalOrders = mergedList.length;
|
||||
const reviewedCount = mergedList.filter(o => o.recheck_status === 'fin').length;
|
||||
const unreviewedCount = totalOrders - reviewedCount;
|
||||
// 复核统计仅计非拦截订单(拦截订单保留在 list 中按单提示)
|
||||
const reviewableOrders = mergedList.filter(
|
||||
o => !this.isInterceptedOrderStatus(o.intercept_status)
|
||||
);
|
||||
const reviewedCount = reviewableOrders.filter(o => o.recheck_status === 'fin').length;
|
||||
const unreviewedCount = reviewableOrders.length - reviewedCount;
|
||||
const waveType = scanViews.find(v => Number(v.wave_type || 0) > 0)?.wave_type || 0;
|
||||
|
||||
return {
|
||||
@ -480,6 +488,8 @@ class RecheckOrderService extends OrderBaseService {
|
||||
* @param {number} waveId 波次ID。
|
||||
* @param {string} waveNo 波次号。
|
||||
* @param {number} warehouseId 仓库ID。
|
||||
* 拦截订单保留在 list 中(带 intercept_status),不参与复核校验与 reviewed/unreviewed/printed 统计,
|
||||
* 波次内存在拦截订单时不再阻断整个扫描视图加载(与团购模式一致)。
|
||||
* @return {Promise<Object|null>} 扁平化扫描视图,包含 picker_id、picker_name、task_id、wave_id、wave_no、
|
||||
* wave_type、pick_mode、strategy_id、strategy_name、total_orders、reviewed_count、unreviewed_count、
|
||||
* printed_count、unprinted_count、list。
|
||||
@ -495,8 +505,15 @@ class RecheckOrderService extends OrderBaseService {
|
||||
const normalizedWaveId = Number(waveId || 0);
|
||||
const orders = Array.isArray(baseWaveView.orders) ? baseWaveView.orders : [];
|
||||
|
||||
// 校验波次内所有订单是否都已拣货,未拣货订单不允许复核
|
||||
for (const order of orders) {
|
||||
// 分离拦截订单:拦截订单保留在 list 中由前端按单提示拦截(intercept_status),
|
||||
// 仅对非拦截订单做复核校验与统计,与团购模式一致,
|
||||
// 波次内存在拦截订单时不再阻断整个散单扫描视图加载
|
||||
const normalOrders = orders.filter(
|
||||
order => !this.isInterceptedOrderStatus(order.intercept_status)
|
||||
);
|
||||
|
||||
// 校验波次内非拦截订单是否都已拣货,未拣货订单不允许复核
|
||||
for (const order of normalOrders) {
|
||||
this.assertOrderCanRecheck(order);
|
||||
}
|
||||
|
||||
@ -506,13 +523,13 @@ class RecheckOrderService extends OrderBaseService {
|
||||
this.getWaveStrategyInfo(normalizedWaveId, warehouseId),
|
||||
]);
|
||||
|
||||
// 计算复核汇总
|
||||
const reviewedCount = orders.filter(o => o.recheck_status === 'fin').length;
|
||||
const unreviewedCount = orders.length - reviewedCount;
|
||||
// 计算复核汇总(仅统计非拦截订单)
|
||||
const reviewedCount = normalOrders.filter(o => o.recheck_status === 'fin').length;
|
||||
const unreviewedCount = normalOrders.length - reviewedCount;
|
||||
|
||||
// 计算打印汇总
|
||||
const printedCount = orders.filter(o => o.is_printed === true).length;
|
||||
const unprintedCount = orders.length - printedCount;
|
||||
// 计算打印汇总(仅统计非拦截订单)
|
||||
const printedCount = normalOrders.filter(o => o.is_printed === true).length;
|
||||
const unprintedCount = normalOrders.length - printedCount;
|
||||
|
||||
// 批量查询包材推荐
|
||||
const packageMaterialMap = await this.batchQueryPackageMaterialRecommendation(orders, warehouseId);
|
||||
@ -2231,16 +2248,36 @@ class RecheckOrderService extends OrderBaseService {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 检查波次下所有订单是否均已复核完成(团购模式以订单表 recheck_status 为准)
|
||||
const unreviewedInWave = await orderModel.count({
|
||||
// 查任务关联的全部波次(团购任务一车多波次,必须任务下所有波次订单全部复核完成才允许解绑)
|
||||
const taskAllWaveRows = await ctx.model.query(
|
||||
`SELECT DISTINCT tw.wave_id
|
||||
FROM wms_wave_pick_task_wave tw
|
||||
WHERE tw.task_id = :taskId
|
||||
AND tw.warehouse_id = :warehouseId`,
|
||||
{
|
||||
replacements: { taskId: fallbackTaskId, warehouseId },
|
||||
type: ctx.model.QueryTypes.SELECT,
|
||||
}
|
||||
);
|
||||
|
||||
const taskAllWaveIds = (Array.isArray(taskAllWaveRows) ? taskAllWaveRows : [])
|
||||
.map(r => Number(r?.wave_id || 0))
|
||||
.filter(id => id > 0);
|
||||
|
||||
if (taskAllWaveIds.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 检查任务下所有波次的订单是否均已复核完成(团购模式以订单表 recheck_status 为准)
|
||||
const unreviewedCount = await orderModel.count({
|
||||
where: {
|
||||
wave_id: orderWaveId,
|
||||
wave_id: { [ctx.app.Sequelize.Op.in]: taskAllWaveIds },
|
||||
warehouse_id: warehouseId,
|
||||
recheck_status: { [ctx.app.Sequelize.Op.ne]: 'fin' },
|
||||
},
|
||||
});
|
||||
|
||||
return unreviewedInWave === 0 ? fallbackTaskId : 0;
|
||||
return unreviewedCount === 0 ? fallbackTaskId : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -6800,7 +6800,7 @@ class WaveService extends OrderBaseService {
|
||||
|
||||
try {
|
||||
const orderRows = await orderModel.findAll({
|
||||
attributes: [ 'id', 'wave_id', 'wave_no', 'step', 'status', 'outbound_status', 'items_hash', 'items', 'logistics_name', 'intercept_status' ],
|
||||
attributes: [ 'id', 'wave_id', 'wave_no', 'step', 'status', 'outbound_status', 'items_hash', 'items', 'logistics_name', 'intercept_status', 'lock_status' ],
|
||||
where: {
|
||||
id: { [Op.in]: normalizedIds },
|
||||
},
|
||||
@ -6824,6 +6824,11 @@ class WaveService extends OrderBaseService {
|
||||
.map(row => Number(row && row.id || 0))
|
||||
.filter(id => Number.isInteger(id) && id > 0)) ]
|
||||
.sort((a, b) => a - b);
|
||||
const excludedLockedOrderIds = [ ...new Set(normalizedOrderRows
|
||||
.filter(row => this.isLockedOrderStatus(row && row.lock_status))
|
||||
.map(row => Number(row && row.id || 0))
|
||||
.filter(id => Number.isInteger(id) && id > 0)) ]
|
||||
.sort((a, b) => a - b);
|
||||
|
||||
const fetchableRows = normalizedOrderRows.filter(row => {
|
||||
const orderId = Number(row && row.id || 0);
|
||||
@ -6842,6 +6847,11 @@ class WaveService extends OrderBaseService {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 已锁定的订单不允许抓取波次
|
||||
if (this.isLockedOrderStatus(row && row.lock_status)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -6862,6 +6872,7 @@ class WaveService extends OrderBaseService {
|
||||
fetched_order_count: 0,
|
||||
excluded_existing_wave_order_ids: excludedExistingWaveOrderIds,
|
||||
excluded_intercepted_order_ids: excludedInterceptedOrderIds,
|
||||
excluded_locked_order_ids: excludedLockedOrderIds,
|
||||
skipped_order_ids: skippedOrderIds,
|
||||
not_found_order_ids: notFoundOrderIds,
|
||||
});
|
||||
@ -6976,6 +6987,7 @@ class WaveService extends OrderBaseService {
|
||||
fetched_order_count: grabbedOrderIds.length,
|
||||
excluded_existing_wave_order_ids: excludedExistingWaveOrderIds,
|
||||
excluded_intercepted_order_ids: excludedInterceptedOrderIds,
|
||||
excluded_locked_order_ids: excludedLockedOrderIds,
|
||||
skipped_order_ids: skippedOrderIds,
|
||||
not_found_order_ids: notFoundOrderIds,
|
||||
});
|
||||
@ -8804,7 +8816,7 @@ class WaveService extends OrderBaseService {
|
||||
|
||||
try {
|
||||
orderRows = await orderModel.findAll({
|
||||
attributes: [ 'id', 'business_key', 'intercept_status' ],
|
||||
attributes: [ 'id', 'business_key', 'intercept_status', 'lock_status' ],
|
||||
where: baseOrderWhere,
|
||||
raw: true,
|
||||
});
|
||||
@ -8820,7 +8832,7 @@ class WaveService extends OrderBaseService {
|
||||
warehouseId,
|
||||
});
|
||||
orderRows = await orderModel.findAll({
|
||||
attributes: [ 'id', 'intercept_status' ],
|
||||
attributes: [ 'id', 'intercept_status', 'lock_status' ],
|
||||
where: baseOrderWhere,
|
||||
raw: true,
|
||||
});
|
||||
@ -8850,10 +8862,27 @@ class WaveService extends OrderBaseService {
|
||||
});
|
||||
}
|
||||
|
||||
const skippedLockedOrderIds = [ ...new Set((Array.isArray(orderRows) ? orderRows : [])
|
||||
.filter(row => this.isLockedOrderStatus(row && row.lock_status))
|
||||
.map(row => Number(row && row.id || 0))
|
||||
.filter(orderId => Number.isInteger(orderId) && orderId > 0)) ]
|
||||
.sort((a, b) => a - b);
|
||||
const skippedLockedOrderIdSet = new Set(skippedLockedOrderIds);
|
||||
if (skippedLockedOrderIds.length > 0) {
|
||||
this.ctx.logger.info('[wave.batchAllocateExpress] 跳过锁定订单', {
|
||||
traceId,
|
||||
taskId: normalizedTaskId,
|
||||
warehouseId,
|
||||
skippedLockedOrderIds,
|
||||
});
|
||||
}
|
||||
|
||||
const normalizedOrders = (Array.isArray(orderRows) ? orderRows : [])
|
||||
.map(row => {
|
||||
const orderId = Number(row && row.id || 0);
|
||||
if (!Number.isInteger(orderId) || orderId <= 0 || skippedInterceptedOrderIdSet.has(orderId)) {
|
||||
if (!Number.isInteger(orderId) || orderId <= 0
|
||||
|| skippedInterceptedOrderIdSet.has(orderId)
|
||||
|| skippedLockedOrderIdSet.has(orderId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -8872,6 +8901,7 @@ class WaveService extends OrderBaseService {
|
||||
warehouseId,
|
||||
waveIds,
|
||||
skippedInterceptedOrderIds,
|
||||
skippedLockedOrderIds,
|
||||
});
|
||||
const durationMs = Date.now() - startTime;
|
||||
await this.setBatchAllocateExpressTaskProgress(normalizedTaskId, 'success', {
|
||||
@ -8882,6 +8912,7 @@ class WaveService extends OrderBaseService {
|
||||
success_order_count: 0,
|
||||
failed_order_count: 0,
|
||||
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
||||
skipped_locked_order_ids: skippedLockedOrderIds,
|
||||
progress_percent: 100,
|
||||
end_time: Date.now(),
|
||||
duration_ms: durationMs,
|
||||
@ -8889,9 +8920,10 @@ class WaveService extends OrderBaseService {
|
||||
wave_ids: waveIds,
|
||||
allocated_order_count: 0,
|
||||
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
||||
skipped_locked_order_ids: skippedLockedOrderIds,
|
||||
duration_ms: durationMs,
|
||||
message: skippedInterceptedOrderIds.length > 0
|
||||
? `拦截订单已跳过,未找到可分配快递号的订单(跳过 ${skippedInterceptedOrderIds.length} 单)`
|
||||
message: skippedInterceptedOrderIds.length > 0 || skippedLockedOrderIds.length > 0
|
||||
? `拦截/锁定订单已跳过,未找到可分配快递号的订单(拦截 ${skippedInterceptedOrderIds.length} 单,锁定 ${skippedLockedOrderIds.length} 单)`
|
||||
: '未找到可分配快递号的订单',
|
||||
},
|
||||
trace_id: traceId,
|
||||
@ -8935,6 +8967,7 @@ class WaveService extends OrderBaseService {
|
||||
success_order_count: normalizedOrders.length,
|
||||
failed_order_count: 0,
|
||||
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
||||
skipped_locked_order_ids: skippedLockedOrderIds,
|
||||
progress_percent: 100,
|
||||
end_time: Date.now(),
|
||||
duration_ms: durationMs,
|
||||
@ -8942,6 +8975,7 @@ class WaveService extends OrderBaseService {
|
||||
wave_ids: waveIds,
|
||||
allocated_order_count: normalizedOrders.length,
|
||||
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
||||
skipped_locked_order_ids: skippedLockedOrderIds,
|
||||
duration_ms: durationMs,
|
||||
message: String(pipelineResult && pipelineResult.message || '分配快递任务已提交').trim(),
|
||||
},
|
||||
@ -9054,7 +9088,7 @@ class WaveService extends OrderBaseService {
|
||||
try {
|
||||
const orderModel = await this.getOrderModel('pendingOrder', warehouseId);
|
||||
const orderRows = await orderModel.findAll({
|
||||
attributes: [ 'id' ],
|
||||
attributes: [ 'id', 'lock_status' ],
|
||||
where: {
|
||||
warehouse_id: warehouseId,
|
||||
wave_id: {
|
||||
@ -9067,9 +9101,14 @@ class WaveService extends OrderBaseService {
|
||||
raw: true,
|
||||
});
|
||||
|
||||
const skippedLockedOrderIdSet = new Set((Array.isArray(orderRows) ? orderRows : [])
|
||||
.filter(row => this.isLockedOrderStatus(row && row.lock_status))
|
||||
.map(row => Number(row && row.id || 0))
|
||||
.filter(orderId => Number.isInteger(orderId) && orderId > 0));
|
||||
const normalizedOrders = [ ...new Set((Array.isArray(orderRows) ? orderRows : [])
|
||||
.map(row => Number(row && row.id || 0))
|
||||
.filter(orderId => Number.isInteger(orderId) && orderId > 0)) ]
|
||||
.filter(orderId => !skippedLockedOrderIdSet.has(orderId))
|
||||
.map(orderId => ({
|
||||
order_id: orderId,
|
||||
business_id: BATCH_ALLOCATE_STORAGE_FORCE_BUSINESS_ID,
|
||||
|
||||
@ -1787,6 +1787,14 @@ class PrintService extends MainService {
|
||||
|
||||
/**
|
||||
* 加载并校验 express 请求涉及平台的打印组件配置。
|
||||
*
|
||||
* 解析顺序:
|
||||
* 1. 直接按 `wms_print_platform.platform_code` 匹配(快递接口透出的打印平台编码,
|
||||
* 如 CAINIAO/DY/JD/KS/PDD/SPH/XHS);
|
||||
* 2. 未匹配的编码视为系统平台编码(如 TB/TM/1688/TGC),经
|
||||
* `wms_platform.code -> print_platform_id -> wms_print_platform.platform_name`
|
||||
* 回退解析对应打印组件。
|
||||
*
|
||||
* @param {Object} payload 查询参数。
|
||||
* @param {Array<string>} payload.platformCodes 平台编码列表。
|
||||
* @return {Promise<{success:boolean,data?:Object,error?:string}>} 查询与校验结果。
|
||||
@ -1803,22 +1811,81 @@ class PrintService extends MainService {
|
||||
};
|
||||
}
|
||||
|
||||
const platformRows = await this.ctx.model.PrintPlatform.findAll({
|
||||
attributes: [ 'platform_code', 'platform_name' ],
|
||||
where: {
|
||||
platform_code: platformCodes,
|
||||
},
|
||||
raw: true,
|
||||
});
|
||||
const printPlatformModel = this.ctx && this.ctx.model && this.ctx.model.PrintPlatform;
|
||||
const platformModel = this.ctx && this.ctx.model && this.ctx.model.Platform;
|
||||
const platformComponentMap = {};
|
||||
for (const row of platformRows) {
|
||||
const platformCode = String(row && row.platform_code ? row.platform_code : '').trim();
|
||||
if (!platformCode) {
|
||||
continue;
|
||||
|
||||
// 1) 优先按打印平台编码直接匹配
|
||||
if (printPlatformModel && typeof printPlatformModel.findAll === 'function') {
|
||||
const platformRows = await printPlatformModel.findAll({
|
||||
attributes: [ 'id', 'platform_code', 'platform_name' ],
|
||||
where: {
|
||||
platform_code: platformCodes,
|
||||
},
|
||||
raw: true,
|
||||
});
|
||||
for (const row of Array.isArray(platformRows) ? platformRows : []) {
|
||||
const platformCode = String(row && row.platform_code ? row.platform_code : '').trim();
|
||||
if (!platformCode) {
|
||||
continue;
|
||||
}
|
||||
platformComponentMap[platformCode] = String(row && row.platform_name ? row.platform_name : '').trim();
|
||||
}
|
||||
platformComponentMap[platformCode] = String(row && row.platform_name ? row.platform_name : '').trim();
|
||||
}
|
||||
console.log('platformComponentMap', platformComponentMap);
|
||||
|
||||
// 2) 未匹配编码按系统平台编码回退解析(TB/TM/1688 等经 print_platform_id 关联)
|
||||
const unresolvedCodes = platformCodes.filter(platformCode => {
|
||||
return !String(platformComponentMap[platformCode] || '').trim();
|
||||
});
|
||||
if (unresolvedCodes.length > 0
|
||||
&& printPlatformModel && typeof printPlatformModel.findAll === 'function'
|
||||
&& platformModel && typeof platformModel.findAll === 'function') {
|
||||
const systemPlatformRows = await platformModel.findAll({
|
||||
attributes: [ 'code', 'print_platform_id' ],
|
||||
where: {
|
||||
code: unresolvedCodes,
|
||||
},
|
||||
raw: true,
|
||||
});
|
||||
const codeListByPrintPlatformIdMap = new Map();
|
||||
for (const row of Array.isArray(systemPlatformRows) ? systemPlatformRows : []) {
|
||||
const platformCode = String(row && row.code ? row.code : '').trim();
|
||||
const printPlatformId = Number(row && row.print_platform_id || 0);
|
||||
if (!platformCode || !Number.isInteger(printPlatformId) || printPlatformId <= 0) {
|
||||
continue;
|
||||
}
|
||||
if (!codeListByPrintPlatformIdMap.has(printPlatformId)) {
|
||||
codeListByPrintPlatformIdMap.set(printPlatformId, []);
|
||||
}
|
||||
codeListByPrintPlatformIdMap.get(printPlatformId).push(platformCode);
|
||||
}
|
||||
|
||||
if (codeListByPrintPlatformIdMap.size > 0) {
|
||||
const printPlatformRows = await printPlatformModel.findAll({
|
||||
attributes: [ 'id', 'platform_name' ],
|
||||
where: {
|
||||
id: Array.from(codeListByPrintPlatformIdMap.keys()),
|
||||
},
|
||||
raw: true,
|
||||
});
|
||||
const componentNameByPrintPlatformIdMap = new Map();
|
||||
for (const row of Array.isArray(printPlatformRows) ? printPlatformRows : []) {
|
||||
const printPlatformId = Number(row && row.id || 0);
|
||||
const componentName = String(row && row.platform_name ? row.platform_name : '').trim();
|
||||
if (!Number.isInteger(printPlatformId) || printPlatformId <= 0) {
|
||||
continue;
|
||||
}
|
||||
componentNameByPrintPlatformIdMap.set(printPlatformId, componentName);
|
||||
}
|
||||
for (const [ printPlatformId, codeList ] of codeListByPrintPlatformIdMap) {
|
||||
const componentName = componentNameByPrintPlatformIdMap.get(printPlatformId) || '';
|
||||
for (const platformCode of codeList) {
|
||||
platformComponentMap[platformCode] = componentName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const platformCode of platformCodes) {
|
||||
const component = String(platformComponentMap[platformCode] || '').trim();
|
||||
if (!component) {
|
||||
@ -1829,6 +1896,10 @@ class PrintService extends MainService {
|
||||
}
|
||||
}
|
||||
|
||||
this.ctx.logger.info('[print.send] express 平台打印组件解析完成', {
|
||||
platformComponents: platformComponentMap,
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: platformComponentMap,
|
||||
@ -2802,34 +2873,65 @@ class PrintService extends MainService {
|
||||
taskId = Number(taskWave.task_id);
|
||||
if (!taskId) return;
|
||||
|
||||
if (waveType === 1) {
|
||||
const taskRows = await ctx.model.query(
|
||||
'SELECT pick_mode FROM wms_wave_pick_task WHERE id = :taskId LIMIT 1',
|
||||
{ replacements: { taskId }, type: ctx.model.QueryTypes.SELECT }
|
||||
);
|
||||
const task = Array.isArray(taskRows) && taskRows.length > 0 ? taskRows[0] : null;
|
||||
const pickMode = task ? Number(task.pick_mode) : 0;
|
||||
if (pickMode !== 1) return;
|
||||
}
|
||||
|
||||
// 团购 / 散单统一按订单维度检查:所有订单均已打印时才解绑
|
||||
const taskOrders = await ctx.model.query(
|
||||
'SELECT DISTINCT order_id FROM wms_wave_pick_task_order WHERE task_id = :taskId',
|
||||
{ replacements: { taskId }, type: ctx.model.QueryTypes.SELECT }
|
||||
);
|
||||
const orderIds = (Array.isArray(taskOrders) ? taskOrders : []).map(r => Number(r && r.order_id)).filter(id => id > 0);
|
||||
if (orderIds.length === 0) return;
|
||||
const orderDeliveryFactory = ctx.model && ctx.model.OrderDeliveryFactory;
|
||||
if (!orderDeliveryFactory || typeof orderDeliveryFactory.getCurrentModel !== 'function') {
|
||||
this.ctx.logger.warn('[print.unbindCart] OrderDeliveryFactory 不可用,跳过检查');
|
||||
return;
|
||||
}
|
||||
const orderDeliveryModel = await orderDeliveryFactory.getCurrentModel(resolvedWarehouseId);
|
||||
const unprintedCount = await orderDeliveryModel.count({
|
||||
where: { id: { [ctx.model.Sequelize.Op.in]: orderIds }, print_status: 'none' },
|
||||
});
|
||||
|
||||
let totalOrderCount = 0;
|
||||
let unprintedCount = 0;
|
||||
|
||||
if (waveType === 1) {
|
||||
// 团购波次:仅团购拣货模式(pick_mode=1 小团购 / pick_mode=5 大团购)参与解绑判断
|
||||
const taskRows = await ctx.model.query(
|
||||
'SELECT pick_mode FROM wms_wave_pick_task WHERE id = :taskId LIMIT 1',
|
||||
{ replacements: { taskId }, type: ctx.model.QueryTypes.SELECT }
|
||||
);
|
||||
const task = Array.isArray(taskRows) && taskRows.length > 0 ? taskRows[0] : null;
|
||||
const pickMode = task ? Number(task.pick_mode) : 0;
|
||||
if (![ 1, 5 ].includes(pickMode)) return;
|
||||
|
||||
// 团购任务订单不写入 wms_wave_pick_task_order,改为按任务关联的全部波次统计:
|
||||
// 任务下所有波次的订单均已打印时才解绑
|
||||
const taskWaveIdRows = await ctx.model.query(
|
||||
'SELECT DISTINCT wave_id FROM wms_wave_pick_task_wave WHERE task_id = :taskId AND warehouse_id = :warehouseId',
|
||||
{ replacements: { taskId, warehouseId: resolvedWarehouseId }, type: ctx.model.QueryTypes.SELECT }
|
||||
);
|
||||
const waveIds = (Array.isArray(taskWaveIdRows) ? taskWaveIdRows : [])
|
||||
.map(r => Number(r && r.wave_id))
|
||||
.filter(id => id > 0);
|
||||
if (waveIds.length === 0) return;
|
||||
unprintedCount = await orderDeliveryModel.count({
|
||||
where: {
|
||||
warehouse_id: resolvedWarehouseId,
|
||||
wave_id: { [ctx.model.Sequelize.Op.in]: waveIds },
|
||||
print_status: 'none',
|
||||
},
|
||||
});
|
||||
totalOrderCount = await orderDeliveryModel.count({
|
||||
where: {
|
||||
warehouse_id: resolvedWarehouseId,
|
||||
wave_id: { [ctx.model.Sequelize.Op.in]: waveIds },
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// 散单波次:按任务订单维度检查,任务下所有订单均已打印时才解绑
|
||||
const taskOrders = await ctx.model.query(
|
||||
'SELECT DISTINCT order_id FROM wms_wave_pick_task_order WHERE task_id = :taskId',
|
||||
{ replacements: { taskId }, type: ctx.model.QueryTypes.SELECT }
|
||||
);
|
||||
const orderIds = (Array.isArray(taskOrders) ? taskOrders : []).map(r => Number(r && r.order_id)).filter(id => id > 0);
|
||||
if (orderIds.length === 0) return;
|
||||
unprintedCount = await orderDeliveryModel.count({
|
||||
where: { id: { [ctx.model.Sequelize.Op.in]: orderIds }, print_status: 'none' },
|
||||
});
|
||||
totalOrderCount = orderIds.length;
|
||||
}
|
||||
|
||||
if (unprintedCount > 0) {
|
||||
this.ctx.logger.info('[print.unbindCart] 尚有未打印订单,跳过解绑', { waveId, warehouseId, taskId, waveType, waveTypeLabel: waveType === 1 ? '团购' : '散单', totalOrders: orderIds.length, unprintedCount });
|
||||
this.ctx.logger.info('[print.unbindCart] 尚有未打印订单,跳过解绑', { waveId, warehouseId, taskId, waveType, waveTypeLabel: waveType === 1 ? '团购' : '散单', totalOrders: totalOrderCount, unprintedCount });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
const Service = require('egg').Service;
|
||||
const { normalizeWarehouseShardId } = require('../../lib/warehouse_shard_guard');
|
||||
const { isLockedOrderStatus } = require('../../lib/lock_guard');
|
||||
|
||||
const DELIVERY_ORDER_STEP = Object.freeze({
|
||||
PENDING_REVIEW: 0,
|
||||
@ -2001,7 +2002,7 @@ class DeliveryOrderService extends Service {
|
||||
id: orderId,
|
||||
warehouse_id: warehouseId,
|
||||
},
|
||||
attributes: [ 'id', 'wave_id', 'step', 'status', 'outbound_status' ],
|
||||
attributes: [ 'id', 'wave_id', 'step', 'status', 'outbound_status', 'lock_status' ],
|
||||
transaction,
|
||||
lock: transaction.LOCK.UPDATE,
|
||||
});
|
||||
@ -2010,6 +2011,12 @@ class DeliveryOrderService extends Service {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 已锁定的订单不允许自动加团
|
||||
if (isLockedOrderStatus(orderRow.lock_status)) {
|
||||
await transaction.commit();
|
||||
return false;
|
||||
}
|
||||
|
||||
const currentWaveId = Number(orderRow.wave_id || 0);
|
||||
if (currentWaveId === normalizedWaveId) {
|
||||
await transaction.commit();
|
||||
@ -2057,6 +2064,7 @@ class DeliveryOrderService extends Service {
|
||||
id: orderId,
|
||||
warehouse_id: warehouseId,
|
||||
wave_id: 0,
|
||||
lock_status: 'none',
|
||||
},
|
||||
transaction,
|
||||
});
|
||||
@ -2139,6 +2147,7 @@ class DeliveryOrderService extends Service {
|
||||
step: { [ctx.app.Sequelize.Op.in]: [ 1, 2, 3 ] },
|
||||
status: { [ctx.app.Sequelize.Op.ne]: 'cancel' },
|
||||
outbound_status: { [ctx.app.Sequelize.Op.ne]: 'padding' },
|
||||
lock_status: 'none',
|
||||
sys_logistics_code: structure.logisticsName,
|
||||
};
|
||||
where[structure.itemPartType] = structure.itemPart;
|
||||
@ -2392,6 +2401,16 @@ class DeliveryOrderService extends Service {
|
||||
return;
|
||||
}
|
||||
|
||||
// 已锁定的订单不自动分配快递、储位,不自动加团
|
||||
if (isLockedOrderStatus(context.order && context.order.lock_status)) {
|
||||
this.ctx.logger.info('[DeliveryOrderService.asyncProcessOrderCreated] 订单已锁定,跳过自动分配快递/储位/自动加团', {
|
||||
warehouseId: context.warehouseId,
|
||||
orderId: context.orderId,
|
||||
lockStatus: context.order.lock_status,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const policyConfig = await this.getStoreWarehousePolicyConfig(context.storeId, context.warehouseId);
|
||||
|
||||
// 截单时间兜底:货主-仓库级未启用时,fallback 到仓库级配置
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
const { Service } = require('egg');
|
||||
|
||||
const { isInterceptedOrderStatus } = require('../../lib/intercept_guard');
|
||||
const { isLockedOrderStatus } = require('../../lib/lock_guard');
|
||||
|
||||
const DEFAULT_CACHE_TTL_SECONDS = 600;
|
||||
const DEFAULT_EXPRESS_PRODUCT_TYPE_CACHE_TTL_SECONDS = 60 * 60;
|
||||
@ -2516,7 +2517,7 @@ class ExpressService extends Service {
|
||||
[Op.ne]: 'cancel',
|
||||
},
|
||||
},
|
||||
attributes: [ 'id', 'sys_platform_code', 'logistics_code', 'sys_platform_name', 'logistics_name', 'store_id', 'pay_no', 'from_key', 'intercept_status' ],
|
||||
attributes: [ 'id', 'sys_platform_code', 'logistics_code', 'sys_platform_name', 'logistics_name', 'store_id', 'pay_no', 'from_key', 'intercept_status', 'lock_status' ],
|
||||
raw: true,
|
||||
});
|
||||
|
||||
@ -2540,7 +2541,7 @@ class ExpressService extends Service {
|
||||
[Op.ne]: 'cancel',
|
||||
},
|
||||
},
|
||||
attributes: [ 'id', 'sys_platform_code', 'logistics_code', 'sys_platform_name', 'logistics_name', 'store_id', 'pay_no', 'from_key', 'intercept_status' ],
|
||||
attributes: [ 'id', 'sys_platform_code', 'logistics_code', 'sys_platform_name', 'logistics_name', 'store_id', 'pay_no', 'from_key', 'intercept_status', 'lock_status' ],
|
||||
raw: true,
|
||||
});
|
||||
}
|
||||
@ -2561,21 +2562,37 @@ class ExpressService extends Service {
|
||||
skippedInterceptedOrderIds,
|
||||
});
|
||||
}
|
||||
|
||||
// 锁定订单跳过(除 none 外一律视为已锁定,锁定期间不允许分配快递)
|
||||
const lockedOrderIdSet = new Set(orders_arr
|
||||
.filter(order => isLockedOrderStatus(order && order.lock_status))
|
||||
.map(order => Number(order && order.id || 0))
|
||||
.filter(orderId => Number.isInteger(orderId) && orderId > 0));
|
||||
const skippedLockedOrderIds = Array.from(lockedOrderIdSet);
|
||||
const activeOrders = orders_arr.filter(order => !lockedOrderIdSet.has(Number(order && order.id || 0)));
|
||||
if (skippedLockedOrderIds.length > 0) {
|
||||
this.ctx.logger.info('[ExpressService.createWaybillCodePipeline] 跳过锁定订单', {
|
||||
traceId,
|
||||
warehouseId,
|
||||
skippedLockedOrderIds,
|
||||
});
|
||||
}
|
||||
this.ctx.logger.info('[ExpressService.createWaybillCodePipeline] 订单筛选结果', {
|
||||
traceId,
|
||||
warehouseId,
|
||||
inputOrderCount: orderList.length,
|
||||
currentCount: (Array.isArray(currentOrders) ? currentOrders : []).length,
|
||||
dispatchCount: dispatchOrders.length,
|
||||
matchedOrderCount: orders_arr.length,
|
||||
matchedOrderCount: activeOrders.length,
|
||||
skippedInterceptedOrderIds,
|
||||
skippedLockedOrderIds,
|
||||
});
|
||||
|
||||
// 【step1.5】过滤已分配运单号(status=1)且传入 business_key=1 的订单,避免重复分配。
|
||||
const orderExpressModel = this.ctx.model && this.ctx.model.OrderExpress;
|
||||
let filteredOrdersArr = orders_arr;
|
||||
if (orderExpressModel && orders_arr.length > 0) {
|
||||
const orderIds = orders_arr.map(o => Number(o.id)).filter(id => id > 0);
|
||||
let filteredOrdersArr = activeOrders;
|
||||
if (orderExpressModel && activeOrders.length > 0) {
|
||||
const orderIds = activeOrders.map(o => Number(o.id)).filter(id => id > 0);
|
||||
const completedRows = await orderExpressModel.findAll({
|
||||
where: {
|
||||
order_id: { [Op.in]: orderIds },
|
||||
@ -2590,8 +2607,8 @@ class ExpressService extends Service {
|
||||
skipSet.add(`${Number(row.order_id)}:${Number(row.business_key)}`);
|
||||
}
|
||||
if (skipSet.size > 0) {
|
||||
const beforeCount = orders_arr.length;
|
||||
filteredOrdersArr = orders_arr.filter(order => {
|
||||
const beforeCount = activeOrders.length;
|
||||
filteredOrdersArr = activeOrders.filter(order => {
|
||||
const matchedExpress = orderList.find(express => Number(order.id) === Number(express.order_id));
|
||||
const businessKey = matchedExpress ? Number(matchedExpress.business_key) : 1;
|
||||
if (businessKey === 1 && skipSet.has(`${Number(order.id)}:1`)) {
|
||||
@ -2603,7 +2620,7 @@ class ExpressService extends Service {
|
||||
this.ctx.logger.info('[ExpressService.createWaybillCodePipeline] 跳过已分配运单号(business_key=1)的订单', {
|
||||
traceId,
|
||||
skippedCount: beforeCount - filteredOrdersArr.length,
|
||||
skippedOrderIds: orders_arr
|
||||
skippedOrderIds: activeOrders
|
||||
.filter(order => {
|
||||
const matchedExpress = orderList.find(express => Number(order.id) === Number(express.order_id));
|
||||
const businessKey = matchedExpress ? Number(matchedExpress.business_key) : 1;
|
||||
@ -2620,6 +2637,7 @@ class ExpressService extends Service {
|
||||
return {
|
||||
message: '所有订单均已分配运单号,无需处理',
|
||||
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
||||
skipped_locked_order_ids: skippedLockedOrderIds,
|
||||
};
|
||||
}
|
||||
|
||||
@ -2725,6 +2743,7 @@ class ExpressService extends Service {
|
||||
return {
|
||||
message: '分配快递任务已提交',
|
||||
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
||||
skipped_locked_order_ids: skippedLockedOrderIds,
|
||||
};
|
||||
}
|
||||
/**
|
||||
|
||||
@ -707,45 +707,44 @@ class ExpressPlatformService extends MainService {
|
||||
object_Id: `${order.warehouse_id.toString(16)}_${order.id}_${order_tmp.business_key}`, // 菠萝派平台要求订单唯一标识必须为字符串
|
||||
orderno: `${order.warehouse_id.toString(16)}_${order.id}_${order_tmp.business_key}`, // 菠萝派平台要求订单号必须为字符串
|
||||
plattradeno: listByWarehousePlatformCode.platform_code === 'DY' && order.from_key === 23060081 && !!order.pay_no ? order.pay_no : order.source_order_codes || order.delivery_order_code || '',
|
||||
ismultiplepieces: order.package_count > 1 ? 1 : 0,
|
||||
logisticno: allocatedWaybillMap.get(`${Number(order.id) || 0}:${Number(order_tmp.business_key) || 0}`) || '',
|
||||
logistictype: order.logistics_code || '',
|
||||
tid:listByWarehousePlatformCode.platform_code === 'DY' && order.from_key === 23060081 && !!order.pay_no ? order.pay_no : order.source_order_codes || order.delivery_order_code || '',
|
||||
//ismultiplepieces: order.package_count > 1 ? 1 : 0,
|
||||
//logisticno: allocatedWaybillMap.get(`${Number(order.id) || 0}:${Number(order_tmp.business_key) || 0}`) || '',
|
||||
logistictype: expressListItem[listByWarehousePlatformCode.platform_code] || '',
|
||||
providercode: expressListItem[listByWarehousePlatformCode.platform_code] || order.logistics_code || '',
|
||||
numpackage: order.package_count || 1,
|
||||
businessType: listByWarehousePlatformCode.product_type,
|
||||
numpackage: order.package_count || '1',
|
||||
businesstype: listByWarehousePlatformCode.product_type,
|
||||
transtype:'0',
|
||||
transtypecode:'1',
|
||||
mainsubpaymode:'1',
|
||||
businessplat: order.sys_platform_code === 'KS' ? order.sys_platform_code : 'OTHERS',
|
||||
paymode: listByWarehousePlatformCode.paymode ?? 1,
|
||||
paymode: listByWarehousePlatformCode.paymode.toString() ?? '1',
|
||||
ordertype: listByWarehousePlatformCode.ordertype ?? 'JH_Normal',
|
||||
ProviderID: listByWarehousePlatformCode.providerid ?? '',
|
||||
procode: order.procode || '普通商品',
|
||||
codpaymoney: order.ar_amount ?? null,
|
||||
packagemoney: order.item_amount ?? null,
|
||||
weight: Number(order.items_weight) || 0, // 单位 g,需确认 PolyAPI 期望单位
|
||||
supporpaymoney: order.total_amount ?? null,
|
||||
length: Number(order.length) || 0,
|
||||
width: Number(order.width) || 0,
|
||||
height: Number(order.height) || 0,
|
||||
volume: Number(order.volume) || 0,
|
||||
ispickup: listByWarehousePlatformCode.ispickup ?? 0,
|
||||
ProductType: listByWarehousePlatformCode.product_type || '',
|
||||
Sipshopid: listByWarehousePlatformCode.platform_shop_id || '',
|
||||
ProviderID:'',
|
||||
//procode: order.procode || '普通商品',
|
||||
//codpaymoney: order.ar_amount ?? null,
|
||||
//packagemoney: order.item_amount ?? null,
|
||||
//weight: Number(order.items_weight) || 0, // 单位 g,需确认 PolyAPI 期望单位
|
||||
//supporpaymoney: order.total_amount ?? null,
|
||||
//ispickup: listByWarehousePlatformCode.ispickup ?? 0,
|
||||
//ProductType: listByWarehousePlatformCode.product_type || '',
|
||||
//Sipshopid: listByWarehousePlatformCode.platform_shop_id || '',
|
||||
oaid: order.oaid || '',
|
||||
sys_express_code: listByWarehousePlatformCode.sys_express_code || '',
|
||||
platform_code: listByWarehousePlatformCode.platform_code || '',
|
||||
cpcode: expressListItem[listByWarehousePlatformCode.platform_code] || '',
|
||||
logisticsproductname: 'JH_02',
|
||||
dmssorting: 0,
|
||||
brandno: listByWarehousePlatformCode.brandno || null,
|
||||
//dmssorting: 0,
|
||||
//brandno: listByWarehousePlatformCode.brandno || null,
|
||||
needencrypt: 1,
|
||||
customername:"测试",
|
||||
ordersource: matchedPlatform.ordersource || '',
|
||||
inputsite: listByWarehousePlatformCode.site_code || '',
|
||||
//inputsite: order.sys_platform_code === 'XHS' ? '' :listByWarehousePlatformCode.site_code || '',
|
||||
sitecode: listByWarehousePlatformCode.site_code || '',
|
||||
shipperno: listByWarehousePlatformCode.shipperno || '',
|
||||
customercode: listByWarehousePlatformCode.shipperno || listByWarehousePlatformCode.client_id || '',
|
||||
shipperno: order.sys_platform_code === 'XHS' ? '' :listByWarehousePlatformCode.shipperno || '',
|
||||
customercode: order.sys_platform_code === 'XHS' ? '' :listByWarehousePlatformCode.shipperno || listByWarehousePlatformCode.client_id || '',
|
||||
sender: {
|
||||
company: listByWarehousePlatformCode.shop_name || '',
|
||||
Company: listByWarehousePlatformCode.shop_name || '',
|
||||
name: listByWarehousePlatformCode.sender_name || '',
|
||||
phone: listByWarehousePlatformCode.sender_tel || '',
|
||||
phone: order.sys_platform_code === 'XHS' ? undefined :listByWarehousePlatformCode.sender_tel || '',
|
||||
mobile: order.sys_platform_code === 'XHS' ? listByWarehousePlatformCode.sender_tel : undefined,
|
||||
country: 'CN',
|
||||
city: listByWarehousePlatformCode.city_name || '',
|
||||
@ -771,21 +770,21 @@ class ExpressPlatformService extends MainService {
|
||||
},
|
||||
goods: (order.orderItems && order.orderItems.map(item => ({
|
||||
productid: item.item_code,
|
||||
cnname: item.item_name || '商品',
|
||||
cnname: 'sp',
|
||||
count: item.plan_qty || 0,
|
||||
}))) || [],
|
||||
Mallmaskid: '',
|
||||
//Mallmaskid: '',
|
||||
|
||||
template_url: listByWarehousePlatformCode.template_id || '',
|
||||
labelformat: listByWarehousePlatformCode.labelformat || '',
|
||||
extraInfo: ExpressList.find(item => item.code === listByWarehousePlatformCode.sys_express_code)?.polyapi_extra_info || '',
|
||||
//labelformat: listByWarehousePlatformCode.labelformat || '',
|
||||
//extraInfo: ExpressList.find(item => item.code === listByWarehousePlatformCode.sys_express_code)?.polyapi_extra_info || '',
|
||||
};
|
||||
console.log('matchedPlatform.platid', matchedPlatform.platid);
|
||||
console.log('startPlayload', playload);
|
||||
|
||||
if (Number(matchedPlatform.platid) === 673) {
|
||||
playload.BizVersion = '2';
|
||||
playload.brandno = listByWarehousePlatformCode.brandno || '';
|
||||
playload.brandno = listByWarehousePlatformCode.brandno === "SF" ? listByWarehousePlatformCode.brandno : undefined;
|
||||
}
|
||||
if (Number(matchedPlatform.platid) === 544) {
|
||||
const {
|
||||
@ -898,7 +897,7 @@ class ExpressPlatformService extends MainService {
|
||||
playload.mainsubpaymode = '1';
|
||||
delete playload.plattradeno;
|
||||
}
|
||||
playload.ProviderID = listByWarehousePlatformCode.providerid;
|
||||
playload.ProviderID = listByWarehousePlatformCode.providerid || "";
|
||||
console.log('playload', playload);
|
||||
return playload;
|
||||
}),
|
||||
@ -1105,7 +1104,7 @@ class ExpressPlatformService extends MainService {
|
||||
receivertel: '',
|
||||
cargoname: '',
|
||||
senddata: '',
|
||||
weight: '',
|
||||
//weight: '',
|
||||
eCustomerCode: '',
|
||||
remark: '',
|
||||
selleruserid: '',
|
||||
@ -1761,6 +1760,8 @@ class ExpressPlatformService extends MainService {
|
||||
.filter(Boolean)
|
||||
: [];
|
||||
const recipientMobile = orderDelivery && (orderDelivery.mobile || orderDelivery.tel) || '';
|
||||
const orderDeliveryOaid = orderDelivery && orderDelivery.oaid ? String(orderDelivery.oaid).trim() : '';
|
||||
const oaidTooLong = orderDeliveryOaid.length > 128;
|
||||
|
||||
const tradeOrderInfo = {
|
||||
logistics_services: normalizedExtData,
|
||||
@ -1797,10 +1798,10 @@ class ExpressPlatformService extends MainService {
|
||||
mobile: recipientMobile,
|
||||
name: orderDelivery && orderDelivery.name || '',
|
||||
phone: recipientMobile,
|
||||
oaid: orderDelivery && orderDelivery.oaid || '',
|
||||
tid: sourceOrderCodes[0] || '',
|
||||
oaid: oaidTooLong ? '' : orderDeliveryOaid,
|
||||
caid: oaidTooLong ? orderDeliveryOaid : '',
|
||||
tid: orderDelivery.pay_no || '',
|
||||
},
|
||||
oaid: orderDelivery && orderDelivery.oaid || '',
|
||||
user_id: listByWarehousePlatformCode.shop && listByWarehousePlatformCode.shop.owner_id || 0,
|
||||
notify_extend_info: normalizedExtData,
|
||||
};
|
||||
@ -1842,7 +1843,8 @@ class ExpressPlatformService extends MainService {
|
||||
shipping_branch_code: String(listByWarehousePlatformCode.site_code || '').trim(),
|
||||
},
|
||||
};
|
||||
console.log('cainiaoPayload', JSON.stringify(cainiaoPayload));
|
||||
|
||||
await this.app.setCacheAsync('Cainiaoquery', JSON.stringify(cainiaoPayload), 3600);
|
||||
const requestParams = {
|
||||
method: 'cainiao.waybill.ii.get',
|
||||
app_key: appKey,
|
||||
@ -1865,7 +1867,7 @@ class ExpressPlatformService extends MainService {
|
||||
sign,
|
||||
},
|
||||
});
|
||||
console.log('菜鸟取号返回数据', JSON.stringify(response));
|
||||
await this.app.setCacheAsync('Cainiaoresult', JSON.stringify(response), 3600);
|
||||
|
||||
const responseData = response && Object.prototype.hasOwnProperty.call(response, 'data')
|
||||
? response.data
|
||||
|
||||
@ -638,17 +638,9 @@ class InboundDirectLogService extends Service {
|
||||
return { code: 400, message: '入库单已绑定收货单且状态为 CREATED,请先审核后再进行上架操作', data: null };
|
||||
}
|
||||
|
||||
// PENDING 状态校验
|
||||
if (entryOrder.order_status === 'PENDING') {
|
||||
if (!hasReceivingBindings) {
|
||||
return { code: 400, message: '入库单未绑定收货单,无法上架', data: null };
|
||||
}
|
||||
for (const item of items) {
|
||||
if (!item.receiving_detail_id) {
|
||||
return { code: 400, message: '随机入库需要选定收货单明细提交,缺少 receiving_detail_id', data: null };
|
||||
}
|
||||
}
|
||||
}
|
||||
// PENDING 状态:允许导入。items 可传 receiving_detail_id 走绑定模式(预占收货明细),
|
||||
// 也可不传走非绑定模式(数量受计划数量限制),不再强制绑定收货单、不再强制传收货单 ID;
|
||||
// 绑定模式下的 space_id/明细可用数量等校验由 _addSingleItem 统一处理。
|
||||
|
||||
// 批量模式下用事务包裹,任一失败整批回退
|
||||
const useTransaction = isBatch;
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
const MainService = require('../main');
|
||||
|
||||
const { isInterceptedOrderStatus } = require('../../lib/intercept_guard');
|
||||
const { isLockedOrderStatus } = require('../../lib/lock_guard');
|
||||
|
||||
const STORAGE_STATUS_FIN = 'fin';
|
||||
const STORAGE_STATUS_ERROR = 'error';
|
||||
@ -645,6 +646,21 @@ class OrderStorageAllocationService extends MainService {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isLockedOrderStatus(orderRow && orderRow.lock_status)) {
|
||||
skippedOrders.push({
|
||||
order_id: orderId,
|
||||
status: 'skipped',
|
||||
lock_status: orderRow.lock_status,
|
||||
skipped_reason: 'locked',
|
||||
});
|
||||
writeAllocationTextLog('[OrderStorageAllocationService.allocatePicking] 过滤订单结果', {
|
||||
orderId,
|
||||
lockStatus: orderRow.lock_status,
|
||||
skippedReason: 'locked',
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (String(orderRow.storage_status || 'none') === STORAGE_STATUS_FIN) {
|
||||
skippedOrders.push({
|
||||
order_id: orderId,
|
||||
|
||||
@ -1494,7 +1494,8 @@ class ReceivingService extends Service {
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送收货单创建/首次绑定货主通知(receiving_store_bound),提醒货主填写车牌号/快递单号。
|
||||
* 发送收货单创建/首次绑定货主通知(receiving_store_bound),提醒货主确认/补填车牌号或快递单号。
|
||||
* 已填写车牌号或快递单号时,文案展示已登记信息;均未填写时才提示及时补充。
|
||||
* 路由由 notice 固定订阅回退链处理:货主收货群 → 无则货主售后群 → 均无则仓库异常群。
|
||||
* @param {Object} options 发送参数
|
||||
* @param {Object} options.receiving 收货单快照
|
||||
@ -1522,10 +1523,23 @@ class ReceivingService extends Service {
|
||||
const storeLabel = String(storeName || receiving.store_name || '').trim() || '货主';
|
||||
const storeFrontendUrl = String(ctx.app.config.storeFrontendUrl || ctx.app.config.frontendUrl || '').trim();
|
||||
|
||||
const licensePlate = String(receiving.license_plate || '').trim();
|
||||
const trackingNumber = String(receiving.tracking_number || '').trim();
|
||||
const vehicleInfoLines = [];
|
||||
if (licensePlate) {
|
||||
vehicleInfoLines.push(`车牌号:${licensePlate} 已登记`);
|
||||
}
|
||||
if (trackingNumber) {
|
||||
vehicleInfoLines.push(`快递单号:${trackingNumber} 已登记`);
|
||||
}
|
||||
if (vehicleInfoLines.length === 0) {
|
||||
vehicleInfoLines.push('请确认是否已填写车牌号或快递单号,未填写请及时补充');
|
||||
}
|
||||
|
||||
const contentLines = [
|
||||
`收货单号:${receivingNumber} 正在收货`,
|
||||
`货主:${storeLabel}`,
|
||||
'请确认是否已填写车牌号或快递单号,未填写请及时补充',
|
||||
...vehicleInfoLines,
|
||||
];
|
||||
const content = [ ...contentLines ].join('\n') + '。';
|
||||
const storeContent = [ ...contentLines, `快速查看:${storeFrontendUrl}/storage/receiving_owner?id=${receivingNumber}` ].join('\n') + '。';
|
||||
@ -2061,6 +2075,8 @@ class ReceivingService extends Service {
|
||||
warehouse_id: result.warehouse_id,
|
||||
store_id: result.store_id,
|
||||
store_name: result.store_name,
|
||||
license_plate: result.license_plate,
|
||||
tracking_number: result.tracking_number,
|
||||
},
|
||||
});
|
||||
} catch (noticeErr) {
|
||||
@ -2422,6 +2438,8 @@ class ReceivingService extends Service {
|
||||
warehouse_id: warehouseId,
|
||||
store_id: storeId,
|
||||
store_name: storeName,
|
||||
license_plate: receiving.license_plate,
|
||||
tracking_number: receiving.tracking_number,
|
||||
},
|
||||
});
|
||||
} catch (noticeErr) {
|
||||
@ -3283,6 +3301,8 @@ class ReceivingService extends Service {
|
||||
warehouse_id: warehouseId,
|
||||
store_id: storeId,
|
||||
store_name: storeName,
|
||||
license_plate: receiving.license_plate,
|
||||
tracking_number: receiving.tracking_number,
|
||||
},
|
||||
});
|
||||
} catch (noticeErr) {
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* 将订单商品表 ext_code 列从 VARCHAR(50) 改为 TEXT。
|
||||
*
|
||||
* 背景:
|
||||
* wms_order_items.ext_code 原为 VARCHAR(50),上游平台(奇门/仓库接口)下发的
|
||||
* 商品外部编码可能超过 50 字符,INSERT 时报
|
||||
* "Data too long for column 'ext_code' at row 1",导致整个订单创建失败。
|
||||
*
|
||||
* 变更:
|
||||
* 1. 主表 wms_order_items 及全部已有分表 wms_order_items_{warehouseId}
|
||||
* (含 _dispatch/_history 后缀)的 ext_code 列统一改为 TEXT。
|
||||
* 2. 模型定义同步改为 TEXT(app/model/order_items.js),后续新建分表直接
|
||||
* 使用 TEXT,OrderItemsFactory 的结构对齐逻辑不会再回退该列。
|
||||
*
|
||||
* @param {import('sequelize').QueryInterface} queryInterface Sequelize 查询接口
|
||||
* @return {Promise<void>} 无返回值
|
||||
*/
|
||||
async function listOrderItemsTables(queryInterface) {
|
||||
const [ rows ] = await queryInterface.sequelize.query(`
|
||||
SELECT TABLE_NAME
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND (TABLE_NAME = 'wms_order_items' OR TABLE_NAME LIKE 'wms_order_items\\_%')
|
||||
`);
|
||||
|
||||
return (Array.isArray(rows) ? rows : []).map(row => row.TABLE_NAME);
|
||||
}
|
||||
|
||||
async function hasColumn(queryInterface, tableName, columnName) {
|
||||
const [ columns ] = await queryInterface.sequelize.query(
|
||||
`
|
||||
SELECT COLUMN_NAME
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = :tableName
|
||||
AND COLUMN_NAME = :columnName
|
||||
`,
|
||||
{ replacements: { tableName, columnName } }
|
||||
);
|
||||
|
||||
return (Array.isArray(columns) ? columns : []).length > 0;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
up: async queryInterface => {
|
||||
const tableNames = await listOrderItemsTables(queryInterface);
|
||||
let alteredCount = 0;
|
||||
|
||||
for (const tableName of tableNames) {
|
||||
if (!(await hasColumn(queryInterface, tableName, 'ext_code'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
await queryInterface.sequelize.query(
|
||||
`ALTER TABLE \`${tableName}\` MODIFY \`ext_code\` TEXT NULL COMMENT '外部编码'`
|
||||
);
|
||||
alteredCount += 1;
|
||||
}
|
||||
|
||||
console.log(`[migrate] wms_order_items ext_code → TEXT,共处理 ${alteredCount} 张表`);
|
||||
},
|
||||
|
||||
down: async queryInterface => {
|
||||
const tableNames = await listOrderItemsTables(queryInterface);
|
||||
|
||||
for (const tableName of tableNames) {
|
||||
if (!(await hasColumn(queryInterface, tableName, 'ext_code'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 注意:若已有数据超过 50 字符,回滚会失败,需先人工截断数据
|
||||
await queryInterface.sequelize.query(
|
||||
`ALTER TABLE \`${tableName}\` MODIFY \`ext_code\` VARCHAR(50) NULL COMMENT '外部编码'`
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
@ -1,4 +1,93 @@
|
||||
[
|
||||
{
|
||||
"version": "2026.08.18-order-list-lock-status-filter-doc",
|
||||
"date": "2026-08-18",
|
||||
"type": "enhanced",
|
||||
"summary": "订单列表 where 补充 lock_status 筛选说明:未锁定传 lock_status=none,已锁定(所有非 none)传 lock_status={operator:ne,value:none};筛选用数据库原始枚举 none/warehouse/store 而非响应 Y/N,条件值为空自动忽略。",
|
||||
"methods": [
|
||||
"order.pendingOrder.list"
|
||||
],
|
||||
"notes": [
|
||||
"仅文档补充,无代码改动:methods/system.json 中 order.pendingOrder.list 的 where 参数 description 增加 lock_status 筛选说明",
|
||||
"行为依据:app/service/systemMethods/order/base.js listByModule/buildWhere 对 where 无字段白名单(仅禁止 warehouse_id/warehouseId),可直接传订单表列名;app/lib/query_condition_parser.js 支持 ne 操作符且条件值为空时自动忽略(isEmptyValue 跳过)",
|
||||
"lock_status 数据库原始枚举 none/warehouse/store(app/model/order_delivery.js LOCK_STATUS),列表响应仍统一输出 Y/N(normalizeLockStatusFlag:none→N,其余→Y),筛选入参必须用原始枚举而非响应 Y/N",
|
||||
"同样经 listByModule 的其它工作台订单列表(order.reviewOrder.list / order.outboundOrder.list / order.expectionOrder.list / order.entrustOrder.list / order.deliveryOrder.list / order.deliveryExpectionOrder.list / order.archiveOrder.list)where 语义一致,本次保持其文档不变,重点仅更新 order.pendingOrder.list"
|
||||
],
|
||||
"module": "order"
|
||||
},
|
||||
{
|
||||
"version": "2026.08.18-setting.expressInterface.update-doc-params",
|
||||
"date": "2026-08-18",
|
||||
"type": "enhanced",
|
||||
"summary": "补全 setting.expressInterface.update 接口文档:入参由 3 个字段扩展为全量可更新字段(含 town_name/townName、is_enabled/isEnabled、providertype 等),并补充全量响应字段与错误码说明。",
|
||||
"methods": [
|
||||
"setting.expressInterface.update"
|
||||
],
|
||||
"notes": [
|
||||
"入参按 app/service/systems/setting/expressInterface.js update() 与包装层 app/service/systemMethods/setting/expressInterface.js update() 实际支持的字段补齐,含驼峰别名(shopId/townName/isEnabled 等),仅传入的字段被更新",
|
||||
"响应按 normalizeInterfaceRow 返回结构补齐全量字段",
|
||||
"仅文档变更,无代码改动"
|
||||
],
|
||||
"module": "setting.expressInterface"
|
||||
},
|
||||
{
|
||||
"version": "2026.08.18-order-lock-status-guard-and-list-yn",
|
||||
"date": "2026-08-18",
|
||||
"type": "enhanced",
|
||||
"summary": "新增锁定订单作业门禁与订单列表 lock_status 转 Y/N:lock_status 非 none(枚举 warehouse/store)的订单在分配储位、分配快递、抓取波次、自动加团等流程中被直接跳过,跳过明细通过 skipped_locked_order_ids / excluded_locked_order_ids / skipped_orders 等字段返回;订单列表 lock_status 统一输出 Y/N(none→N,其余→Y)。",
|
||||
"methods": [
|
||||
"order.pendingOrder.list",
|
||||
"order.pendingOrder.allocateExpressCode",
|
||||
"order.pendingOrder.allocateStorage",
|
||||
"order.wave.singleFetchByIds",
|
||||
"order.wave.waveStrategyFallbackOrderList",
|
||||
"order.wave.batchAllocateExpress",
|
||||
"order.wave.batchAllocateExpressTaskProgress",
|
||||
"order.wave.batchAllocateStorage",
|
||||
"order.wave.batchAllocateStorageTaskProgress"
|
||||
],
|
||||
"notes": [
|
||||
"新增 app/lib/lock_guard.js isLockedOrderStatus:lock_status 非 'none' 即视为已锁定(枚举 none/warehouse/store)",
|
||||
"app/service/systems/order_storage_allocation.js allocatePicking:过滤循环新增锁定订单跳过,skipped 记录含 lock_status 与 skipped_reason='locked';order.storageAllocation.allocateStorage / order.pendingOrder.allocateStorage / order.wave.batchAllocateStorage 共用该底层入口",
|
||||
"app/service/systems/express.js createWaybillCodePipeline:查询新增 lock_status 字段,锁定订单与拦截订单同样剔除,返回结果新增 skipped_locked_order_ids",
|
||||
"app/service/systemMethods/order/wave.js runBatchAllocateExpressTask:查询新增 lock_status,任务进度与 result 新增 skipped_locked_order_ids;singleFetchByIds 查询属性新增 lock_status 并过滤锁定订单,响应新增 excluded_locked_order_ids(两个返回分支均返回);waveStrategyFallbackOrderList 查询追加 lock_status/intercept_status 非 none 条件,列表行新增 excluded_reason(locked/intercepted/printed/no_match)",
|
||||
"app/service/systems/delivery_order.js asyncProcessOrderCreated:订单已锁定时跳过自动分配快递/储位/自动加团三步;appendOrderToWave 增加锁定校验且更新波次时 where 追加 lock_status='none';countCandidateGroupOrders 过滤 lock_status='none'(内部流程,无公开接口)",
|
||||
"app/service/systemMethods/order/base.js 新增 normalizeLockStatusFlag:none(含空值)返回 'N',其余值一律返回 'Y';normalizeOrderListItem 统一覆盖 lock_status 输出为 Y/N,影响 order.pendingOrder.list、order.wave.waveStrategyFallbackOrderList 及经 listByModule 的各类工作台订单列表",
|
||||
"同步更新 methods/system.json 中上述 method 的 description 与 response 字段"
|
||||
],
|
||||
"module": "order"
|
||||
},
|
||||
{
|
||||
"version": "2026.08.18-storage.entry.addItem-non-binding",
|
||||
"date": "2026-08-18",
|
||||
"type": "fixed",
|
||||
"summary": "库存导入(storage.entry.addItem 导入/PDA 入库)不再强制绑定收货单:原 PENDING 状态下未绑定收货单拒绝上架、每项缺少 receiving_detail_id 拒绝,导致移除绑定收货单后仍限制必须传入收货单 ID。现 PENDING 状态允许不绑定收货单直接导入(非绑定模式,数量受计划数量限制),传 receiving_detail_id 时仍走绑定模式(预占收货明细)",
|
||||
"methods": [
|
||||
"storage.entry.addItem"
|
||||
],
|
||||
"notes": [
|
||||
"app/service/systems/inbound_direct_log.js addItem:删除 PENDING 状态下 hasReceivingBindings 与 receiving_detail_id 的强制校验,绑定模式 space_id/可用数量校验仍由 _addSingleItem 统一处理;CREATED 已绑定收货单需先审核的限制保留",
|
||||
"PENDING 非绑定模式导入数量仍受计划数量限制(isManualImport 仅 CREATED 且非绑定可超计划),防止超计划入库",
|
||||
"同步更新 methods/system.json 中 storage.entry.addItem 的 description、receiving_detail_id 参数说明与错误码列表(移除两条 PENDING 绑定错误码)"
|
||||
],
|
||||
"module": "storage.entry"
|
||||
},
|
||||
{
|
||||
"version": "2026.08.18-recheckOrder.scanOrder.singleIntercept",
|
||||
"date": "2026-08-18",
|
||||
"type": "fixed",
|
||||
"summary": "修复 order.recheckOrder.scanOrder 散单模式拦截订单识别:原逻辑对波次内所有订单执行复核校验,只要波次内存在一单已进入拦截流程(requested/requesting/intercepting/intercepted_in_transit/intercepted_at_warehouse,历史值 intercepted 兼容),整个散单扫描视图即报错「订单已被拦截,无法提交复核」,导致波次内其他正常订单也无法复核。现拦截订单保留在 list 中按单提示(intercept_status),不再阻断整个扫描视图加载,且不计入复核/打印统计",
|
||||
"methods": [
|
||||
"order.recheckOrder.scanOrder",
|
||||
"order.recheckOrder.scanTask"
|
||||
],
|
||||
"notes": [
|
||||
"buildSingleWaveScanView:用 isInterceptedOrderStatus 分离拦截订单,仅非拦截订单参与 assertOrderCanRecheck 校验与 reviewed/unreviewed/printed/unprinted 统计,拦截订单保留在 list 中按单提示",
|
||||
"车号/任务模式(cart/task)合并多个波次后,reviewed_count/unreviewed_count 仅统计非拦截订单,total_orders 仍为订单总数",
|
||||
"同步更新 methods/system.json 中 scanOrder 散单订单项 intercept_status 字段说明"
|
||||
],
|
||||
"module": "order"
|
||||
},
|
||||
{
|
||||
"version": "2026.08.17-inbox-group-reset",
|
||||
"date": "2026-08-17",
|
||||
@ -6226,5 +6315,24 @@
|
||||
"退回查询 _resolveReturnOrderInfo 优先主表快照,空时实时兜底(交易单号→原运单/原订单,店铺→store_remask)"
|
||||
],
|
||||
"module": "returnUnpack"
|
||||
},
|
||||
{
|
||||
"version": "2026.08.18-storeWarehouse-sign-confirmSign-doc",
|
||||
"date": "2026-08-18",
|
||||
"type": "added",
|
||||
"summary": "补齐 storeWarehouse 签约接口文档(纯文档补全,无业务代码变更):新增 storeWarehouse.store.confirmSign(货主侧确认签约)、storeWarehouse.warehouse.sign(仓库侧发起签约)、storeWarehouse.warehouse.confirmSign(仓库侧确认签约)三个方法的入参/出参/错误码说明。",
|
||||
"methods": [
|
||||
"storeWarehouse.store.confirmSign",
|
||||
"storeWarehouse.warehouse.sign",
|
||||
"storeWarehouse.warehouse.confirmSign"
|
||||
],
|
||||
"notes": [
|
||||
"storeWarehouse.store.confirmSign:当前主体作为对方主体确认待签约申请,auth_status 由 1(申请中)变更为 2(已通过);入参 id(兼容 contract_id);400=id 缺失或签约状态非待签约、403=当前主体不在签约关系中或发起方自确认、404=签约关系不存在;响应 data.mode=confirm 与 data.contract 精简对象(id/store_id/warehouse_id/counterparty_name/remask/use_status/auth_status/auth_status_label/auth_end/print_quantity/has_qimen_config)",
|
||||
"storeWarehouse.warehouse.sign:仓库侧发起签约,当前仓库在 store_id 方、对方在 warehouse_id 方,支持签约外部合作仓库;入参 counterparty_id(兼容 warehouse_id / store_id),当前主体自动识别;响应 data.mode=initiate/already_exists/already_confirmed 与 data.contract;400=对方主体缺失/日期非法,404=签约对象不存在",
|
||||
"storeWarehouse.warehouse.confirmSign:仓库侧确认签约,校验逻辑与货主侧确认一致(400/403/404 同 storeWarehouse.store.confirmSign)",
|
||||
"代码对齐:app/service/systemMethods/storeWarehouse/store.js#confirmSign、app/service/systemMethods/storeWarehouse/warehouse.js#sign/#confirmSign 均已注册(_noNeedAuth 含三个方法,isNeedAuth=false、isNeedLogin=true);实现位于 app/service/systems/store_warehouse.js#sign/#confirmSign;权限表 method id 397「签约确定」",
|
||||
"仅文档变更,无业务代码修改"
|
||||
],
|
||||
"module": "storeWarehouse"
|
||||
}
|
||||
]
|
||||
|
||||
@ -224,5 +224,20 @@
|
||||
"dev 库已回填:26 仓库组-主管、27 仓库组-员工、28 客服组-主管、30 客服组-员工"
|
||||
],
|
||||
"module": "permission"
|
||||
},
|
||||
{
|
||||
"version": "2026-08-17-warehouse-08",
|
||||
"date": "2026-08-17",
|
||||
"type": "fixed",
|
||||
"summary": "修复 receiving_store_bound 通知文案不感知车牌/快递单号:创建收货单时已填车牌仍提示「请确认是否已填写车牌号或快递单号」,改为已填写时展示已登记信息、未填写才提示补充",
|
||||
"methods": [
|
||||
"notify.reply"
|
||||
],
|
||||
"notes": [
|
||||
"sendStoreBoundNotice 根据 receiving.license_plate / receiving.tracking_number 动态生成第三行:已填车牌显示「车牌号:X 已登记」、已填快递单号显示「快递单号:X 已登记」、均未填才显示「请确认是否已填写车牌号或快递单号,未填写请及时补充」",
|
||||
"三个触发点(create/bindStore/updateReceivingStats)的 receiving 快照均补充 license_plate / tracking_number 字段",
|
||||
"背景:R20682003 创建时已写入车牌粤EH22E2,但通知为固定提醒文案导致货主误以为车牌未生效"
|
||||
],
|
||||
"module": "receiving"
|
||||
}
|
||||
]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -312,7 +312,8 @@ function applyDocUpdate(doc, groupSpec, methods, docMeta) {
|
||||
function appendChange(changes, change) {
|
||||
const exists = changes.some(item => item && item.version === change.version);
|
||||
assert(!exists, `Duplicate change version detected: ${change.version}`);
|
||||
changes.push(cloneJson(change));
|
||||
// 变更记录保持“新记录在数组开头”的顺序(与 methods/changes/*.json 现有约定一致)
|
||||
changes.unshift(cloneJson(change));
|
||||
}
|
||||
|
||||
function main() {
|
||||
@ -384,4 +385,4 @@ module.exports = {
|
||||
applyDocUpdate,
|
||||
parseArgs,
|
||||
validateSpec,
|
||||
};
|
||||
};
|
||||
|
||||
@ -25,6 +25,8 @@ function createContext(options = {}) {
|
||||
sendOrderMarks: [],
|
||||
redisGetKeys: [],
|
||||
platformFindAllWheres: [],
|
||||
systemPlatformFindAllWheres: [],
|
||||
printPlatformIdFindAllWheres: [],
|
||||
orderDeliveryLockUpdates: [],
|
||||
operationLogCreatePayloads: [],
|
||||
};
|
||||
@ -66,6 +68,18 @@ function createContext(options = {}) {
|
||||
douyin: '抖音',
|
||||
};
|
||||
|
||||
const platformPrintIdMap = requestOptions.platformPrintIdMap || {
|
||||
TB: 2,
|
||||
TM: 2,
|
||||
1688: 2,
|
||||
TGC: 2,
|
||||
MAOCHAO: 2,
|
||||
};
|
||||
|
||||
const printPlatformNameById = requestOptions.printPlatformNameById || {
|
||||
2: '菜鸟',
|
||||
};
|
||||
|
||||
const printStation = requestOptions.printStation || {
|
||||
id: 101,
|
||||
warehouse_id: 100000,
|
||||
@ -276,18 +290,41 @@ function createContext(options = {}) {
|
||||
},
|
||||
PrintPlatform: {
|
||||
async findAll(query) {
|
||||
calls.platformFindAllWheres.push(query && query.where ? query.where : {});
|
||||
const codeList = query && query.where && Array.isArray(query.where.platform_code)
|
||||
? query.where.platform_code
|
||||
: [];
|
||||
return codeList.map(platformCode => ({
|
||||
platform_code: platformCode,
|
||||
platform_name: Object.prototype.hasOwnProperty.call(platformComponents, platformCode)
|
||||
? platformComponents[platformCode]
|
||||
const where = query && query.where ? query.where : {};
|
||||
if (Array.isArray(where.platform_code)) {
|
||||
calls.platformFindAllWheres.push(where);
|
||||
const codeList = where.platform_code;
|
||||
return codeList.map(platformCode => ({
|
||||
id: null,
|
||||
platform_code: platformCode,
|
||||
platform_name: Object.prototype.hasOwnProperty.call(platformComponents, platformCode)
|
||||
? platformComponents[platformCode]
|
||||
: '',
|
||||
}));
|
||||
}
|
||||
calls.printPlatformIdFindAllWheres.push(where);
|
||||
const idList = Array.isArray(where.id) ? where.id : [];
|
||||
return idList.map(printPlatformId => ({
|
||||
id: printPlatformId,
|
||||
platform_name: Object.prototype.hasOwnProperty.call(printPlatformNameById, printPlatformId)
|
||||
? printPlatformNameById[printPlatformId]
|
||||
: '',
|
||||
}));
|
||||
},
|
||||
},
|
||||
Platform: {
|
||||
async findAll(query) {
|
||||
const where = query && query.where ? query.where : {};
|
||||
calls.systemPlatformFindAllWheres.push(where);
|
||||
const codeList = Array.isArray(where.code) ? where.code : [];
|
||||
return codeList.map(platformCode => ({
|
||||
code: platformCode,
|
||||
print_platform_id: Object.prototype.hasOwnProperty.call(platformPrintIdMap, platformCode)
|
||||
? platformPrintIdMap[platformCode]
|
||||
: null,
|
||||
}));
|
||||
},
|
||||
},
|
||||
OrderDeliveryFactory: {
|
||||
async getCurrentModel() {
|
||||
return {
|
||||
@ -690,6 +727,100 @@ describe('test/app/service/systemMethods/print.send.test.js', () => {
|
||||
assert.equal(calls.sendToComputerPayloads.length, 0);
|
||||
});
|
||||
|
||||
it('type=express 系统平台编码 TB 应经 wms_platform 回退解析打印组件', async () => {
|
||||
const { ctx, calls } = createContext({
|
||||
componentStatuses: {
|
||||
'printer:PC-STATION-001:name:菜鸟:status': 'connected',
|
||||
},
|
||||
});
|
||||
const service = new PrintService(ctx);
|
||||
|
||||
const result = await service.send({
|
||||
type: 'express',
|
||||
printStationId: 101,
|
||||
requestCode: 'REQ-TB-FALLBACK-001',
|
||||
data: {
|
||||
waveGroups: [
|
||||
{
|
||||
wave_id: 1,
|
||||
wave_no: 'WAVE-TB-1',
|
||||
platforms: [
|
||||
{
|
||||
platform: 'TB',
|
||||
sys_logistics_code: 'STO',
|
||||
orders: [
|
||||
{
|
||||
print_data: {
|
||||
documentID: 'DOC-TB-1',
|
||||
contents: [
|
||||
{
|
||||
marker: 'TB-1',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(result.flag, 'success');
|
||||
assert.equal(calls.sendToComputerPayloads.length, 1);
|
||||
const components = calls.sendToComputerPayloads.map(item => item.data.component);
|
||||
assert.deepEqual(components, [ '菜鸟' ]);
|
||||
assert.deepEqual(calls.systemPlatformFindAllWheres[0].code, [ 'TB' ]);
|
||||
assert.deepEqual(calls.printPlatformIdFindAllWheres[0].id, [ 2 ]);
|
||||
assert.ok(calls.redisGetKeys.includes('printer:PC-STATION-001:name:菜鸟:status'));
|
||||
});
|
||||
|
||||
it('type=express 系统平台编码无映射时应失败且不发送任务', async () => {
|
||||
const { ctx, calls } = createContext({
|
||||
platformPrintIdMap: {},
|
||||
});
|
||||
const service = new PrintService(ctx);
|
||||
|
||||
const result = await service.send({
|
||||
type: 'express',
|
||||
printStationId: 101,
|
||||
requestCode: 'REQ-TB-UNMAPPED-001',
|
||||
data: {
|
||||
waveGroups: [
|
||||
{
|
||||
wave_id: 1,
|
||||
wave_no: 'WAVE-TB-2',
|
||||
platforms: [
|
||||
{
|
||||
platform: 'TB',
|
||||
sys_logistics_code: 'STO',
|
||||
orders: [
|
||||
{
|
||||
print_data: {
|
||||
documentID: 'DOC-TB-2',
|
||||
contents: [
|
||||
{
|
||||
marker: 'TB-2',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(result.flag, 'failure');
|
||||
assert.equal(result.code, 400);
|
||||
assert.match(result.message, /平台 TB 未配置打印组件/);
|
||||
assert.equal(calls.printRecordCreatePayloads.length, 0);
|
||||
assert.equal(calls.sendToComputerPayloads.length, 0);
|
||||
});
|
||||
|
||||
it('type=express 快手平台应按10单分批发送并注入文档位置信息', async () => {
|
||||
const { ctx, calls } = createContext({
|
||||
platformComponents: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user