Compare commits
No commits in common. "932761155227d5966184c3951911ca9e603c993e" and "591a69d35ef388a8218a81f1067c3bfc53a2fb28" have entirely different histories.
9327611552
...
591a69d35e
@ -1,29 +0,0 @@
|
|||||||
'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 => {
|
module.exports = app => {
|
||||||
const { Sequelize, model } = app;
|
const { Sequelize, model } = app;
|
||||||
const { STRING, BIGINT, DECIMAL, INTEGER, JSON, TEXT } = Sequelize;
|
const { STRING, BIGINT, DECIMAL, INTEGER, JSON } = Sequelize;
|
||||||
|
|
||||||
const OrderItems = model.define('wms_order_items', {
|
const OrderItems = model.define('wms_order_items', {
|
||||||
id: {
|
id: {
|
||||||
@ -28,7 +28,7 @@ module.exports = app => {
|
|||||||
comment: '零售价格',
|
comment: '零售价格',
|
||||||
},
|
},
|
||||||
ext_code: {
|
ext_code: {
|
||||||
type: TEXT,
|
type: STRING(50),
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
comment: '外部编码',
|
comment: '外部编码',
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
const MainService = require('../../main');
|
const MainService = require('../../main');
|
||||||
const { parseWhereConditions } = require('../../../lib/query_condition_parser');
|
const { parseWhereConditions } = require('../../../lib/query_condition_parser');
|
||||||
const { isInterceptedOrderStatus } = require('../../../lib/intercept_guard');
|
const { isInterceptedOrderStatus } = require('../../../lib/intercept_guard');
|
||||||
const { isLockedOrderStatus } = require('../../../lib/lock_guard');
|
|
||||||
|
|
||||||
const DEFAULT_PAGE_SIZE = 20;
|
const DEFAULT_PAGE_SIZE = 20;
|
||||||
const MAX_PAGE_SIZE = 500;
|
const MAX_PAGE_SIZE = 500;
|
||||||
@ -209,16 +208,6 @@ class OrderBaseService extends MainService {
|
|||||||
return isInterceptedOrderStatus(status);
|
return isInterceptedOrderStatus(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断订单锁定状态是否属于"已锁定"(lock_status != none)。
|
|
||||||
*
|
|
||||||
* @param {*} status 锁定状态值。
|
|
||||||
* @return {boolean} 是否已锁定。
|
|
||||||
*/
|
|
||||||
isLockedOrderStatus(status = '') {
|
|
||||||
return isLockedOrderStatus(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 断言订单未进入拦截流程,否则抛出阻断异常。
|
* 断言订单未进入拦截流程,否则抛出阻断异常。
|
||||||
*
|
*
|
||||||
@ -578,17 +567,6 @@ class OrderBaseService extends MainService {
|
|||||||
return Number.isNaN(numericVersion) ? strategyVersion : numericVersion;
|
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 订单列表行数据。
|
* @param {Object} order 订单列表行数据。
|
||||||
@ -607,7 +585,6 @@ class OrderBaseService extends MainService {
|
|||||||
wave_strategy_version: this.normalizeWaveStrategyVersion(order.wave_strategy_version),
|
wave_strategy_version: this.normalizeWaveStrategyVersion(order.wave_strategy_version),
|
||||||
wave_scan_result: this.normalizeWaveScanResult(order.wave_scan_result),
|
wave_scan_result: this.normalizeWaveScanResult(order.wave_scan_result),
|
||||||
create_channel: this.formatCreateChannelLabel(order.create_channel),
|
create_channel: this.formatCreateChannelLabel(order.create_channel),
|
||||||
lock_status: this.normalizeLockStatusFlag(order.lock_status),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5048,7 +5048,7 @@ ${numbered}`;
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
businessType: 'order',
|
businessType: 'order',
|
||||||
businessId: orderId,
|
businessId: logWarehouseId,
|
||||||
operationCode: 'ORDER_LOCK',
|
operationCode: 'ORDER_LOCK',
|
||||||
operator,
|
operator,
|
||||||
extras: {
|
extras: {
|
||||||
@ -5557,7 +5557,7 @@ ${numbered}`;
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
businessType: 'order',
|
businessType: 'order',
|
||||||
businessId: orderId,
|
businessId: logWarehouseId,
|
||||||
operationCode: 'ORDER_UNLOCK',
|
operationCode: 'ORDER_UNLOCK',
|
||||||
operator,
|
operator,
|
||||||
extras: {
|
extras: {
|
||||||
|
|||||||
@ -290,12 +290,8 @@ class RecheckOrderService extends OrderBaseService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const totalOrders = mergedList.length;
|
const totalOrders = mergedList.length;
|
||||||
// 复核统计仅计非拦截订单(拦截订单保留在 list 中按单提示)
|
const reviewedCount = mergedList.filter(o => o.recheck_status === 'fin').length;
|
||||||
const reviewableOrders = mergedList.filter(
|
const unreviewedCount = totalOrders - reviewedCount;
|
||||||
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 waveType = scanViews.find(v => Number(v.wave_type || 0) > 0)?.wave_type || 0;
|
||||||
const pickerInfo = await this.getPickerInfoByTaskId(taskId, warehouseId);
|
const pickerInfo = await this.getPickerInfoByTaskId(taskId, warehouseId);
|
||||||
|
|
||||||
@ -455,12 +451,8 @@ class RecheckOrderService extends OrderBaseService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const totalOrders = mergedList.length;
|
const totalOrders = mergedList.length;
|
||||||
// 复核统计仅计非拦截订单(拦截订单保留在 list 中按单提示)
|
const reviewedCount = mergedList.filter(o => o.recheck_status === 'fin').length;
|
||||||
const reviewableOrders = mergedList.filter(
|
const unreviewedCount = totalOrders - reviewedCount;
|
||||||
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 waveType = scanViews.find(v => Number(v.wave_type || 0) > 0)?.wave_type || 0;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -488,8 +480,6 @@ class RecheckOrderService extends OrderBaseService {
|
|||||||
* @param {number} waveId 波次ID。
|
* @param {number} waveId 波次ID。
|
||||||
* @param {string} waveNo 波次号。
|
* @param {string} waveNo 波次号。
|
||||||
* @param {number} warehouseId 仓库ID。
|
* @param {number} warehouseId 仓库ID。
|
||||||
* 拦截订单保留在 list 中(带 intercept_status),不参与复核校验与 reviewed/unreviewed/printed 统计,
|
|
||||||
* 波次内存在拦截订单时不再阻断整个扫描视图加载(与团购模式一致)。
|
|
||||||
* @return {Promise<Object|null>} 扁平化扫描视图,包含 picker_id、picker_name、task_id、wave_id、wave_no、
|
* @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、
|
* wave_type、pick_mode、strategy_id、strategy_name、total_orders、reviewed_count、unreviewed_count、
|
||||||
* printed_count、unprinted_count、list。
|
* printed_count、unprinted_count、list。
|
||||||
@ -505,15 +495,8 @@ class RecheckOrderService extends OrderBaseService {
|
|||||||
const normalizedWaveId = Number(waveId || 0);
|
const normalizedWaveId = Number(waveId || 0);
|
||||||
const orders = Array.isArray(baseWaveView.orders) ? baseWaveView.orders : [];
|
const orders = Array.isArray(baseWaveView.orders) ? baseWaveView.orders : [];
|
||||||
|
|
||||||
// 分离拦截订单:拦截订单保留在 list 中由前端按单提示拦截(intercept_status),
|
// 校验波次内所有订单是否都已拣货,未拣货订单不允许复核
|
||||||
// 仅对非拦截订单做复核校验与统计,与团购模式一致,
|
for (const order of orders) {
|
||||||
// 波次内存在拦截订单时不再阻断整个散单扫描视图加载
|
|
||||||
const normalOrders = orders.filter(
|
|
||||||
order => !this.isInterceptedOrderStatus(order.intercept_status)
|
|
||||||
);
|
|
||||||
|
|
||||||
// 校验波次内非拦截订单是否都已拣货,未拣货订单不允许复核
|
|
||||||
for (const order of normalOrders) {
|
|
||||||
this.assertOrderCanRecheck(order);
|
this.assertOrderCanRecheck(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,13 +506,13 @@ class RecheckOrderService extends OrderBaseService {
|
|||||||
this.getWaveStrategyInfo(normalizedWaveId, warehouseId),
|
this.getWaveStrategyInfo(normalizedWaveId, warehouseId),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 计算复核汇总(仅统计非拦截订单)
|
// 计算复核汇总
|
||||||
const reviewedCount = normalOrders.filter(o => o.recheck_status === 'fin').length;
|
const reviewedCount = orders.filter(o => o.recheck_status === 'fin').length;
|
||||||
const unreviewedCount = normalOrders.length - reviewedCount;
|
const unreviewedCount = orders.length - reviewedCount;
|
||||||
|
|
||||||
// 计算打印汇总(仅统计非拦截订单)
|
// 计算打印汇总
|
||||||
const printedCount = normalOrders.filter(o => o.is_printed === true).length;
|
const printedCount = orders.filter(o => o.is_printed === true).length;
|
||||||
const unprintedCount = normalOrders.length - printedCount;
|
const unprintedCount = orders.length - printedCount;
|
||||||
|
|
||||||
// 批量查询包材推荐
|
// 批量查询包材推荐
|
||||||
const packageMaterialMap = await this.batchQueryPackageMaterialRecommendation(orders, warehouseId);
|
const packageMaterialMap = await this.batchQueryPackageMaterialRecommendation(orders, warehouseId);
|
||||||
@ -2248,36 +2231,16 @@ class RecheckOrderService extends OrderBaseService {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查任务关联的全部波次(团购任务一车多波次,必须任务下所有波次订单全部复核完成才允许解绑)
|
// 检查波次下所有订单是否均已复核完成(团购模式以订单表 recheck_status 为准)
|
||||||
const taskAllWaveRows = await ctx.model.query(
|
const unreviewedInWave = await orderModel.count({
|
||||||
`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: {
|
where: {
|
||||||
wave_id: { [ctx.app.Sequelize.Op.in]: taskAllWaveIds },
|
wave_id: orderWaveId,
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
recheck_status: { [ctx.app.Sequelize.Op.ne]: 'fin' },
|
recheck_status: { [ctx.app.Sequelize.Op.ne]: 'fin' },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return unreviewedCount === 0 ? fallbackTaskId : 0;
|
return unreviewedInWave === 0 ? fallbackTaskId : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -6800,7 +6800,7 @@ class WaveService extends OrderBaseService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const orderRows = await orderModel.findAll({
|
const orderRows = await orderModel.findAll({
|
||||||
attributes: [ 'id', 'wave_id', 'wave_no', 'step', 'status', 'outbound_status', 'items_hash', 'items', 'logistics_name', 'intercept_status', 'lock_status' ],
|
attributes: [ 'id', 'wave_id', 'wave_no', 'step', 'status', 'outbound_status', 'items_hash', 'items', 'logistics_name', 'intercept_status' ],
|
||||||
where: {
|
where: {
|
||||||
id: { [Op.in]: normalizedIds },
|
id: { [Op.in]: normalizedIds },
|
||||||
},
|
},
|
||||||
@ -6824,11 +6824,6 @@ class WaveService extends OrderBaseService {
|
|||||||
.map(row => Number(row && row.id || 0))
|
.map(row => Number(row && row.id || 0))
|
||||||
.filter(id => Number.isInteger(id) && id > 0)) ]
|
.filter(id => Number.isInteger(id) && id > 0)) ]
|
||||||
.sort((a, b) => a - b);
|
.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 fetchableRows = normalizedOrderRows.filter(row => {
|
||||||
const orderId = Number(row && row.id || 0);
|
const orderId = Number(row && row.id || 0);
|
||||||
@ -6847,11 +6842,6 @@ class WaveService extends OrderBaseService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 已锁定的订单不允许抓取波次
|
|
||||||
if (this.isLockedOrderStatus(row && row.lock_status)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -6872,7 +6862,6 @@ class WaveService extends OrderBaseService {
|
|||||||
fetched_order_count: 0,
|
fetched_order_count: 0,
|
||||||
excluded_existing_wave_order_ids: excludedExistingWaveOrderIds,
|
excluded_existing_wave_order_ids: excludedExistingWaveOrderIds,
|
||||||
excluded_intercepted_order_ids: excludedInterceptedOrderIds,
|
excluded_intercepted_order_ids: excludedInterceptedOrderIds,
|
||||||
excluded_locked_order_ids: excludedLockedOrderIds,
|
|
||||||
skipped_order_ids: skippedOrderIds,
|
skipped_order_ids: skippedOrderIds,
|
||||||
not_found_order_ids: notFoundOrderIds,
|
not_found_order_ids: notFoundOrderIds,
|
||||||
});
|
});
|
||||||
@ -6987,7 +6976,6 @@ class WaveService extends OrderBaseService {
|
|||||||
fetched_order_count: grabbedOrderIds.length,
|
fetched_order_count: grabbedOrderIds.length,
|
||||||
excluded_existing_wave_order_ids: excludedExistingWaveOrderIds,
|
excluded_existing_wave_order_ids: excludedExistingWaveOrderIds,
|
||||||
excluded_intercepted_order_ids: excludedInterceptedOrderIds,
|
excluded_intercepted_order_ids: excludedInterceptedOrderIds,
|
||||||
excluded_locked_order_ids: excludedLockedOrderIds,
|
|
||||||
skipped_order_ids: skippedOrderIds,
|
skipped_order_ids: skippedOrderIds,
|
||||||
not_found_order_ids: notFoundOrderIds,
|
not_found_order_ids: notFoundOrderIds,
|
||||||
});
|
});
|
||||||
@ -8816,7 +8804,7 @@ class WaveService extends OrderBaseService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
orderRows = await orderModel.findAll({
|
orderRows = await orderModel.findAll({
|
||||||
attributes: [ 'id', 'business_key', 'intercept_status', 'lock_status' ],
|
attributes: [ 'id', 'business_key', 'intercept_status' ],
|
||||||
where: baseOrderWhere,
|
where: baseOrderWhere,
|
||||||
raw: true,
|
raw: true,
|
||||||
});
|
});
|
||||||
@ -8832,7 +8820,7 @@ class WaveService extends OrderBaseService {
|
|||||||
warehouseId,
|
warehouseId,
|
||||||
});
|
});
|
||||||
orderRows = await orderModel.findAll({
|
orderRows = await orderModel.findAll({
|
||||||
attributes: [ 'id', 'intercept_status', 'lock_status' ],
|
attributes: [ 'id', 'intercept_status' ],
|
||||||
where: baseOrderWhere,
|
where: baseOrderWhere,
|
||||||
raw: true,
|
raw: true,
|
||||||
});
|
});
|
||||||
@ -8862,27 +8850,10 @@ 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 : [])
|
const normalizedOrders = (Array.isArray(orderRows) ? orderRows : [])
|
||||||
.map(row => {
|
.map(row => {
|
||||||
const orderId = Number(row && row.id || 0);
|
const orderId = Number(row && row.id || 0);
|
||||||
if (!Number.isInteger(orderId) || orderId <= 0
|
if (!Number.isInteger(orderId) || orderId <= 0 || skippedInterceptedOrderIdSet.has(orderId)) {
|
||||||
|| skippedInterceptedOrderIdSet.has(orderId)
|
|
||||||
|| skippedLockedOrderIdSet.has(orderId)) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8901,7 +8872,6 @@ class WaveService extends OrderBaseService {
|
|||||||
warehouseId,
|
warehouseId,
|
||||||
waveIds,
|
waveIds,
|
||||||
skippedInterceptedOrderIds,
|
skippedInterceptedOrderIds,
|
||||||
skippedLockedOrderIds,
|
|
||||||
});
|
});
|
||||||
const durationMs = Date.now() - startTime;
|
const durationMs = Date.now() - startTime;
|
||||||
await this.setBatchAllocateExpressTaskProgress(normalizedTaskId, 'success', {
|
await this.setBatchAllocateExpressTaskProgress(normalizedTaskId, 'success', {
|
||||||
@ -8912,7 +8882,6 @@ class WaveService extends OrderBaseService {
|
|||||||
success_order_count: 0,
|
success_order_count: 0,
|
||||||
failed_order_count: 0,
|
failed_order_count: 0,
|
||||||
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
||||||
skipped_locked_order_ids: skippedLockedOrderIds,
|
|
||||||
progress_percent: 100,
|
progress_percent: 100,
|
||||||
end_time: Date.now(),
|
end_time: Date.now(),
|
||||||
duration_ms: durationMs,
|
duration_ms: durationMs,
|
||||||
@ -8920,10 +8889,9 @@ class WaveService extends OrderBaseService {
|
|||||||
wave_ids: waveIds,
|
wave_ids: waveIds,
|
||||||
allocated_order_count: 0,
|
allocated_order_count: 0,
|
||||||
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
||||||
skipped_locked_order_ids: skippedLockedOrderIds,
|
|
||||||
duration_ms: durationMs,
|
duration_ms: durationMs,
|
||||||
message: skippedInterceptedOrderIds.length > 0 || skippedLockedOrderIds.length > 0
|
message: skippedInterceptedOrderIds.length > 0
|
||||||
? `拦截/锁定订单已跳过,未找到可分配快递号的订单(拦截 ${skippedInterceptedOrderIds.length} 单,锁定 ${skippedLockedOrderIds.length} 单)`
|
? `拦截订单已跳过,未找到可分配快递号的订单(跳过 ${skippedInterceptedOrderIds.length} 单)`
|
||||||
: '未找到可分配快递号的订单',
|
: '未找到可分配快递号的订单',
|
||||||
},
|
},
|
||||||
trace_id: traceId,
|
trace_id: traceId,
|
||||||
@ -8967,7 +8935,6 @@ class WaveService extends OrderBaseService {
|
|||||||
success_order_count: normalizedOrders.length,
|
success_order_count: normalizedOrders.length,
|
||||||
failed_order_count: 0,
|
failed_order_count: 0,
|
||||||
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
||||||
skipped_locked_order_ids: skippedLockedOrderIds,
|
|
||||||
progress_percent: 100,
|
progress_percent: 100,
|
||||||
end_time: Date.now(),
|
end_time: Date.now(),
|
||||||
duration_ms: durationMs,
|
duration_ms: durationMs,
|
||||||
@ -8975,7 +8942,6 @@ class WaveService extends OrderBaseService {
|
|||||||
wave_ids: waveIds,
|
wave_ids: waveIds,
|
||||||
allocated_order_count: normalizedOrders.length,
|
allocated_order_count: normalizedOrders.length,
|
||||||
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
||||||
skipped_locked_order_ids: skippedLockedOrderIds,
|
|
||||||
duration_ms: durationMs,
|
duration_ms: durationMs,
|
||||||
message: String(pipelineResult && pipelineResult.message || '分配快递任务已提交').trim(),
|
message: String(pipelineResult && pipelineResult.message || '分配快递任务已提交').trim(),
|
||||||
},
|
},
|
||||||
@ -9088,7 +9054,7 @@ class WaveService extends OrderBaseService {
|
|||||||
try {
|
try {
|
||||||
const orderModel = await this.getOrderModel('pendingOrder', warehouseId);
|
const orderModel = await this.getOrderModel('pendingOrder', warehouseId);
|
||||||
const orderRows = await orderModel.findAll({
|
const orderRows = await orderModel.findAll({
|
||||||
attributes: [ 'id', 'lock_status' ],
|
attributes: [ 'id' ],
|
||||||
where: {
|
where: {
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
wave_id: {
|
wave_id: {
|
||||||
@ -9101,14 +9067,9 @@ class WaveService extends OrderBaseService {
|
|||||||
raw: true,
|
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 : [])
|
const normalizedOrders = [ ...new Set((Array.isArray(orderRows) ? orderRows : [])
|
||||||
.map(row => Number(row && row.id || 0))
|
.map(row => Number(row && row.id || 0))
|
||||||
.filter(orderId => Number.isInteger(orderId) && orderId > 0)) ]
|
.filter(orderId => Number.isInteger(orderId) && orderId > 0)) ]
|
||||||
.filter(orderId => !skippedLockedOrderIdSet.has(orderId))
|
|
||||||
.map(orderId => ({
|
.map(orderId => ({
|
||||||
order_id: orderId,
|
order_id: orderId,
|
||||||
business_id: BATCH_ALLOCATE_STORAGE_FORCE_BUSINESS_ID,
|
business_id: BATCH_ALLOCATE_STORAGE_FORCE_BUSINESS_ID,
|
||||||
|
|||||||
@ -1787,14 +1787,6 @@ class PrintService extends MainService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载并校验 express 请求涉及平台的打印组件配置。
|
* 加载并校验 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 {Object} payload 查询参数。
|
||||||
* @param {Array<string>} payload.platformCodes 平台编码列表。
|
* @param {Array<string>} payload.platformCodes 平台编码列表。
|
||||||
* @return {Promise<{success:boolean,data?:Object,error?:string}>} 查询与校验结果。
|
* @return {Promise<{success:boolean,data?:Object,error?:string}>} 查询与校验结果。
|
||||||
@ -1811,81 +1803,22 @@ class PrintService extends MainService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const printPlatformModel = this.ctx && this.ctx.model && this.ctx.model.PrintPlatform;
|
const platformRows = await this.ctx.model.PrintPlatform.findAll({
|
||||||
const platformModel = this.ctx && this.ctx.model && this.ctx.model.Platform;
|
attributes: [ 'platform_code', 'platform_name' ],
|
||||||
const platformComponentMap = {};
|
where: {
|
||||||
|
platform_code: platformCodes,
|
||||||
// 1) 优先按打印平台编码直接匹配
|
},
|
||||||
if (printPlatformModel && typeof printPlatformModel.findAll === 'function') {
|
raw: true,
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2) 未匹配编码按系统平台编码回退解析(TB/TM/1688 等经 print_platform_id 关联)
|
|
||||||
const unresolvedCodes = platformCodes.filter(platformCode => {
|
|
||||||
return !String(platformComponentMap[platformCode] || '').trim();
|
|
||||||
});
|
});
|
||||||
if (unresolvedCodes.length > 0
|
const platformComponentMap = {};
|
||||||
&& printPlatformModel && typeof printPlatformModel.findAll === 'function'
|
for (const row of platformRows) {
|
||||||
&& platformModel && typeof platformModel.findAll === 'function') {
|
const platformCode = String(row && row.platform_code ? row.platform_code : '').trim();
|
||||||
const systemPlatformRows = await platformModel.findAll({
|
if (!platformCode) {
|
||||||
attributes: [ 'code', 'print_platform_id' ],
|
continue;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
platformComponentMap[platformCode] = String(row && row.platform_name ? row.platform_name : '').trim();
|
||||||
}
|
}
|
||||||
|
console.log('platformComponentMap', platformComponentMap);
|
||||||
for (const platformCode of platformCodes) {
|
for (const platformCode of platformCodes) {
|
||||||
const component = String(platformComponentMap[platformCode] || '').trim();
|
const component = String(platformComponentMap[platformCode] || '').trim();
|
||||||
if (!component) {
|
if (!component) {
|
||||||
@ -1896,10 +1829,6 @@ class PrintService extends MainService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ctx.logger.info('[print.send] express 平台打印组件解析完成', {
|
|
||||||
platformComponents: platformComponentMap,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: platformComponentMap,
|
data: platformComponentMap,
|
||||||
@ -2873,65 +2802,34 @@ class PrintService extends MainService {
|
|||||||
taskId = Number(taskWave.task_id);
|
taskId = Number(taskWave.task_id);
|
||||||
if (!taskId) return;
|
if (!taskId) 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);
|
|
||||||
|
|
||||||
let totalOrderCount = 0;
|
|
||||||
let unprintedCount = 0;
|
|
||||||
|
|
||||||
if (waveType === 1) {
|
if (waveType === 1) {
|
||||||
// 团购波次:仅团购拣货模式(pick_mode=1 小团购 / pick_mode=5 大团购)参与解绑判断
|
|
||||||
const taskRows = await ctx.model.query(
|
const taskRows = await ctx.model.query(
|
||||||
'SELECT pick_mode FROM wms_wave_pick_task WHERE id = :taskId LIMIT 1',
|
'SELECT pick_mode FROM wms_wave_pick_task WHERE id = :taskId LIMIT 1',
|
||||||
{ replacements: { taskId }, type: ctx.model.QueryTypes.SELECT }
|
{ replacements: { taskId }, type: ctx.model.QueryTypes.SELECT }
|
||||||
);
|
);
|
||||||
const task = Array.isArray(taskRows) && taskRows.length > 0 ? taskRows[0] : null;
|
const task = Array.isArray(taskRows) && taskRows.length > 0 ? taskRows[0] : null;
|
||||||
const pickMode = task ? Number(task.pick_mode) : 0;
|
const pickMode = task ? Number(task.pick_mode) : 0;
|
||||||
if (![ 1, 5 ].includes(pickMode)) return;
|
if (pickMode !== 1) 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 团购 / 散单统一按订单维度检查:所有订单均已打印时才解绑
|
||||||
|
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' },
|
||||||
|
});
|
||||||
if (unprintedCount > 0) {
|
if (unprintedCount > 0) {
|
||||||
this.ctx.logger.info('[print.unbindCart] 尚有未打印订单,跳过解绑', { waveId, warehouseId, taskId, waveType, waveTypeLabel: waveType === 1 ? '团购' : '散单', totalOrders: totalOrderCount, unprintedCount });
|
this.ctx.logger.info('[print.unbindCart] 尚有未打印订单,跳过解绑', { waveId, warehouseId, taskId, waveType, waveTypeLabel: waveType === 1 ? '团购' : '散单', totalOrders: orderIds.length, unprintedCount });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const Service = require('egg').Service;
|
const Service = require('egg').Service;
|
||||||
const { normalizeWarehouseShardId } = require('../../lib/warehouse_shard_guard');
|
const { normalizeWarehouseShardId } = require('../../lib/warehouse_shard_guard');
|
||||||
const { isLockedOrderStatus } = require('../../lib/lock_guard');
|
|
||||||
|
|
||||||
const DELIVERY_ORDER_STEP = Object.freeze({
|
const DELIVERY_ORDER_STEP = Object.freeze({
|
||||||
PENDING_REVIEW: 0,
|
PENDING_REVIEW: 0,
|
||||||
@ -2002,7 +2001,7 @@ class DeliveryOrderService extends Service {
|
|||||||
id: orderId,
|
id: orderId,
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
},
|
},
|
||||||
attributes: [ 'id', 'wave_id', 'step', 'status', 'outbound_status', 'lock_status' ],
|
attributes: [ 'id', 'wave_id', 'step', 'status', 'outbound_status' ],
|
||||||
transaction,
|
transaction,
|
||||||
lock: transaction.LOCK.UPDATE,
|
lock: transaction.LOCK.UPDATE,
|
||||||
});
|
});
|
||||||
@ -2011,12 +2010,6 @@ class DeliveryOrderService extends Service {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 已锁定的订单不允许自动加团
|
|
||||||
if (isLockedOrderStatus(orderRow.lock_status)) {
|
|
||||||
await transaction.commit();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentWaveId = Number(orderRow.wave_id || 0);
|
const currentWaveId = Number(orderRow.wave_id || 0);
|
||||||
if (currentWaveId === normalizedWaveId) {
|
if (currentWaveId === normalizedWaveId) {
|
||||||
await transaction.commit();
|
await transaction.commit();
|
||||||
@ -2064,7 +2057,6 @@ class DeliveryOrderService extends Service {
|
|||||||
id: orderId,
|
id: orderId,
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
wave_id: 0,
|
wave_id: 0,
|
||||||
lock_status: 'none',
|
|
||||||
},
|
},
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
@ -2147,7 +2139,6 @@ class DeliveryOrderService extends Service {
|
|||||||
step: { [ctx.app.Sequelize.Op.in]: [ 1, 2, 3 ] },
|
step: { [ctx.app.Sequelize.Op.in]: [ 1, 2, 3 ] },
|
||||||
status: { [ctx.app.Sequelize.Op.ne]: 'cancel' },
|
status: { [ctx.app.Sequelize.Op.ne]: 'cancel' },
|
||||||
outbound_status: { [ctx.app.Sequelize.Op.ne]: 'padding' },
|
outbound_status: { [ctx.app.Sequelize.Op.ne]: 'padding' },
|
||||||
lock_status: 'none',
|
|
||||||
sys_logistics_code: structure.logisticsName,
|
sys_logistics_code: structure.logisticsName,
|
||||||
};
|
};
|
||||||
where[structure.itemPartType] = structure.itemPart;
|
where[structure.itemPartType] = structure.itemPart;
|
||||||
@ -2401,16 +2392,6 @@ class DeliveryOrderService extends Service {
|
|||||||
return;
|
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);
|
const policyConfig = await this.getStoreWarehousePolicyConfig(context.storeId, context.warehouseId);
|
||||||
|
|
||||||
// 截单时间兜底:货主-仓库级未启用时,fallback 到仓库级配置
|
// 截单时间兜底:货主-仓库级未启用时,fallback 到仓库级配置
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
const { Service } = require('egg');
|
const { Service } = require('egg');
|
||||||
|
|
||||||
const { isInterceptedOrderStatus } = require('../../lib/intercept_guard');
|
const { isInterceptedOrderStatus } = require('../../lib/intercept_guard');
|
||||||
const { isLockedOrderStatus } = require('../../lib/lock_guard');
|
|
||||||
|
|
||||||
const DEFAULT_CACHE_TTL_SECONDS = 600;
|
const DEFAULT_CACHE_TTL_SECONDS = 600;
|
||||||
const DEFAULT_EXPRESS_PRODUCT_TYPE_CACHE_TTL_SECONDS = 60 * 60;
|
const DEFAULT_EXPRESS_PRODUCT_TYPE_CACHE_TTL_SECONDS = 60 * 60;
|
||||||
@ -2517,7 +2516,7 @@ class ExpressService extends Service {
|
|||||||
[Op.ne]: 'cancel',
|
[Op.ne]: 'cancel',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
attributes: [ 'id', 'sys_platform_code', 'logistics_code', 'sys_platform_name', 'logistics_name', 'store_id', 'pay_no', 'from_key', 'intercept_status', 'lock_status' ],
|
attributes: [ 'id', 'sys_platform_code', 'logistics_code', 'sys_platform_name', 'logistics_name', 'store_id', 'pay_no', 'from_key', 'intercept_status' ],
|
||||||
raw: true,
|
raw: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2541,7 +2540,7 @@ class ExpressService extends Service {
|
|||||||
[Op.ne]: 'cancel',
|
[Op.ne]: 'cancel',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
attributes: [ 'id', 'sys_platform_code', 'logistics_code', 'sys_platform_name', 'logistics_name', 'store_id', 'pay_no', 'from_key', 'intercept_status', 'lock_status' ],
|
attributes: [ 'id', 'sys_platform_code', 'logistics_code', 'sys_platform_name', 'logistics_name', 'store_id', 'pay_no', 'from_key', 'intercept_status' ],
|
||||||
raw: true,
|
raw: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2562,37 +2561,21 @@ class ExpressService extends Service {
|
|||||||
skippedInterceptedOrderIds,
|
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] 订单筛选结果', {
|
this.ctx.logger.info('[ExpressService.createWaybillCodePipeline] 订单筛选结果', {
|
||||||
traceId,
|
traceId,
|
||||||
warehouseId,
|
warehouseId,
|
||||||
inputOrderCount: orderList.length,
|
inputOrderCount: orderList.length,
|
||||||
currentCount: (Array.isArray(currentOrders) ? currentOrders : []).length,
|
currentCount: (Array.isArray(currentOrders) ? currentOrders : []).length,
|
||||||
dispatchCount: dispatchOrders.length,
|
dispatchCount: dispatchOrders.length,
|
||||||
matchedOrderCount: activeOrders.length,
|
matchedOrderCount: orders_arr.length,
|
||||||
skippedInterceptedOrderIds,
|
skippedInterceptedOrderIds,
|
||||||
skippedLockedOrderIds,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 【step1.5】过滤已分配运单号(status=1)且传入 business_key=1 的订单,避免重复分配。
|
// 【step1.5】过滤已分配运单号(status=1)且传入 business_key=1 的订单,避免重复分配。
|
||||||
const orderExpressModel = this.ctx.model && this.ctx.model.OrderExpress;
|
const orderExpressModel = this.ctx.model && this.ctx.model.OrderExpress;
|
||||||
let filteredOrdersArr = activeOrders;
|
let filteredOrdersArr = orders_arr;
|
||||||
if (orderExpressModel && activeOrders.length > 0) {
|
if (orderExpressModel && orders_arr.length > 0) {
|
||||||
const orderIds = activeOrders.map(o => Number(o.id)).filter(id => id > 0);
|
const orderIds = orders_arr.map(o => Number(o.id)).filter(id => id > 0);
|
||||||
const completedRows = await orderExpressModel.findAll({
|
const completedRows = await orderExpressModel.findAll({
|
||||||
where: {
|
where: {
|
||||||
order_id: { [Op.in]: orderIds },
|
order_id: { [Op.in]: orderIds },
|
||||||
@ -2607,8 +2590,8 @@ class ExpressService extends Service {
|
|||||||
skipSet.add(`${Number(row.order_id)}:${Number(row.business_key)}`);
|
skipSet.add(`${Number(row.order_id)}:${Number(row.business_key)}`);
|
||||||
}
|
}
|
||||||
if (skipSet.size > 0) {
|
if (skipSet.size > 0) {
|
||||||
const beforeCount = activeOrders.length;
|
const beforeCount = orders_arr.length;
|
||||||
filteredOrdersArr = activeOrders.filter(order => {
|
filteredOrdersArr = orders_arr.filter(order => {
|
||||||
const matchedExpress = orderList.find(express => Number(order.id) === Number(express.order_id));
|
const matchedExpress = orderList.find(express => Number(order.id) === Number(express.order_id));
|
||||||
const businessKey = matchedExpress ? Number(matchedExpress.business_key) : 1;
|
const businessKey = matchedExpress ? Number(matchedExpress.business_key) : 1;
|
||||||
if (businessKey === 1 && skipSet.has(`${Number(order.id)}:1`)) {
|
if (businessKey === 1 && skipSet.has(`${Number(order.id)}:1`)) {
|
||||||
@ -2620,7 +2603,7 @@ class ExpressService extends Service {
|
|||||||
this.ctx.logger.info('[ExpressService.createWaybillCodePipeline] 跳过已分配运单号(business_key=1)的订单', {
|
this.ctx.logger.info('[ExpressService.createWaybillCodePipeline] 跳过已分配运单号(business_key=1)的订单', {
|
||||||
traceId,
|
traceId,
|
||||||
skippedCount: beforeCount - filteredOrdersArr.length,
|
skippedCount: beforeCount - filteredOrdersArr.length,
|
||||||
skippedOrderIds: activeOrders
|
skippedOrderIds: orders_arr
|
||||||
.filter(order => {
|
.filter(order => {
|
||||||
const matchedExpress = orderList.find(express => Number(order.id) === Number(express.order_id));
|
const matchedExpress = orderList.find(express => Number(order.id) === Number(express.order_id));
|
||||||
const businessKey = matchedExpress ? Number(matchedExpress.business_key) : 1;
|
const businessKey = matchedExpress ? Number(matchedExpress.business_key) : 1;
|
||||||
@ -2637,7 +2620,6 @@ class ExpressService extends Service {
|
|||||||
return {
|
return {
|
||||||
message: '所有订单均已分配运单号,无需处理',
|
message: '所有订单均已分配运单号,无需处理',
|
||||||
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
||||||
skipped_locked_order_ids: skippedLockedOrderIds,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2743,7 +2725,6 @@ class ExpressService extends Service {
|
|||||||
return {
|
return {
|
||||||
message: '分配快递任务已提交',
|
message: '分配快递任务已提交',
|
||||||
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
skipped_intercepted_order_ids: skippedInterceptedOrderIds,
|
||||||
skipped_locked_order_ids: skippedLockedOrderIds,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -707,44 +707,45 @@ class ExpressPlatformService extends MainService {
|
|||||||
object_Id: `${order.warehouse_id.toString(16)}_${order.id}_${order_tmp.business_key}`, // 菠萝派平台要求订单唯一标识必须为字符串
|
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}`, // 菠萝派平台要求订单号必须为字符串
|
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 || '',
|
plattradeno: listByWarehousePlatformCode.platform_code === 'DY' && order.from_key === 23060081 && !!order.pay_no ? order.pay_no : order.source_order_codes || order.delivery_order_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,
|
||||||
//ismultiplepieces: order.package_count > 1 ? 1 : 0,
|
logisticno: allocatedWaybillMap.get(`${Number(order.id) || 0}:${Number(order_tmp.business_key) || 0}`) || '',
|
||||||
//logisticno: allocatedWaybillMap.get(`${Number(order.id) || 0}:${Number(order_tmp.business_key) || 0}`) || '',
|
logistictype: order.logistics_code || '',
|
||||||
logistictype: expressListItem[listByWarehousePlatformCode.platform_code] || '',
|
|
||||||
providercode: expressListItem[listByWarehousePlatformCode.platform_code] || order.logistics_code || '',
|
providercode: expressListItem[listByWarehousePlatformCode.platform_code] || order.logistics_code || '',
|
||||||
numpackage: order.package_count || '1',
|
numpackage: order.package_count || 1,
|
||||||
businesstype: listByWarehousePlatformCode.product_type,
|
businessType: listByWarehousePlatformCode.product_type,
|
||||||
transtype:'0',
|
|
||||||
transtypecode:'1',
|
|
||||||
mainsubpaymode:'1',
|
|
||||||
businessplat: order.sys_platform_code === 'KS' ? order.sys_platform_code : 'OTHERS',
|
businessplat: order.sys_platform_code === 'KS' ? order.sys_platform_code : 'OTHERS',
|
||||||
paymode: listByWarehousePlatformCode.paymode.toString() ?? '1',
|
paymode: listByWarehousePlatformCode.paymode ?? 1,
|
||||||
ordertype: listByWarehousePlatformCode.ordertype ?? 'JH_Normal',
|
ordertype: listByWarehousePlatformCode.ordertype ?? 'JH_Normal',
|
||||||
ProviderID:'',
|
ProviderID: listByWarehousePlatformCode.providerid ?? '',
|
||||||
//procode: order.procode || '普通商品',
|
procode: order.procode || '普通商品',
|
||||||
//codpaymoney: order.ar_amount ?? null,
|
codpaymoney: order.ar_amount ?? null,
|
||||||
//packagemoney: order.item_amount ?? null,
|
packagemoney: order.item_amount ?? null,
|
||||||
//weight: Number(order.items_weight) || 0, // 单位 g,需确认 PolyAPI 期望单位
|
weight: Number(order.items_weight) || 0, // 单位 g,需确认 PolyAPI 期望单位
|
||||||
//supporpaymoney: order.total_amount ?? null,
|
supporpaymoney: order.total_amount ?? null,
|
||||||
//ispickup: listByWarehousePlatformCode.ispickup ?? 0,
|
length: Number(order.length) || 0,
|
||||||
//ProductType: listByWarehousePlatformCode.product_type || '',
|
width: Number(order.width) || 0,
|
||||||
//Sipshopid: listByWarehousePlatformCode.platform_shop_id || '',
|
height: Number(order.height) || 0,
|
||||||
|
volume: Number(order.volume) || 0,
|
||||||
|
ispickup: listByWarehousePlatformCode.ispickup ?? 0,
|
||||||
|
ProductType: listByWarehousePlatformCode.product_type || '',
|
||||||
|
Sipshopid: listByWarehousePlatformCode.platform_shop_id || '',
|
||||||
oaid: order.oaid || '',
|
oaid: order.oaid || '',
|
||||||
|
sys_express_code: listByWarehousePlatformCode.sys_express_code || '',
|
||||||
|
platform_code: listByWarehousePlatformCode.platform_code || '',
|
||||||
cpcode: expressListItem[listByWarehousePlatformCode.platform_code] || '',
|
cpcode: expressListItem[listByWarehousePlatformCode.platform_code] || '',
|
||||||
logisticsproductname: 'JH_02',
|
logisticsproductname: 'JH_02',
|
||||||
//dmssorting: 0,
|
dmssorting: 0,
|
||||||
//brandno: listByWarehousePlatformCode.brandno || null,
|
brandno: listByWarehousePlatformCode.brandno || null,
|
||||||
needencrypt: 1,
|
needencrypt: 1,
|
||||||
customername:"测试",
|
|
||||||
ordersource: matchedPlatform.ordersource || '',
|
ordersource: matchedPlatform.ordersource || '',
|
||||||
//inputsite: order.sys_platform_code === 'XHS' ? '' :listByWarehousePlatformCode.site_code || '',
|
inputsite: listByWarehousePlatformCode.site_code || '',
|
||||||
sitecode: listByWarehousePlatformCode.site_code || '',
|
sitecode: listByWarehousePlatformCode.site_code || '',
|
||||||
shipperno: order.sys_platform_code === 'XHS' ? '' :listByWarehousePlatformCode.shipperno || '',
|
shipperno: listByWarehousePlatformCode.shipperno || '',
|
||||||
customercode: order.sys_platform_code === 'XHS' ? '' :listByWarehousePlatformCode.shipperno || listByWarehousePlatformCode.client_id || '',
|
customercode: listByWarehousePlatformCode.shipperno || listByWarehousePlatformCode.client_id || '',
|
||||||
sender: {
|
sender: {
|
||||||
Company: listByWarehousePlatformCode.shop_name || '',
|
company: listByWarehousePlatformCode.shop_name || '',
|
||||||
name: listByWarehousePlatformCode.sender_name || '',
|
name: listByWarehousePlatformCode.sender_name || '',
|
||||||
phone: order.sys_platform_code === 'XHS' ? undefined :listByWarehousePlatformCode.sender_tel || '',
|
phone: listByWarehousePlatformCode.sender_tel || '',
|
||||||
mobile: order.sys_platform_code === 'XHS' ? listByWarehousePlatformCode.sender_tel : undefined,
|
mobile: order.sys_platform_code === 'XHS' ? listByWarehousePlatformCode.sender_tel : undefined,
|
||||||
country: 'CN',
|
country: 'CN',
|
||||||
city: listByWarehousePlatformCode.city_name || '',
|
city: listByWarehousePlatformCode.city_name || '',
|
||||||
@ -770,21 +771,21 @@ class ExpressPlatformService extends MainService {
|
|||||||
},
|
},
|
||||||
goods: (order.orderItems && order.orderItems.map(item => ({
|
goods: (order.orderItems && order.orderItems.map(item => ({
|
||||||
productid: item.item_code,
|
productid: item.item_code,
|
||||||
cnname: 'sp',
|
cnname: item.item_name || '商品',
|
||||||
count: item.plan_qty || 0,
|
count: item.plan_qty || 0,
|
||||||
}))) || [],
|
}))) || [],
|
||||||
//Mallmaskid: '',
|
Mallmaskid: '',
|
||||||
|
|
||||||
template_url: listByWarehousePlatformCode.template_id || '',
|
template_url: listByWarehousePlatformCode.template_id || '',
|
||||||
//labelformat: listByWarehousePlatformCode.labelformat || '',
|
labelformat: listByWarehousePlatformCode.labelformat || '',
|
||||||
//extraInfo: ExpressList.find(item => item.code === listByWarehousePlatformCode.sys_express_code)?.polyapi_extra_info || '',
|
extraInfo: ExpressList.find(item => item.code === listByWarehousePlatformCode.sys_express_code)?.polyapi_extra_info || '',
|
||||||
};
|
};
|
||||||
console.log('matchedPlatform.platid', matchedPlatform.platid);
|
console.log('matchedPlatform.platid', matchedPlatform.platid);
|
||||||
console.log('startPlayload', playload);
|
console.log('startPlayload', playload);
|
||||||
|
|
||||||
if (Number(matchedPlatform.platid) === 673) {
|
if (Number(matchedPlatform.platid) === 673) {
|
||||||
playload.BizVersion = '2';
|
playload.BizVersion = '2';
|
||||||
playload.brandno = listByWarehousePlatformCode.brandno === "SF" ? listByWarehousePlatformCode.brandno : undefined;
|
playload.brandno = listByWarehousePlatformCode.brandno || '';
|
||||||
}
|
}
|
||||||
if (Number(matchedPlatform.platid) === 544) {
|
if (Number(matchedPlatform.platid) === 544) {
|
||||||
const {
|
const {
|
||||||
@ -897,7 +898,7 @@ class ExpressPlatformService extends MainService {
|
|||||||
playload.mainsubpaymode = '1';
|
playload.mainsubpaymode = '1';
|
||||||
delete playload.plattradeno;
|
delete playload.plattradeno;
|
||||||
}
|
}
|
||||||
playload.ProviderID = listByWarehousePlatformCode.providerid || "";
|
playload.ProviderID = listByWarehousePlatformCode.providerid;
|
||||||
console.log('playload', playload);
|
console.log('playload', playload);
|
||||||
return playload;
|
return playload;
|
||||||
}),
|
}),
|
||||||
@ -1104,7 +1105,7 @@ class ExpressPlatformService extends MainService {
|
|||||||
receivertel: '',
|
receivertel: '',
|
||||||
cargoname: '',
|
cargoname: '',
|
||||||
senddata: '',
|
senddata: '',
|
||||||
//weight: '',
|
weight: '',
|
||||||
eCustomerCode: '',
|
eCustomerCode: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
selleruserid: '',
|
selleruserid: '',
|
||||||
@ -1760,8 +1761,6 @@ class ExpressPlatformService extends MainService {
|
|||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
: [];
|
: [];
|
||||||
const recipientMobile = orderDelivery && (orderDelivery.mobile || orderDelivery.tel) || '';
|
const recipientMobile = orderDelivery && (orderDelivery.mobile || orderDelivery.tel) || '';
|
||||||
const orderDeliveryOaid = orderDelivery && orderDelivery.oaid ? String(orderDelivery.oaid).trim() : '';
|
|
||||||
const oaidTooLong = orderDeliveryOaid.length > 128;
|
|
||||||
|
|
||||||
const tradeOrderInfo = {
|
const tradeOrderInfo = {
|
||||||
logistics_services: normalizedExtData,
|
logistics_services: normalizedExtData,
|
||||||
@ -1798,10 +1797,10 @@ class ExpressPlatformService extends MainService {
|
|||||||
mobile: recipientMobile,
|
mobile: recipientMobile,
|
||||||
name: orderDelivery && orderDelivery.name || '',
|
name: orderDelivery && orderDelivery.name || '',
|
||||||
phone: recipientMobile,
|
phone: recipientMobile,
|
||||||
oaid: oaidTooLong ? '' : orderDeliveryOaid,
|
oaid: orderDelivery && orderDelivery.oaid || '',
|
||||||
caid: oaidTooLong ? orderDeliveryOaid : '',
|
tid: sourceOrderCodes[0] || '',
|
||||||
tid: orderDelivery.pay_no || '',
|
|
||||||
},
|
},
|
||||||
|
oaid: orderDelivery && orderDelivery.oaid || '',
|
||||||
user_id: listByWarehousePlatformCode.shop && listByWarehousePlatformCode.shop.owner_id || 0,
|
user_id: listByWarehousePlatformCode.shop && listByWarehousePlatformCode.shop.owner_id || 0,
|
||||||
notify_extend_info: normalizedExtData,
|
notify_extend_info: normalizedExtData,
|
||||||
};
|
};
|
||||||
@ -1843,8 +1842,7 @@ class ExpressPlatformService extends MainService {
|
|||||||
shipping_branch_code: String(listByWarehousePlatformCode.site_code || '').trim(),
|
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 = {
|
const requestParams = {
|
||||||
method: 'cainiao.waybill.ii.get',
|
method: 'cainiao.waybill.ii.get',
|
||||||
app_key: appKey,
|
app_key: appKey,
|
||||||
@ -1867,7 +1865,7 @@ class ExpressPlatformService extends MainService {
|
|||||||
sign,
|
sign,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await this.app.setCacheAsync('Cainiaoresult', JSON.stringify(response), 3600);
|
console.log('菜鸟取号返回数据', JSON.stringify(response));
|
||||||
|
|
||||||
const responseData = response && Object.prototype.hasOwnProperty.call(response, 'data')
|
const responseData = response && Object.prototype.hasOwnProperty.call(response, 'data')
|
||||||
? response.data
|
? response.data
|
||||||
|
|||||||
@ -638,9 +638,17 @@ class InboundDirectLogService extends Service {
|
|||||||
return { code: 400, message: '入库单已绑定收货单且状态为 CREATED,请先审核后再进行上架操作', data: null };
|
return { code: 400, message: '入库单已绑定收货单且状态为 CREATED,请先审核后再进行上架操作', data: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
// PENDING 状态:允许导入。items 可传 receiving_detail_id 走绑定模式(预占收货明细),
|
// PENDING 状态校验
|
||||||
// 也可不传走非绑定模式(数量受计划数量限制),不再强制绑定收货单、不再强制传收货单 ID;
|
if (entryOrder.order_status === 'PENDING') {
|
||||||
// 绑定模式下的 space_id/明细可用数量等校验由 _addSingleItem 统一处理。
|
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 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 批量模式下用事务包裹,任一失败整批回退
|
// 批量模式下用事务包裹,任一失败整批回退
|
||||||
const useTransaction = isBatch;
|
const useTransaction = isBatch;
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
const MainService = require('../main');
|
const MainService = require('../main');
|
||||||
|
|
||||||
const { isInterceptedOrderStatus } = require('../../lib/intercept_guard');
|
const { isInterceptedOrderStatus } = require('../../lib/intercept_guard');
|
||||||
const { isLockedOrderStatus } = require('../../lib/lock_guard');
|
|
||||||
|
|
||||||
const STORAGE_STATUS_FIN = 'fin';
|
const STORAGE_STATUS_FIN = 'fin';
|
||||||
const STORAGE_STATUS_ERROR = 'error';
|
const STORAGE_STATUS_ERROR = 'error';
|
||||||
@ -646,21 +645,6 @@ class OrderStorageAllocationService extends MainService {
|
|||||||
continue;
|
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) {
|
if (String(orderRow.storage_status || 'none') === STORAGE_STATUS_FIN) {
|
||||||
skippedOrders.push({
|
skippedOrders.push({
|
||||||
order_id: orderId,
|
order_id: orderId,
|
||||||
|
|||||||
@ -1494,8 +1494,7 @@ class ReceivingService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送收货单创建/首次绑定货主通知(receiving_store_bound),提醒货主确认/补填车牌号或快递单号。
|
* 发送收货单创建/首次绑定货主通知(receiving_store_bound),提醒货主填写车牌号/快递单号。
|
||||||
* 已填写车牌号或快递单号时,文案展示已登记信息;均未填写时才提示及时补充。
|
|
||||||
* 路由由 notice 固定订阅回退链处理:货主收货群 → 无则货主售后群 → 均无则仓库异常群。
|
* 路由由 notice 固定订阅回退链处理:货主收货群 → 无则货主售后群 → 均无则仓库异常群。
|
||||||
* @param {Object} options 发送参数
|
* @param {Object} options 发送参数
|
||||||
* @param {Object} options.receiving 收货单快照
|
* @param {Object} options.receiving 收货单快照
|
||||||
@ -1523,23 +1522,10 @@ class ReceivingService extends Service {
|
|||||||
const storeLabel = String(storeName || receiving.store_name || '').trim() || '货主';
|
const storeLabel = String(storeName || receiving.store_name || '').trim() || '货主';
|
||||||
const storeFrontendUrl = String(ctx.app.config.storeFrontendUrl || ctx.app.config.frontendUrl || '').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 = [
|
const contentLines = [
|
||||||
`收货单号:${receivingNumber} 正在收货`,
|
`收货单号:${receivingNumber} 正在收货`,
|
||||||
`货主:${storeLabel}`,
|
`货主:${storeLabel}`,
|
||||||
...vehicleInfoLines,
|
'请确认是否已填写车牌号或快递单号,未填写请及时补充',
|
||||||
];
|
];
|
||||||
const content = [ ...contentLines ].join('\n') + '。';
|
const content = [ ...contentLines ].join('\n') + '。';
|
||||||
const storeContent = [ ...contentLines, `快速查看:${storeFrontendUrl}/storage/receiving_owner?id=${receivingNumber}` ].join('\n') + '。';
|
const storeContent = [ ...contentLines, `快速查看:${storeFrontendUrl}/storage/receiving_owner?id=${receivingNumber}` ].join('\n') + '。';
|
||||||
@ -2075,8 +2061,6 @@ class ReceivingService extends Service {
|
|||||||
warehouse_id: result.warehouse_id,
|
warehouse_id: result.warehouse_id,
|
||||||
store_id: result.store_id,
|
store_id: result.store_id,
|
||||||
store_name: result.store_name,
|
store_name: result.store_name,
|
||||||
license_plate: result.license_plate,
|
|
||||||
tracking_number: result.tracking_number,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (noticeErr) {
|
} catch (noticeErr) {
|
||||||
@ -2438,8 +2422,6 @@ class ReceivingService extends Service {
|
|||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
store_id: storeId,
|
store_id: storeId,
|
||||||
store_name: storeName,
|
store_name: storeName,
|
||||||
license_plate: receiving.license_plate,
|
|
||||||
tracking_number: receiving.tracking_number,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (noticeErr) {
|
} catch (noticeErr) {
|
||||||
@ -3301,8 +3283,6 @@ class ReceivingService extends Service {
|
|||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
store_id: storeId,
|
store_id: storeId,
|
||||||
store_name: storeName,
|
store_name: storeName,
|
||||||
license_plate: receiving.license_plate,
|
|
||||||
tracking_number: receiving.tracking_number,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (noticeErr) {
|
} catch (noticeErr) {
|
||||||
|
|||||||
@ -1,79 +0,0 @@
|
|||||||
'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,93 +1,4 @@
|
|||||||
[
|
[
|
||||||
{
|
|
||||||
"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",
|
"version": "2026.08.17-inbox-group-reset",
|
||||||
"date": "2026-08-17",
|
"date": "2026-08-17",
|
||||||
@ -6315,24 +6226,5 @@
|
|||||||
"退回查询 _resolveReturnOrderInfo 优先主表快照,空时实时兜底(交易单号→原运单/原订单,店铺→store_remask)"
|
"退回查询 _resolveReturnOrderInfo 优先主表快照,空时实时兜底(交易单号→原运单/原订单,店铺→store_remask)"
|
||||||
],
|
],
|
||||||
"module": "returnUnpack"
|
"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,20 +224,5 @@
|
|||||||
"dev 库已回填:26 仓库组-主管、27 仓库组-员工、28 客服组-主管、30 客服组-员工"
|
"dev 库已回填:26 仓库组-主管、27 仓库组-员工、28 客服组-主管、30 客服组-员工"
|
||||||
],
|
],
|
||||||
"module": "permission"
|
"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,8 +312,7 @@ function applyDocUpdate(doc, groupSpec, methods, docMeta) {
|
|||||||
function appendChange(changes, change) {
|
function appendChange(changes, change) {
|
||||||
const exists = changes.some(item => item && item.version === change.version);
|
const exists = changes.some(item => item && item.version === change.version);
|
||||||
assert(!exists, `Duplicate change version detected: ${change.version}`);
|
assert(!exists, `Duplicate change version detected: ${change.version}`);
|
||||||
// 变更记录保持“新记录在数组开头”的顺序(与 methods/changes/*.json 现有约定一致)
|
changes.push(cloneJson(change));
|
||||||
changes.unshift(cloneJson(change));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
|||||||
@ -25,8 +25,6 @@ function createContext(options = {}) {
|
|||||||
sendOrderMarks: [],
|
sendOrderMarks: [],
|
||||||
redisGetKeys: [],
|
redisGetKeys: [],
|
||||||
platformFindAllWheres: [],
|
platformFindAllWheres: [],
|
||||||
systemPlatformFindAllWheres: [],
|
|
||||||
printPlatformIdFindAllWheres: [],
|
|
||||||
orderDeliveryLockUpdates: [],
|
orderDeliveryLockUpdates: [],
|
||||||
operationLogCreatePayloads: [],
|
operationLogCreatePayloads: [],
|
||||||
};
|
};
|
||||||
@ -68,18 +66,6 @@ function createContext(options = {}) {
|
|||||||
douyin: '抖音',
|
douyin: '抖音',
|
||||||
};
|
};
|
||||||
|
|
||||||
const platformPrintIdMap = requestOptions.platformPrintIdMap || {
|
|
||||||
TB: 2,
|
|
||||||
TM: 2,
|
|
||||||
1688: 2,
|
|
||||||
TGC: 2,
|
|
||||||
MAOCHAO: 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
const printPlatformNameById = requestOptions.printPlatformNameById || {
|
|
||||||
2: '菜鸟',
|
|
||||||
};
|
|
||||||
|
|
||||||
const printStation = requestOptions.printStation || {
|
const printStation = requestOptions.printStation || {
|
||||||
id: 101,
|
id: 101,
|
||||||
warehouse_id: 100000,
|
warehouse_id: 100000,
|
||||||
@ -290,38 +276,15 @@ function createContext(options = {}) {
|
|||||||
},
|
},
|
||||||
PrintPlatform: {
|
PrintPlatform: {
|
||||||
async findAll(query) {
|
async findAll(query) {
|
||||||
const where = query && query.where ? query.where : {};
|
calls.platformFindAllWheres.push(query && query.where ? query.where : {});
|
||||||
if (Array.isArray(where.platform_code)) {
|
const codeList = query && query.where && Array.isArray(query.where.platform_code)
|
||||||
calls.platformFindAllWheres.push(where);
|
? query.where.platform_code
|
||||||
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 => ({
|
return codeList.map(platformCode => ({
|
||||||
code: platformCode,
|
platform_code: platformCode,
|
||||||
print_platform_id: Object.prototype.hasOwnProperty.call(platformPrintIdMap, platformCode)
|
platform_name: Object.prototype.hasOwnProperty.call(platformComponents, platformCode)
|
||||||
? platformPrintIdMap[platformCode]
|
? platformComponents[platformCode]
|
||||||
: null,
|
: '',
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -727,100 +690,6 @@ describe('test/app/service/systemMethods/print.send.test.js', () => {
|
|||||||
assert.equal(calls.sendToComputerPayloads.length, 0);
|
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 () => {
|
it('type=express 快手平台应按10单分批发送并注入文档位置信息', async () => {
|
||||||
const { ctx, calls } = createContext({
|
const { ctx, calls } = createContext({
|
||||||
platformComponents: {
|
platformComponents: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user