refactor(order): 自动出库当天订单开关改排除语义,allow_same_day_outbound 更名为 exclude_same_day_outbound(默认排除)

This commit is contained in:
liufumingren 2026-09-23 02:46:11 +08:00
parent ec632cf3e5
commit 01acf106ae
4 changed files with 18 additions and 18 deletions

View File

@ -39,7 +39,7 @@ module.exports = app => {
require_sync: true, require_sync: true,
require_print: true, require_print: true,
require_pick: true, require_pick: true,
allow_same_day_outbound: false, exclude_same_day_outbound: true,
same_day_outbound_deadline_time: '06:00', same_day_outbound_deadline_time: '06:00',
same_day_outbound_release_time: '22:00', same_day_outbound_release_time: '22:00',
}); });
@ -269,7 +269,7 @@ module.exports = app => {
require_sync: parsed.require_sync !== false, require_sync: parsed.require_sync !== false,
require_print: parsed.require_print !== false, require_print: parsed.require_print !== false,
require_pick: parsed.require_pick !== false, require_pick: parsed.require_pick !== false,
allow_same_day_outbound: normalizeBooleanFlag(parsed.allow_same_day_outbound, 'auto_outbound_rules.allow_same_day_outbound') === true, exclude_same_day_outbound: normalizeBooleanFlag(parsed.exclude_same_day_outbound, 'auto_outbound_rules.exclude_same_day_outbound') !== false,
same_day_outbound_deadline_time: sameDayOutboundDeadlineTime, same_day_outbound_deadline_time: sameDayOutboundDeadlineTime,
same_day_outbound_release_time: sameDayOutboundReleaseTime, same_day_outbound_release_time: sameDayOutboundReleaseTime,
}; };

View File

@ -15,11 +15,11 @@
* *
* 各条件是否必须可由仓库配置独立控制。 * 各条件是否必须可由仓库配置独立控制。
* *
* 当天订单限制(allow_same_day_outbound,默认 false): * 当天订单限制(exclude_same_day_outbound,默认 true):
* 未开启时,在当天放开时间(same_day_outbound_release_time,默认北京时间 22:00)前, * 开启时,在当天放开时间(same_day_outbound_release_time,默认北京时间 22:00)前,
* 北京时间当天「允许当天出库最后时间」(same_day_outbound_deadline_time,默认 06:00) * 北京时间当天「允许当天出库最后时间」(same_day_outbound_deadline_time,默认 06:00)
* 起复核(recheck_time)的订单不自动出库; * 起复核(recheck_time)的订单不自动出库;
* 到达放开时间后当天复核订单恢复自动出库。开启则全程不受限制。 * 到达放开时间后当天复核订单恢复自动出库。关闭则全程不受限制。
*/ */
module.exports = { module.exports = {
schedule: { schedule: {

View File

@ -117,15 +117,15 @@ class OrderAutoOutboundService extends MainService {
* - {boolean} [rules.require_sync] 是否要求已同步(sync_status='fin') * - {boolean} [rules.require_sync] 是否要求已同步(sync_status='fin')
* - {boolean} [rules.require_print] 是否要求已打印(print_status='fin') * - {boolean} [rules.require_print] 是否要求已打印(print_status='fin')
* - {boolean} [rules.require_pick] 是否要求已拣货(pick_status='fin') * - {boolean} [rules.require_pick] 是否要求已拣货(pick_status='fin')
* - {boolean} [rules.allow_same_day_outbound] 是否允许当天复核订单当天出库(默认 false); * - {boolean} [rules.exclude_same_day_outbound] 是否不出库当天复核订单(默认 true);
* 为 false 时,在到达当天放开时间(same_day_outbound_release_time,默认北京时间 22:00)前, * 为 true 时,在到达当天放开时间(same_day_outbound_release_time,默认北京时间 22:00)前,
* 北京时间当天「允许当天出库最后时间」(same_day_outbound_deadline_time,默认 06:00)起复核(recheck_time)的订单当天不参与自动出库; * 北京时间当天「允许当天出库最后时间」(same_day_outbound_deadline_time,默认 06:00)起复核(recheck_time)的订单当天不参与自动出库;
* recheck_time 早于该最后时间或为 null 的订单不受影响; * recheck_time 早于该最后时间或为 null 的订单不受影响;
* 到达放开时间后当天复核订单恢复自动出库。 * 到达放开时间后当天复核订单恢复自动出库。
* - {string} [rules.same_day_outbound_deadline_time] 允许当天出库最后时间(HH:mm,默认 '06:00'), * - {string} [rules.same_day_outbound_deadline_time] 允许当天出库最后时间(HH:mm,默认 '06:00'),
* 复核时间早于该时间的订单不受「出库当天订单」关闭的影响。 * 复核时间早于该时间的订单不受「不出库当天订单」开启的影响。
* - {string} [rules.same_day_outbound_release_time] 当天放开时间(HH:mm,默认 '22:00'), * - {string} [rules.same_day_outbound_release_time] 当天放开时间(HH:mm,默认 '22:00'),
* 仅在 allow_same_day_outbound 为 false 时生效。 * 仅在 exclude_same_day_outbound 为 true 时生效。
* @return {Object} Sequelize where 条件对象。 * @return {Object} Sequelize where 条件对象。
*/ */
buildAutoOutboundWhere(rules) { buildAutoOutboundWhere(rules) {
@ -141,11 +141,11 @@ class OrderAutoOutboundService extends MainService {
where.recheck_status = 'fin'; where.recheck_status = 'fin';
} }
// 未开启「出库当天订单」时:当天到达放开时间(默认北京时间 22:00)前, // 开启「不出库当天订单」(默认开启)时:当天到达放开时间(默认北京时间 22:00)前,
// 排除当天「允许当天出库最后时间」(默认 06:00)起复核的订单(recheck_time 为 null 不排除); // 排除当天「允许当天出库最后时间」(默认 06:00)起复核的订单(recheck_time 为 null 不排除);
// 到达放开时间后不再限制当天复核订单,当天即可出库。 // 到达放开时间后不再限制当天复核订单,当天即可出库。
// 注意:应用按 UTC 读写 DATETIME,recheck_time 存储为 UTC 时刻,边界需按北京时间(UTC+8)换算。 // 注意:应用按 UTC 读写 DATETIME,recheck_time 存储为 UTC 时刻,边界需按北京时间(UTC+8)换算。
if (rules.allow_same_day_outbound !== true) { if (rules.exclude_same_day_outbound !== false) {
const now = new Date(); const now = new Date();
const releaseUtc = this.buildSameDayReleaseUtc(now, rules.same_day_outbound_release_time); const releaseUtc = this.buildSameDayReleaseUtc(now, rules.same_day_outbound_release_time);
if (now.getTime() < releaseUtc.getTime()) { if (now.getTime() < releaseUtc.getTime()) {
@ -223,7 +223,7 @@ class OrderAutoOutboundService extends MainService {
* 计算「允许当天出库最后时间」边界(UTC 时刻)。 * 计算「允许当天出库最后时间」边界(UTC 时刻)。
* *
* 边界为北京时间当天配置时刻(默认 06:00,UTC+8): * 边界为北京时间当天配置时刻(默认 06:00,UTC+8):
* - recheck_time(UTC 存储)早于该边界 → 不受「出库当天订单」关闭影响,当天允许自动出库; * - recheck_time(UTC 存储)早于该边界 → 不受「不出库当天订单」开启影响,当天允许自动出库;
* - recheck_time 晚于或等于该边界 → 在到达当天放开时间前不自动出库, * - recheck_time 晚于或等于该边界 → 在到达当天放开时间前不自动出库,
* 到达放开时间(默认 22:00)后放开。 * 到达放开时间(默认 22:00)后放开。
* *
@ -274,8 +274,8 @@ class OrderAutoOutboundService extends MainService {
/** /**
* 计算北京时间当天「放开时间」对应的 UTC Date。 * 计算北京时间当天「放开时间」对应的 UTC Date。
* *
* 仅在未开启「出库当天订单」时使用:当前时刻早于该边界时, * 仅在开启「不出库当天订单」时使用:当前时刻早于该边界时,
* 当天 06:00 后复核的订单不自动出库;晚于或等于该边界时放开。 * 当天最后时间之后复核的订单不自动出库;晚于或等于该边界时放开。
* *
* @param {Date} [now] 当前时刻(默认 new Date())。 * @param {Date} [now] 当前时刻(默认 new Date())。
* @param {string} [timeText] 放开时间(HH:mm,默认 22:00)。 * @param {string} [timeText] 放开时间(HH:mm,默认 22:00)。

View File

@ -226,7 +226,7 @@ const WAREHOUSE_SETTING_FIELDS = Object.freeze([
key: 'auto_outbound_rules', key: 'auto_outbound_rules',
name: '自动出库规则', name: '自动出库规则',
type: 'object', type: 'object',
default: Object.freeze({ enabled: false, require_recheck: true, require_pack: true, require_weigh: true, require_sync: true, require_print: true, require_pick: true, allow_same_day_outbound: false, same_day_outbound_deadline_time: '06:00', same_day_outbound_release_time: '22:00' }), default: Object.freeze({ enabled: false, require_recheck: true, require_pack: true, require_weigh: true, require_sync: true, require_print: true, require_pick: true, exclude_same_day_outbound: true, same_day_outbound_deadline_time: '06:00', same_day_outbound_release_time: '22:00' }),
required: false, required: false,
description: '满足条件自动标记出库。全部条件满足时自动标记待出库', description: '满足条件自动标记出库。全部条件满足时自动标记待出库',
item_keys: Object.freeze([ item_keys: Object.freeze([
@ -237,9 +237,9 @@ const WAREHOUSE_SETTING_FIELDS = Object.freeze([
Object.freeze({ key: 'require_sync', name: '需已同步', type: 'flag', required: false, description: '是否要求 sync_status=fin' }), Object.freeze({ key: 'require_sync', name: '需已同步', type: 'flag', required: false, description: '是否要求 sync_status=fin' }),
Object.freeze({ key: 'require_print', name: '需已打印', type: 'flag', required: false, description: '是否要求 print_status=fin' }), Object.freeze({ key: 'require_print', name: '需已打印', type: 'flag', required: false, description: '是否要求 print_status=fin' }),
Object.freeze({ key: 'require_pick', name: '需已拣货', type: 'flag', required: false, description: '是否要求 pick_status=fin' }), Object.freeze({ key: 'require_pick', name: '需已拣货', type: 'flag', required: false, description: '是否要求 pick_status=fin' }),
Object.freeze({ key: 'allow_same_day_outbound', name: '出库当天订单', type: 'flag', required: false, description: '是否允许当天复核的订单当天自动出库' }), Object.freeze({ key: 'exclude_same_day_outbound', name: '不出库当天订单', type: 'flag', required: false, default: true, description: '开启后,在当天放开时间前,「允许当天出库最后时间」之后复核的订单不自动出库,到达当天放开时间后恢复' }),
Object.freeze({ key: 'same_day_outbound_deadline_time', name: '允许当天出库最后时间', type: 'string', required: false, default: '06:00', maxLength: 5, min: '00:00', max: '23:59', description: '复核时间早于该时间的订单不受「出库当天订单」关闭的影响,格式 HH:mm,不能大于当天放开时间' }), Object.freeze({ key: 'same_day_outbound_deadline_time', name: '允许当天出库最后时间', type: 'string', required: false, default: '06:00', maxLength: 5, min: '00:00', max: '23:59', description: '复核时间早于该时间的订单不受「不出库当天订单」开启的影响,格式 HH:mm,不能大于当天放开时间' }),
Object.freeze({ key: 'same_day_outbound_release_time', name: '当天放开时间', type: 'string', required: false, default: '22:00', maxLength: 5, min: '00:00', max: '23:59', description: '未开启「出库当天订单」时,当天到达该时间后不再限制当天复核订单的自动出库,格式 HH:mm' }), Object.freeze({ key: 'same_day_outbound_release_time', name: '当天放开时间', type: 'string', required: false, default: '22:00', maxLength: 5, min: '00:00', max: '23:59', description: '开启「不出库当天订单」时,当天到达该时间后不再限制当天复核订单的自动出库,格式 HH:mm' }),
]), ]),
}), }),
Object.freeze({ Object.freeze({