ming #1
@ -986,6 +986,8 @@ class WaveService extends OrderBaseService {
|
|||||||
intercept_status: 'none',
|
intercept_status: 'none',
|
||||||
lock_status: 'none',
|
lock_status: 'none',
|
||||||
wave_id: 0,
|
wave_id: 0,
|
||||||
|
// 波次抓取不抓取 B2B 订单(NULL 视为非 B2B,兼容存量行)
|
||||||
|
is_b2b: { [Op.or]: [{ [Op.is]: null }, 'N' ] },
|
||||||
};
|
};
|
||||||
|
|
||||||
const itemPartType = String(structure.item_part_type || '').trim();
|
const itemPartType = String(structure.item_part_type || '').trim();
|
||||||
@ -2913,6 +2915,8 @@ class WaveService extends OrderBaseService {
|
|||||||
intercept_status: 'none',
|
intercept_status: 'none',
|
||||||
lock_status: 'none',
|
lock_status: 'none',
|
||||||
wave_id: 0,
|
wave_id: 0,
|
||||||
|
// 波次抓取不抓取 B2B 订单(NULL 视为非 B2B,兼容存量行)
|
||||||
|
is_b2b: { [Op.or]: [{ [Op.is]: null }, 'N' ] },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (storeId > 0) {
|
if (storeId > 0) {
|
||||||
@ -3167,6 +3171,8 @@ class WaveService extends OrderBaseService {
|
|||||||
intercept_status: 'none',
|
intercept_status: 'none',
|
||||||
lock_status: 'none',
|
lock_status: 'none',
|
||||||
wave_id: 0,
|
wave_id: 0,
|
||||||
|
// 波次抓取不抓取 B2B 订单(NULL 视为非 B2B,兼容存量行)
|
||||||
|
is_b2b: { [Op.or]: [{ [Op.is]: null }, 'N' ] },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (storeId > 0) {
|
if (storeId > 0) {
|
||||||
@ -3431,6 +3437,8 @@ class WaveService extends OrderBaseService {
|
|||||||
intercept_status: 'none',
|
intercept_status: 'none',
|
||||||
lock_status: 'none',
|
lock_status: 'none',
|
||||||
wave_id: 0,
|
wave_id: 0,
|
||||||
|
// 波次抓取不抓取 B2B 订单(NULL 视为非 B2B,兼容存量行)
|
||||||
|
is_b2b: { [Op.or]: [{ [Op.is]: null }, 'N' ] },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (storeId > 0) {
|
if (storeId > 0) {
|
||||||
@ -3734,6 +3742,7 @@ class WaveService extends OrderBaseService {
|
|||||||
AND o.outbound_status != 'padding'
|
AND o.outbound_status != 'padding'
|
||||||
AND o.intercept_status = 'none'
|
AND o.intercept_status = 'none'
|
||||||
AND o.lock_status = 'none'
|
AND o.lock_status = 'none'
|
||||||
|
AND (o.is_b2b IS NULL OR o.is_b2b = 'N')
|
||||||
WHERE m.warehouse_id = :warehouseId
|
WHERE m.warehouse_id = :warehouseId
|
||||||
AND m.strategy_id = :strategyId
|
AND m.strategy_id = :strategyId
|
||||||
ORDER BY o.id ASC
|
ORDER BY o.id ASC
|
||||||
@ -3975,6 +3984,7 @@ class WaveService extends OrderBaseService {
|
|||||||
AND o.outbound_status != 'padding'
|
AND o.outbound_status != 'padding'
|
||||||
AND o.intercept_status = 'none'
|
AND o.intercept_status = 'none'
|
||||||
AND o.lock_status = 'none'
|
AND o.lock_status = 'none'
|
||||||
|
AND (o.is_b2b IS NULL OR o.is_b2b = 'N')
|
||||||
INNER JOIN (
|
INNER JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
src.items_hash AS structure_key${groupKeyExtra},
|
src.items_hash AS structure_key${groupKeyExtra},
|
||||||
@ -3990,6 +4000,7 @@ class WaveService extends OrderBaseService {
|
|||||||
AND src.outbound_status != 'padding'
|
AND src.outbound_status != 'padding'
|
||||||
AND src.intercept_status = 'none'
|
AND src.intercept_status = 'none'
|
||||||
AND src.lock_status = 'none'
|
AND src.lock_status = 'none'
|
||||||
|
AND (src.is_b2b IS NULL OR src.is_b2b = 'N')
|
||||||
GROUP BY src.items_hash${requireSameExpress ? `, ${expressExpr('src')}` : ''}
|
GROUP BY src.items_hash${requireSameExpress ? `, ${expressExpr('src')}` : ''}
|
||||||
) same_structure
|
) same_structure
|
||||||
ON same_structure.structure_key = o.items_hash${joinKeyExtra}
|
ON same_structure.structure_key = o.items_hash${joinKeyExtra}
|
||||||
@ -4077,6 +4088,7 @@ class WaveService extends OrderBaseService {
|
|||||||
AND o.outbound_status != 'padding'
|
AND o.outbound_status != 'padding'
|
||||||
AND o.intercept_status = 'none'
|
AND o.intercept_status = 'none'
|
||||||
AND o.lock_status = 'none'
|
AND o.lock_status = 'none'
|
||||||
|
AND (o.is_b2b IS NULL OR o.is_b2b = 'N')
|
||||||
INNER JOIN (
|
INNER JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
src.items_hash AS structure_key${groupKeyExtra},
|
src.items_hash AS structure_key${groupKeyExtra},
|
||||||
@ -4092,6 +4104,7 @@ class WaveService extends OrderBaseService {
|
|||||||
AND src.outbound_status != 'padding'
|
AND src.outbound_status != 'padding'
|
||||||
AND src.intercept_status = 'none'
|
AND src.intercept_status = 'none'
|
||||||
AND src.lock_status = 'none'
|
AND src.lock_status = 'none'
|
||||||
|
AND (src.is_b2b IS NULL OR src.is_b2b = 'N')
|
||||||
GROUP BY src.items_hash${requireSameExpress ? `, ${expressExpr('src')}` : ''}
|
GROUP BY src.items_hash${requireSameExpress ? `, ${expressExpr('src')}` : ''}
|
||||||
) same_structure
|
) same_structure
|
||||||
ON same_structure.structure_key = o.items_hash${joinKeyExtra}
|
ON same_structure.structure_key = o.items_hash${joinKeyExtra}
|
||||||
@ -6943,6 +6956,8 @@ class WaveService extends OrderBaseService {
|
|||||||
intercept_status: 'none',
|
intercept_status: 'none',
|
||||||
lock_status: 'none',
|
lock_status: 'none',
|
||||||
print_status: { [Op.ne]: 'fin' },
|
print_status: { [Op.ne]: 'fin' },
|
||||||
|
// 波次策略扫描不扫描 B2B 订单(NULL 视为非 B2B,兼容存量行)
|
||||||
|
is_b2b: { [Op.or]: [{ [Op.is]: null }, 'N' ] },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!forceRescan) {
|
if (!forceRescan) {
|
||||||
@ -7502,6 +7517,7 @@ class WaveService extends OrderBaseService {
|
|||||||
intercept_status: 'none',
|
intercept_status: 'none',
|
||||||
lock_status: 'none',
|
lock_status: 'none',
|
||||||
print_status: { [Op.ne]: 'fin' },
|
print_status: { [Op.ne]: 'fin' },
|
||||||
|
is_b2b: { [Op.or]: [{ [Op.is]: null }, 'N' ] },
|
||||||
[Op.or]: [
|
[Op.or]: [
|
||||||
{ wave_strategy_version: { [Op.ne]: currentVersion } },
|
{ wave_strategy_version: { [Op.ne]: currentVersion } },
|
||||||
{ wave_strategy_version: { [Op.is]: null } },
|
{ wave_strategy_version: { [Op.is]: null } },
|
||||||
@ -8188,6 +8204,8 @@ class WaveService extends OrderBaseService {
|
|||||||
step: { [Op.in]: [ 1, 2, 3 ] },
|
step: { [Op.in]: [ 1, 2, 3 ] },
|
||||||
status: { [Op.ne]: 'cancel' },
|
status: { [Op.ne]: 'cancel' },
|
||||||
outbound_status: { [Op.ne]: 'padding' },
|
outbound_status: { [Op.ne]: 'padding' },
|
||||||
|
// 波次抓取不抓取 B2B 订单(NULL 视为非 B2B,兼容存量行)
|
||||||
|
is_b2b: { [Op.or]: [{ [Op.is]: null }, 'N' ] },
|
||||||
[Op.or]: candidateWhereList,
|
[Op.or]: candidateWhereList,
|
||||||
},
|
},
|
||||||
raw: true,
|
raw: true,
|
||||||
@ -8276,7 +8294,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', 'lock_status', 'is_b2b' ],
|
||||||
where: {
|
where: {
|
||||||
id: { [Op.in]: normalizedIds },
|
id: { [Op.in]: normalizedIds },
|
||||||
},
|
},
|
||||||
@ -8305,6 +8323,12 @@ 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);
|
||||||
|
// B2B 订单不参与波次抓取(NULL 视为非 B2B,兼容存量行)
|
||||||
|
const excludedB2bOrderIds = [ ...new Set(normalizedOrderRows
|
||||||
|
.filter(row => String(row && row.is_b2b || '').trim() === 'Y')
|
||||||
|
.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);
|
||||||
@ -8328,6 +8352,11 @@ class WaveService extends OrderBaseService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// B2B 订单不允许抓取波次
|
||||||
|
if (String(row && row.is_b2b || '').trim() === 'Y') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -8349,6 +8378,7 @@ class WaveService extends OrderBaseService {
|
|||||||
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,
|
excluded_locked_order_ids: excludedLockedOrderIds,
|
||||||
|
excluded_b2b_order_ids: excludedB2bOrderIds,
|
||||||
skipped_order_ids: skippedOrderIds,
|
skipped_order_ids: skippedOrderIds,
|
||||||
not_found_order_ids: notFoundOrderIds,
|
not_found_order_ids: notFoundOrderIds,
|
||||||
});
|
});
|
||||||
@ -8467,6 +8497,7 @@ class WaveService extends OrderBaseService {
|
|||||||
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,
|
excluded_locked_order_ids: excludedLockedOrderIds,
|
||||||
|
excluded_b2b_order_ids: excludedB2bOrderIds,
|
||||||
skipped_order_ids: skippedOrderIds,
|
skipped_order_ids: skippedOrderIds,
|
||||||
not_found_order_ids: notFoundOrderIds,
|
not_found_order_ids: notFoundOrderIds,
|
||||||
});
|
});
|
||||||
@ -11858,6 +11889,7 @@ class WaveService extends OrderBaseService {
|
|||||||
AND o.outbound_status != 'padding'
|
AND o.outbound_status != 'padding'
|
||||||
AND o.intercept_status = 'none'
|
AND o.intercept_status = 'none'
|
||||||
AND o.lock_status = 'none'
|
AND o.lock_status = 'none'
|
||||||
|
AND (o.is_b2b IS NULL OR o.is_b2b = 'N')
|
||||||
AND (:createdBefore IS NULL OR o.create_at < :createdBefore)
|
AND (:createdBefore IS NULL OR o.create_at < :createdBefore)
|
||||||
INNER JOIN (
|
INNER JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
@ -11874,6 +11906,7 @@ class WaveService extends OrderBaseService {
|
|||||||
AND src.outbound_status != 'padding'
|
AND src.outbound_status != 'padding'
|
||||||
AND src.intercept_status = 'none'
|
AND src.intercept_status = 'none'
|
||||||
AND src.lock_status = 'none'
|
AND src.lock_status = 'none'
|
||||||
|
AND (src.is_b2b IS NULL OR src.is_b2b = 'N')
|
||||||
GROUP BY ${structureExpr('src')}${groupKeyExtra}
|
GROUP BY ${structureExpr('src')}${groupKeyExtra}
|
||||||
) same_structure
|
) same_structure
|
||||||
ON same_structure.structure_key = ${structureExpr('o')}${joinKeyExtra}
|
ON same_structure.structure_key = ${structureExpr('o')}${joinKeyExtra}
|
||||||
@ -12152,6 +12185,8 @@ class WaveService extends OrderBaseService {
|
|||||||
step: { [Op.ne]: 0 },
|
step: { [Op.ne]: 0 },
|
||||||
status: { [Op.ne]: 'cancel' },
|
status: { [Op.ne]: 'cancel' },
|
||||||
outbound_status: { [Op.ne]: 'padding' },
|
outbound_status: { [Op.ne]: 'padding' },
|
||||||
|
// 尾部兜底:候选筛选后再次排除 B2B 订单(NULL 视为非 B2B,兼容存量行)
|
||||||
|
is_b2b: { [Op.or]: [{ [Op.is]: null }, 'N' ] },
|
||||||
},
|
},
|
||||||
raw: true,
|
raw: true,
|
||||||
transaction,
|
transaction,
|
||||||
@ -12402,6 +12437,7 @@ class WaveService extends OrderBaseService {
|
|||||||
AND o.outbound_status != 'padding'
|
AND o.outbound_status != 'padding'
|
||||||
AND o.intercept_status = 'none'
|
AND o.intercept_status = 'none'
|
||||||
AND o.lock_status = 'none'
|
AND o.lock_status = 'none'
|
||||||
|
AND (o.is_b2b IS NULL OR o.is_b2b = 'N')
|
||||||
AND ${structureExpr('o')} IN (:structureKeys)${expressCondition}
|
AND ${structureExpr('o')} IN (:structureKeys)${expressCondition}
|
||||||
ORDER BY o.id ASC
|
ORDER BY o.id ASC
|
||||||
`, {
|
`, {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user