团购打印面单
This commit is contained in:
parent
0c3518e65d
commit
81785081a2
@ -214,6 +214,31 @@ function parseItems(rawItems) {
|
||||
return rawItems;
|
||||
}
|
||||
|
||||
if (isPlainObject(rawItems)) {
|
||||
for (const key of Object.keys(rawItems)) {
|
||||
if (Array.isArray(rawItems[key])) {
|
||||
return rawItems[key];
|
||||
}
|
||||
}
|
||||
|
||||
const candidates = [
|
||||
rawItems.items,
|
||||
rawItems.list,
|
||||
rawItems.goods,
|
||||
rawItems.products,
|
||||
rawItems.product_list,
|
||||
rawItems.rows,
|
||||
];
|
||||
|
||||
for (const candidate of candidates) {
|
||||
if (Array.isArray(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
if (typeof rawItems === 'string') {
|
||||
const text = rawItems.trim();
|
||||
if (!text) {
|
||||
@ -222,15 +247,103 @@ function parseItems(rawItems) {
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(text);
|
||||
return Array.isArray(parsed) ? parsed : [];
|
||||
return parseItems(parsed);
|
||||
} catch (error) {
|
||||
return [];
|
||||
function isNoiseQuantityOnlyText(value) {
|
||||
const sample = String(value || '').trim();
|
||||
if (!sample) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return /^(?:\[?\s*\d+(?:\.\d+)?\s*\]?|【\s*\d+(?:\.\d+)?\s*】)(?:\s+0+)?$/.test(sample);
|
||||
}
|
||||
|
||||
function parseLooseItemText(rawText) {
|
||||
const normalizedText = String(rawText || '').replace(/[;;]+$/g, '').trim();
|
||||
if (!normalizedText || isNoiseQuantityOnlyText(normalizedText)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let quantity = '1';
|
||||
let workingText = normalizedText;
|
||||
|
||||
const qtyBracketMatch = workingText.match(/【\s*(\d+(?:\.\d+)?)\s*】/);
|
||||
if (qtyBracketMatch) {
|
||||
quantity = String(qtyBracketMatch[1] || '1').trim() || '1';
|
||||
workingText = workingText.replace(qtyBracketMatch[0], ' ').trim();
|
||||
} else {
|
||||
const qtyTailMatch = workingText.match(/(?:[xX×*]\s*(\d+(?:\.\d+)?))\s*$/);
|
||||
if (qtyTailMatch) {
|
||||
quantity = String(qtyTailMatch[1] || '1').trim() || '1';
|
||||
workingText = workingText.slice(0, qtyTailMatch.index).trim();
|
||||
}
|
||||
}
|
||||
|
||||
const barcodeMatch = workingText.match(/(?:^|[;;\s])(\d{5,})(?!\d)/);
|
||||
const barcode = barcodeMatch ? String(barcodeMatch[1] || '').trim() : '';
|
||||
|
||||
let pickLocation = '';
|
||||
let itemName = workingText;
|
||||
const locationMatch = workingText.match(/^([^\s;;]+(?:[-_][^\s;;]+)*)\s+/);
|
||||
if (locationMatch) {
|
||||
pickLocation = String(locationMatch[1] || '').trim();
|
||||
itemName = workingText.slice(locationMatch[0].length).trim();
|
||||
}
|
||||
|
||||
if (barcode) {
|
||||
itemName = itemName.replace(new RegExp(`(?:^|[;;\\s])${barcode}(?:$|[;;\\s])`), ' ').trim();
|
||||
}
|
||||
itemName = itemName.replace(/[;;]+/g, ' ').trim();
|
||||
|
||||
if (isNoiseQuantityOnlyText(itemName)) {
|
||||
itemName = '';
|
||||
}
|
||||
|
||||
return {
|
||||
pick_location: pickLocation,
|
||||
item_name: itemName || workingText,
|
||||
barcode,
|
||||
quantity,
|
||||
raw_text: normalizedText,
|
||||
};
|
||||
}
|
||||
|
||||
const itemTextList = text
|
||||
.split(/\||\r\n|\n|\r/)
|
||||
.map(part => String(part || '').trim())
|
||||
.filter(Boolean);
|
||||
|
||||
if (itemTextList.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const parsedItems = itemTextList
|
||||
.map(itemText => parseLooseItemText(itemText))
|
||||
.filter(item => isPlainObject(item));
|
||||
return parsedItems;
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析自定义区商品来源,优先兼容 order_delivery 与 order_express 双来源。
|
||||
* @param {Object} orderExpress 快递单对象。
|
||||
* @param {Object} orderDelivery 订单对象。
|
||||
* @return {Array<Object>} 商品列表。
|
||||
*/
|
||||
function resolveCustomComposeItems(orderExpress, orderDelivery) {
|
||||
const safeOrderExpress = isPlainObject(orderExpress) ? orderExpress : {};
|
||||
const safeOrderDelivery = isPlainObject(orderDelivery) ? orderDelivery : {};
|
||||
const deliveryItems = parseItems(safeOrderDelivery.items);
|
||||
if (deliveryItems.length > 0) {
|
||||
return deliveryItems;
|
||||
}
|
||||
|
||||
return parseItems(safeOrderExpress.items);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在候选键中读取首个非空字段。
|
||||
* @param {Object} item 商品对象。
|
||||
@ -292,6 +405,7 @@ function resolveItemBarcodeText(item) {
|
||||
'item_barcode',
|
||||
'item_code',
|
||||
'sku_code',
|
||||
'sku',
|
||||
]);
|
||||
}
|
||||
|
||||
@ -342,18 +456,20 @@ function resolveItemQuantity(item) {
|
||||
* @param {string} lineBreak 换行符。
|
||||
* @return {string} 自定义区文本。
|
||||
*/
|
||||
function buildWaybillCustomProductInfo(items, policyConfig, lineBreak = LINE_BREAK_MAP.LF) {
|
||||
function buildWaybillCustomProductInfoLines(items, policyConfig = {}, options = {}) {
|
||||
const safeItems = Array.isArray(items) ? items : [];
|
||||
const safePolicyConfig = isPlainObject(policyConfig) ? policyConfig : {};
|
||||
const displayType = String(
|
||||
safePolicyConfig[WAYBILL_CUSTOM_DISPLAY_FIELD] || WAYBILL_CUSTOM_DISPLAY_TYPES.HIDE
|
||||
).trim();
|
||||
const safeOptions = isPlainObject(options) ? options : {};
|
||||
const hasDisplayType = Object.prototype.hasOwnProperty.call(safePolicyConfig, WAYBILL_CUSTOM_DISPLAY_FIELD);
|
||||
const displayType = hasDisplayType
|
||||
? String(safePolicyConfig[WAYBILL_CUSTOM_DISPLAY_FIELD] || '').trim()
|
||||
: WAYBILL_CUSTOM_DISPLAY_TYPES.PICK_LOCATION_NAME_BARCODE_QTY;
|
||||
|
||||
if (displayType === WAYBILL_CUSTOM_DISPLAY_TYPES.HIDE || safeItems.length === 0) {
|
||||
return '';
|
||||
if (displayType === WAYBILL_CUSTOM_DISPLAY_TYPES.HIDE) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const lines = [];
|
||||
const detailLines = [];
|
||||
let totalQty = 0;
|
||||
|
||||
for (const item of safeItems) {
|
||||
@ -384,6 +500,10 @@ function buildWaybillCustomProductInfo(items, policyConfig, lineBreak = LINE_BRE
|
||||
break;
|
||||
case WAYBILL_CUSTOM_DISPLAY_TYPES.PICK_LOCATION_BARCODE_LAST5_QTY: {
|
||||
const barcodeLast5 = barcode ? barcode.slice(-5) : '';
|
||||
if (!pickLocation && !barcodeLast5) {
|
||||
line = '';
|
||||
break;
|
||||
}
|
||||
line = `${pickLocation} ${barcodeLast5} 【${qtyText}】`.trim();
|
||||
break;
|
||||
}
|
||||
@ -396,16 +516,59 @@ function buildWaybillCustomProductInfo(items, policyConfig, lineBreak = LINE_BRE
|
||||
}
|
||||
|
||||
if (line) {
|
||||
lines.push(line.replace(/\s{2,}/g, ' '));
|
||||
detailLines.push(line.replace(/\s{2,}/g, ' '));
|
||||
}
|
||||
}
|
||||
|
||||
if (lines.length === 0) {
|
||||
const waveNo = String(safeOptions.waveNo || '').trim();
|
||||
const waveTotalOrders = toNumber(safeOptions.wave_total_orders, 0);
|
||||
const waveIndex = toNumber(safeOptions.wave_index, 0);
|
||||
const platformsIndex = toNumber(safeOptions.platforms_index, 0);
|
||||
const expressInterfaceName = String(safeOptions.expressInterfaceName || '').trim();
|
||||
const fallbackTotalQtyRaw = Number(safeOptions.fallbackTotalQty);
|
||||
const finalTotalQty = totalQty > 0
|
||||
? totalQty
|
||||
: (Number.isFinite(fallbackTotalQtyRaw) && fallbackTotalQtyRaw > 0 ? fallbackTotalQtyRaw : 0);
|
||||
const hasWaveCustomPrefix = waveTotalOrders > 0
|
||||
&& waveIndex > 0
|
||||
&& platformsIndex > 0
|
||||
&& Boolean(waveNo);
|
||||
const waveHeaderText = hasWaveCustomPrefix
|
||||
? `【${waveTotalOrders}】${waveNo}_${waveIndex}_${platformsIndex}`
|
||||
: waveNo;
|
||||
const headerParts = [ waveHeaderText, expressInterfaceName ].filter(Boolean);
|
||||
headerParts.push(`商品数量【${finalTotalQty}】`);
|
||||
const headerLine = headerParts.join(' ');
|
||||
|
||||
if (detailLines.length === 0) {
|
||||
return [ headerLine ];
|
||||
}
|
||||
|
||||
return [ headerLine, ...detailLines ];
|
||||
}
|
||||
|
||||
/**
|
||||
* 将自定义文本行按平台换行符合并为字符串。
|
||||
* @param {Array<string>} lines 文本行数组。
|
||||
* @param {Object} options 合并选项。
|
||||
* @param {string} [options.lineBreak=LINE_BREAK_MAP.LF] 换行符。
|
||||
* @param {boolean} [options.trailingLineBreak=false] 是否追加末尾换行。
|
||||
* @return {string} 合并后的文本。
|
||||
*/
|
||||
function mergeWaybillCustomLines(lines = [], options = {}) {
|
||||
const safeLines = Array.isArray(lines) ? lines.filter(line => String(line || '').trim() !== '') : [];
|
||||
if (safeLines.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const header = `商品总数 【${Number.isFinite(totalQty) ? totalQty : 0}】`;
|
||||
return normalizeLineBreak([ header, ...lines ].join(LINE_BREAK_MAP.LF), lineBreak);
|
||||
const safeOptions = isPlainObject(options) ? options : {};
|
||||
const lineBreak = safeOptions.lineBreak || LINE_BREAK_MAP.LF;
|
||||
const trailingLineBreak = Boolean(safeOptions.trailingLineBreak);
|
||||
let text = normalizeLineBreak(safeLines.join(LINE_BREAK_MAP.LF), lineBreak);
|
||||
if (trailingLineBreak) {
|
||||
text += lineBreak;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -660,7 +823,7 @@ function sanitizeTemplatePrivateFields(value, warnings, currentKey = '') {
|
||||
* @param {Object} policyConfig 策略配置对象。
|
||||
* @param {string} customDataTemplateURL 自定义区模板地址默认值。
|
||||
*/
|
||||
function applyKuaishouExpressFieldMapping(platform, skeleton, orderExpress, warnings, policyConfig, customDataTemplateURL) {
|
||||
function applyKuaishouExpressFieldMapping(platform, skeleton, orderExpress, orderDelivery, warnings, policyConfig, customDataTemplateURL) {
|
||||
if (platform !== 'kuaishou') {
|
||||
return;
|
||||
}
|
||||
@ -680,11 +843,28 @@ function applyKuaishouExpressFieldMapping(platform, skeleton, orderExpress, warn
|
||||
const signature = toTrimmedString(safeOrderExpress.signature);
|
||||
const key = toTrimmedString(safeOrderExpress.encryptprintinfo);
|
||||
const waybillCode = toTrimmedString(safeOrderExpress.waybill_code);
|
||||
const customProductInfo = buildWaybillCustomProductInfo(
|
||||
parseItems(safeOrderExpress.items),
|
||||
const safeOrderDelivery = isPlainObject(orderDelivery) ? orderDelivery : {};
|
||||
const composeItems = resolveCustomComposeItems(safeOrderExpress, safeOrderDelivery);
|
||||
const customProductInfoLines = buildWaybillCustomProductInfoLines(
|
||||
composeItems,
|
||||
safePolicyConfig,
|
||||
LINE_BREAK_MAP.LF
|
||||
{
|
||||
waveNo: toTrimmedString(safeOrderDelivery.wave_no),
|
||||
wave_total_orders: Number(safeOrderDelivery.wave_total_orders || 0),
|
||||
wave_index: Number(safeOrderDelivery.wave_index || 0),
|
||||
platforms_index: Number(safeOrderDelivery.platforms_index || 0),
|
||||
expressInterfaceName: toTrimmedString(
|
||||
safeOrderExpress.logistics_interface_name
|
||||
|| safeOrderExpress.logistics_name
|
||||
|| safeOrderDelivery.logistics_interface_name
|
||||
|| safeOrderDelivery.logistics_name
|
||||
),
|
||||
fallbackTotalQty: Number(safeOrderDelivery.items_count || safeOrderDelivery.items_total || 0),
|
||||
}
|
||||
);
|
||||
const customProductInfo = mergeWaybillCustomLines(customProductInfoLines, {
|
||||
lineBreak: LINE_BREAK_MAP.LF,
|
||||
});
|
||||
|
||||
for (const document of documents) {
|
||||
if (!isPlainObject(document)) {
|
||||
@ -782,7 +962,7 @@ function applyKuaishouExpressFieldMapping(platform, skeleton, orderExpress, warn
|
||||
* @param {Object} orderExpress 快递单对象。
|
||||
* @param {Object} policyConfig 策略配置对象。
|
||||
*/
|
||||
function applyPddExpressFieldMapping(platform, skeleton, orderExpress, policyConfig) {
|
||||
function applyPddExpressFieldMapping(platform, skeleton, orderExpress, orderDelivery, policyConfig) {
|
||||
if (platform !== 'pdd') {
|
||||
return;
|
||||
}
|
||||
@ -801,11 +981,29 @@ function applyPddExpressFieldMapping(platform, skeleton, orderExpress, policyCon
|
||||
const encryptedData = toTrimmedString(safeOrderExpress.printinfo);
|
||||
const signature = toTrimmedString(safeOrderExpress.signature);
|
||||
const waybillCode = toTrimmedString(safeOrderExpress.waybill_code);
|
||||
const customProductInfo = buildWaybillCustomProductInfo(
|
||||
parseItems(safeOrderExpress.items),
|
||||
const safeOrderDelivery = isPlainObject(orderDelivery) ? orderDelivery : {};
|
||||
const composeItems = resolveCustomComposeItems(safeOrderExpress, safeOrderDelivery);
|
||||
const customProductInfoLines = buildWaybillCustomProductInfoLines(
|
||||
composeItems,
|
||||
safePolicyConfig,
|
||||
LINE_BREAK_MAP.CR
|
||||
{
|
||||
waveNo: toTrimmedString(safeOrderDelivery.wave_no),
|
||||
wave_total_orders: Number(safeOrderDelivery.wave_total_orders || 0),
|
||||
wave_index: Number(safeOrderDelivery.wave_index || 0),
|
||||
platforms_index: Number(safeOrderDelivery.platforms_index || 0),
|
||||
expressInterfaceName: toTrimmedString(
|
||||
safeOrderExpress.logistics_interface_name
|
||||
|| safeOrderExpress.logistics_name
|
||||
|| safeOrderDelivery.logistics_interface_name
|
||||
|| safeOrderDelivery.logistics_name
|
||||
),
|
||||
fallbackTotalQty: Number(safeOrderDelivery.items_count || safeOrderDelivery.items_total || 0),
|
||||
}
|
||||
);
|
||||
const customProductInfo = mergeWaybillCustomLines(customProductInfoLines, {
|
||||
lineBreak: LINE_BREAK_MAP.CR,
|
||||
trailingLineBreak: true,
|
||||
});
|
||||
|
||||
/**
|
||||
* 判断内容对象是否属于拼多多自定义区。
|
||||
@ -997,6 +1195,7 @@ function buildPlatformRequestSkeleton(input = {}) {
|
||||
normalized.platform,
|
||||
skeleton,
|
||||
orderExpressForCompose,
|
||||
orderDeliveryForCompose,
|
||||
warnings,
|
||||
policyConfig,
|
||||
customDataTemplateURL
|
||||
@ -1006,6 +1205,7 @@ function buildPlatformRequestSkeleton(input = {}) {
|
||||
normalized.platform,
|
||||
skeleton,
|
||||
orderExpressForCompose,
|
||||
orderDeliveryForCompose,
|
||||
policyConfig
|
||||
);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -26,6 +26,273 @@ const SYS_PLATFORM_TO_PRINT_PLATFORM_MAP = Object.freeze({
|
||||
});
|
||||
|
||||
class OrderPrintSystemService extends OrderBaseService {
|
||||
/**
|
||||
* 判断当前配置是否需要补查拣货明细。
|
||||
*
|
||||
* 未配置时默认按类型5处理,因此也需要补查。
|
||||
*
|
||||
* @param {Object} policyConfig 策略配置。
|
||||
* @return {boolean} 是否需要补查拣货明细。
|
||||
*/
|
||||
shouldLoadPickingDetails(policyConfig = {}) {
|
||||
const config = this.isPlainObject(policyConfig) ? policyConfig : {};
|
||||
const displayType = Object.prototype.hasOwnProperty.call(config, 'waybill_custom_display_type')
|
||||
? String(config.waybill_custom_display_type || '').trim()
|
||||
: '5';
|
||||
|
||||
return [ '2', '3', '4', '5' ].includes(displayType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 归一化商品快照,兼容 JSON 字符串。
|
||||
*
|
||||
* @param {*} rawSnapshot 原始商品快照。
|
||||
* @return {Object} 快照对象。
|
||||
*/
|
||||
normalizeItemSnapshot(rawSnapshot) {
|
||||
if (this.isPlainObject(rawSnapshot)) {
|
||||
return rawSnapshot;
|
||||
}
|
||||
|
||||
if (typeof rawSnapshot === 'string') {
|
||||
const text = rawSnapshot.trim();
|
||||
if (!text) {
|
||||
return {};
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(text);
|
||||
return this.isPlainObject(parsed) ? parsed : {};
|
||||
} catch (error) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 从候选字段中读取首个非空文本。
|
||||
*
|
||||
* @param {Object} source 源对象。
|
||||
* @param {Array<string>} keys 候选键。
|
||||
* @return {string} 首个非空文本。
|
||||
*/
|
||||
getFirstNonEmptyFieldText(source, keys = []) {
|
||||
if (!this.isPlainObject(source)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
for (const key of keys) {
|
||||
const value = source[key];
|
||||
if (value === undefined || value === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const text = String(value).trim();
|
||||
if (text) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量补查打印所需的拣货明细。
|
||||
*
|
||||
* 优先使用 wms_picking.space_name,只有缺失时才查询库位表,减少额外 SQL。
|
||||
*
|
||||
* @param {Array<Object>} orderRows 订单列表。
|
||||
* @param {number} warehouseId 仓库ID。
|
||||
* @return {Promise<Map<number, Object>>} 订单ID到补齐后订单对象的映射。
|
||||
*/
|
||||
async buildPrintOrderRowMapWithPicking(orderRows = [], warehouseId) {
|
||||
const rows = Array.isArray(orderRows) ? orderRows : [];
|
||||
const orderIds = Array.from(new Set(rows
|
||||
.map(row => Number(row && row.id || 0))
|
||||
.filter(orderId => Number.isInteger(orderId) && orderId > 0)));
|
||||
const resultMap = new Map();
|
||||
|
||||
if (orderIds.length === 0) {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
const pickingModel = this.ctx.model && this.ctx.model.Picking;
|
||||
if (!pickingModel || typeof pickingModel.findAll !== 'function') {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
const pickingRows = await pickingModel.findAll({
|
||||
where: {
|
||||
order_id: {
|
||||
[Op.in]: orderIds,
|
||||
},
|
||||
status: {
|
||||
[Op.ne]: 'cancel',
|
||||
},
|
||||
},
|
||||
attributes: [ 'id', 'order_id', 'order_item_id', 'quantity', 'space_id', 'space_name', 'status' ],
|
||||
order: [[ 'order_id', 'ASC' ], [ 'id', 'ASC' ]],
|
||||
raw: true,
|
||||
});
|
||||
|
||||
const normalizedPickingRows = Array.isArray(pickingRows) ? pickingRows : [];
|
||||
if (normalizedPickingRows.length === 0) {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
const orderItemIds = Array.from(new Set(normalizedPickingRows
|
||||
.map(row => Number(row && row.order_item_id || 0))
|
||||
.filter(orderItemId => Number.isInteger(orderItemId) && orderItemId > 0)));
|
||||
|
||||
const orderItemModelFactory = this.ctx.model && this.ctx.model.OrderItemsFactory;
|
||||
const orderItemModel = orderItemModelFactory && typeof orderItemModelFactory.getCurrentModel === 'function'
|
||||
? await orderItemModelFactory.getCurrentModel(warehouseId)
|
||||
: null;
|
||||
|
||||
const orderItemRows = orderItemModel && typeof orderItemModel.findAll === 'function' && orderItemIds.length > 0
|
||||
? await orderItemModel.findAll({
|
||||
where: {
|
||||
id: {
|
||||
[Op.in]: orderItemIds,
|
||||
},
|
||||
},
|
||||
attributes: [ 'id', 'order_id', 'item_code', 'item_name', 'plan_qty', 'item_snapshot' ],
|
||||
raw: true,
|
||||
})
|
||||
: [];
|
||||
|
||||
const orderItemMap = new Map();
|
||||
for (const row of Array.isArray(orderItemRows) ? orderItemRows : []) {
|
||||
const orderItemId = Number(row && row.id || 0);
|
||||
if (orderItemId > 0) {
|
||||
orderItemMap.set(orderItemId, row);
|
||||
}
|
||||
}
|
||||
|
||||
const locationFallbackSpaceIds = Array.from(new Set(normalizedPickingRows
|
||||
.filter(row => !String(row && row.space_name || '').trim())
|
||||
.map(row => Number(row && row.space_id || 0))
|
||||
.filter(spaceId => Number.isInteger(spaceId) && spaceId > 0)));
|
||||
const locationModel = this.ctx.model && this.ctx.model.LocationSpace;
|
||||
const locationRows = locationModel
|
||||
&& typeof locationModel.findAll === 'function'
|
||||
&& locationFallbackSpaceIds.length > 0
|
||||
? await locationModel.findAll({
|
||||
where: {
|
||||
id: {
|
||||
[Op.in]: locationFallbackSpaceIds,
|
||||
},
|
||||
warehouse_id: warehouseId,
|
||||
},
|
||||
attributes: [ 'id', 'space_code', 'custom_name', 'custom_barcode' ],
|
||||
raw: true,
|
||||
})
|
||||
: [];
|
||||
const locationMap = new Map((Array.isArray(locationRows) ? locationRows : [])
|
||||
.map(row => [ Number(row && row.id || 0), row ]));
|
||||
|
||||
const pickingRowsByOrderId = new Map();
|
||||
for (const row of normalizedPickingRows) {
|
||||
const orderId = Number(row && row.order_id || 0);
|
||||
if (orderId <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const list = pickingRowsByOrderId.get(orderId) || [];
|
||||
list.push(row);
|
||||
pickingRowsByOrderId.set(orderId, list);
|
||||
}
|
||||
|
||||
for (const orderRow of rows) {
|
||||
const orderId = Number(orderRow && orderRow.id || 0);
|
||||
const pickingList = pickingRowsByOrderId.get(orderId) || [];
|
||||
if (pickingList.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const printItems = pickingList.map(pickingRow => {
|
||||
const orderItemId = Number(pickingRow && pickingRow.order_item_id || 0);
|
||||
const orderItemRow = orderItemMap.get(orderItemId) || {};
|
||||
const itemSnapshot = this.normalizeItemSnapshot(orderItemRow.item_snapshot);
|
||||
const locationRow = locationMap.get(Number(pickingRow && pickingRow.space_id || 0)) || {};
|
||||
const pickLocation = this.getFirstNonEmptyFieldText({
|
||||
space_name: pickingRow && pickingRow.space_name,
|
||||
space_code: locationRow.space_code,
|
||||
custom_name: locationRow.custom_name,
|
||||
custom_barcode: locationRow.custom_barcode,
|
||||
}, [ 'space_name', 'space_code', 'custom_name', 'custom_barcode' ]);
|
||||
const itemName = this.getFirstNonEmptyFieldText({
|
||||
snapshot_item_name: itemSnapshot.item_name,
|
||||
snapshot_name: itemSnapshot.name,
|
||||
snapshot_title: itemSnapshot.title,
|
||||
item_name: orderItemRow.item_name,
|
||||
}, [ 'snapshot_item_name', 'snapshot_name', 'snapshot_title', 'item_name' ]);
|
||||
const barcode = this.getFirstNonEmptyFieldText({
|
||||
barcode: itemSnapshot.barcode,
|
||||
item_barcode: itemSnapshot.item_barcode,
|
||||
bar_code: itemSnapshot.bar_code,
|
||||
item_code: orderItemRow.item_code,
|
||||
sku_code: itemSnapshot.sku_code,
|
||||
sku: itemSnapshot.sku,
|
||||
}, [ 'barcode', 'item_barcode', 'bar_code', 'item_code', 'sku_code', 'sku' ]);
|
||||
const quantity = Number(pickingRow && pickingRow.quantity || orderItemRow.plan_qty || 0);
|
||||
|
||||
return {
|
||||
order_item_id: orderItemId,
|
||||
item_name: itemName,
|
||||
barcode,
|
||||
quantity: quantity > 0 ? quantity : 0,
|
||||
pick_location: pickLocation,
|
||||
};
|
||||
}).filter(item => {
|
||||
return String(item.item_name || '').trim()
|
||||
|| String(item.barcode || '').trim()
|
||||
|| String(item.pick_location || '').trim();
|
||||
});
|
||||
|
||||
if (printItems.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
resultMap.set(orderId, {
|
||||
...orderRow,
|
||||
items: JSON.stringify(printItems),
|
||||
});
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 归一化签约策略配置,兼容缓存中的字符串形态。
|
||||
*
|
||||
* @param {*} rawPolicyConfig 原始策略配置。
|
||||
* @return {Object} 归一化后的策略配置对象。
|
||||
*/
|
||||
normalizeContractPolicyConfig(rawPolicyConfig) {
|
||||
if (this.isPlainObject(rawPolicyConfig)) {
|
||||
return rawPolicyConfig;
|
||||
}
|
||||
|
||||
if (typeof rawPolicyConfig === 'string') {
|
||||
const text = rawPolicyConfig.trim();
|
||||
if (!text) {
|
||||
return {};
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(text);
|
||||
return this.isPlainObject(parsed) ? parsed : {};
|
||||
} catch (error) {
|
||||
this.ctx.logger.warn('[orderPrint.normalizeContractPolicyConfig] policy_config 解析失败: %s', error.message);
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取波次打印数据。
|
||||
*
|
||||
@ -151,6 +418,17 @@ class OrderPrintSystemService extends OrderBaseService {
|
||||
this.assertBusinessWaybillCompleteness(orderIds, orderExpressRows);
|
||||
const orderExpressMap = this.buildOrderExpressMap(orderExpressRows);
|
||||
const policyConfigMap = await this.getPolicyConfigMapByStore(validOrderRows, normalizedWarehouseId);
|
||||
const pickingCandidateRows = validOrderRows.filter(orderRow => {
|
||||
const storeId = Number(orderRow && orderRow.store_id || 0);
|
||||
const policyConfig = policyConfigMap.get(storeId) || {};
|
||||
return this.shouldLoadPickingDetails(policyConfig);
|
||||
});
|
||||
const printOrderRowMap = await this.buildPrintOrderRowMapWithPicking(pickingCandidateRows, normalizedWarehouseId);
|
||||
const waveOrderIndexMap = await this.queryWaveOrderIndexMapByOrderIds(orderIds, normalizedWarehouseId);
|
||||
const waveIdsForCount = Array.from(new Set(Array.from(waveOrderIndexMap.values())
|
||||
.map(item => Number(item && item.wave_id || 0))
|
||||
.filter(waveId => Number.isInteger(waveId) && waveId > 0)));
|
||||
const waveTotalOrderCountMap = await this.queryWaveTotalOrderCountMap(waveIdsForCount, normalizedWarehouseId);
|
||||
const templateSampleCache = new Map();
|
||||
const orderPrintList = [];
|
||||
|
||||
@ -161,13 +439,25 @@ class OrderPrintSystemService extends OrderBaseService {
|
||||
}
|
||||
|
||||
const orderExpress = orderExpressMap.get(orderId) || {};
|
||||
const effectiveOrderRow = printOrderRowMap.get(orderId) || orderRow;
|
||||
const waveOrderIndexInfo = waveOrderIndexMap.get(orderId) || {};
|
||||
const waveIdForCount = Number(waveOrderIndexInfo.wave_id || effectiveOrderRow.wave_id || 0);
|
||||
const waveTotalOrders = Number(waveTotalOrderCountMap.get(waveIdForCount) || 0);
|
||||
const waveIndex = Number(waveOrderIndexInfo.wave_index || 0);
|
||||
const platformsIndex = Number(waveOrderIndexInfo.platforms_index || 0);
|
||||
const effectiveOrderRowWithWaveIndex = {
|
||||
...effectiveOrderRow,
|
||||
wave_total_orders: waveTotalOrders > 0 ? waveTotalOrders : 0,
|
||||
wave_index: waveIndex > 0 ? waveIndex : 0,
|
||||
platforms_index: platformsIndex > 0 ? platformsIndex : 0,
|
||||
};
|
||||
const storeId = Number(orderRow && orderRow.store_id || 0);
|
||||
const policyConfig = policyConfigMap.get(storeId) || {};
|
||||
const platformCode = this.resolvePrintPlatformCode(orderRow, orderExpress);
|
||||
const platformCode = this.resolvePrintPlatformCode(effectiveOrderRow, orderExpress);
|
||||
const templateSample = this.loadTemplateSampleByPlatform(platformCode, templateSampleCache);
|
||||
|
||||
orderPrintList.push(this.buildOrderPlatformPrintItem({
|
||||
orderRow,
|
||||
orderRow: effectiveOrderRowWithWaveIndex,
|
||||
orderExpress,
|
||||
policyConfig,
|
||||
platformCode,
|
||||
@ -363,6 +653,7 @@ class OrderPrintSystemService extends OrderBaseService {
|
||||
'waybill_code',
|
||||
'logistics_code',
|
||||
'logistics_name',
|
||||
'logistics_interface_name',
|
||||
'platform_code',
|
||||
'warehouse_id',
|
||||
'printinfo',
|
||||
@ -382,6 +673,128 @@ class OrderPrintSystemService extends OrderBaseService {
|
||||
return Array.isArray(rows) ? rows : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 按订单ID批量查询波次顺序信息。
|
||||
*
|
||||
* 数据来源:wms_order_wave_index。
|
||||
* 当 query 能力不可用、SQL 执行失败或无数据时,优雅降级返回空映射。
|
||||
*
|
||||
* @param {Array<number>} orderIds 订单ID数组。
|
||||
* @param {number} warehouseId 仓库ID。
|
||||
* @return {Promise<Map<number, {wave_id:number, wave_index:number, platforms_index:number}>>} 订单顺序映射。
|
||||
*/
|
||||
async queryWaveOrderIndexMapByOrderIds(orderIds = [], warehouseId) {
|
||||
const resultMap = new Map();
|
||||
const normalizedOrderIds = Array.from(new Set((Array.isArray(orderIds) ? orderIds : [])
|
||||
.map(id => Number(id))
|
||||
.filter(id => Number.isInteger(id) && id > 0)));
|
||||
|
||||
if (normalizedOrderIds.length === 0) {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
const queryMethod = this.ctx.model && this.ctx.model.query;
|
||||
if (typeof queryMethod !== 'function') {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
const querySql = `
|
||||
SELECT order_id, wave_id, wave_index, platforms_index
|
||||
FROM wms_order_wave_index
|
||||
WHERE warehouse_id = :warehouseId
|
||||
AND order_id IN (:orderIds)
|
||||
`;
|
||||
|
||||
try {
|
||||
const rows = await queryMethod.call(this.ctx.model, querySql, {
|
||||
replacements: {
|
||||
warehouseId,
|
||||
orderIds: normalizedOrderIds,
|
||||
},
|
||||
type: this.ctx.model.QueryTypes && this.ctx.model.QueryTypes.SELECT,
|
||||
});
|
||||
|
||||
for (const row of Array.isArray(rows) ? rows : []) {
|
||||
const orderId = Number(row && row.order_id || 0);
|
||||
if (!Number.isInteger(orderId) || orderId <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
resultMap.set(orderId, {
|
||||
wave_id: Number(row && row.wave_id || 0),
|
||||
wave_index: Number(row && row.wave_index || 0),
|
||||
platforms_index: Number(row && row.platforms_index || 0),
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
this.ctx.logger.warn(
|
||||
`[orderPrint.queryWaveOrderIndexMapByOrderIds] 查询失败 warehouseId=${warehouseId} message=${error.message}`
|
||||
);
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按波次ID批量查询波次总订单数。
|
||||
*
|
||||
* 数据来源:wms_order_wave_index。
|
||||
* 当 query 能力不可用、SQL 执行失败或无数据时,优雅降级返回空映射。
|
||||
*
|
||||
* @param {Array<number>} waveIds 波次ID数组。
|
||||
* @param {number} warehouseId 仓库ID。
|
||||
* @return {Promise<Map<number, number>>} 波次ID到总订单数映射。
|
||||
*/
|
||||
async queryWaveTotalOrderCountMap(waveIds = [], warehouseId) {
|
||||
const resultMap = new Map();
|
||||
const normalizedWaveIds = Array.from(new Set((Array.isArray(waveIds) ? waveIds : [])
|
||||
.map(id => Number(id))
|
||||
.filter(id => Number.isInteger(id) && id > 0)));
|
||||
|
||||
if (normalizedWaveIds.length === 0) {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
const queryMethod = this.ctx.model && this.ctx.model.query;
|
||||
if (typeof queryMethod !== 'function') {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
const querySql = `
|
||||
SELECT wave_id, COUNT(1) AS total_orders
|
||||
FROM wms_order_wave_index
|
||||
WHERE warehouse_id = :warehouseId
|
||||
AND wave_id IN (:waveIds)
|
||||
GROUP BY wave_id
|
||||
`;
|
||||
|
||||
try {
|
||||
const rows = await queryMethod.call(this.ctx.model, querySql, {
|
||||
replacements: {
|
||||
warehouseId,
|
||||
waveIds: normalizedWaveIds,
|
||||
},
|
||||
type: this.ctx.model.QueryTypes && this.ctx.model.QueryTypes.SELECT,
|
||||
});
|
||||
|
||||
for (const row of Array.isArray(rows) ? rows : []) {
|
||||
const waveId = Number(row && row.wave_id || 0);
|
||||
if (!Number.isInteger(waveId) || waveId <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const totalOrders = Number(row && row.total_orders || 0);
|
||||
resultMap.set(waveId, totalOrders > 0 ? totalOrders : 0);
|
||||
}
|
||||
} catch (error) {
|
||||
this.ctx.logger.warn(
|
||||
`[orderPrint.queryWaveTotalOrderCountMap] 查询失败 warehouseId=${warehouseId} message=${error.message}`
|
||||
);
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验业务ID为1的运单号数据完整性。
|
||||
*
|
||||
@ -476,9 +889,7 @@ class OrderPrintSystemService extends OrderBaseService {
|
||||
await Promise.all(storeIds.map(async storeId => {
|
||||
try {
|
||||
const contractConfig = await storeWarehouseService.getContractConfig(warehouseId, storeId);
|
||||
const policyConfig = this.isPlainObject(contractConfig && contractConfig.policy_config)
|
||||
? contractConfig.policy_config
|
||||
: {};
|
||||
const policyConfig = this.normalizeContractPolicyConfig(contractConfig && contractConfig.policy_config);
|
||||
policyMap.set(storeId, policyConfig);
|
||||
} catch (error) {
|
||||
this.ctx.logger.warn(
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* 创建订单波次顺序副表。
|
||||
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
|
||||
* @param {import('sequelize')} Sequelize Sequelize 实例
|
||||
* @returns {Promise<void>} 无返回值
|
||||
*/
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.createTable('wms_order_wave_index', {
|
||||
id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
comment: '主键ID',
|
||||
},
|
||||
warehouse_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: '仓库ID',
|
||||
},
|
||||
order_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: '订单ID',
|
||||
},
|
||||
wave_id: {
|
||||
type: Sequelize.BIGINT.UNSIGNED,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: '波次ID',
|
||||
},
|
||||
wave_index: {
|
||||
type: Sequelize.INTEGER.UNSIGNED,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: '订单在波次中的全局顺序',
|
||||
},
|
||||
platforms_index: {
|
||||
type: Sequelize.INTEGER.UNSIGNED,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: '订单在平台分组内顺序',
|
||||
},
|
||||
create_at: {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
|
||||
comment: '创建时间',
|
||||
},
|
||||
}, {
|
||||
comment: '订单波次顺序定位副表',
|
||||
engine: 'InnoDB',
|
||||
charset: 'utf8mb4',
|
||||
collate: 'utf8mb4_general_ci',
|
||||
});
|
||||
|
||||
await queryInterface.addIndex('wms_order_wave_index', [ 'warehouse_id', 'order_id' ], {
|
||||
name: 'uk_warehouse_order',
|
||||
unique: true,
|
||||
});
|
||||
await queryInterface.addIndex('wms_order_wave_index', [ 'warehouse_id', 'wave_id' ], {
|
||||
name: 'idx_warehouse_wave',
|
||||
});
|
||||
await queryInterface.addIndex('wms_order_wave_index', [ 'warehouse_id', 'wave_id', 'wave_index' ], {
|
||||
name: 'idx_warehouse_wave_index',
|
||||
});
|
||||
await queryInterface.addIndex('wms_order_wave_index', [ 'warehouse_id', 'wave_id', 'platforms_index' ], {
|
||||
name: 'idx_warehouse_wave_platform_index',
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 回滚删除订单波次顺序副表。
|
||||
* @param {import('sequelize').QueryInterface} queryInterface 查询接口
|
||||
* @param {import('sequelize')} Sequelize Sequelize 实例
|
||||
* @returns {Promise<void>} 无返回值
|
||||
*/
|
||||
async down(queryInterface, Sequelize) {
|
||||
await queryInterface.dropTable('wms_order_wave_index');
|
||||
},
|
||||
};
|
||||
@ -444,4 +444,125 @@ describe('test/app/service/systemMethods/order/wave.fetch.test.js', () => {
|
||||
assert.ok(fallbackCall);
|
||||
assert.equal(fallbackCall.options.transaction, transaction);
|
||||
});
|
||||
|
||||
it('fetchSingleStructure 成功后应写入 wms_order_wave_index', async () => {
|
||||
const transaction = {
|
||||
LOCK: {
|
||||
UPDATE: 'UPDATE',
|
||||
},
|
||||
async commit() {},
|
||||
async rollback() {},
|
||||
};
|
||||
|
||||
const sqlCalls = [];
|
||||
const orders = [
|
||||
{ id: 301, wave_id: 0 },
|
||||
{ id: 302, wave_id: 0 },
|
||||
];
|
||||
|
||||
const ctx = {
|
||||
app: {
|
||||
config: {},
|
||||
},
|
||||
user: {
|
||||
store_id: 100000,
|
||||
},
|
||||
logger: {
|
||||
info() {},
|
||||
warn() {},
|
||||
error() {},
|
||||
},
|
||||
model: {
|
||||
QueryTypes: {
|
||||
SELECT: 'SELECT',
|
||||
},
|
||||
async transaction() {
|
||||
return transaction;
|
||||
},
|
||||
async query(sql, options = {}) {
|
||||
sqlCalls.push({ sql, options });
|
||||
if (sql.includes('INSERT INTO wms_wave_batch')) {
|
||||
return [{ insertId: 900003 }, { insertId: 900003 }];
|
||||
}
|
||||
if (sql.includes('SELECT wave_no')) {
|
||||
return [];
|
||||
}
|
||||
if (sql.includes('UPDATE wms_wave_batch')) {
|
||||
return [{ affectedRows: 1 }];
|
||||
}
|
||||
if (sql.includes('DELETE FROM wms_wave_batch')) {
|
||||
return [{ affectedRows: 1 }];
|
||||
}
|
||||
if (sql.includes('DELETE FROM wms_order_wave_index')) {
|
||||
return [{ affectedRows: 2 }];
|
||||
}
|
||||
if (sql.includes('INSERT INTO wms_order_wave_index')) {
|
||||
return [{ affectedRows: 2 }];
|
||||
}
|
||||
return [[]];
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const service = new WaveService(ctx);
|
||||
service.app.Sequelize = {
|
||||
literal(value) {
|
||||
return value;
|
||||
},
|
||||
};
|
||||
service.batchCreateOrderOperationLogs = async () => 0;
|
||||
service.getCurrentDatePart = () => '20260513';
|
||||
service.getNextWaveNoSequence = async () => 3;
|
||||
|
||||
const model = {
|
||||
async findAll(options = {}) {
|
||||
const where = options.where || {};
|
||||
if (where.wave_id === 0) {
|
||||
return orders
|
||||
.filter(item => item.wave_id === 0)
|
||||
.map(item => ({ id: item.id }));
|
||||
}
|
||||
if (where.wave_id === 900003) {
|
||||
return orders
|
||||
.filter(item => item.wave_id === 900003)
|
||||
.map(item => ({ id: item.id }));
|
||||
}
|
||||
return [];
|
||||
},
|
||||
async update(values = {}, options = {}) {
|
||||
const where = options.where || {};
|
||||
const targetIds = (where.id && where.id[Op.in]) || [];
|
||||
for (const item of orders) {
|
||||
if (targetIds.includes(item.id) && item.wave_id === 0) {
|
||||
item.wave_id = Number(values.wave_id || 0);
|
||||
item.wave_no = String(values.wave_no || '');
|
||||
}
|
||||
}
|
||||
return [ targetIds.length ];
|
||||
},
|
||||
};
|
||||
|
||||
await service.fetchSingleStructure(
|
||||
model,
|
||||
{
|
||||
item_detail_machine: 'token-c',
|
||||
quantity: 2,
|
||||
item_part_type: 'items_hash',
|
||||
item_part: 'hash-c',
|
||||
distinguish_express: false,
|
||||
logistics_name: '',
|
||||
item_snapshot_key: '',
|
||||
},
|
||||
100000,
|
||||
'B',
|
||||
1,
|
||||
{ maxFetchQuantity: 2 }
|
||||
);
|
||||
|
||||
const deleteCall = sqlCalls.find(call => call.sql.includes('DELETE FROM wms_order_wave_index'));
|
||||
assert.ok(deleteCall, '应触发 DELETE FROM wms_order_wave_index');
|
||||
|
||||
const insertCall = sqlCalls.find(call => call.sql.includes('INSERT INTO wms_order_wave_index'));
|
||||
assert.ok(insertCall, '应触发 INSERT INTO wms_order_wave_index');
|
||||
});
|
||||
});
|
||||
|
||||
@ -63,6 +63,8 @@ describe('test/app/service/systems/order_print.getWavePlatformPrintData.test.js'
|
||||
printinfo: 'ENC_FROM_DB',
|
||||
signature: 'SIG_FROM_DB',
|
||||
encryptprintinfo: 'KEY_FROM_DB',
|
||||
logistics_name: '顺丰',
|
||||
logistics_interface_name: '申通快递',
|
||||
},
|
||||
policyConfig: {
|
||||
province_name: '浙江省',
|
||||
@ -124,7 +126,7 @@ describe('test/app/service/systems/order_print.getWavePlatformPrintData.test.js'
|
||||
const customDataContent = result.print_data.contents.find(content => content && content.customData);
|
||||
assert.ok(customDataContent);
|
||||
assert.equal(customDataContent.templateURL, 'http://www.ye4s.com/mb/kuaishou.xml');
|
||||
assert.ok(customDataContent.customData.productInfo.includes('商品总数 【2】'));
|
||||
assert.ok(customDataContent.customData.productInfo.includes('W010 申通快递 商品数量【2】'));
|
||||
assert.ok(customDataContent.customData.productInfo.includes('E2区02-04-02 化妆品 6973348850399 【2】'));
|
||||
});
|
||||
|
||||
@ -151,6 +153,8 @@ describe('test/app/service/systems/order_print.getWavePlatformPrintData.test.js'
|
||||
waybill_code: ' WB201 ',
|
||||
printinfo: ' ENC_FROM_DB_PDD ',
|
||||
signature: ' SIG_FROM_DB_PDD ',
|
||||
logistics_name: '中通',
|
||||
logistics_interface_name: '顺丰空运',
|
||||
},
|
||||
policyConfig: {
|
||||
province_name: '广东省',
|
||||
@ -215,10 +219,466 @@ describe('test/app/service/systems/order_print.getWavePlatformPrintData.test.js'
|
||||
assert.ok(customContent);
|
||||
assert.equal(customContent.templateURL, 'http://www.ye4s.com/mb/pdd.xml');
|
||||
assert.ok(customContent.data.list[0].text.includes('\r'));
|
||||
assert.ok(customContent.data.list[0].text.includes('商品总数 【1】'));
|
||||
assert.ok(customContent.data.list[0].text.includes('W020 顺丰空运 商品数量【1】'));
|
||||
assert.ok(customContent.data.list[0].text.includes('A1-01-01 90123 【1】'));
|
||||
});
|
||||
|
||||
it('should build custom text when order items is wrapped object string', () => {
|
||||
const service = createOrderPrintServiceHarness();
|
||||
|
||||
const result = service.buildOrderPlatformPrintItem({
|
||||
orderRow: {
|
||||
id: 202,
|
||||
wave_id: 21,
|
||||
wave_no: 'W021',
|
||||
delivery_order_code: 'DO202',
|
||||
store_id: 1,
|
||||
warehouse_id: 100000,
|
||||
items: JSON.stringify({
|
||||
items: [
|
||||
{
|
||||
pick_location: 'C1-01-01',
|
||||
barcode: '9988776655443',
|
||||
quantity: 3,
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
orderExpress: {
|
||||
waybill_code: 'WB202',
|
||||
printinfo: 'ENC_202',
|
||||
signature: 'SIG_202',
|
||||
logistics_name: '圆通',
|
||||
},
|
||||
policyConfig: {
|
||||
waybill_custom_display_type: '3',
|
||||
sender_name: '张三',
|
||||
sender_tel: '13800000000',
|
||||
province_name: '浙江省',
|
||||
city_name: '杭州市',
|
||||
district_name: '西湖区',
|
||||
address: '文三路 1 号',
|
||||
},
|
||||
platformCode: 'pdd',
|
||||
templateSample: {
|
||||
cmd: 'print',
|
||||
requestID: 'REQ-202',
|
||||
version: '11',
|
||||
task: {
|
||||
documents: [
|
||||
{
|
||||
contents: [
|
||||
{
|
||||
addData: {
|
||||
sender: {
|
||||
address: {
|
||||
city: '',
|
||||
detail: '',
|
||||
district: '',
|
||||
province: '',
|
||||
},
|
||||
mobile: '',
|
||||
name: '',
|
||||
},
|
||||
},
|
||||
encryptedData: '',
|
||||
signature: '',
|
||||
templateUrl: 'https://file-link.pinduoduo.com/sto_one',
|
||||
userid: '',
|
||||
ver: '11',
|
||||
},
|
||||
{
|
||||
data: {
|
||||
height: 240,
|
||||
list: [
|
||||
{
|
||||
fontSize: 28,
|
||||
left: 2.08,
|
||||
text: '',
|
||||
top: 2.08,
|
||||
width: 550,
|
||||
},
|
||||
],
|
||||
waterdata: {
|
||||
text: '',
|
||||
},
|
||||
width: 560,
|
||||
},
|
||||
templateURL: 'http://www.ye4s.com/mb/pdd.xml',
|
||||
},
|
||||
],
|
||||
documentID: 'DOC-202',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const customContent = result.print_data.contents.find(content => content && content.data && Array.isArray(content.data.list));
|
||||
assert.ok(customContent);
|
||||
assert.ok(customContent.data.list[0].text.includes('W021 圆通 商品数量【3】'));
|
||||
assert.ok(customContent.data.list[0].text.includes('C1-01-01 9988776655443 【3】'));
|
||||
});
|
||||
|
||||
it('should parse string policy_config in getPolicyConfigMapByStore', async () => {
|
||||
const service = createOrderPrintServiceHarness();
|
||||
service.ctx.service.systems.storeWarehouse.getContractConfig = async () => ({
|
||||
policy_config: JSON.stringify({
|
||||
waybill_custom_display_type: '3',
|
||||
sender_name: '赵六',
|
||||
}),
|
||||
});
|
||||
|
||||
const policyMap = await service.getPolicyConfigMapByStore([
|
||||
{ store_id: 9 },
|
||||
], 100000);
|
||||
|
||||
const storePolicy = policyMap.get(9) || {};
|
||||
assert.equal(storePolicy.waybill_custom_display_type, '3');
|
||||
assert.equal(storePolicy.sender_name, '赵六');
|
||||
});
|
||||
|
||||
it('should default to literal compose when waybill display type is missing', () => {
|
||||
const service = createOrderPrintServiceHarness();
|
||||
|
||||
const result = service.buildOrderPlatformPrintItem({
|
||||
orderRow: {
|
||||
id: 203,
|
||||
wave_id: 22,
|
||||
wave_no: 'W022',
|
||||
delivery_order_code: 'DO203',
|
||||
store_id: 1,
|
||||
warehouse_id: 100000,
|
||||
items: JSON.stringify([
|
||||
{
|
||||
item_name: '皮带黑色',
|
||||
pick_location: 'E2区08-05-02',
|
||||
barcode: '665835404213',
|
||||
quantity: 1,
|
||||
},
|
||||
]),
|
||||
},
|
||||
orderExpress: {
|
||||
waybill_code: 'WB203',
|
||||
printinfo: 'ENC_203',
|
||||
signature: 'SIG_203',
|
||||
logistics_name: '韵达',
|
||||
},
|
||||
policyConfig: {
|
||||
province_name: '广东省',
|
||||
city_name: '广州市',
|
||||
district_name: '白云区',
|
||||
address: '良沙二路32号',
|
||||
sender_name: '刘付明仁',
|
||||
sender_tel: '18022440198',
|
||||
},
|
||||
platformCode: 'pdd',
|
||||
templateSample: {
|
||||
cmd: 'print',
|
||||
requestID: 'REQ-203',
|
||||
version: '11',
|
||||
task: {
|
||||
documents: [
|
||||
{
|
||||
contents: [
|
||||
{
|
||||
addData: {
|
||||
sender: {
|
||||
address: {
|
||||
city: '',
|
||||
detail: '',
|
||||
district: '',
|
||||
province: '',
|
||||
},
|
||||
mobile: '',
|
||||
name: '',
|
||||
},
|
||||
},
|
||||
encryptedData: '',
|
||||
signature: '',
|
||||
templateUrl: 'https://file-link.pinduoduo.com/sto_one',
|
||||
userid: '',
|
||||
ver: '11',
|
||||
},
|
||||
{
|
||||
data: {
|
||||
height: 240,
|
||||
list: [
|
||||
{
|
||||
fontSize: 28,
|
||||
left: 2.08,
|
||||
text: '',
|
||||
top: 2.08,
|
||||
width: 550,
|
||||
},
|
||||
],
|
||||
waterdata: {
|
||||
text: '',
|
||||
},
|
||||
width: 560,
|
||||
},
|
||||
templateURL: 'http://www.ye4s.com/mb/pdd.xml',
|
||||
},
|
||||
],
|
||||
documentID: 'DOC-203',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const customContent = result.print_data.contents.find(content => content && content.data && Array.isArray(content.data.list));
|
||||
assert.ok(customContent);
|
||||
assert.ok(customContent.data.list[0].text.includes('W022 韵达 商品数量【1】'));
|
||||
assert.ok(customContent.data.list[0].text.includes('E2区08-05-02 皮带黑色 665835404213 【1】'));
|
||||
});
|
||||
|
||||
it('should keep header line when item details are unavailable', () => {
|
||||
const service = createOrderPrintServiceHarness();
|
||||
|
||||
const result = service.buildOrderPlatformPrintItem({
|
||||
orderRow: {
|
||||
id: 204,
|
||||
wave_id: 23,
|
||||
wave_no: 'W023',
|
||||
delivery_order_code: 'DO204',
|
||||
store_id: 1,
|
||||
warehouse_id: 100000,
|
||||
items: '',
|
||||
items_count: 2,
|
||||
},
|
||||
orderExpress: {
|
||||
waybill_code: 'WB204',
|
||||
printinfo: 'ENC_204',
|
||||
signature: 'SIG_204',
|
||||
logistics_name: '中通',
|
||||
},
|
||||
policyConfig: {
|
||||
waybill_custom_display_type: '5',
|
||||
province_name: '广东省',
|
||||
city_name: '广州市',
|
||||
district_name: '白云区',
|
||||
address: '良沙二路32号',
|
||||
sender_name: '刘付明仁',
|
||||
sender_tel: '18022440198',
|
||||
},
|
||||
platformCode: 'pdd',
|
||||
templateSample: {
|
||||
cmd: 'print',
|
||||
requestID: 'REQ-204',
|
||||
version: '11',
|
||||
task: {
|
||||
documents: [
|
||||
{
|
||||
contents: [
|
||||
{
|
||||
addData: {
|
||||
sender: {
|
||||
address: {
|
||||
city: '',
|
||||
detail: '',
|
||||
district: '',
|
||||
province: '',
|
||||
},
|
||||
mobile: '',
|
||||
name: '',
|
||||
},
|
||||
},
|
||||
encryptedData: '',
|
||||
signature: '',
|
||||
templateUrl: 'https://file-link.pinduoduo.com/sto_one',
|
||||
userid: '',
|
||||
ver: '11',
|
||||
},
|
||||
{
|
||||
data: {
|
||||
height: 240,
|
||||
list: [
|
||||
{
|
||||
fontSize: 28,
|
||||
left: 2.08,
|
||||
text: '',
|
||||
top: 2.08,
|
||||
width: 550,
|
||||
},
|
||||
],
|
||||
waterdata: {
|
||||
text: '',
|
||||
},
|
||||
width: 560,
|
||||
},
|
||||
templateURL: 'http://www.ye4s.com/mb/pdd.xml',
|
||||
},
|
||||
],
|
||||
documentID: 'DOC-204',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const customContent = result.print_data.contents.find(content => content && content.data && Array.isArray(content.data.list));
|
||||
assert.ok(customContent);
|
||||
assert.equal(customContent.data.list[0].text, 'W023 中通 商品数量【2】\r');
|
||||
});
|
||||
|
||||
it('should render detail lines from non-json string items', () => {
|
||||
const service = createOrderPrintServiceHarness();
|
||||
|
||||
const result = service.buildOrderPlatformPrintItem({
|
||||
orderRow: {
|
||||
id: 205,
|
||||
wave_id: 24,
|
||||
wave_no: 'W024',
|
||||
delivery_order_code: 'DO205',
|
||||
store_id: 1,
|
||||
warehouse_id: 100000,
|
||||
items: '皮带黑色*1|皮带金色*2',
|
||||
items_count: 2,
|
||||
},
|
||||
orderExpress: {
|
||||
waybill_code: 'WB205',
|
||||
printinfo: 'ENC_205',
|
||||
signature: 'SIG_205',
|
||||
logistics_name: '申通快递',
|
||||
},
|
||||
policyConfig: {
|
||||
waybill_custom_display_type: '2',
|
||||
province_name: '广东省',
|
||||
city_name: '广州市',
|
||||
district_name: '白云区',
|
||||
address: '良沙二路32号',
|
||||
sender_name: '刘付明仁',
|
||||
sender_tel: '18022440198',
|
||||
},
|
||||
platformCode: 'kuaishou',
|
||||
templateSample: {
|
||||
cmd: 'print',
|
||||
requestID: 'REQ-205',
|
||||
version: '1.0',
|
||||
task: {
|
||||
documents: [
|
||||
{
|
||||
contents: [
|
||||
{
|
||||
encryptedData: '',
|
||||
signature: '',
|
||||
key: '',
|
||||
templateURL: 'https://example.com/kuaishou.xml',
|
||||
},
|
||||
{
|
||||
templateURL: 'http://www.ye4s.com/mb/kuaishou.xml',
|
||||
customData: {
|
||||
productInfo: '',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const customDataContent = result.print_data.contents.find(content => content && content.customData);
|
||||
assert.ok(customDataContent);
|
||||
assert.ok(customDataContent.customData.productInfo.includes('W024 申通快递 商品数量【3】'));
|
||||
assert.ok(customDataContent.customData.productInfo.includes('皮带黑色 【1】'));
|
||||
assert.ok(customDataContent.customData.productInfo.includes('皮带金色 【2】'));
|
||||
});
|
||||
|
||||
it('should render display type 4 as pick location + last 5 barcode + qty per line', () => {
|
||||
const service = createOrderPrintServiceHarness();
|
||||
|
||||
const result = service.buildOrderPlatformPrintItem({
|
||||
orderRow: {
|
||||
id: 206,
|
||||
wave_id: 25,
|
||||
wave_no: 'W025',
|
||||
delivery_order_code: 'DO206',
|
||||
store_id: 1,
|
||||
warehouse_id: 100000,
|
||||
items: 'E2区08-05-02 皮带黑色;665835404213 【1】 0|E2区08-04-02 皮带金色;600507 【1】 0',
|
||||
items_count: 2,
|
||||
},
|
||||
orderExpress: {
|
||||
waybill_code: 'WB206',
|
||||
printinfo: 'ENC_206',
|
||||
signature: 'SIG_206',
|
||||
logistics_name: '顺丰空运',
|
||||
},
|
||||
policyConfig: {
|
||||
waybill_custom_display_type: '4',
|
||||
province_name: '广东省',
|
||||
city_name: '广州市',
|
||||
district_name: '白云区',
|
||||
address: '良沙二路32号',
|
||||
sender_name: '刘付明仁',
|
||||
sender_tel: '18022440198',
|
||||
},
|
||||
platformCode: 'pdd',
|
||||
templateSample: {
|
||||
cmd: 'print',
|
||||
requestID: 'REQ-206',
|
||||
version: '11',
|
||||
task: {
|
||||
documents: [
|
||||
{
|
||||
contents: [
|
||||
{
|
||||
addData: {
|
||||
sender: {
|
||||
address: {
|
||||
city: '',
|
||||
detail: '',
|
||||
district: '',
|
||||
province: '',
|
||||
},
|
||||
mobile: '',
|
||||
name: '',
|
||||
},
|
||||
},
|
||||
encryptedData: '',
|
||||
signature: '',
|
||||
templateUrl: 'https://file-link.pinduoduo.com/sto_one',
|
||||
userid: '',
|
||||
ver: '11',
|
||||
},
|
||||
{
|
||||
data: {
|
||||
height: 240,
|
||||
list: [
|
||||
{
|
||||
fontSize: 28,
|
||||
left: 2.08,
|
||||
text: '',
|
||||
top: 2.08,
|
||||
width: 550,
|
||||
},
|
||||
],
|
||||
waterdata: {
|
||||
text: '',
|
||||
},
|
||||
width: 560,
|
||||
},
|
||||
templateURL: 'http://www.ye4s.com/mb/pdd.xml',
|
||||
},
|
||||
],
|
||||
documentID: 'DOC-206',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const customContent = result.print_data.contents.find(content => content && content.data && Array.isArray(content.data.list));
|
||||
assert.ok(customContent);
|
||||
const text = customContent.data.list[0].text;
|
||||
assert.ok(text.includes('W025 顺丰空运 商品数量【2】'));
|
||||
assert.ok(text.includes('E2区08-05-02 04213 【1】'));
|
||||
assert.ok(text.includes('E2区08-04-02 00507 【1】'));
|
||||
assert.ok(!text.includes('\r【1】\r'));
|
||||
});
|
||||
|
||||
it('should query order_express with kuaishou encrypted payload columns', async () => {
|
||||
const service = createOrderPrintServiceHarness();
|
||||
let capturedAttributes = [];
|
||||
@ -236,6 +696,7 @@ describe('test/app/service/systems/order_print.getWavePlatformPrintData.test.js'
|
||||
assert.ok(capturedAttributes.includes('printinfo'));
|
||||
assert.ok(capturedAttributes.includes('signature'));
|
||||
assert.ok(capturedAttributes.includes('encryptprintinfo'));
|
||||
assert.ok(capturedAttributes.includes('logistics_interface_name'));
|
||||
assert.equal(capturedWhere.business_key, 1);
|
||||
});
|
||||
|
||||
@ -448,4 +909,292 @@ describe('test/app/service/systems/order_print.getWavePlatformPrintData.test.js'
|
||||
filtered_wave_ids: [],
|
||||
});
|
||||
});
|
||||
|
||||
it('should batch load picking locations from wms_picking for print items', async () => {
|
||||
const service = createOrderPrintServiceHarness();
|
||||
const currentOrderItemsModel = {
|
||||
async findAll() {
|
||||
return [
|
||||
{
|
||||
id: 5001,
|
||||
order_id: 301,
|
||||
item_code: 'SKU-301',
|
||||
item_name: '商品301',
|
||||
plan_qty: 1,
|
||||
item_snapshot: {
|
||||
barcode: '9988776655443',
|
||||
},
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
service.ctx.model.Picking = {
|
||||
async findAll() {
|
||||
return [
|
||||
{
|
||||
id: 1,
|
||||
order_id: 301,
|
||||
order_item_id: 5001,
|
||||
quantity: 1,
|
||||
space_id: 9001,
|
||||
space_name: 'E2区08-05-02',
|
||||
status: 'pending',
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
service.ctx.model.OrderItemsFactory = {
|
||||
async getCurrentModel() {
|
||||
return currentOrderItemsModel;
|
||||
},
|
||||
};
|
||||
service.ctx.model.LocationSpace = {
|
||||
async findAll() {
|
||||
throw new Error('space_name 已存在时不应查询库位表');
|
||||
},
|
||||
};
|
||||
|
||||
service.queryWavesByIds = async () => ([
|
||||
{ wave_id: 30, wave_no: 'W030' },
|
||||
]);
|
||||
service.queryOrdersByWaveIds = async () => ([
|
||||
{
|
||||
id: 301,
|
||||
wave_id: 30,
|
||||
wave_no: 'W030',
|
||||
warehouse_id: 100000,
|
||||
store_id: 1,
|
||||
delivery_order_code: 'O301',
|
||||
post_status: 'fin',
|
||||
sys_platform_code: 'pdd',
|
||||
items: '',
|
||||
},
|
||||
]);
|
||||
service.filterFullyAssignedExpressWaves = () => ({
|
||||
validWaveIds: [ 30 ],
|
||||
filteredWaveIds: [],
|
||||
});
|
||||
service.queryOrderExpressByOrderIds = async () => ([
|
||||
{
|
||||
order_id: 301,
|
||||
business_key: 1,
|
||||
waybill_code: 'WB301',
|
||||
logistics_name: '顺丰空运',
|
||||
},
|
||||
]);
|
||||
service.queryWaveOrderIndexMapByOrderIds = async () => new Map([
|
||||
[ 301, {
|
||||
wave_id: 30,
|
||||
wave_index: 12,
|
||||
platforms_index: 3,
|
||||
} ],
|
||||
]);
|
||||
service.queryWaveTotalOrderCountMap = async () => new Map([
|
||||
[ 30, 66 ],
|
||||
]);
|
||||
service.getPolicyConfigMapByStore = async () => new Map([
|
||||
[ 1, {
|
||||
waybill_custom_display_type: '4',
|
||||
} ],
|
||||
]);
|
||||
service.loadTemplateSampleByPlatform = () => ({
|
||||
cmd: 'print',
|
||||
requestID: 'REQ-301',
|
||||
version: '11',
|
||||
task: {
|
||||
documents: [
|
||||
{
|
||||
contents: [
|
||||
{
|
||||
addData: {
|
||||
sender: {
|
||||
address: {},
|
||||
},
|
||||
},
|
||||
encryptedData: '',
|
||||
signature: '',
|
||||
templateUrl: 'https://file-link.pinduoduo.com/sto_one',
|
||||
userid: '',
|
||||
ver: '11',
|
||||
},
|
||||
{
|
||||
templateURL: 'http://www.ye4s.com/mb/pdd.xml',
|
||||
data: {
|
||||
height: 240,
|
||||
list: [
|
||||
{
|
||||
fontSize: 28,
|
||||
left: 2.08,
|
||||
text: '',
|
||||
top: 2.08,
|
||||
width: 550,
|
||||
},
|
||||
],
|
||||
waterdata: {
|
||||
text: '',
|
||||
},
|
||||
width: 560,
|
||||
},
|
||||
},
|
||||
],
|
||||
documentID: 'DOC-301',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const result = await service.getWavePlatformPrintData({
|
||||
waveIds: [ 30 ],
|
||||
warehouseId: 100000,
|
||||
});
|
||||
|
||||
const printText = result.waveGroups[0].platforms[0].orders[0].contents[1].data.list[0].text;
|
||||
assert.ok(printText.includes('【66】W030_12_3'));
|
||||
assert.ok(printText.includes('E2区08-05-02 55443 【1】'));
|
||||
});
|
||||
|
||||
it('should prefer snapshot item_name for display type 2 in getWavePlatformPrintData', async () => {
|
||||
const service = createOrderPrintServiceHarness();
|
||||
const currentOrderItemsModel = {
|
||||
async findAll() {
|
||||
return [
|
||||
{
|
||||
id: 6001,
|
||||
order_id: 302,
|
||||
item_code: 'SKU-302',
|
||||
item_name: '旧商品名-不应展示',
|
||||
plan_qty: 1,
|
||||
item_snapshot: {
|
||||
item_name: '快照商品名-应展示',
|
||||
},
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
service.ctx.model.Picking = {
|
||||
async findAll() {
|
||||
return [
|
||||
{
|
||||
id: 2,
|
||||
order_id: 302,
|
||||
order_item_id: 6001,
|
||||
quantity: 1,
|
||||
space_id: 9101,
|
||||
space_name: 'A1区01-01-01',
|
||||
status: 'pending',
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
service.ctx.model.OrderItemsFactory = {
|
||||
async getCurrentModel() {
|
||||
return currentOrderItemsModel;
|
||||
},
|
||||
};
|
||||
service.ctx.model.LocationSpace = {
|
||||
async findAll() {
|
||||
throw new Error('space_name 已存在时不应查询库位表');
|
||||
},
|
||||
};
|
||||
|
||||
service.queryWavesByIds = async () => ([
|
||||
{ wave_id: 31, wave_no: 'W031' },
|
||||
]);
|
||||
service.queryOrdersByWaveIds = async () => ([
|
||||
{
|
||||
id: 302,
|
||||
wave_id: 31,
|
||||
wave_no: 'W031',
|
||||
warehouse_id: 100000,
|
||||
store_id: 1,
|
||||
delivery_order_code: 'O302',
|
||||
post_status: 'fin',
|
||||
sys_platform_code: 'pdd',
|
||||
items: '',
|
||||
},
|
||||
]);
|
||||
service.filterFullyAssignedExpressWaves = () => ({
|
||||
validWaveIds: [ 31 ],
|
||||
filteredWaveIds: [],
|
||||
});
|
||||
service.queryOrderExpressByOrderIds = async () => ([
|
||||
{
|
||||
order_id: 302,
|
||||
business_key: 1,
|
||||
waybill_code: 'WB302',
|
||||
logistics_name: '圆通',
|
||||
},
|
||||
]);
|
||||
service.queryWaveOrderIndexMapByOrderIds = async () => new Map([
|
||||
[ 302, {
|
||||
wave_id: 31,
|
||||
wave_index: 1,
|
||||
platforms_index: 1,
|
||||
} ],
|
||||
]);
|
||||
service.queryWaveTotalOrderCountMap = async () => new Map([
|
||||
[ 31, 10 ],
|
||||
]);
|
||||
service.getPolicyConfigMapByStore = async () => new Map([
|
||||
[ 1, {
|
||||
waybill_custom_display_type: '2',
|
||||
} ],
|
||||
]);
|
||||
service.loadTemplateSampleByPlatform = () => ({
|
||||
cmd: 'print',
|
||||
requestID: 'REQ-302',
|
||||
version: '11',
|
||||
task: {
|
||||
documents: [
|
||||
{
|
||||
contents: [
|
||||
{
|
||||
addData: {
|
||||
sender: {
|
||||
address: {},
|
||||
},
|
||||
},
|
||||
encryptedData: '',
|
||||
signature: '',
|
||||
templateUrl: 'https://file-link.pinduoduo.com/sto_one',
|
||||
userid: '',
|
||||
ver: '11',
|
||||
},
|
||||
{
|
||||
templateURL: 'http://www.ye4s.com/mb/pdd.xml',
|
||||
data: {
|
||||
height: 240,
|
||||
list: [
|
||||
{
|
||||
fontSize: 28,
|
||||
left: 2.08,
|
||||
text: '',
|
||||
top: 2.08,
|
||||
width: 550,
|
||||
},
|
||||
],
|
||||
waterdata: {
|
||||
text: '',
|
||||
},
|
||||
width: 560,
|
||||
},
|
||||
},
|
||||
],
|
||||
documentID: 'DOC-302',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const result = await service.getWavePlatformPrintData({
|
||||
waveIds: [ 31 ],
|
||||
warehouseId: 100000,
|
||||
});
|
||||
|
||||
const printText = result.waveGroups[0].platforms[0].orders[0].contents[1].data.list[0].text;
|
||||
assert.ok(printText.includes('快照商品名-应展示'));
|
||||
assert.ok(!printText.includes('旧商品名-不应展示'));
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user