diff --git a/app/lib/polo_api_client.js b/app/lib/polo_api_client.js index e61d05d..f400c75 100644 --- a/app/lib/polo_api_client.js +++ b/app/lib/polo_api_client.js @@ -60,7 +60,7 @@ class PoloApiClient { }, content: formBody, }); - + console.log('formBody', formBody); let result; if (Buffer.isBuffer(response.data)) { diff --git a/app/lib/printer_data_builder.js b/app/lib/printer_data_builder.js index 8f4cfa7..727b8fd 100644 --- a/app/lib/printer_data_builder.js +++ b/app/lib/printer_data_builder.js @@ -1253,6 +1253,7 @@ function sanitizeTemplatePrivateFields(value, warnings, currentKey = '') { * @param {string[]} warnings 风险提示列表。 * @param {Object} policyConfig 策略配置对象。 * @param {string} customDataTemplateURL 自定义区模板地址默认值。 + * @param extraCustomLines */ function applyKuaishouExpressFieldMapping(platform, skeleton, orderExpress, orderDelivery, warnings, policyConfig, customDataTemplateURL, extraCustomLines = []) { if (platform !== 'kuaishou') { @@ -1402,6 +1403,7 @@ function applyKuaishouExpressFieldMapping(platform, skeleton, orderExpress, orde * @param {Object} orderExpress 快递单对象。 * @param {Object} orderDelivery 订单对象。 * @param {Object} policyConfig 策略配置对象。 + * @param extraCustomLines */ function applyPddExpressFieldMapping(platform, skeleton, orderExpress, orderDelivery, policyConfig, extraCustomLines = []) { if (platform !== 'pdd') { @@ -1724,6 +1726,7 @@ function applyDouyinExpressFieldMapping(platform, skeleton, orderExpress, orderD * @param {Object} policyConfig 策略配置对象。 * @param {string} customControlTemplateURL 菜鸟自定义区模板地址。 * @param {string[]} warnings 风险提示列表。 + * @param extraCustomLines */ function applyCainiaoExpressFieldMapping( platform, @@ -1934,6 +1937,7 @@ function resolveXhsMainContentFromPrintinfo(printinfo, warnings = []) { * @param {Object} orderDelivery 订单对象。 * @param {Object} policyConfig 策略配置对象。 * @param {string[]} warnings 风险提示列表。 + * @param extraCustomLines */ function applyXhsExpressFieldMapping( platform, @@ -2036,6 +2040,7 @@ function applyXhsExpressFieldMapping( * @param {Object} orderExpress 快递单对象。 * @param {Object} orderDelivery 订单对象。 * @param {Object} policyConfig 策略配置对象。 + * @param extraCustomLines */ function applySphExpressFieldMapping( platform, @@ -2176,6 +2181,7 @@ function resolveJdTemplateUrlFromOrderExpress(orderExpress) { * @param {Object} policyConfig 策略配置对象。 * @param {Object} templateSample 模板样例对象。 * @param {string[]} warnings 风险提示列表。 + * @param extraCustomLines */ function applyJdExpressFieldMapping( platform, diff --git a/app/model/after_sale_work_order.js b/app/model/after_sale_work_order.js index 0d7e9dd..90e0c89 100644 --- a/app/model/after_sale_work_order.js +++ b/app/model/after_sale_work_order.js @@ -71,7 +71,7 @@ module.exports = app => { /** * 根据 business_type 获取关联表名 * @param {string} businessType 业务类型 - * @returns {string|null} 关联表名 + * @return {string|null} 关联表名 */ function getBusinessTable(businessType) { return BUSINESS_TYPES[businessType]?.table || null; @@ -81,7 +81,7 @@ module.exports = app => { * 校验 business_type + business_sub_type 组合是否合法 * @param {string} businessType 业务类型 * @param {string} businessSubType 业务子类型 - * @returns {boolean} 是否合法 + * @return {boolean} 是否合法 */ function isValidSubType(businessType, businessSubType) { const def = BUSINESS_TYPES[businessType]; diff --git a/app/model/camera.js b/app/model/camera.js index 90a7858..04fa30e 100644 --- a/app/model/camera.js +++ b/app/model/camera.js @@ -105,11 +105,11 @@ module.exports = app => { deletedAt: 'deleted_at', comment: '摄像头表', indexes: [ - { name: 'idx_warehouse_id', fields: ['warehouse_id'] }, - { name: 'idx_server_id', fields: ['server_id'] }, - { name: 'uk_server_channel', unique: true, fields: ['server_id', 'channel_id', 'deleted_at'] }, - { name: 'idx_status', fields: ['status'] }, - { name: 'idx_deleted_at', fields: ['deleted_at'] }, + { name: 'idx_warehouse_id', fields: [ 'warehouse_id' ] }, + { name: 'idx_server_id', fields: [ 'server_id' ] }, + { name: 'uk_server_channel', unique: true, fields: [ 'server_id', 'channel_id', 'deleted_at' ] }, + { name: 'idx_status', fields: [ 'status' ] }, + { name: 'idx_deleted_at', fields: [ 'deleted_at' ] }, ], }); diff --git a/app/model/camera_server.js b/app/model/camera_server.js index 7b4712c..900a202 100644 --- a/app/model/camera_server.js +++ b/app/model/camera_server.js @@ -90,9 +90,9 @@ module.exports = app => { deletedAt: 'deleted_at', comment: '录像服务器表', indexes: [ - { name: 'idx_warehouse_id', fields: ['warehouse_id'] }, - { name: 'idx_status', fields: ['status'] }, - { name: 'idx_deleted_at', fields: ['deleted_at'] }, + { name: 'idx_warehouse_id', fields: [ 'warehouse_id' ] }, + { name: 'idx_status', fields: [ 'status' ] }, + { name: 'idx_deleted_at', fields: [ 'deleted_at' ] }, ], }); diff --git a/app/model/workbench.js b/app/model/workbench.js index ee65b8a..d8d08e0 100644 --- a/app/model/workbench.js +++ b/app/model/workbench.js @@ -71,10 +71,10 @@ module.exports = app => { deletedAt: 'deleted_at', comment: '工作台表', indexes: [ - { name: 'idx_warehouse_id', fields: ['warehouse_id'] }, - { name: 'idx_barcode', fields: ['barcode'] }, - { name: 'uk_warehouse_barcode', unique: true, fields: ['warehouse_id', 'barcode', 'deleted_at'] }, - { name: 'idx_deleted_at', fields: ['deleted_at'] }, + { name: 'idx_warehouse_id', fields: [ 'warehouse_id' ] }, + { name: 'idx_barcode', fields: [ 'barcode' ] }, + { name: 'uk_warehouse_barcode', unique: true, fields: [ 'warehouse_id', 'barcode', 'deleted_at' ] }, + { name: 'idx_deleted_at', fields: [ 'deleted_at' ] }, ], }); diff --git a/app/service/systemMethods/dashboard.js b/app/service/systemMethods/dashboard.js index 5b630c7..eeb246e 100644 --- a/app/service/systemMethods/dashboard.js +++ b/app/service/systemMethods/dashboard.js @@ -25,7 +25,7 @@ class dashboardService extends MainService { return this.fail('缺少仓库上下文'); } const stats = await this.queryWarehouseStats(warehouseId); - return this.success('ok', this.mergeStoreStats([stats])); + return this.success('ok', this.mergeStoreStats([ stats ])); } async storeSideStoreStats() { diff --git a/app/service/systemMethods/setting/expressInterface.js b/app/service/systemMethods/setting/expressInterface.js index e10f187..1d2d007 100644 --- a/app/service/systemMethods/setting/expressInterface.js +++ b/app/service/systemMethods/setting/expressInterface.js @@ -130,11 +130,11 @@ class expressInterfaceService extends MainService { } // 收集唯一 shop_id(去重) - const shopIds = [...new Set( + const shopIds = [ ...new Set( list .map(item => item.shop_id) .filter(id => id !== null && id !== undefined && Number(id) !== 0) - )]; + ) ]; if (shopIds.length === 0) { const defaultList = list.map(item => ({ ...item, quantity: 0, recycled_quantity: 0, cancel_quantity: 0, allocated_quantity: 0 })); @@ -151,7 +151,7 @@ class expressInterfaceService extends MainService { // 并行调用 getShopExpressList,构建 Map const shopExpressMap = new Map(); const shopResults = await Promise.all( - shopIds.map(async (shopId) => { + shopIds.map(async shopId => { try { const shopExpressResult = await ctx.service.systemMethods.index.getShopExpressList({ shop_id: shopId, diff --git a/app/service/systemMethods/storeWarehouse/warehouse.js b/app/service/systemMethods/storeWarehouse/warehouse.js index 0aa4ab4..5661b49 100644 --- a/app/service/systemMethods/storeWarehouse/warehouse.js +++ b/app/service/systemMethods/storeWarehouse/warehouse.js @@ -51,6 +51,7 @@ class StoreWarehouseWarehouseService extends MainService { /** * 仓库侧发起签约。 + * @param data */ async sign(data = {}) { const targetService = this.service && this.service.systems && this.service.systems.storeWarehouse; @@ -68,6 +69,7 @@ class StoreWarehouseWarehouseService extends MainService { /** * 仓库侧确认签约。 + * @param data */ async confirmSign(data = {}) { const targetService = this.service && this.service.systems && this.service.systems.storeWarehouse; diff --git a/app/service/systemMethods/workbench.js b/app/service/systemMethods/workbench.js index 1f7c3fe..c4a9282 100644 --- a/app/service/systemMethods/workbench.js +++ b/app/service/systemMethods/workbench.js @@ -14,6 +14,7 @@ class WorkbenchService extends MainService { /** * 工作台列表(分页 + 筛选) + * @param data */ async list(data) { const { service } = this; @@ -27,6 +28,7 @@ class WorkbenchService extends MainService { /** * 工作台详情 + * @param data */ async detail(data) { const { service } = this; @@ -42,6 +44,7 @@ class WorkbenchService extends MainService { /** * 创建工作台 + * @param data */ async create(data) { const { service } = this; @@ -55,6 +58,7 @@ class WorkbenchService extends MainService { /** * 更新工作台 + * @param data */ async update(data) { const { service } = this; @@ -70,6 +74,7 @@ class WorkbenchService extends MainService { /** * 删除工作台(软删除) + * @param data */ async delete(data) { const { service } = this; @@ -102,6 +107,7 @@ class WorkbenchService extends MainService { /** * 工作台绑定摄像头 + * @param data */ async bindCamera(data) { const { service } = this; @@ -117,6 +123,7 @@ class WorkbenchService extends MainService { /** * 检查条码是否已存在 + * @param data */ async checkBarcode(data) { const { service } = this; diff --git a/app/service/systems/cameraServer.js b/app/service/systems/cameraServer.js index 6437e65..0bdd0fe 100644 --- a/app/service/systems/cameraServer.js +++ b/app/service/systems/cameraServer.js @@ -20,7 +20,7 @@ class CameraServerService extends Service { const { count, rows } = await ctx.model.CameraServer.findAndCountAll({ where: queryWhere, - order: [['created_at', 'DESC']], + order: [[ 'created_at', 'DESC' ]], offset: (page - 1) * pageSize, limit: pageSize, }); diff --git a/app/service/systems/delivery_order.js b/app/service/systems/delivery_order.js index 45f954d..18c7df2 100644 --- a/app/service/systems/delivery_order.js +++ b/app/service/systems/delivery_order.js @@ -1161,7 +1161,7 @@ class DeliveryOrderService extends Service { isUrgency, invoiceFlag, receiverInfo, - sourceOrderCode + sourceOrderCode, } = deliveryOrder; const policyConfig = await this.getStoreWarehousePolicyConfig(info.storeId, info.warehouseId); @@ -1371,12 +1371,12 @@ class DeliveryOrderService extends Service { resolvedItems.sort((a, b) => a.stockId - b.stockId); // ===== 批量查询 wms_stock_warehouse 获取仓库侧称重毛重 ===== - const stockIds = [...new Set(resolvedItems.map(item => item.stockId).filter(Boolean))]; + const stockIds = [ ...new Set(resolvedItems.map(item => item.stockId).filter(Boolean)) ]; const warehouseWeightMap = new Map(); if (stockIds.length > 0) { const warehouseRecords = await app.model.StockWarehouse.findAll({ where: { id: stockIds }, - attributes: ['id', 'gross_weight'], + attributes: [ 'id', 'gross_weight' ], transaction, raw: true, }); diff --git a/app/service/systems/express_platform.js b/app/service/systems/express_platform.js index cb382d0..71cf8bb 100644 --- a/app/service/systems/express_platform.js +++ b/app/service/systems/express_platform.js @@ -780,8 +780,8 @@ class ExpressPlatformService extends MainService { labelformat: listByWarehousePlatformCode.labelformat || '', extraInfo: ExpressList.find(item => item.code === listByWarehousePlatformCode.sys_express_code)?.polyapi_extra_info || '', }; - console.log("matchedPlatform.platid",matchedPlatform.platid); - console.log("startPlayload",playload); + console.log('matchedPlatform.platid', matchedPlatform.platid); + console.log('startPlayload', playload); if (Number(matchedPlatform.platid) === 673) { playload.BizVersion = '2'; @@ -891,7 +891,7 @@ class ExpressPlatformService extends MainService { if (!order.extend_props.ewaybill_order_code) { throw new Error('订单数据错误,参数不全缺失extend_props.ewaybill_order_code,请复制次信息给ERP方反馈'); } - playload.oaid = order.extend_props.ewaybill_order_code||order.oaid||undefined; + playload.oaid = order.extend_props.ewaybill_order_code || order.oaid || undefined; playload.transtype = '0'; playload.Mallmaskid = order.buyer_nick; @@ -919,7 +919,7 @@ class ExpressPlatformService extends MainService { api: 'Differ.JH.Logistics.PostOrder', response: JSON.stringify(result), }); - console.log("分配运单号结果",result); + console.log('分配运单号结果', result); // 统一处理:不再依赖顶层 code,直接从 results 逐条提取 issuccess 和 submessage { @@ -1109,14 +1109,14 @@ class ExpressPlatformService extends MainService { eCustomerCode: '', remark: '', selleruserid: '', - printno: "", + printno: '', iscloudprint: 'false', needprintdetail: 'false', extenddata: '', providercode: String(item.procode || item.realcpcode || item.logisticcompanycode || ''), packageno: '', fontsize: '', - platorderno: "", + platorderno: '', sipshopid: 0, })); console.log('京东批量打印请求参数', JSON.stringify({ @@ -1783,7 +1783,7 @@ class ExpressPlatformService extends MainService { count: item.plan_qty, })) || [], goods_description: '物品', - id:`${orderDelivery.warehouse_id}_${orderDelivery.id}_${order_tmp.business_key}`, + id: `${orderDelivery.warehouse_id}_${orderDelivery.id}_${order_tmp.business_key}`, }, recipient: { address: { @@ -2363,7 +2363,7 @@ class ExpressPlatformService extends MainService { name: item.item_name || '商品', count: item.plan_qty, })) || [], - id:`${order_tmp.order_delivery.warehouse_id}_${order_tmp.order_delivery.id}_${order_tmp.business_key}`, + id: `${order_tmp.order_delivery.warehouse_id}_${order_tmp.order_delivery.id}_${order_tmp.business_key}`, }, recipient: { address: { diff --git a/app/service/systems/shops.js b/app/service/systems/shops.js index 8e792b7..ad9d8d2 100644 --- a/app/service/systems/shops.js +++ b/app/service/systems/shops.js @@ -722,7 +722,7 @@ class ShopsService extends Service { requestData.VenderID = shopPlain.id; } if (platName === '视频号') { - if(!appId || !toUserName) { + if (!appId || !toUserName) { throw this.createError('视频号授权需要提供 appId 和 toUserName', 400); } requestData.appId = appId; diff --git a/app/service/systems/stock_store.js b/app/service/systems/stock_store.js index c7c5f0d..9e377e4 100644 --- a/app/service/systems/stock_store.js +++ b/app/service/systems/stock_store.js @@ -1599,6 +1599,8 @@ class stockStoreService extends Service { * @param {Object} sortParams - 排序参数 * @param {string} sortParams.sortField - 排序字段,默认'create_at' * @param {string} sortParams.sortOrder - 排序方式,默认'DESC' + * @param externalWarehouseId + * @param externalStoreId * @return {Promise} 返回查询结果 */ async getWarehouseStock(where, pageParams = {}, sortParams = {}, externalWarehouseId = 0, externalStoreId = 0) { @@ -2842,7 +2844,7 @@ class stockStoreService extends Service { ]); } // 批量查询奇门应用名称 - const appKeys = [...new Set(barcodes.map(item => item.app_key).filter(Boolean))]; + const appKeys = [ ...new Set(barcodes.map(item => item.app_key).filter(Boolean)) ]; const qimenAppMap = new Map(); if (appKeys.length > 0) { const qimenApps = await ctx.model.QimenApp.findAll({ diff --git a/app/service/systems/storage/report.js b/app/service/systems/storage/report.js index 54e24a3..42a059a 100644 --- a/app/service/systems/storage/report.js +++ b/app/service/systems/storage/report.js @@ -328,6 +328,9 @@ class StorageReportService extends Service { * @param {number[]} [options.storeIds=[]] 货主ID列表 * @param {number[]} [options.spaceIds=[]] 库位ID列表 * @param {boolean} [options.includeBarcode=false] 是否加载条码映射 + * @param options.entryOrderIds + * @param options.orderIds + * @param options.warehouseId * @return {Promise} 映射对象 */ async loadReportReferenceMaps({ diff --git a/app/service/systems/store_express_binding_policy.js b/app/service/systems/store_express_binding_policy.js index 49e5104..c6f1732 100644 --- a/app/service/systems/store_express_binding_policy.js +++ b/app/service/systems/store_express_binding_policy.js @@ -92,6 +92,8 @@ class StoreExpressBindingPolicyService extends Service { /** * 校验快递编码是否存在。 * @param {string} expressCode 快递编码 + * @param value + * @param fieldName * @return {Promise} 标准化快递编码 */ normalizeJsonArray(value, fieldName) { diff --git a/app/service/systems/store_warehouse.js b/app/service/systems/store_warehouse.js index d4dae35..ea24806 100644 --- a/app/service/systems/store_warehouse.js +++ b/app/service/systems/store_warehouse.js @@ -1852,6 +1852,7 @@ class SettingStoreWarehouseService extends Service { /** * 精简签约对象,仅保留前端需要的字段。 + * @param serialized */ trimContract(serialized) { return { @@ -2198,7 +2199,7 @@ class SettingStoreWarehouseService extends Service { const accountIds = Array.from(accountIdSet).filter(id => Number.isFinite(id) && id > 0); // 批量查询账号姓名 - let accountNameMap = {}; + const accountNameMap = {}; if (accountIds.length > 0) { try { const accounts = await ctx.model.Account.findAll({ diff --git a/database/migrations/20260710000000-fix-custom-barcode-unique-to-per-warehouse.js b/database/migrations/20260710000000-fix-custom-barcode-unique-to-per-warehouse.js index 4f1004f..aa5e3c2 100644 --- a/database/migrations/20260710000000-fix-custom-barcode-unique-to-per-warehouse.js +++ b/database/migrations/20260710000000-fix-custom-barcode-unique-to-per-warehouse.js @@ -4,7 +4,7 @@ module.exports = { async up(queryInterface, Sequelize) { // 将 custom_barcode 唯一索引从全局改为仓库级别 await queryInterface.removeIndex('wms_location_space', 'uk_custom_barcode'); - await queryInterface.addIndex('wms_location_space', ['warehouse_id', 'custom_barcode', 'deleted_at'], { + await queryInterface.addIndex('wms_location_space', [ 'warehouse_id', 'custom_barcode', 'deleted_at' ], { name: 'uk_warehouse_custom_barcode', unique: true, }); @@ -12,7 +12,7 @@ module.exports = { async down(queryInterface, Sequelize) { await queryInterface.removeIndex('wms_location_space', 'uk_warehouse_custom_barcode'); - await queryInterface.addIndex('wms_location_space', ['custom_barcode'], { + await queryInterface.addIndex('wms_location_space', [ 'custom_barcode' ], { name: 'uk_custom_barcode', unique: true, }); diff --git a/database/migrations/20260713150000-set-auto-increment-wms-order-delivery-1000028.js b/database/migrations/20260713150000-set-auto-increment-wms-order-delivery-1000028.js index 14e8da6..93286cf 100644 --- a/database/migrations/20260713150000-set-auto-increment-wms-order-delivery-1000028.js +++ b/database/migrations/20260713150000-set-auto-increment-wms-order-delivery-1000028.js @@ -5,7 +5,7 @@ module.exports = { // 紧急修复:将 wms_order_delivery_1000028 自增值提升至 15000+ // 原因:表重建后 AUTO_INCREMENT 被重置为 151,与历史水位差距过大 await queryInterface.sequelize.query( - "ALTER TABLE wms_order_delivery_1000028 AUTO_INCREMENT = 15000" + 'ALTER TABLE wms_order_delivery_1000028 AUTO_INCREMENT = 15000' ); }, diff --git a/database/migrations/20260715160000-create-wms-workbench.js b/database/migrations/20260715160000-create-wms-workbench.js index 4912d91..53ca5f5 100644 --- a/database/migrations/20260715160000-create-wms-workbench.js +++ b/database/migrations/20260715160000-create-wms-workbench.js @@ -62,23 +62,23 @@ module.exports = { }); // 仓库隔离查询 - await queryInterface.addIndex(TABLE_NAME, ['warehouse_id'], { + await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id' ], { name: 'idx_warehouse_id', }); // 条码检索 - await queryInterface.addIndex(TABLE_NAME, ['barcode'], { + await queryInterface.addIndex(TABLE_NAME, [ 'barcode' ], { name: 'idx_barcode', }); // 仓库级别唯一条码(含软删除,遵循 location_space 同款模式) - await queryInterface.addIndex(TABLE_NAME, ['warehouse_id', 'barcode', 'deleted_at'], { + await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id', 'barcode', 'deleted_at' ], { unique: true, name: 'uk_warehouse_barcode', }); // 软删除查询优化 - await queryInterface.addIndex(TABLE_NAME, ['deleted_at'], { + await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], { name: 'idx_deleted_at', }); }, diff --git a/database/migrations/20260715170000-add-type-to-wms-workbench.js b/database/migrations/20260715170000-add-type-to-wms-workbench.js index 5ce0cda..4e10f28 100644 --- a/database/migrations/20260715170000-add-type-to-wms-workbench.js +++ b/database/migrations/20260715170000-add-type-to-wms-workbench.js @@ -13,7 +13,7 @@ module.exports = { }); }, - down: async (queryInterface) => { + down: async queryInterface => { await queryInterface.removeColumn(TABLE_NAME, 'type'); }, }; diff --git a/database/migrations/20260715180000-extend-wms-pack-task.js b/database/migrations/20260715180000-extend-wms-pack-task.js index 365b690..54a3dbb 100644 --- a/database/migrations/20260715180000-extend-wms-pack-task.js +++ b/database/migrations/20260715180000-extend-wms-pack-task.js @@ -130,12 +130,12 @@ module.exports = { }); // ======== 索引 ======== - await queryInterface.addIndex(TABLE_NAME, ['warehouse_id'], { name: 'idx_warehouse_id' }); - await queryInterface.addIndex(TABLE_NAME, ['workbench_id'], { name: 'idx_workbench_id' }); - await queryInterface.addIndex(TABLE_NAME, ['wave_id'], { name: 'idx_wave_id' }); - await queryInterface.addIndex(TABLE_NAME, ['waybill_code'], { name: 'idx_waybill_code' }); - await queryInterface.addIndex(TABLE_NAME, ['start_time'], { name: 'idx_start_time' }); - await queryInterface.addIndex(TABLE_NAME, ['status'], { name: 'idx_status' }); + await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id' ], { name: 'idx_warehouse_id' }); + await queryInterface.addIndex(TABLE_NAME, [ 'workbench_id' ], { name: 'idx_workbench_id' }); + await queryInterface.addIndex(TABLE_NAME, [ 'wave_id' ], { name: 'idx_wave_id' }); + await queryInterface.addIndex(TABLE_NAME, [ 'waybill_code' ], { name: 'idx_waybill_code' }); + await queryInterface.addIndex(TABLE_NAME, [ 'start_time' ], { name: 'idx_start_time' }); + await queryInterface.addIndex(TABLE_NAME, [ 'status' ], { name: 'idx_status' }); }, down: async queryInterface => { diff --git a/database/migrations/20260715220000-create-wms-camera-server.js b/database/migrations/20260715220000-create-wms-camera-server.js index 5ad66f3..5e2dc93 100644 --- a/database/migrations/20260715220000-create-wms-camera-server.js +++ b/database/migrations/20260715220000-create-wms-camera-server.js @@ -87,9 +87,9 @@ module.exports = { }, }); - await queryInterface.addIndex(TABLE_NAME, ['warehouse_id'], { name: 'idx_warehouse_id' }); - await queryInterface.addIndex(TABLE_NAME, ['status'], { name: 'idx_status' }); - await queryInterface.addIndex(TABLE_NAME, ['deleted_at'], { name: 'idx_deleted_at' }); + await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id' ], { name: 'idx_warehouse_id' }); + await queryInterface.addIndex(TABLE_NAME, [ 'status' ], { name: 'idx_status' }); + await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], { name: 'idx_deleted_at' }); }, down: async queryInterface => { diff --git a/database/migrations/20260715220001-create-wms-camera.js b/database/migrations/20260715220001-create-wms-camera.js index 6a6e894..328ddc3 100644 --- a/database/migrations/20260715220001-create-wms-camera.js +++ b/database/migrations/20260715220001-create-wms-camera.js @@ -71,15 +71,15 @@ module.exports = { }, }); - await queryInterface.addIndex(TABLE_NAME, ['warehouse_id'], { name: 'idx_warehouse_id' }); - await queryInterface.addIndex(TABLE_NAME, ['server_id'], { name: 'idx_server_id' }); + await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id' ], { name: 'idx_warehouse_id' }); + await queryInterface.addIndex(TABLE_NAME, [ 'server_id' ], { name: 'idx_server_id' }); // 同一服务器下通道号唯一 - await queryInterface.addIndex(TABLE_NAME, ['server_id', 'channel_id', 'deleted_at'], { + await queryInterface.addIndex(TABLE_NAME, [ 'server_id', 'channel_id', 'deleted_at' ], { unique: true, name: 'uk_server_channel', }); - await queryInterface.addIndex(TABLE_NAME, ['status'], { name: 'idx_status' }); - await queryInterface.addIndex(TABLE_NAME, ['deleted_at'], { name: 'idx_deleted_at' }); + await queryInterface.addIndex(TABLE_NAME, [ 'status' ], { name: 'idx_status' }); + await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], { name: 'idx_deleted_at' }); }, down: async queryInterface => { diff --git a/database/migrations/20260715230000-create-wms-pack-task-video.js b/database/migrations/20260715230000-create-wms-pack-task-video.js index ceeeffa..32a871c 100644 --- a/database/migrations/20260715230000-create-wms-pack-task-video.js +++ b/database/migrations/20260715230000-create-wms-pack-task-video.js @@ -61,9 +61,9 @@ module.exports = { }, }); - await queryInterface.addIndex(TABLE_NAME, ['pack_task_id'], { name: 'idx_pack_task_id' }); - await queryInterface.addIndex(TABLE_NAME, ['camera_id'], { name: 'idx_camera_id' }); - await queryInterface.addIndex(TABLE_NAME, ['deleted_at'], { name: 'idx_deleted_at' }); + await queryInterface.addIndex(TABLE_NAME, [ 'pack_task_id' ], { name: 'idx_pack_task_id' }); + await queryInterface.addIndex(TABLE_NAME, [ 'camera_id' ], { name: 'idx_camera_id' }); + await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], { name: 'idx_deleted_at' }); }, down: async queryInterface => { diff --git a/database/migrations/20260717150000-add-camera-device-fields.js b/database/migrations/20260717150000-add-camera-device-fields.js index 6acfe27..46ce25e 100644 --- a/database/migrations/20260717150000-add-camera-device-fields.js +++ b/database/migrations/20260717150000-add-camera-device-fields.js @@ -43,7 +43,7 @@ module.exports = { }, down: async queryInterface => { - const columns = ['stream_type', 'serial_number', 'model', 'port', 'ip']; + const columns = [ 'stream_type', 'serial_number', 'model', 'port', 'ip' ]; for (const col of columns) { const tableInfo = await queryInterface.describeTable(TABLE_NAME); if (tableInfo[col]) { diff --git a/database/migrations/20260718170000-fix-supervisor-cs-permissions.js b/database/migrations/20260718170000-fix-supervisor-cs-permissions.js index 9f201d5..4a11bca 100644 --- a/database/migrations/20260718170000-fix-supervisor-cs-permissions.js +++ b/database/migrations/20260718170000-fix-supervisor-cs-permissions.js @@ -32,7 +32,7 @@ const OLD_PERMISSIONS = '[1,4,8,9,11,12,13,14,15,17,18,19,20,21,22,24,25,26,27,2 * @param {import('sequelize').QueryInterface} queryInterface */ module.exports.up = async queryInterface => { - const [result] = await queryInterface.sequelize.query( + const [ result ] = await queryInterface.sequelize.query( `UPDATE \`${TABLE}\` SET permissions = :permissions, updated_at = NOW() WHERE id = :id AND is_system = 1`, { replacements: { id: ROLE_ID, permissions: NEW_PERMISSIONS } } @@ -46,7 +46,7 @@ module.exports.up = async queryInterface => { * @param {import('sequelize').QueryInterface} queryInterface */ module.exports.down = async queryInterface => { - const [result] = await queryInterface.sequelize.query( + const [ result ] = await queryInterface.sequelize.query( `UPDATE \`${TABLE}\` SET permissions = :permissions, updated_at = NOW() WHERE id = :id AND is_system = 1`, { replacements: { id: ROLE_ID, permissions: OLD_PERMISSIONS } } diff --git a/database/migrations/20260720160000-add-print-qty-log-export-permissions.js b/database/migrations/20260720160000-add-print-qty-log-export-permissions.js index fdc0d75..b10acfe 100644 --- a/database/migrations/20260720160000-add-print-qty-log-export-permissions.js +++ b/database/migrations/20260720160000-add-print-qty-log-export-permissions.js @@ -21,7 +21,7 @@ const TABLE_PERMISSION = 'wms_permission'; const TABLE_ROLE = 'wms_role'; /** 需要授权的角色ID(财务以上:货主管理员 + 经理) */ -const TARGET_ROLE_IDS = [5, 8]; +const TARGET_ROLE_IDS = [ 5, 8 ]; /** @type {{path: string, name: string, meta_title: string, type: string}[]} */ const NEW_PERMISSIONS = [ @@ -149,7 +149,7 @@ module.exports.up = async queryInterface => { } console.log( - `[Migration] 面单余额导出权限迁移完成:` + + '[Migration] 面单余额导出权限迁移完成:' + `新增 ${NEW_PERMISSIONS.length} 条权限,授权 ${TARGET_ROLE_IDS.length} 个角色` ); }; diff --git a/database/migrations/20260725150000-add-print-computer-permissions.js b/database/migrations/20260725150000-add-print-computer-permissions.js index 0cdfe6f..3fb6c96 100644 --- a/database/migrations/20260725150000-add-print-computer-permissions.js +++ b/database/migrations/20260725150000-add-print-computer-permissions.js @@ -20,8 +20,8 @@ module.exports = { await queryInterface.bulkInsert('wms_permission', permissions); // 2. 查询刚插入的权限 ID - const [rows] = await queryInterface.sequelize.query( - `SELECT id FROM wms_permission WHERE path IN ('print_computer.list', 'print_computer.update', 'print_computer.delete') ORDER BY id` + const [ rows ] = await queryInterface.sequelize.query( + 'SELECT id FROM wms_permission WHERE path IN (\'print_computer.list\', \'print_computer.update\', \'print_computer.delete\') ORDER BY id' ); const ids = rows.map(r => r.id); if (ids.length !== 3) { @@ -29,7 +29,7 @@ module.exports = { } // 3. 授权客服主管及以上角色(排除 permissions='*' 的超级管理员角色) - const roleIds = [2, 5, 7, 8, 22, 26, 28, 29]; + const roleIds = [ 2, 5, 7, 8, 22, 26, 28, 29 ]; for (const permId of ids) { await queryInterface.sequelize.query(` UPDATE wms_role @@ -52,16 +52,16 @@ module.exports = { * @return {Promise} 无返回值 */ async down(queryInterface, Sequelize) { - const paths = ['print_computer.list', 'print_computer.update', 'print_computer.delete']; + const paths = [ 'print_computer.list', 'print_computer.update', 'print_computer.delete' ]; // 1. 查询权限 ID - const [rows] = await queryInterface.sequelize.query( + const [ rows ] = await queryInterface.sequelize.query( `SELECT id FROM wms_permission WHERE path IN ('${paths.join("','")}')` ); const ids = rows.map(r => r.id); // 2. 从角色权限中移除 - const roleIds = [2, 5, 7, 8, 22, 26, 28, 29]; + const roleIds = [ 2, 5, 7, 8, 22, 26, 28, 29 ]; for (const permId of ids) { await queryInterface.sequelize.query(` UPDATE wms_role diff --git a/database/migrations/20260725170000-add-recording-permissions.js b/database/migrations/20260725170000-add-recording-permissions.js index 4542c82..384bdad 100644 --- a/database/migrations/20260725170000-add-recording-permissions.js +++ b/database/migrations/20260725170000-add-recording-permissions.js @@ -19,8 +19,8 @@ module.exports = { await queryInterface.bulkInsert('wms_permission', permissions); // 2. 查询刚插入的权限 ID - const [rows] = await queryInterface.sequelize.query( - `SELECT id FROM wms_permission WHERE path IN ('print_computer.setRecording', 'print_computer.cancelRecording') ORDER BY id` + const [ rows ] = await queryInterface.sequelize.query( + 'SELECT id FROM wms_permission WHERE path IN (\'print_computer.setRecording\', \'print_computer.cancelRecording\') ORDER BY id' ); const ids = rows.map(r => r.id); if (ids.length !== 2) { @@ -28,7 +28,7 @@ module.exports = { } // 3. 授权客服主管及以上角色 - const roleIds = [2, 5, 7, 8, 22, 26, 28, 29]; + const roleIds = [ 2, 5, 7, 8, 22, 26, 28, 29 ]; for (const permId of ids) { await queryInterface.sequelize.query(` UPDATE wms_role @@ -51,14 +51,14 @@ module.exports = { * @return {Promise} 无返回值 */ async down(queryInterface, Sequelize) { - const paths = ['print_computer.setRecording', 'print_computer.cancelRecording']; + const paths = [ 'print_computer.setRecording', 'print_computer.cancelRecording' ]; - const [rows] = await queryInterface.sequelize.query( + const [ rows ] = await queryInterface.sequelize.query( `SELECT id FROM wms_permission WHERE path IN ('${paths.join("','")}')` ); const ids = rows.map(r => r.id); - const roleIds = [2, 5, 7, 8, 22, 26, 28, 29]; + const roleIds = [ 2, 5, 7, 8, 22, 26, 28, 29 ]; for (const permId of ids) { await queryInterface.sequelize.query(` UPDATE wms_role diff --git a/database/migrations/20260728120000-create-wms-after-sale-work-order.js b/database/migrations/20260728120000-create-wms-after-sale-work-order.js index 6854144..c6c6ab1 100644 --- a/database/migrations/20260728120000-create-wms-after-sale-work-order.js +++ b/database/migrations/20260728120000-create-wms-after-sale-work-order.js @@ -153,58 +153,58 @@ module.exports = { }); // 工单号唯一 - await queryInterface.addIndex(TABLE_NAME, ['work_order_no'], { + await queryInterface.addIndex(TABLE_NAME, [ 'work_order_no' ], { unique: true, name: 'uk_work_order_no', }); // 仓库隔离查询 - await queryInterface.addIndex(TABLE_NAME, ['warehouse_id'], { + await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id' ], { name: 'idx_warehouse_id', }); // 货主隔离查询 - await queryInterface.addIndex(TABLE_NAME, ['store_id'], { + await queryInterface.addIndex(TABLE_NAME, [ 'store_id' ], { name: 'idx_store_id', }); // 按业务类型+子类型+单据ID反查工单 - await queryInterface.addIndex(TABLE_NAME, ['business_type', 'business_sub_type', 'business_id'], { + await queryInterface.addIndex(TABLE_NAME, [ 'business_type', 'business_sub_type', 'business_id' ], { name: 'idx_business_type_subtype_id', }); // 按状态筛选 - await queryInterface.addIndex(TABLE_NAME, ['status'], { + await queryInterface.addIndex(TABLE_NAME, [ 'status' ], { name: 'idx_status', }); // 按处理人查询 - await queryInterface.addIndex(TABLE_NAME, ['assignee_id'], { + await queryInterface.addIndex(TABLE_NAME, [ 'assignee_id' ], { name: 'idx_assignee_id', }); // 按父工单查子工单 - await queryInterface.addIndex(TABLE_NAME, ['parent_work_order_id'], { + await queryInterface.addIndex(TABLE_NAME, [ 'parent_work_order_id' ], { name: 'idx_parent_work_order_id', }); // 按优先级排序 - await queryInterface.addIndex(TABLE_NAME, ['priority'], { + await queryInterface.addIndex(TABLE_NAME, [ 'priority' ], { name: 'idx_priority', }); // 按理赔状态筛选 - await queryInterface.addIndex(TABLE_NAME, ['claim_status'], { + await queryInterface.addIndex(TABLE_NAME, [ 'claim_status' ], { name: 'idx_claim_status', }); // 按时间排序 - await queryInterface.addIndex(TABLE_NAME, ['created_at'], { + await queryInterface.addIndex(TABLE_NAME, [ 'created_at' ], { name: 'idx_created_at', }); // 软删除查询优化 - await queryInterface.addIndex(TABLE_NAME, ['deleted_at'], { + await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], { name: 'idx_deleted_at', }); }, diff --git a/database/migrations/20260728130000-create-wms-after-sale-work-order-step.js b/database/migrations/20260728130000-create-wms-after-sale-work-order-step.js index 3564929..77e2b6f 100644 --- a/database/migrations/20260728130000-create-wms-after-sale-work-order-step.js +++ b/database/migrations/20260728130000-create-wms-after-sale-work-order-step.js @@ -88,22 +88,22 @@ module.exports = { }); // 按工单查所有步骤 - await queryInterface.addIndex(TABLE_NAME, ['work_order_id'], { + await queryInterface.addIndex(TABLE_NAME, [ 'work_order_id' ], { name: 'idx_work_order_id', }); // 按操作人反查 - await queryInterface.addIndex(TABLE_NAME, ['operator_id'], { + await queryInterface.addIndex(TABLE_NAME, [ 'operator_id' ], { name: 'idx_operator_id', }); // 软删除查询优化 - await queryInterface.addIndex(TABLE_NAME, ['deleted_at'], { + await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], { name: 'idx_deleted_at', }); // 同一工单下步骤序号唯一(含软删除) - await queryInterface.addIndex(TABLE_NAME, ['work_order_id', 'step_order', 'deleted_at'], { + await queryInterface.addIndex(TABLE_NAME, [ 'work_order_id', 'step_order', 'deleted_at' ], { unique: true, name: 'uk_work_order_step', }); diff --git a/database/migrations/20260729140000-add-waybill-list-indexes.js b/database/migrations/20260729140000-add-waybill-list-indexes.js index c5bdef9..049fad5 100644 --- a/database/migrations/20260729140000-add-waybill-list-indexes.js +++ b/database/migrations/20260729140000-add-waybill-list-indexes.js @@ -33,28 +33,28 @@ module.exports = { if (!indexNameSet.has('idx_warehouse_id_status')) { await queryInterface.addIndex(TABLE_NAME, { name: 'idx_warehouse_id_status', - fields: ['warehouse_id', 'status'], + fields: [ 'warehouse_id', 'status' ], }); } if (!indexNameSet.has('idx_logistics_code')) { await queryInterface.addIndex(TABLE_NAME, { name: 'idx_logistics_code', - fields: ['logistics_code'], + fields: [ 'logistics_code' ], }); } if (!indexNameSet.has('idx_logistics_interface_id')) { await queryInterface.addIndex(TABLE_NAME, { name: 'idx_logistics_interface_id', - fields: ['logistics_interface_id'], + fields: [ 'logistics_interface_id' ], }); } if (!indexNameSet.has('idx_warehouse_id_create_at')) { await queryInterface.addIndex(TABLE_NAME, { name: 'idx_warehouse_id_create_at', - fields: ['warehouse_id', 'create_at'], + fields: [ 'warehouse_id', 'create_at' ], }); } }, diff --git a/database/migrations/20260730000000-add-camera-username-password.js b/database/migrations/20260730000000-add-camera-username-password.js index bf89be1..2ba43b6 100644 --- a/database/migrations/20260730000000-add-camera-username-password.js +++ b/database/migrations/20260730000000-add-camera-username-password.js @@ -31,7 +31,7 @@ module.exports = { }, down: async queryInterface => { - const columns = ['password', 'username']; + const columns = [ 'password', 'username' ]; for (const col of columns) { const tableInfo = await queryInterface.describeTable(TABLE_NAME); if (tableInfo[col]) { diff --git a/database/migrations/20260730200000-backfill-wms-order-express-store-id.js b/database/migrations/20260730200000-backfill-wms-order-express-store-id.js index 401be9e..88df70b 100644 --- a/database/migrations/20260730200000-backfill-wms-order-express-store-id.js +++ b/database/migrations/20260730200000-backfill-wms-order-express-store-id.js @@ -11,7 +11,7 @@ const TABLE_NAME = 'wms_order_express'; */ async function backfill(queryInterface) { // 获取所有不同的 warehouse_id - const [warehouses] = await queryInterface.sequelize.query( + const [ warehouses ] = await queryInterface.sequelize.query( `SELECT DISTINCT warehouse_id FROM ${TABLE_NAME} WHERE store_id IS NULL AND warehouse_id IS NOT NULL` ); @@ -22,14 +22,14 @@ async function backfill(queryInterface) { for (const row of warehouses) { const warehouseId = row.warehouse_id; const tableTypes = [ - `wms_order_delivery_${warehouseId}`, // current(配送表 / 待处理表) - `wms_order_delivery_${warehouseId}_history`, // history - `wms_order_delivery_${warehouseId}_dispatch`, // dispatch + `wms_order_delivery_${warehouseId}`, // current(配送表 / 待处理表) + `wms_order_delivery_${warehouseId}_history`, // history + `wms_order_delivery_${warehouseId}_dispatch`, // dispatch ]; for (const deliveryTable of tableTypes) { try { - const [result] = await queryInterface.sequelize.query(` + const [ result ] = await queryInterface.sequelize.query(` UPDATE ${TABLE_NAME} e INNER JOIN ${deliveryTable} d ON e.order_id = d.id AND e.warehouse_id = d.warehouse_id SET e.store_id = d.store_id diff --git a/database/migrations/20260730210000-backfill-order-express-delivery-fields.js b/database/migrations/20260730210000-backfill-order-express-delivery-fields.js index 8736c81..46bff59 100644 --- a/database/migrations/20260730210000-backfill-order-express-delivery-fields.js +++ b/database/migrations/20260730210000-backfill-order-express-delivery-fields.js @@ -10,7 +10,7 @@ const TABLE_NAME = 'wms_order_express'; * @return {Promise} 无返回值。 */ async function backfill(queryInterface) { - const [warehouses] = await queryInterface.sequelize.query( + const [ warehouses ] = await queryInterface.sequelize.query( `SELECT DISTINCT warehouse_id FROM ${TABLE_NAME} WHERE delivery_order_code IS NULL AND warehouse_id IS NOT NULL` ); @@ -28,7 +28,7 @@ async function backfill(queryInterface) { for (const deliveryTable of tableTypes) { try { - const [result] = await queryInterface.sequelize.query(` + const [ result ] = await queryInterface.sequelize.query(` UPDATE ${TABLE_NAME} e INNER JOIN ${deliveryTable} d ON e.order_id = d.id AND e.warehouse_id = d.warehouse_id SET e.delivery_order_code = COALESCE(e.delivery_order_code, d.delivery_order_code), diff --git a/database/migrations/20260805120000-add-express-fields-to-inbox-group.js b/database/migrations/20260805120000-add-express-fields-to-inbox-group.js index c2ae5ec..926880e 100644 --- a/database/migrations/20260805120000-add-express-fields-to-inbox-group.js +++ b/database/migrations/20260805120000-add-express-fields-to-inbox-group.js @@ -29,7 +29,7 @@ module.exports = { } }, - down: async (queryInterface) => { + down: async queryInterface => { const tableInfo = await queryInterface.describeTable('wms_inbox_group'); if (tableInfo.express_interfaces) { diff --git a/database/migrations/20260805140000-add-inbox-indexes.js b/database/migrations/20260805140000-add-inbox-indexes.js index 558a0dc..974cf49 100644 --- a/database/migrations/20260805140000-add-inbox-indexes.js +++ b/database/migrations/20260805140000-add-inbox-indexes.js @@ -22,7 +22,7 @@ module.exports = { // 检查已有索引(通过尝试添加,重复则忽略) try { await queryInterface.addIndex('wms_inbox_message', { - fields: ['warehouse_id', 'group_id', 'created_at'], + fields: [ 'warehouse_id', 'group_id', 'created_at' ], name: 'idx_warehouse_group_created', }); console.log('[idx] wms_inbox_message.idx_warehouse_group_created 已创建'); @@ -37,7 +37,7 @@ module.exports = { // ── wms_inbox_group 索引 ── try { await queryInterface.addIndex('wms_inbox_group', { - fields: ['group_id'], + fields: [ 'group_id' ], name: 'idx_group_id', }); console.log('[idx] wms_inbox_group.idx_group_id 已创建'); @@ -51,7 +51,7 @@ module.exports = { try { await queryInterface.addIndex('wms_inbox_group', { - fields: ['warehouse_id', 'group_id'], + fields: [ 'warehouse_id', 'group_id' ], name: 'idx_warehouse_group_id', }); console.log('[idx] wms_inbox_group.idx_warehouse_group_id 已创建'); diff --git a/database/migrations/20260805150000-add-group-api-permissions.js b/database/migrations/20260805150000-add-group-api-permissions.js index 95cc4e6..0464573 100644 --- a/database/migrations/20260805150000-add-group-api-permissions.js +++ b/database/migrations/20260805150000-add-group-api-permissions.js @@ -13,13 +13,13 @@ module.exports = { // eslint-disable-next-line no-unused-vars async up(queryInterface, Sequelize) { const methods = [ - [495, 'inbox.group.list'], - [496, 'inbox.group.disable'], - [497, 'inbox.group.update'], - [498, 'inbox.group.messages'], + [ 495, 'inbox.group.list' ], + [ 496, 'inbox.group.disable' ], + [ 497, 'inbox.group.update' ], + [ 498, 'inbox.group.messages' ], ]; - for (const [id, method] of methods) { + for (const [ id, method ] of methods) { await queryInterface.sequelize.query(` INSERT INTO wms_permission (id, path, component, name, redirect, meta_title, meta_icon, hidden, always_show, parent_id, type, sort, status, created_at, update_at) VALUES (${id}, '${method}', NULL, '${method}', NULL, 'API:${method}', NULL, 0, 0, NULL, 'api', 0, 1, NOW(), NOW()) diff --git a/database/migrations/20260806120000-add-ai-thoughts-to-inbox-message.js b/database/migrations/20260806120000-add-ai-thoughts-to-inbox-message.js index fe6095d..303c981 100644 --- a/database/migrations/20260806120000-add-ai-thoughts-to-inbox-message.js +++ b/database/migrations/20260806120000-add-ai-thoughts-to-inbox-message.js @@ -18,7 +18,7 @@ module.exports = { }, // eslint-disable-next-line no-unused-vars - down: async (queryInterface) => { + down: async queryInterface => { const tableInfo = await queryInterface.describeTable('wms_inbox_message'); if (tableInfo.ai_thoughts) { await queryInterface.removeColumn('wms_inbox_message', 'ai_thoughts'); diff --git a/database/migrations/20260807120000-add-express-code-to-wms-order-stockout.js b/database/migrations/20260807120000-add-express-code-to-wms-order-stockout.js index bace1e7..8c1386e 100644 --- a/database/migrations/20260807120000-add-express-code-to-wms-order-stockout.js +++ b/database/migrations/20260807120000-add-express-code-to-wms-order-stockout.js @@ -29,7 +29,7 @@ module.exports = { } }, - down: async (queryInterface) => { + down: async queryInterface => { const columns = await queryInterface.describeTable(TABLE); if (columns.express_code) { diff --git a/database/migrations/20260807130000-add-stockout-api-permissions.js b/database/migrations/20260807130000-add-stockout-api-permissions.js index 1dcb27c..f4b39d5 100644 --- a/database/migrations/20260807130000-add-stockout-api-permissions.js +++ b/database/migrations/20260807130000-add-stockout-api-permissions.js @@ -12,16 +12,16 @@ * 授权角色:经理(8)、仓库组-主管(26)、客服组-主管(28)、生产组-主管(29)、客服组-员工(30) */ module.exports = { - up: async (queryInterface) => { + up: async queryInterface => { // ===== 第一步:写入权限行 ===== const perms = [ - [504, 'storage.stockout.list', '出库单列表'], - [505, 'storage.stockout.listItems', '出库单明细'], - [506, 'storage.stockout.confirm', '出库单确认'], - [507, 'storage.stockout.updateExpress', '更新运单号'], + [ 504, 'storage.stockout.list', '出库单列表' ], + [ 505, 'storage.stockout.listItems', '出库单明细' ], + [ 506, 'storage.stockout.confirm', '出库单确认' ], + [ 507, 'storage.stockout.updateExpress', '更新运单号' ], ]; - for (const [id, method, desc] of perms) { + for (const [ id, method, desc ] of perms) { await queryInterface.sequelize.query(` INSERT INTO wms_permission (id, path, component, name, redirect, meta_title, meta_icon, hidden, always_show, parent_id, type, sort, status, created_at, update_at) VALUES (${id}, '${method}', NULL, '${method}', NULL, 'API:${desc}', NULL, 0, 0, NULL, 'api', 0, 1, NOW(), NOW()) @@ -30,8 +30,8 @@ module.exports = { } // ===== 第二步:授权给客服组员工及以上角色 ===== - const roleIds = [8, 26, 28, 29, 30]; // 经理 + 各主管 + 客服组-员工 - const newPermIds = [504, 505, 506, 507]; + const roleIds = [ 8, 26, 28, 29, 30 ]; // 经理 + 各主管 + 客服组-员工 + const newPermIds = [ 504, 505, 506, 507 ]; for (const roleId of roleIds) { for (const permId of newPermIds) { @@ -50,9 +50,9 @@ module.exports = { } }, - down: async (queryInterface) => { + down: async queryInterface => { // 移除授权 - const roleIds = [8, 26, 28, 29, 30]; + const roleIds = [ 8, 26, 28, 29, 30 ]; const permIdStr = '504, 505, 506, 507'; for (const roleId of roleIds) { diff --git a/database/migrations/20260807140000-add-express-name-waybill-to-wms-order-stockout.js b/database/migrations/20260807140000-add-express-name-waybill-to-wms-order-stockout.js index b9c4912..158b5e0 100644 --- a/database/migrations/20260807140000-add-express-name-waybill-to-wms-order-stockout.js +++ b/database/migrations/20260807140000-add-express-name-waybill-to-wms-order-stockout.js @@ -38,7 +38,7 @@ module.exports = { } }, - down: async (queryInterface) => { + down: async queryInterface => { const columns = await queryInterface.describeTable(TABLE); if (columns.express_name) { diff --git a/database/migrations/20260808100000-add-delivery-code-store-index.js b/database/migrations/20260808100000-add-delivery-code-store-index.js index 6537aaf..8bcba00 100644 --- a/database/migrations/20260808100000-add-delivery-code-store-index.js +++ b/database/migrations/20260808100000-add-delivery-code-store-index.js @@ -3,7 +3,7 @@ module.exports = { async up(queryInterface, Sequelize) { // Query 3 关联查询:delivery_order_code + store_id 联合索引(最高频缺失索引) - await queryInterface.addIndex('wms_order_express', ['delivery_order_code', 'store_id'], { + await queryInterface.addIndex('wms_order_express', [ 'delivery_order_code', 'store_id' ], { name: 'idx_delivery_code_store', }); }, diff --git a/scripts/auth/grant-cs-up.js b/scripts/auth/grant-cs-up.js index fd4fbef..ff8e8ad 100644 --- a/scripts/auth/grant-cs-up.js +++ b/scripts/auth/grant-cs-up.js @@ -19,11 +19,11 @@ const mysql = projectRequire('mysql2/promise'); const CS_CHAIN_ROLES = [ { id: 30, code: '04', name: '客服组-员工' }, { id: 28, code: '05', name: '客服组-主管' }, - { id: 8, code: '2', name: '经理' }, + { id: 8, code: '2', name: '经理' }, ]; // 已有通配符 * 的角色,自动拥有所有权限,跳过 -const WILDCARD_ROLES = [7, 2]; +const WILDCARD_ROLES = [ 7, 2 ]; // ── 数据库连接 ── @@ -58,9 +58,9 @@ async function createConnection(env) { // ── 权限校验 ── async function getPermission(conn, permId) { - const [rows] = await conn.query( + const [ rows ] = await conn.query( 'SELECT id, name, meta_title, type, path FROM wms_permission WHERE id = ?', - [permId] + [ permId ] ); return rows[0] || null; } @@ -71,9 +71,9 @@ async function grantPermission(conn, permId, envLabel) { const results = []; for (const role of CS_CHAIN_ROLES) { - const [rows] = await conn.query( + const [ rows ] = await conn.query( 'SELECT id, role_code, role_name, permissions FROM wms_role WHERE id = ? AND deleted_at IS NULL', - [role.id] + [ role.id ] ); if (rows.length === 0) { @@ -94,7 +94,7 @@ async function grantPermission(conn, permId, envLabel) { try { perms = JSON.parse(record.permissions); } catch { - results.push({ role, status: 'error', msg: `permissions JSON 解析失败` }); + results.push({ role, status: 'error', msg: 'permissions JSON 解析失败' }); continue; } diff --git a/scripts/auth/revoke-cs-up.js b/scripts/auth/revoke-cs-up.js index d9bf651..e1431d3 100644 --- a/scripts/auth/revoke-cs-up.js +++ b/scripts/auth/revoke-cs-up.js @@ -19,7 +19,7 @@ const mysql = projectRequire('mysql2/promise'); const CS_CHAIN_ROLES = [ { id: 30, code: '04', name: '客服组-员工' }, { id: 28, code: '05', name: '客服组-主管' }, - { id: 8, code: '2', name: '经理' }, + { id: 8, code: '2', name: '经理' }, ]; // ── 数据库连接 ── @@ -58,9 +58,9 @@ async function revokePermission(conn, permId, envLabel) { const results = []; for (const role of CS_CHAIN_ROLES) { - const [rows] = await conn.query( + const [ rows ] = await conn.query( 'SELECT id, role_code, role_name, permissions FROM wms_role WHERE id = ? AND deleted_at IS NULL', - [role.id] + [ role.id ] ); if (rows.length === 0) { @@ -127,7 +127,7 @@ async function main() { console.log('═══════════════════════════════════════'); console.log(` 权限 ID: ${permIdNum}`); console.log(` 目标角色: ${CS_CHAIN_ROLES.map(r => `${r.name}(${r.id})`).join(' → ')}`); - console.log(` 通配符角色(跳过): id=7,2 (已有 *)`); + console.log(' 通配符角色(跳过): id=7,2 (已有 *)'); console.log('═══════════════════════════════════════\n'); // ── 开发环境:查询权限信息 ── @@ -139,9 +139,9 @@ async function main() { process.exit(1); } - const [permRows] = await devConn.query( + const [ permRows ] = await devConn.query( 'SELECT id, name, meta_title, type, path FROM wms_permission WHERE id = ?', - [permIdNum] + [ permIdNum ] ); if (permRows.length > 0) { diff --git a/test/app/service/systemMethods/order/pendingOrder.manualWaybill.log.test.js b/test/app/service/systemMethods/order/pendingOrder.manualWaybill.log.test.js index 31b806d..1cd7fc6 100644 --- a/test/app/service/systemMethods/order/pendingOrder.manualWaybill.log.test.js +++ b/test/app/service/systemMethods/order/pendingOrder.manualWaybill.log.test.js @@ -7,6 +7,7 @@ const PendingOrderService = require('../../../../../app/service/systemMethods/or * 创建 manualWaybill 操作日志回归测试上下文。 * * 仅覆盖 operationLog.createOperationLog 的 businessId 传入值。 + * @param options */ function createManualWaybillLogHarness(options = {}) { const calls = { @@ -103,14 +104,14 @@ function createManualWaybillLogHarness(options = {}) { }, }); - service.buildOrderWhere = (orderIds) => ({ + service.buildOrderWhere = orderIds => ({ id: { [ctx.app.Sequelize.Op.in]: orderIds }, warehouse_id: warehouseId, }); service.success = (msg, data) => ({ code: 0, msg, data }); - service.syncOrderIds = (payload) => { + service.syncOrderIds = payload => { calls.syncOrderIdsPayload = payload; return Promise.resolve(); };