diff --git a/app/controller/docs.js b/app/controller/docs.js
index 3958a9e..aed64dd 100644
--- a/app/controller/docs.js
+++ b/app/controller/docs.js
@@ -1356,6 +1356,23 @@ function renderHtmlPage({
}).join('&');
}
+ /**
+ * 归一化 query 参数值,规则与后端签名保持一致。
+ * @param {*} value 参数值。
+ * @return {string} 可用于签名拼接的字符串。
+ */
+ function normalizeParamValue(value) {
+ if (value === undefined || value === null) {
+ return '';
+ }
+
+ if (typeof value === 'object') {
+ return stableStringify(value);
+ }
+
+ return String(value);
+ }
+
/**
* 构建参与签名的 canonical query。
* @param {Object} queryParams query 对象。
@@ -1370,7 +1387,7 @@ function renderHtmlPage({
return Object.keys(queryParams || {}).filter(function(key) {
return !ignoredSet[String(key).toLowerCase()] && queryParams[key] !== undefined;
}).sort().map(function(key) {
- return key + '=' + String(queryParams[key] == null ? '' : queryParams[key]);
+ return key + '=' + normalizeParamValue(queryParams[key]);
}).join('&');
}
diff --git a/app/controller/home.js b/app/controller/home.js
index f6e9df3..3872ddd 100644
--- a/app/controller/home.js
+++ b/app/controller/home.js
@@ -204,12 +204,11 @@ class HomeController extends Controller {
if (logData.result && logData.result.length > 65535) {
logData.result = logData.result.substring(0, 65535);
}
- try {
- await this.app.fileWriter.writeRecord('qimen-logs', logData);
- } catch (writeErr) {
+ // 日志落盘改为异步投递,避免阻塞主请求响应。
+ Promise.resolve(this.app.fileWriter.writeRecord('qimen-logs', logData)).catch(writeErr => {
ctx.logger.error('[qimen-log-sink] 写入文件失败: ' + writeErr.message);
ctx.logger.info('[qimen-log-sink] 日志数据: ', JSON.stringify(logData));
- }
+ });
}
}
diff --git a/app/lib/api_sign.js b/app/lib/api_sign.js
index 8047d7b..68fa0be 100644
--- a/app/lib/api_sign.js
+++ b/app/lib/api_sign.js
@@ -101,7 +101,8 @@ function buildBodySign(body) {
? body
: stableStringify(body);
- return crypto.createHash('md5').update(serializedBody, 'utf8').digest('hex').toLowerCase();
+ return crypto.createHash('md5').update(serializedBody, 'utf8').digest('hex')
+ .toLowerCase();
}
/**
@@ -125,7 +126,8 @@ function signRequest({ query = {}, body, selfAppSecret, ignoreKeys } = {}) {
const canonicalQuery = buildCanonicalQuery(query, mergedIgnoreKeys);
const bodySign = buildBodySign(body);
const signText = `${canonicalQuery}${normalizedSecret}${bodySign}`;
- const sign = crypto.createHash('md5').update(signText, 'utf8').digest('hex').toLowerCase();
+ const sign = crypto.createHash('md5').update(signText, 'utf8').digest('hex')
+ .toLowerCase();
return {
canonicalQuery,
diff --git a/app/lib/polo_api_client.js b/app/lib/polo_api_client.js
index 1a5cfb0..8d05817 100644
--- a/app/lib/polo_api_client.js
+++ b/app/lib/polo_api_client.js
@@ -207,7 +207,7 @@ class PoloApiClient {
if (Buffer.isBuffer(response.data)) {
// 如果是 Buffer,转字符串再解析
const str = response.data.toString('utf8');
- console.log("菠萝派平台接口响应原始数据",str)
+ console.log('菠萝派平台接口响应原始数据', str);
result = JSON.parse(str);
} else if (typeof response.data === 'string') {
result = JSON.parse(response.data);
diff --git a/app/lib/qimen_client.js b/app/lib/qimen_client.js
index 8dd0d20..e6582e8 100644
--- a/app/lib/qimen_client.js
+++ b/app/lib/qimen_client.js
@@ -20,7 +20,7 @@ class QimenClient {
? signService.toXml.bind(signService)
: qimenService && typeof qimenService.formatResponse === 'function'
? qimenService.formatResponse.bind(qimenService)
- : null),
+ : null),
parseXmlToArray: runtime.parseXmlToArray || (qimenService && typeof qimenService.parseXmlToArray === 'function'
? qimenService.parseXmlToArray.bind(qimenService)
: null),
@@ -47,9 +47,9 @@ class QimenClient {
}
replaceXmlTagsWithString(xmlString, oldTag, newTag) {
- const startTagRegex = new RegExp(`<\s*${oldTag}(\s+[^>]*)?>`, 'gi');
- const endTagRegex = new RegExp(`<\s*/\s*${oldTag}\s*>`, 'gi');
- const selfClosingRegex = new RegExp(`<\s*${oldTag}(\s+[^>]*)?\s*/>`, 'gi');
+ const startTagRegex = new RegExp(`<\\s*${oldTag}(\\s+[^>]*)?>`, 'gi');
+ const endTagRegex = new RegExp(`<\\s*/\\s*${oldTag}\\s*>`, 'gi');
+ const selfClosingRegex = new RegExp(`<\\s*${oldTag}(\\s+[^>]*)?\\s*/>`, 'gi');
return xmlString
.replace(startTagRegex, (match, attributes = '') => `<${newTag}${attributes}>`)
@@ -57,6 +57,30 @@ class QimenClient {
.replace(selfClosingRegex, (match, attributes = '') => `<${newTag}${attributes}/>`);
}
+ replaceDeliveryConfirmOrderLineTags(xmlString) {
+ const orderLinesBlockRegex = /<\s*orderLines(\s+[^>]*)?>[\s\S]*?<\s*\/\s*orderLines\s*>/gi;
+
+ return String(xmlString || '').replace(orderLinesBlockRegex, block => {
+ return this.replaceXmlTagsWithString(block, 'item', 'orderLine');
+ });
+ }
+
+ replaceDeliveryConfirmPackageTags(xmlString) {
+ const packagesBlockRegex = /<\s*packages(\s+[^>]*)?>[\s\S]*?<\s*\/\s*packages\s*>/gi;
+
+ return String(xmlString || '').replace(packagesBlockRegex, block => {
+ return block
+ .replace(/<\s*package\s*>\s*<\s*item\s*>/gi, '')
+ .replace(/<\s*\/\s*item\s*>\s*<\s*item\s*>/gi, '')
+ .replace(/<\s*\/\s*item\s*>\s*<\s*\/\s*package\s*>/gi, '');
+ });
+ }
+
+ replaceDeliveryConfirmPayloadTags(xmlString) {
+ const withPackages = this.replaceDeliveryConfirmPackageTags(xmlString);
+ return this.replaceDeliveryConfirmOrderLineTags(withPackages);
+ }
+
addSign(baseQueryParams, sign) {
return Object.assign({}, baseQueryParams, { sign });
}
@@ -106,7 +130,9 @@ class QimenClient {
const baseUrl = 'http://qimen.api.taobao.com/router/qimen/service';
const requestPayload = this.normalizeRequestPayload(data);
const xmlData = await helpers.toXml(requestPayload);
- const queryData = this.replaceXmlTagsWithString(xmlData, 'item', 'orderLine');
+ const queryData = method === 'taobao.qimen.deliveryorder.confirm'
+ ? this.replaceDeliveryConfirmPayloadTags(xmlData)
+ : this.replaceXmlTagsWithString(xmlData, 'item', 'orderLine');
const sign = await helpers.signTopRequest(baseQueryParams, queryData, this.app.config.qimen.security, 'md5');
const queryParams = this.addSign(baseQueryParams, sign);
const url = this.generateUrlWithParams(baseUrl, queryParams);
@@ -213,4 +239,4 @@ class QimenClient {
}
}
-module.exports = QimenClient;
\ No newline at end of file
+module.exports = QimenClient;
diff --git a/app/model/express_interface.js b/app/model/express_interface.js
index 03cdaa7..bb41c98 100644
--- a/app/model/express_interface.js
+++ b/app/model/express_interface.js
@@ -118,7 +118,7 @@ module.exports = app => {
allowNull: true,
comment: '平台店铺',
},
- address:{
+ address: {
type: STRING(255),
allowNull: true,
comment: '地址',
diff --git a/app/model/notification_webhook.js b/app/model/notification_webhook.js
index efbcda3..2f1bba8 100644
--- a/app/model/notification_webhook.js
+++ b/app/model/notification_webhook.js
@@ -39,6 +39,8 @@ module.exports = app => {
Object.freeze({ code: 'all', name: '全部事件', business: 'all', description: '订阅后接收所有通知事件' }),
Object.freeze({ code: '*', name: '全部事件(兼容别名)', business: 'all', description: '兼容旧配置,等价于 all' }),
Object.freeze({ code: 'receiving_completed', name: '收货完成', business: 'receiving', description: '收货单完成后的通知' }),
+ Object.freeze({ code: 'receiving_rejected', name: '收货驳回', business: 'receiving', description: '收货单被驳回并恢复为收货中后的通知' }),
+ Object.freeze({ code: 'receiving_reviewed', name: '收货审核完成', business: 'receiving', description: '收货单批量审核通过后的通知' }),
Object.freeze({ code: 'order_sync_completed', name: '订单同步完成', business: 'order', description: '本地创建入口同步完成后的通知' }),
Object.freeze({ code: 'order_cancel_intercepted', name: '订单取消拦截', business: 'order', description: '订单取消失败并触发拦截执行后的通知' }),
Object.freeze({
diff --git a/app/model/order_delivery.js b/app/model/order_delivery.js
index fa6abb5..55d8429 100644
--- a/app/model/order_delivery.js
+++ b/app/model/order_delivery.js
@@ -6,26 +6,26 @@ module.exports = app => {
// 状态机枚举定义
const StatusEnum = {
- STATUS: ['pedding', 'created', 'cancel', 'error'],
- SYNC_STATUS: ['padding', 'fin', 'error'],
- POST_STATUS: ['padding', 'fin', 'timeout', 'error', 'none'],
- STORAGE_STATUS: ['padding', 'fin', 'error', 'none'],
- PICK_STATUS: ['padding', 'fin', 'error', 'none'],
- PACK_STATUS: ['none', 'padding', 'fin', 'error'],
- SENDED_STATUS: ['none', 'padding', 'fin', 'error'],
- INSPECTION_STATUS: ['none', 'padding', 'running', 'fin', 'error'],
- PRINT_STATUS: ['none', 'padding', 'fin', 'error'],
- CLAIM_STATUS: ['none', 'padding', 'fin', 'error'],
- OUTBOUND_STATUS: ['none', 'padding', 'fin', 'timeout', 'error'],
- LOCK_STATUS: ['none', 'warehouse', 'store'],
+ STATUS: [ 'pedding', 'created', 'cancel', 'error' ],
+ SYNC_STATUS: [ 'padding', 'fin', 'error' ],
+ POST_STATUS: [ 'padding', 'fin', 'timeout', 'error', 'none' ],
+ STORAGE_STATUS: [ 'padding', 'fin', 'error', 'none' ],
+ PICK_STATUS: [ 'padding', 'fin', 'error', 'none' ],
+ PACK_STATUS: [ 'none', 'padding', 'fin', 'error' ],
+ SENDED_STATUS: [ 'none', 'padding', 'fin', 'error' ],
+ INSPECTION_STATUS: [ 'none', 'padding', 'running', 'fin', 'error' ],
+ PRINT_STATUS: [ 'none', 'padding', 'fin', 'error' ],
+ CLAIM_STATUS: [ 'none', 'padding', 'fin', 'error' ],
+ OUTBOUND_STATUS: [ 'none', 'padding', 'fin', 'timeout', 'error' ],
+ LOCK_STATUS: [ 'none', 'warehouse', 'store' ],
INTERCEPT_STATUS: [
'none', 'requesting', 'requested', 'intercepting',
'intercepted_in_transit', 'intercepted_at_warehouse',
'returning', 'returned', 'delivered_by_mistake',
'timeout', 'cancelled', 'failed', 'exception',
],
- URGENCY: ['Y', 'N'],
- INVOICE: ['Y', 'N'],
+ URGENCY: [ 'Y', 'N' ],
+ INVOICE: [ 'Y', 'N' ],
};
// 基础模型定义
@@ -216,6 +216,12 @@ module.exports = app => {
allowNull: true,
comment: '系统物流公司名称',
},
+
+ basket_number:{
+ type: STRING(50),
+ allowNull: true,
+ comment: '筐号',
+ },
express_code: {
type: STRING(50),
allowNull: true,
@@ -470,16 +476,16 @@ module.exports = app => {
indexes: [
{
name: 'idx_current_store_id',
- fields: ['store_id'],
+ fields: [ 'store_id' ],
},
{
name: 'idx_current_warehouse_id',
- fields: ['warehouse_id'],
+ fields: [ 'warehouse_id' ],
},
{
name: 'idx_current_delivery_code',
unique: true,
- fields: ['delivery_order_code', 'store_id', 'warehouse_id'],
+ fields: [ 'delivery_order_code', 'store_id', 'warehouse_id' ],
},
{
name: 'idx_items',
@@ -487,15 +493,15 @@ module.exports = app => {
},
{
name: 'idx_items_hash',
- fields: ['items_hash'],
+ fields: [ 'items_hash' ],
},
{
name: 'idx_hash_crc',
- fields: ['items_hash', 'items_crc', 'warehouse_id'],
+ fields: [ 'items_hash', 'items_crc', 'warehouse_id' ],
},
{
name: 'wave_id',
- fields: ['status', 'wave_id'],
+ fields: [ 'status', 'wave_id' ],
},
// 状态机索引
{
diff --git a/app/model/order_delivery_factory.js b/app/model/order_delivery_factory.js
index 0f6c62e..d7497b9 100644
--- a/app/model/order_delivery_factory.js
+++ b/app/model/order_delivery_factory.js
@@ -615,7 +615,7 @@ module.exports = app => {
* @param {Object} [DynamicModel] 已构建的动态模型。
* @return {Promise} 是否执行了同步。
*/
-
+
async ensureManagedTableSchema(tableName, type, warehouseId, DynamicModel = null) {
const modelType = this.resolveModelType(type);
const dynamicModel = DynamicModel || this.buildManagedModel(warehouseId, modelType, tableName);
diff --git a/app/model/order_express.js b/app/model/order_express.js
index 66d0fca..f740971 100644
--- a/app/model/order_express.js
+++ b/app/model/order_express.js
@@ -102,16 +102,16 @@ module.exports = app => {
allowNull: true,
comment: '加密打印信息',
},
- encryptedtoken:{
+ encryptedtoken: {
type: TEXT,
allowNull: true,
comment: '加密令牌',
},
- warehouse_id:{
+ warehouse_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '仓库ID',
- }
+ },
}, {
tableName: 'wms_order_express',
freezeTableName: true,
diff --git a/app/model/platform.js b/app/model/platform.js
index fce3b7e..f3d326f 100644
--- a/app/model/platform.js
+++ b/app/model/platform.js
@@ -55,11 +55,11 @@ module.exports = app => {
allowNull: true,
comment: '店铺类型',
},
- ordersource:{
+ ordersource: {
type: STRING(50),
allowNull: true,
comment: '订单来源',
- }
+ },
}, {
tableName: 'wms_platform',
freezeTableName: true,
diff --git a/app/model/receiving.js b/app/model/receiving.js
index fe07bcc..340808e 100644
--- a/app/model/receiving.js
+++ b/app/model/receiving.js
@@ -1,6 +1,6 @@
// app/model/receiving.js
module.exports = app => {
- const { STRING, INTEGER, DATE, TEXT, BOOLEAN, ENUM } = app.Sequelize;
+ const { STRING, INTEGER, BIGINT, DATE, TEXT, BOOLEAN, ENUM, TINYINT } = app.Sequelize;
const Receiving = app.model.define('wms_receiving', {
id: {
@@ -108,6 +108,22 @@ module.exports = app => {
type: DATE,
comment: '收货结束时间',
},
+ is_review: {
+ type: TINYINT(1),
+ allowNull: false,
+ defaultValue: 0,
+ comment: '是否已审核:0-未审核,1-已审核',
+ },
+ reviewer_name: {
+ type: STRING(50),
+ allowNull: true,
+ comment: '审核人姓名',
+ },
+ reviewer_employee_id: {
+ type: BIGINT.UNSIGNED,
+ allowNull: true,
+ comment: '审核人员工ID,关联 wms_account_store_employee.id',
+ },
is_deleted: {
type: BOOLEAN,
defaultValue: false,
diff --git a/app/model/store_warehouse.js b/app/model/store_warehouse.js
index 0ea2787..617dfd3 100644
--- a/app/model/store_warehouse.js
+++ b/app/model/store_warehouse.js
@@ -25,6 +25,14 @@ module.exports = app => {
required: false,
description: '收货上架时是否自动推荐库位',
}),
+ Object.freeze({
+ key: 'allow_receiving_quick_putaway',
+ name: '收货单快捷入库',
+ type: 'flag',
+ default: 0,
+ required: false,
+ description: '控制该货主在当前仓库下是否允许使用收货单快捷入库',
+ }),
Object.freeze({
key: 'allow_mix_batch',
name: '允许混批',
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-TB-20260428173606.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-TB-20260428173606.xlsx
new file mode 100644
index 0000000..19e0214
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-TB-20260428173606.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-TB-20260428174354.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-TB-20260428174354.xlsx
new file mode 100644
index 0000000..e1ee76c
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-TB-20260428174354.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428171657.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428171657.xlsx
new file mode 100644
index 0000000..fa21da7
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428171657.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428172850.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428172850.xlsx
new file mode 100644
index 0000000..c8a3e81
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428172850.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428172924.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428172924.xlsx
new file mode 100644
index 0000000..22de3a8
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428172924.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428173158.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428173158.xlsx
new file mode 100644
index 0000000..0921b1a
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428173158.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428173431.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428173431.xlsx
new file mode 100644
index 0000000..71bf294
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428173431.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428173540.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428173540.xlsx
new file mode 100644
index 0000000..9b6ac9b
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428173540.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428174607.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428174607.xlsx
new file mode 100644
index 0000000..f499f7f
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428174607.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428174609.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428174609.xlsx
new file mode 100644
index 0000000..1d70ba2
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428174609.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428174640.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428174640.xlsx
new file mode 100644
index 0000000..eb9dc4d
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-20260428174640.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260428175459-1777370099464.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260428175459-1777370099464.xlsx
new file mode 100644
index 0000000..afa7232
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260428175459-1777370099464.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260428175504-1777370104248.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260428175504-1777370104248.xlsx
new file mode 100644
index 0000000..5391401
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260428175504-1777370104248.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260428175506-1777370106125.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260428175506-1777370106125.xlsx
new file mode 100644
index 0000000..f3a8a29
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260428175506-1777370106125.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260429010658-1777396018375.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260429010658-1777396018375.xlsx
new file mode 100644
index 0000000..d4a5365
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260429010658-1777396018375.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260429010718-1777396038210.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260429010718-1777396038210.xlsx
new file mode 100644
index 0000000..0895e1d
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260429010718-1777396038210.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260429011359-1777396439929.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260429011359-1777396439929.xlsx
new file mode 100644
index 0000000..b43aab0
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260429011359-1777396439929.xlsx differ
diff --git a/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260429011416-1777396456342.xlsx b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260429011416-1777396456342.xlsx
new file mode 100644
index 0000000..68cddda
Binary files /dev/null and b/app/public/exports/warehouse/warehouse-rack-spaces-WH-E01-20260429011416-1777396456342.xlsx differ
diff --git a/app/service/systemMethods/index.js b/app/service/systemMethods/index.js
index 8bb25d5..a887c5b 100644
--- a/app/service/systemMethods/index.js
+++ b/app/service/systemMethods/index.js
@@ -11,9 +11,9 @@ class indexService extends MainService {
constructor(ctx) {
super(ctx);
const _noNeedLogin = 'getI18nMessage,putI18nCollect';
- const _noNeedRight = 'getI18nMessage,putI18nCollect,fastWhereTree,loadStores,getImages,getCOSUploadConfig,uploadSuccessNotify,getMessageDetail,searchSpace,listInterfaceTypes,getExpressList,getExpressProductTypeList,getPlatformList,recognizeLicensePlate';
+ const _noNeedRight = 'getI18nMessage,putI18nCollect,fastWhereTree,loadStores,getImages,getCOSUploadConfig,uploadSuccessNotify,getMessageDetail,searchSpace,listInterfaceTypes,getLocationTypeList,getExpressList,getExpressProductTypeList,getPlatformList,recognizeLicensePlate';
const _noNeedLog = '*';
- const _noNeedAuth = 'getI18nMessage,putI18nCollect,fastWhereTree,loadStores,getImages,getMessageDetail,searchSpace,listInterfaceTypes,getExpressList,getExpressProductTypeList,getPlatformList,recognizeLicensePlate';
+ const _noNeedAuth = 'getI18nMessage,putI18nCollect,fastWhereTree,loadStores,getImages,getMessageDetail,searchSpace,listInterfaceTypes,getLocationTypeList,getExpressList,getExpressProductTypeList,getPlatformList,recognizeLicensePlate';
this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth);
}
async fastWhereTree(data) {
@@ -417,6 +417,61 @@ class indexService extends MainService {
});
return this.success('ok', { list, total: list.length, code: 200 });
}
+ async getLocationTypeList() {
+ const { ctx } = this;
+ const { Op } = this.app.Sequelize;
+ const warehouseId = ctx.user && ctx.user.store_id ? Number(ctx.user.store_id) : null;
+ const cacheKey = `index:locationTypeList:${warehouseId || 'global'}`;
+ const cached = await this.app.getCacheAsync(cacheKey);
+
+ if (Array.isArray(cached)) {
+ return this.success('ok', { list: cached, total: cached.length, code: 200 });
+ }
+
+ const where = {
+ is_active: true,
+ };
+
+ if (warehouseId) {
+ where[Op.or] = [
+ { warehouse_id: warehouseId },
+ { warehouse_id: null },
+ ];
+ } else {
+ where.warehouse_id = null;
+ }
+
+ const rows = await ctx.model.LocationType.findAll({
+ where,
+ attributes: [
+ 'id',
+ 'type_code',
+ 'type_name',
+ 'temperature_zone',
+ 'allow_allocation',
+ 'allow_transfer_out',
+ 'description',
+ 'warehouse_id',
+ ],
+ order: [[ 'warehouse_id', 'ASC' ], [ 'id', 'ASC' ]],
+ raw: true,
+ });
+
+ const list = rows.map(item => ({
+ id: Number(item.id || 0),
+ type_code: item.type_code || '',
+ type_name: item.type_name || '',
+ temperature_zone: item.temperature_zone || '',
+ allow_allocation: Boolean(item.allow_allocation),
+ allow_transfer_out: Boolean(item.allow_transfer_out),
+ description: item.description || '',
+ warehouse_id: item.warehouse_id === null || item.warehouse_id === undefined ? null : Number(item.warehouse_id),
+ }));
+
+ await this.app.setCacheAsync(cacheKey, list, 300);
+
+ return this.success('ok', { list, total: list.length, code: 200 });
+ }
/**
* 获取快递列表。
*
diff --git a/app/service/systemMethods/order/base.js b/app/service/systemMethods/order/base.js
index 084f531..47c9331 100644
--- a/app/service/systemMethods/order/base.js
+++ b/app/service/systemMethods/order/base.js
@@ -4,7 +4,7 @@ const MainService = require('../../main');
const { parseWhereConditions } = require('../../../lib/query_condition_parser');
const DEFAULT_PAGE_SIZE = 20;
-const MAX_PAGE_SIZE = 200;
+const MAX_PAGE_SIZE = 500;
const FORBIDDEN_WAREHOUSE_FIELDS = new Set([ 'warehouse_id', 'warehouseId' ]);
const WAREHOUSE_FIELD_ERROR_MESSAGE = '订单工作台查询条件禁止传入 warehouse_id / warehouseId,请使用当前用户上下文的 store_id。';
@@ -21,7 +21,7 @@ const BADGE_COUNT_OVER_LIMIT_VALUE = '99+';
const ORDER_LIST_BASE_ATTRIBUTES = Object.freeze([
'id', 'delivery_order_code', 'pre_delivery_order_code', 'pre_delivery_order_id',
- 'order_type', 'order_flag','source_order_codes',
+ 'order_type', 'order_flag', 'source_order_codes',
'sys_platform_code', 'sys_platform_name',
'create_at',
'place_order_time', 'pay_time', 'pay_no', 'service_code',
@@ -29,7 +29,7 @@ const ORDER_LIST_BASE_ATTRIBUTES = Object.freeze([
'shop_nick', 'seller_nick', 'buyer_nick',
'total_amount', 'item_amount', 'discount_amount', 'freight',
'ar_amount', 'got_amount', 'service_fee',
- 'logistics_name',
+ 'logistics_name',
'delivery_type', 'weight_type',
'is_urgency', 'invoice_flag', 'status',
'name', 'zip_code', 'tel', 'mobile', 'email',
@@ -40,7 +40,7 @@ const ORDER_LIST_BASE_ATTRIBUTES = Object.freeze([
'wave_id',
'post_status', 'storage_status', 'pick_status', 'pack_status',
'inspection_status', 'print_status', 'claim_status',
- 'outbound_status', 'lock_status', 'intercept_status',
+ 'outbound_status', 'lock_status', 'intercept_status','basket_number'
]);
const ORDER_WEIGHT_TYPE_LABELS = Object.freeze({
@@ -147,6 +147,29 @@ const MODULE_CONFIGS = Object.freeze({
* 负责仓库上下文、分页规范、where 解析、模型选择与审核状态更新。
*/
class OrderBaseService extends MainService {
+ /**
+ * 脱敏展示值:保留首尾字符,中间统一替换为 ***。
+ * @param {string|number|null|undefined} value 原始值。
+ * @return {string|null} 脱敏后的值。
+ */
+ maskListSensitiveValue(value) {
+ if (value === null || value === undefined) {
+ return value;
+ }
+
+ const normalizedValue = String(value);
+ if (!normalizedValue) {
+ return normalizedValue;
+ }
+
+ const chars = Array.from(normalizedValue);
+ if (chars.length <= 1) {
+ return normalizedValue;
+ }
+
+ return `${chars[0]}***${chars[chars.length - 1]}`;
+ }
+
/**
* 获取当前请求对应的仓库ID。
* @return {number|string|null} 仓库ID。
@@ -393,6 +416,8 @@ class OrderBaseService extends MainService {
return {
...order,
+ name: this.maskListSensitiveValue(order.name),
+ tel: this.maskListSensitiveValue(order.tel),
weight_type: this.formatWeightTypeLabel(order.weight_type),
};
}
@@ -598,6 +623,9 @@ class OrderBaseService extends MainService {
return {
...orderRow,
+ name: this.maskListSensitiveValue(orderRow.name),
+ tel: this.maskListSensitiveValue(orderRow.tel),
+ mobile: this.maskListSensitiveValue(orderRow.mobile),
sys_platform_name: Object.prototype.hasOwnProperty.call(orderRow, 'sys_platform_name')
? (orderRow.sys_platform_name ?? null)
: null,
@@ -670,6 +698,140 @@ class OrderBaseService extends MainService {
});
}
+ /**
+ * 提取订单列表中的运单号虚拟筛选条件。
+ * @param {Object} whereInput 标准化后的 where 条件。
+ * @return {{ where: Object, expressNumbers: string[] }} 清洗后的 where 与运单号集合。
+ */
+ extractOrderListExpressVirtualFilter(whereInput = {}) {
+ const normalizedWhere = this.isPlainObject(whereInput)
+ ? { ...whereInput }
+ : {};
+ const waybillCondition = normalizedWhere.waybill_codes;
+ const expressCondition = normalizedWhere.express_numbers;
+
+ delete normalizedWhere.waybill_codes;
+ delete normalizedWhere.express_numbers;
+
+ const expressNumbers = Array.from(new Set([
+ ...this.normalizeExpressFilterValues(waybillCondition),
+ ...this.normalizeExpressFilterValues(expressCondition),
+ ]));
+
+ return {
+ where: normalizedWhere,
+ expressNumbers,
+ };
+ }
+
+ /**
+ * 规范化运单号筛选输入,兼容字符串、数组与 { value } 结构。
+ * @param {*} condition 运单号筛选条件。
+ * @return {string[]} 规范化后的运单号列表。
+ */
+ normalizeExpressFilterValues(condition) {
+ const sourceValue = this.isPlainObject(condition) && Object.prototype.hasOwnProperty.call(condition, 'value')
+ ? condition.value
+ : condition;
+ const sourceItems = [];
+
+ if (Array.isArray(sourceValue)) {
+ sourceItems.push(...sourceValue);
+ } else if (typeof sourceValue === 'string') {
+ sourceItems.push(...sourceValue.split(','));
+ } else if (sourceValue !== undefined && sourceValue !== null && sourceValue !== '') {
+ sourceItems.push(sourceValue);
+ }
+
+ return sourceItems
+ .map(item => String(item || '').trim())
+ .filter(Boolean);
+ }
+
+ /**
+ * 根据运单号筛选条件查询命中的订单ID。
+ * @param {string[]} expressNumbers 运单号列表。
+ * @param {number|string} warehouseId 仓库ID。
+ * @return {Promise} 命中的订单ID列表。
+ */
+ async findOrderIdsByExpressNumbers(expressNumbers = [], warehouseId = this.getWarehouseId()) {
+ const contextWarehouseId = this.getWarehouseId();
+
+ if (contextWarehouseId === null || contextWarehouseId === undefined || contextWarehouseId === '') {
+ throw new Error('缺少当前用户仓库上下文 store_id');
+ }
+
+ if (warehouseId !== null && warehouseId !== undefined && warehouseId !== ''
+ && String(warehouseId) !== String(contextWarehouseId)) {
+ throw new Error('订单工作台仓库ID必须来自当前用户上下文 store_id,禁止传入外部仓库ID。');
+ }
+
+ const normalizedExpressNumbers = Array.from(new Set(
+ (Array.isArray(expressNumbers) ? expressNumbers : [])
+ .map(item => String(item || '').trim())
+ .filter(Boolean)
+ ));
+
+ if (normalizedExpressNumbers.length === 0) {
+ return [];
+ }
+
+ const orderExpressModel = this.ctx.model && this.ctx.model.OrderExpress;
+ if (!orderExpressModel || typeof orderExpressModel.findAll !== 'function') {
+ return [];
+ }
+
+ const { Op } = this.app.Sequelize;
+ const rows = await orderExpressModel.findAll({
+ where: {
+ warehouse_id: contextWarehouseId,
+ waybill_code: {
+ [Op.in]: normalizedExpressNumbers,
+ },
+ },
+ attributes: [ 'order_id' ],
+ raw: true,
+ });
+
+ return Array.from(new Set((Array.isArray(rows) ? rows : [])
+ .map(row => Number(row && row.order_id))
+ .filter(orderId => Number.isFinite(orderId) && orderId > 0)));
+ }
+
+ /**
+ * 将命中的订单ID并入 Sequelize where 条件。
+ * @param {Object} queryWhere 原始 where 条件。
+ * @param {number[]} orderIds 命中的订单ID。
+ * @return {Object} 合并后的 where 条件。
+ */
+ appendOrderIdsFilterToWhere(queryWhere = {}, orderIds = []) {
+ const { Op } = this.app.Sequelize;
+ const normalizedOrderIds = Array.from(new Set((Array.isArray(orderIds) ? orderIds : [])
+ .map(item => Number(item))
+ .filter(orderId => Number.isFinite(orderId) && orderId > 0)));
+ const orderIdCondition = {
+ id: {
+ [Op.in]: normalizedOrderIds,
+ },
+ };
+
+ if (!this.isPlainObject(queryWhere)
+ || (Object.keys(queryWhere).length === 0 && Object.getOwnPropertySymbols(queryWhere).length === 0)) {
+ return orderIdCondition;
+ }
+
+ if (Array.isArray(queryWhere[Op.and])) {
+ return {
+ ...queryWhere,
+ [Op.and]: [ ...queryWhere[Op.and], orderIdCondition ],
+ };
+ }
+
+ return {
+ [Op.and]: [ queryWhere, orderIdCondition ],
+ };
+ }
+
/**
* 构造列表排序参数。
* @param {Object} sort 排序参数。
@@ -801,14 +963,21 @@ class OrderBaseService extends MainService {
},
},
});
- const mergedWhere = this.mergeWhereObjects(this.getDefaultWhere(moduleName), where);
- const queryWhere = this.buildWhere(mergedWhere, contextWarehouseId, {
+ const { where: sanitizedWhere, expressNumbers } = this.extractOrderListExpressVirtualFilter(where);
+ const mergedWhere = this.mergeWhereObjects(this.getDefaultWhere(moduleName), sanitizedWhere);
+ let queryWhere = this.buildWhere(mergedWhere, contextWarehouseId, {
specialFieldMap: {
quickWhere: {
bucket: 'quick',
},
},
});
+
+ if (expressNumbers.length > 0) {
+ const orderIds = await this.findOrderIdsByExpressNumbers(expressNumbers, contextWarehouseId);
+ queryWhere = this.appendOrderIdsFilterToWhere(queryWhere, orderIds);
+ }
+
const model = await this.getOrderModel(moduleName, contextWarehouseId);
const order = this.buildListOrder(requestData.sort, moduleName);
const offset = (page - 1) * pageSize;
@@ -887,21 +1056,137 @@ class OrderBaseService extends MainService {
order: [[ 'id', 'ASC' ]],
raw: true,
});
+ const orderItemImagesByStockId = await this.getOrderItemImagesByStockIds(orderItems);
+ const orderItemsWithImages = this.attachImagesToOrderItems(orderItems, orderItemImagesByStockId);
const expresses = await this.getOrderExpressesByOrderId(orderId);
- const waybillCodes = Array.from(new Set(expresses
- .map(item => String(item && item.waybill_code || '').trim())
- .filter(Boolean)));
-
+ const logs = await this.getOrderOperationLogs(orderId);
return {
- order,
detail: order,
- orderItems: Array.isArray(orderItems) ? orderItems : [],
- items: Array.isArray(orderItems) ? orderItems : [],
+ items: orderItemsWithImages,
expresses,
- waybill_codes: waybillCodes,
+ logs,
};
}
+ /**
+ * 按订单商品批量查询图片并按 stock_id 建立映射。
+ * @param {Object[]} orderItems 订单商品列表。
+ * @return {Promise