ming #1

Merged
liufumingren merged 558 commits from ming into main 2026-11-18 16:13:25 +08:00
48 changed files with 165 additions and 141 deletions
Showing only changes of commit 358fef0f71 - Show all commits

View File

@ -1253,6 +1253,7 @@ function sanitizeTemplatePrivateFields(value, warnings, currentKey = '') {
* @param {string[]} warnings 风险提示列表。 * @param {string[]} warnings 风险提示列表。
* @param {Object} policyConfig 策略配置对象。 * @param {Object} policyConfig 策略配置对象。
* @param {string} customDataTemplateURL 自定义区模板地址默认值。 * @param {string} customDataTemplateURL 自定义区模板地址默认值。
* @param extraCustomLines
*/ */
function applyKuaishouExpressFieldMapping(platform, skeleton, orderExpress, orderDelivery, warnings, policyConfig, customDataTemplateURL, extraCustomLines = []) { function applyKuaishouExpressFieldMapping(platform, skeleton, orderExpress, orderDelivery, warnings, policyConfig, customDataTemplateURL, extraCustomLines = []) {
if (platform !== 'kuaishou') { if (platform !== 'kuaishou') {
@ -1402,6 +1403,7 @@ function applyKuaishouExpressFieldMapping(platform, skeleton, orderExpress, orde
* @param {Object} orderExpress 快递单对象。 * @param {Object} orderExpress 快递单对象。
* @param {Object} orderDelivery 订单对象。 * @param {Object} orderDelivery 订单对象。
* @param {Object} policyConfig 策略配置对象。 * @param {Object} policyConfig 策略配置对象。
* @param extraCustomLines
*/ */
function applyPddExpressFieldMapping(platform, skeleton, orderExpress, orderDelivery, policyConfig, extraCustomLines = []) { function applyPddExpressFieldMapping(platform, skeleton, orderExpress, orderDelivery, policyConfig, extraCustomLines = []) {
if (platform !== 'pdd') { if (platform !== 'pdd') {
@ -1724,6 +1726,7 @@ function applyDouyinExpressFieldMapping(platform, skeleton, orderExpress, orderD
* @param {Object} policyConfig 策略配置对象。 * @param {Object} policyConfig 策略配置对象。
* @param {string} customControlTemplateURL 菜鸟自定义区模板地址。 * @param {string} customControlTemplateURL 菜鸟自定义区模板地址。
* @param {string[]} warnings 风险提示列表。 * @param {string[]} warnings 风险提示列表。
* @param extraCustomLines
*/ */
function applyCainiaoExpressFieldMapping( function applyCainiaoExpressFieldMapping(
platform, platform,
@ -1934,6 +1937,7 @@ function resolveXhsMainContentFromPrintinfo(printinfo, warnings = []) {
* @param {Object} orderDelivery 订单对象。 * @param {Object} orderDelivery 订单对象。
* @param {Object} policyConfig 策略配置对象。 * @param {Object} policyConfig 策略配置对象。
* @param {string[]} warnings 风险提示列表。 * @param {string[]} warnings 风险提示列表。
* @param extraCustomLines
*/ */
function applyXhsExpressFieldMapping( function applyXhsExpressFieldMapping(
platform, platform,
@ -2036,6 +2040,7 @@ function applyXhsExpressFieldMapping(
* @param {Object} orderExpress 快递单对象。 * @param {Object} orderExpress 快递单对象。
* @param {Object} orderDelivery 订单对象。 * @param {Object} orderDelivery 订单对象。
* @param {Object} policyConfig 策略配置对象。 * @param {Object} policyConfig 策略配置对象。
* @param extraCustomLines
*/ */
function applySphExpressFieldMapping( function applySphExpressFieldMapping(
platform, platform,
@ -2176,6 +2181,7 @@ function resolveJdTemplateUrlFromOrderExpress(orderExpress) {
* @param {Object} policyConfig 策略配置对象。 * @param {Object} policyConfig 策略配置对象。
* @param {Object} templateSample 模板样例对象。 * @param {Object} templateSample 模板样例对象。
* @param {string[]} warnings 风险提示列表。 * @param {string[]} warnings 风险提示列表。
* @param extraCustomLines
*/ */
function applyJdExpressFieldMapping( function applyJdExpressFieldMapping(
platform, platform,

View File

@ -71,7 +71,7 @@ module.exports = app => {
/** /**
* 根据 business_type 获取关联表名 * 根据 business_type 获取关联表名
* @param {string} businessType 业务类型 * @param {string} businessType 业务类型
* @returns {string|null} 关联表名 * @return {string|null} 关联表名
*/ */
function getBusinessTable(businessType) { function getBusinessTable(businessType) {
return BUSINESS_TYPES[businessType]?.table || null; return BUSINESS_TYPES[businessType]?.table || null;
@ -81,7 +81,7 @@ module.exports = app => {
* 校验 business_type + business_sub_type 组合是否合法 * 校验 business_type + business_sub_type 组合是否合法
* @param {string} businessType 业务类型 * @param {string} businessType 业务类型
* @param {string} businessSubType 业务子类型 * @param {string} businessSubType 业务子类型
* @returns {boolean} 是否合法 * @return {boolean} 是否合法
*/ */
function isValidSubType(businessType, businessSubType) { function isValidSubType(businessType, businessSubType) {
const def = BUSINESS_TYPES[businessType]; const def = BUSINESS_TYPES[businessType];

View File

@ -105,11 +105,11 @@ module.exports = app => {
deletedAt: 'deleted_at', deletedAt: 'deleted_at',
comment: '摄像头表', comment: '摄像头表',
indexes: [ indexes: [
{ name: 'idx_warehouse_id', fields: ['warehouse_id'] }, { name: 'idx_warehouse_id', fields: [ 'warehouse_id' ] },
{ name: 'idx_server_id', fields: ['server_id'] }, { name: 'idx_server_id', fields: [ 'server_id' ] },
{ name: 'uk_server_channel', unique: true, fields: ['server_id', 'channel_id', 'deleted_at'] }, { name: 'uk_server_channel', unique: true, fields: [ 'server_id', 'channel_id', 'deleted_at' ] },
{ name: 'idx_status', fields: ['status'] }, { name: 'idx_status', fields: [ 'status' ] },
{ name: 'idx_deleted_at', fields: ['deleted_at'] }, { name: 'idx_deleted_at', fields: [ 'deleted_at' ] },
], ],
}); });

View File

@ -90,9 +90,9 @@ module.exports = app => {
deletedAt: 'deleted_at', deletedAt: 'deleted_at',
comment: '录像服务器表', comment: '录像服务器表',
indexes: [ indexes: [
{ name: 'idx_warehouse_id', fields: ['warehouse_id'] }, { name: 'idx_warehouse_id', fields: [ 'warehouse_id' ] },
{ name: 'idx_status', fields: ['status'] }, { name: 'idx_status', fields: [ 'status' ] },
{ name: 'idx_deleted_at', fields: ['deleted_at'] }, { name: 'idx_deleted_at', fields: [ 'deleted_at' ] },
], ],
}); });

View File

@ -71,10 +71,10 @@ module.exports = app => {
deletedAt: 'deleted_at', deletedAt: 'deleted_at',
comment: '工作台表', comment: '工作台表',
indexes: [ indexes: [
{ name: 'idx_warehouse_id', fields: ['warehouse_id'] }, { name: 'idx_warehouse_id', fields: [ 'warehouse_id' ] },
{ name: 'idx_barcode', fields: ['barcode'] }, { name: 'idx_barcode', fields: [ 'barcode' ] },
{ name: 'uk_warehouse_barcode', unique: true, fields: ['warehouse_id', 'barcode', 'deleted_at'] }, { name: 'uk_warehouse_barcode', unique: true, fields: [ 'warehouse_id', 'barcode', 'deleted_at' ] },
{ name: 'idx_deleted_at', fields: ['deleted_at'] }, { name: 'idx_deleted_at', fields: [ 'deleted_at' ] },
], ],
}); });

View File

@ -25,7 +25,7 @@ class dashboardService extends MainService {
return this.fail('缺少仓库上下文'); return this.fail('缺少仓库上下文');
} }
const stats = await this.queryWarehouseStats(warehouseId); const stats = await this.queryWarehouseStats(warehouseId);
return this.success('ok', this.mergeStoreStats([stats])); return this.success('ok', this.mergeStoreStats([ stats ]));
} }
async storeSideStoreStats() { async storeSideStoreStats() {

View File

@ -130,11 +130,11 @@ class expressInterfaceService extends MainService {
} }
// 收集唯一 shop_id(去重) // 收集唯一 shop_id(去重)
const shopIds = [...new Set( const shopIds = [ ...new Set(
list list
.map(item => item.shop_id) .map(item => item.shop_id)
.filter(id => id !== null && id !== undefined && Number(id) !== 0) .filter(id => id !== null && id !== undefined && Number(id) !== 0)
)]; ) ];
if (shopIds.length === 0) { if (shopIds.length === 0) {
const defaultList = list.map(item => ({ ...item, quantity: 0, recycled_quantity: 0, cancel_quantity: 0, allocated_quantity: 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<shopId, expressList> // 并行调用 getShopExpressList,构建 Map<shopId, expressList>
const shopExpressMap = new Map(); const shopExpressMap = new Map();
const shopResults = await Promise.all( const shopResults = await Promise.all(
shopIds.map(async (shopId) => { shopIds.map(async shopId => {
try { try {
const shopExpressResult = await ctx.service.systemMethods.index.getShopExpressList({ const shopExpressResult = await ctx.service.systemMethods.index.getShopExpressList({
shop_id: shopId, shop_id: shopId,

View File

@ -51,6 +51,7 @@ class StoreWarehouseWarehouseService extends MainService {
/** /**
* 仓库侧发起签约。 * 仓库侧发起签约。
* @param data
*/ */
async sign(data = {}) { async sign(data = {}) {
const targetService = this.service && this.service.systems && this.service.systems.storeWarehouse; const targetService = this.service && this.service.systems && this.service.systems.storeWarehouse;
@ -68,6 +69,7 @@ class StoreWarehouseWarehouseService extends MainService {
/** /**
* 仓库侧确认签约。 * 仓库侧确认签约。
* @param data
*/ */
async confirmSign(data = {}) { async confirmSign(data = {}) {
const targetService = this.service && this.service.systems && this.service.systems.storeWarehouse; const targetService = this.service && this.service.systems && this.service.systems.storeWarehouse;

View File

@ -14,6 +14,7 @@ class WorkbenchService extends MainService {
/** /**
* 工作台列表(分页 + 筛选) * 工作台列表(分页 + 筛选)
* @param data
*/ */
async list(data) { async list(data) {
const { service } = this; const { service } = this;
@ -27,6 +28,7 @@ class WorkbenchService extends MainService {
/** /**
* 工作台详情 * 工作台详情
* @param data
*/ */
async detail(data) { async detail(data) {
const { service } = this; const { service } = this;
@ -42,6 +44,7 @@ class WorkbenchService extends MainService {
/** /**
* 创建工作台 * 创建工作台
* @param data
*/ */
async create(data) { async create(data) {
const { service } = this; const { service } = this;
@ -55,6 +58,7 @@ class WorkbenchService extends MainService {
/** /**
* 更新工作台 * 更新工作台
* @param data
*/ */
async update(data) { async update(data) {
const { service } = this; const { service } = this;
@ -70,6 +74,7 @@ class WorkbenchService extends MainService {
/** /**
* 删除工作台(软删除) * 删除工作台(软删除)
* @param data
*/ */
async delete(data) { async delete(data) {
const { service } = this; const { service } = this;
@ -102,6 +107,7 @@ class WorkbenchService extends MainService {
/** /**
* 工作台绑定摄像头 * 工作台绑定摄像头
* @param data
*/ */
async bindCamera(data) { async bindCamera(data) {
const { service } = this; const { service } = this;
@ -117,6 +123,7 @@ class WorkbenchService extends MainService {
/** /**
* 检查条码是否已存在 * 检查条码是否已存在
* @param data
*/ */
async checkBarcode(data) { async checkBarcode(data) {
const { service } = this; const { service } = this;

View File

@ -20,7 +20,7 @@ class CameraServerService extends Service {
const { count, rows } = await ctx.model.CameraServer.findAndCountAll({ const { count, rows } = await ctx.model.CameraServer.findAndCountAll({
where: queryWhere, where: queryWhere,
order: [['created_at', 'DESC']], order: [[ 'created_at', 'DESC' ]],
offset: (page - 1) * pageSize, offset: (page - 1) * pageSize,
limit: pageSize, limit: pageSize,
}); });

View File

@ -1161,7 +1161,7 @@ class DeliveryOrderService extends Service {
isUrgency, isUrgency,
invoiceFlag, invoiceFlag,
receiverInfo, receiverInfo,
sourceOrderCode sourceOrderCode,
} = deliveryOrder; } = deliveryOrder;
const policyConfig = await this.getStoreWarehousePolicyConfig(info.storeId, info.warehouseId); 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); resolvedItems.sort((a, b) => a.stockId - b.stockId);
// ===== 批量查询 wms_stock_warehouse 获取仓库侧称重毛重 ===== // ===== 批量查询 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(); const warehouseWeightMap = new Map();
if (stockIds.length > 0) { if (stockIds.length > 0) {
const warehouseRecords = await app.model.StockWarehouse.findAll({ const warehouseRecords = await app.model.StockWarehouse.findAll({
where: { id: stockIds }, where: { id: stockIds },
attributes: ['id', 'gross_weight'], attributes: [ 'id', 'gross_weight' ],
transaction, transaction,
raw: true, raw: true,
}); });

View File

@ -780,8 +780,8 @@ class ExpressPlatformService extends MainService {
labelformat: listByWarehousePlatformCode.labelformat || '', labelformat: listByWarehousePlatformCode.labelformat || '',
extraInfo: ExpressList.find(item => item.code === listByWarehousePlatformCode.sys_express_code)?.polyapi_extra_info || '', extraInfo: ExpressList.find(item => item.code === listByWarehousePlatformCode.sys_express_code)?.polyapi_extra_info || '',
}; };
console.log("matchedPlatform.platid",matchedPlatform.platid); console.log('matchedPlatform.platid', matchedPlatform.platid);
console.log("startPlayload",playload); console.log('startPlayload', playload);
if (Number(matchedPlatform.platid) === 673) { if (Number(matchedPlatform.platid) === 673) {
playload.BizVersion = '2'; playload.BizVersion = '2';
@ -891,7 +891,7 @@ class ExpressPlatformService extends MainService {
if (!order.extend_props.ewaybill_order_code) { if (!order.extend_props.ewaybill_order_code) {
throw new Error('订单数据错误,参数不全缺失extend_props.ewaybill_order_code,请复制次信息给ERP方反馈'); 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.transtype = '0';
playload.Mallmaskid = order.buyer_nick; playload.Mallmaskid = order.buyer_nick;
@ -919,7 +919,7 @@ class ExpressPlatformService extends MainService {
api: 'Differ.JH.Logistics.PostOrder', api: 'Differ.JH.Logistics.PostOrder',
response: JSON.stringify(result), response: JSON.stringify(result),
}); });
console.log("分配运单号结果",result); console.log('分配运单号结果', result);
// 统一处理:不再依赖顶层 code,直接从 results 逐条提取 issuccess 和 submessage // 统一处理:不再依赖顶层 code,直接从 results 逐条提取 issuccess 和 submessage
{ {
@ -1109,14 +1109,14 @@ class ExpressPlatformService extends MainService {
eCustomerCode: '', eCustomerCode: '',
remark: '', remark: '',
selleruserid: '', selleruserid: '',
printno: "", printno: '',
iscloudprint: 'false', iscloudprint: 'false',
needprintdetail: 'false', needprintdetail: 'false',
extenddata: '', extenddata: '',
providercode: String(item.procode || item.realcpcode || item.logisticcompanycode || ''), providercode: String(item.procode || item.realcpcode || item.logisticcompanycode || ''),
packageno: '', packageno: '',
fontsize: '', fontsize: '',
platorderno: "", platorderno: '',
sipshopid: 0, sipshopid: 0,
})); }));
console.log('京东批量打印请求参数', JSON.stringify({ console.log('京东批量打印请求参数', JSON.stringify({
@ -1783,7 +1783,7 @@ class ExpressPlatformService extends MainService {
count: item.plan_qty, count: item.plan_qty,
})) || [], })) || [],
goods_description: '物品', goods_description: '物品',
id:`${orderDelivery.warehouse_id}_${orderDelivery.id}_${order_tmp.business_key}`, id: `${orderDelivery.warehouse_id}_${orderDelivery.id}_${order_tmp.business_key}`,
}, },
recipient: { recipient: {
address: { address: {
@ -2363,7 +2363,7 @@ class ExpressPlatformService extends MainService {
name: item.item_name || '商品', name: item.item_name || '商品',
count: item.plan_qty, 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: { recipient: {
address: { address: {

View File

@ -722,7 +722,7 @@ class ShopsService extends Service {
requestData.VenderID = shopPlain.id; requestData.VenderID = shopPlain.id;
} }
if (platName === '视频号') { if (platName === '视频号') {
if(!appId || !toUserName) { if (!appId || !toUserName) {
throw this.createError('视频号授权需要提供 appId 和 toUserName', 400); throw this.createError('视频号授权需要提供 appId 和 toUserName', 400);
} }
requestData.appId = appId; requestData.appId = appId;

View File

@ -1599,6 +1599,8 @@ class stockStoreService extends Service {
* @param {Object} sortParams - 排序参数 * @param {Object} sortParams - 排序参数
* @param {string} sortParams.sortField - 排序字段,默认'create_at' * @param {string} sortParams.sortField - 排序字段,默认'create_at'
* @param {string} sortParams.sortOrder - 排序方式,默认'DESC' * @param {string} sortParams.sortOrder - 排序方式,默认'DESC'
* @param externalWarehouseId
* @param externalStoreId
* @return {Promise<Object>} 返回查询结果 * @return {Promise<Object>} 返回查询结果
*/ */
async getWarehouseStock(where, pageParams = {}, sortParams = {}, externalWarehouseId = 0, externalStoreId = 0) { 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(); const qimenAppMap = new Map();
if (appKeys.length > 0) { if (appKeys.length > 0) {
const qimenApps = await ctx.model.QimenApp.findAll({ const qimenApps = await ctx.model.QimenApp.findAll({

View File

@ -328,6 +328,9 @@ class StorageReportService extends Service {
* @param {number[]} [options.storeIds=[]] 货主ID列表 * @param {number[]} [options.storeIds=[]] 货主ID列表
* @param {number[]} [options.spaceIds=[]] 库位ID列表 * @param {number[]} [options.spaceIds=[]] 库位ID列表
* @param {boolean} [options.includeBarcode=false] 是否加载条码映射 * @param {boolean} [options.includeBarcode=false] 是否加载条码映射
* @param options.entryOrderIds
* @param options.orderIds
* @param options.warehouseId
* @return {Promise<Object>} 映射对象 * @return {Promise<Object>} 映射对象
*/ */
async loadReportReferenceMaps({ async loadReportReferenceMaps({

View File

@ -92,6 +92,8 @@ class StoreExpressBindingPolicyService extends Service {
/** /**
* 校验快递编码是否存在。 * 校验快递编码是否存在。
* @param {string} expressCode 快递编码 * @param {string} expressCode 快递编码
* @param value
* @param fieldName
* @return {Promise<string>} 标准化快递编码 * @return {Promise<string>} 标准化快递编码
*/ */
normalizeJsonArray(value, fieldName) { normalizeJsonArray(value, fieldName) {

View File

@ -1852,6 +1852,7 @@ class SettingStoreWarehouseService extends Service {
/** /**
* 精简签约对象,仅保留前端需要的字段。 * 精简签约对象,仅保留前端需要的字段。
* @param serialized
*/ */
trimContract(serialized) { trimContract(serialized) {
return { return {
@ -2198,7 +2199,7 @@ class SettingStoreWarehouseService extends Service {
const accountIds = Array.from(accountIdSet).filter(id => Number.isFinite(id) && id > 0); const accountIds = Array.from(accountIdSet).filter(id => Number.isFinite(id) && id > 0);
// 批量查询账号姓名 // 批量查询账号姓名
let accountNameMap = {}; const accountNameMap = {};
if (accountIds.length > 0) { if (accountIds.length > 0) {
try { try {
const accounts = await ctx.model.Account.findAll({ const accounts = await ctx.model.Account.findAll({

View File

@ -4,7 +4,7 @@ module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
// 将 custom_barcode 唯一索引从全局改为仓库级别 // 将 custom_barcode 唯一索引从全局改为仓库级别
await queryInterface.removeIndex('wms_location_space', 'uk_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', name: 'uk_warehouse_custom_barcode',
unique: true, unique: true,
}); });
@ -12,7 +12,7 @@ module.exports = {
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.removeIndex('wms_location_space', 'uk_warehouse_custom_barcode'); 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', name: 'uk_custom_barcode',
unique: true, unique: true,
}); });

View File

@ -5,7 +5,7 @@ module.exports = {
// 紧急修复:将 wms_order_delivery_1000028 自增值提升至 15000+ // 紧急修复:将 wms_order_delivery_1000028 自增值提升至 15000+
// 原因:表重建后 AUTO_INCREMENT 被重置为 151,与历史水位差距过大 // 原因:表重建后 AUTO_INCREMENT 被重置为 151,与历史水位差距过大
await queryInterface.sequelize.query( await queryInterface.sequelize.query(
"ALTER TABLE wms_order_delivery_1000028 AUTO_INCREMENT = 15000" 'ALTER TABLE wms_order_delivery_1000028 AUTO_INCREMENT = 15000'
); );
}, },

View File

@ -62,23 +62,23 @@ module.exports = {
}); });
// 仓库隔离查询 // 仓库隔离查询
await queryInterface.addIndex(TABLE_NAME, ['warehouse_id'], { await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id' ], {
name: 'idx_warehouse_id', name: 'idx_warehouse_id',
}); });
// 条码检索 // 条码检索
await queryInterface.addIndex(TABLE_NAME, ['barcode'], { await queryInterface.addIndex(TABLE_NAME, [ 'barcode' ], {
name: 'idx_barcode', name: 'idx_barcode',
}); });
// 仓库级别唯一条码(含软删除,遵循 location_space 同款模式) // 仓库级别唯一条码(含软删除,遵循 location_space 同款模式)
await queryInterface.addIndex(TABLE_NAME, ['warehouse_id', 'barcode', 'deleted_at'], { await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id', 'barcode', 'deleted_at' ], {
unique: true, unique: true,
name: 'uk_warehouse_barcode', name: 'uk_warehouse_barcode',
}); });
// 软删除查询优化 // 软删除查询优化
await queryInterface.addIndex(TABLE_NAME, ['deleted_at'], { await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], {
name: 'idx_deleted_at', name: 'idx_deleted_at',
}); });
}, },

View File

@ -13,7 +13,7 @@ module.exports = {
}); });
}, },
down: async (queryInterface) => { down: async queryInterface => {
await queryInterface.removeColumn(TABLE_NAME, 'type'); await queryInterface.removeColumn(TABLE_NAME, 'type');
}, },
}; };

View File

@ -130,12 +130,12 @@ module.exports = {
}); });
// ======== 索引 ======== // ======== 索引 ========
await queryInterface.addIndex(TABLE_NAME, ['warehouse_id'], { name: 'idx_warehouse_id' }); 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, [ 'workbench_id' ], { name: 'idx_workbench_id' });
await queryInterface.addIndex(TABLE_NAME, ['wave_id'], { name: 'idx_wave_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, [ 'waybill_code' ], { name: 'idx_waybill_code' });
await queryInterface.addIndex(TABLE_NAME, ['start_time'], { name: 'idx_start_time' }); 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, [ 'status' ], { name: 'idx_status' });
}, },
down: async queryInterface => { down: async queryInterface => {

View File

@ -87,9 +87,9 @@ module.exports = {
}, },
}); });
await queryInterface.addIndex(TABLE_NAME, ['warehouse_id'], { name: 'idx_warehouse_id' }); 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, [ 'status' ], { name: 'idx_status' });
await queryInterface.addIndex(TABLE_NAME, ['deleted_at'], { name: 'idx_deleted_at' }); await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], { name: 'idx_deleted_at' });
}, },
down: async queryInterface => { down: async queryInterface => {

View File

@ -71,15 +71,15 @@ module.exports = {
}, },
}); });
await queryInterface.addIndex(TABLE_NAME, ['warehouse_id'], { name: 'idx_warehouse_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' ], { 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, unique: true,
name: 'uk_server_channel', name: 'uk_server_channel',
}); });
await queryInterface.addIndex(TABLE_NAME, ['status'], { name: 'idx_status' }); 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, [ 'deleted_at' ], { name: 'idx_deleted_at' });
}, },
down: async queryInterface => { down: async queryInterface => {

View File

@ -61,9 +61,9 @@ module.exports = {
}, },
}); });
await queryInterface.addIndex(TABLE_NAME, ['pack_task_id'], { name: 'idx_pack_task_id' }); 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, [ 'camera_id' ], { name: 'idx_camera_id' });
await queryInterface.addIndex(TABLE_NAME, ['deleted_at'], { name: 'idx_deleted_at' }); await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], { name: 'idx_deleted_at' });
}, },
down: async queryInterface => { down: async queryInterface => {

View File

@ -43,7 +43,7 @@ module.exports = {
}, },
down: async queryInterface => { 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) { for (const col of columns) {
const tableInfo = await queryInterface.describeTable(TABLE_NAME); const tableInfo = await queryInterface.describeTable(TABLE_NAME);
if (tableInfo[col]) { if (tableInfo[col]) {

View File

@ -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 * @param {import('sequelize').QueryInterface} queryInterface
*/ */
module.exports.up = async 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() `UPDATE \`${TABLE}\` SET permissions = :permissions, updated_at = NOW()
WHERE id = :id AND is_system = 1`, WHERE id = :id AND is_system = 1`,
{ replacements: { id: ROLE_ID, permissions: NEW_PERMISSIONS } } { replacements: { id: ROLE_ID, permissions: NEW_PERMISSIONS } }
@ -46,7 +46,7 @@ module.exports.up = async queryInterface => {
* @param {import('sequelize').QueryInterface} queryInterface * @param {import('sequelize').QueryInterface} queryInterface
*/ */
module.exports.down = async 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() `UPDATE \`${TABLE}\` SET permissions = :permissions, updated_at = NOW()
WHERE id = :id AND is_system = 1`, WHERE id = :id AND is_system = 1`,
{ replacements: { id: ROLE_ID, permissions: OLD_PERMISSIONS } } { replacements: { id: ROLE_ID, permissions: OLD_PERMISSIONS } }

View File

@ -21,7 +21,7 @@ const TABLE_PERMISSION = 'wms_permission';
const TABLE_ROLE = 'wms_role'; const TABLE_ROLE = 'wms_role';
/** 需要授权的角色ID(财务以上:货主管理员 + 经理) */ /** 需要授权的角色ID(财务以上:货主管理员 + 经理) */
const TARGET_ROLE_IDS = [5, 8]; const TARGET_ROLE_IDS = [ 5, 8 ];
/** @type {{path: string, name: string, meta_title: string, type: string}[]} */ /** @type {{path: string, name: string, meta_title: string, type: string}[]} */
const NEW_PERMISSIONS = [ const NEW_PERMISSIONS = [
@ -149,7 +149,7 @@ module.exports.up = async queryInterface => {
} }
console.log( console.log(
`[Migration] 面单余额导出权限迁移完成:` + '[Migration] 面单余额导出权限迁移完成:' +
`新增 ${NEW_PERMISSIONS.length} 条权限,授权 ${TARGET_ROLE_IDS.length} 个角色` `新增 ${NEW_PERMISSIONS.length} 条权限,授权 ${TARGET_ROLE_IDS.length} 个角色`
); );
}; };

View File

@ -20,8 +20,8 @@ module.exports = {
await queryInterface.bulkInsert('wms_permission', permissions); await queryInterface.bulkInsert('wms_permission', permissions);
// 2. 查询刚插入的权限 ID // 2. 查询刚插入的权限 ID
const [rows] = await queryInterface.sequelize.query( 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` '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); const ids = rows.map(r => r.id);
if (ids.length !== 3) { if (ids.length !== 3) {
@ -29,7 +29,7 @@ module.exports = {
} }
// 3. 授权客服主管及以上角色(排除 permissions='*' 的超级管理员角色) // 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) { for (const permId of ids) {
await queryInterface.sequelize.query(` await queryInterface.sequelize.query(`
UPDATE wms_role UPDATE wms_role
@ -52,16 +52,16 @@ module.exports = {
* @return {Promise<void>} 无返回值 * @return {Promise<void>} 无返回值
*/ */
async down(queryInterface, Sequelize) { 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 // 1. 查询权限 ID
const [rows] = await queryInterface.sequelize.query( const [ rows ] = await queryInterface.sequelize.query(
`SELECT id FROM wms_permission WHERE path IN ('${paths.join("','")}')` `SELECT id FROM wms_permission WHERE path IN ('${paths.join("','")}')`
); );
const ids = rows.map(r => r.id); const ids = rows.map(r => r.id);
// 2. 从角色权限中移除 // 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) { for (const permId of ids) {
await queryInterface.sequelize.query(` await queryInterface.sequelize.query(`
UPDATE wms_role UPDATE wms_role

View File

@ -19,8 +19,8 @@ module.exports = {
await queryInterface.bulkInsert('wms_permission', permissions); await queryInterface.bulkInsert('wms_permission', permissions);
// 2. 查询刚插入的权限 ID // 2. 查询刚插入的权限 ID
const [rows] = await queryInterface.sequelize.query( const [ rows ] = await queryInterface.sequelize.query(
`SELECT id FROM wms_permission WHERE path IN ('print_computer.setRecording', 'print_computer.cancelRecording') ORDER BY id` 'SELECT id FROM wms_permission WHERE path IN (\'print_computer.setRecording\', \'print_computer.cancelRecording\') ORDER BY id'
); );
const ids = rows.map(r => r.id); const ids = rows.map(r => r.id);
if (ids.length !== 2) { if (ids.length !== 2) {
@ -28,7 +28,7 @@ module.exports = {
} }
// 3. 授权客服主管及以上角色 // 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) { for (const permId of ids) {
await queryInterface.sequelize.query(` await queryInterface.sequelize.query(`
UPDATE wms_role UPDATE wms_role
@ -51,14 +51,14 @@ module.exports = {
* @return {Promise<void>} 无返回值 * @return {Promise<void>} 无返回值
*/ */
async down(queryInterface, Sequelize) { 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("','")}')` `SELECT id FROM wms_permission WHERE path IN ('${paths.join("','")}')`
); );
const ids = rows.map(r => r.id); 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) { for (const permId of ids) {
await queryInterface.sequelize.query(` await queryInterface.sequelize.query(`
UPDATE wms_role UPDATE wms_role

View File

@ -153,58 +153,58 @@ module.exports = {
}); });
// 工单号唯一 // 工单号唯一
await queryInterface.addIndex(TABLE_NAME, ['work_order_no'], { await queryInterface.addIndex(TABLE_NAME, [ 'work_order_no' ], {
unique: true, unique: true,
name: 'uk_work_order_no', name: 'uk_work_order_no',
}); });
// 仓库隔离查询 // 仓库隔离查询
await queryInterface.addIndex(TABLE_NAME, ['warehouse_id'], { await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id' ], {
name: 'idx_warehouse_id', name: 'idx_warehouse_id',
}); });
// 货主隔离查询 // 货主隔离查询
await queryInterface.addIndex(TABLE_NAME, ['store_id'], { await queryInterface.addIndex(TABLE_NAME, [ 'store_id' ], {
name: 'idx_store_id', name: 'idx_store_id',
}); });
// 按业务类型+子类型+单据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', name: 'idx_business_type_subtype_id',
}); });
// 按状态筛选 // 按状态筛选
await queryInterface.addIndex(TABLE_NAME, ['status'], { await queryInterface.addIndex(TABLE_NAME, [ 'status' ], {
name: 'idx_status', name: 'idx_status',
}); });
// 按处理人查询 // 按处理人查询
await queryInterface.addIndex(TABLE_NAME, ['assignee_id'], { await queryInterface.addIndex(TABLE_NAME, [ 'assignee_id' ], {
name: 'idx_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', name: 'idx_parent_work_order_id',
}); });
// 按优先级排序 // 按优先级排序
await queryInterface.addIndex(TABLE_NAME, ['priority'], { await queryInterface.addIndex(TABLE_NAME, [ 'priority' ], {
name: 'idx_priority', name: 'idx_priority',
}); });
// 按理赔状态筛选 // 按理赔状态筛选
await queryInterface.addIndex(TABLE_NAME, ['claim_status'], { await queryInterface.addIndex(TABLE_NAME, [ 'claim_status' ], {
name: 'idx_claim_status', name: 'idx_claim_status',
}); });
// 按时间排序 // 按时间排序
await queryInterface.addIndex(TABLE_NAME, ['created_at'], { await queryInterface.addIndex(TABLE_NAME, [ 'created_at' ], {
name: 'idx_created_at', name: 'idx_created_at',
}); });
// 软删除查询优化 // 软删除查询优化
await queryInterface.addIndex(TABLE_NAME, ['deleted_at'], { await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], {
name: 'idx_deleted_at', name: 'idx_deleted_at',
}); });
}, },

View File

@ -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', name: 'idx_work_order_id',
}); });
// 按操作人反查 // 按操作人反查
await queryInterface.addIndex(TABLE_NAME, ['operator_id'], { await queryInterface.addIndex(TABLE_NAME, [ 'operator_id' ], {
name: 'idx_operator_id', name: 'idx_operator_id',
}); });
// 软删除查询优化 // 软删除查询优化
await queryInterface.addIndex(TABLE_NAME, ['deleted_at'], { await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], {
name: 'idx_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, unique: true,
name: 'uk_work_order_step', name: 'uk_work_order_step',
}); });

View File

@ -33,28 +33,28 @@ module.exports = {
if (!indexNameSet.has('idx_warehouse_id_status')) { if (!indexNameSet.has('idx_warehouse_id_status')) {
await queryInterface.addIndex(TABLE_NAME, { await queryInterface.addIndex(TABLE_NAME, {
name: 'idx_warehouse_id_status', name: 'idx_warehouse_id_status',
fields: ['warehouse_id', 'status'], fields: [ 'warehouse_id', 'status' ],
}); });
} }
if (!indexNameSet.has('idx_logistics_code')) { if (!indexNameSet.has('idx_logistics_code')) {
await queryInterface.addIndex(TABLE_NAME, { await queryInterface.addIndex(TABLE_NAME, {
name: 'idx_logistics_code', name: 'idx_logistics_code',
fields: ['logistics_code'], fields: [ 'logistics_code' ],
}); });
} }
if (!indexNameSet.has('idx_logistics_interface_id')) { if (!indexNameSet.has('idx_logistics_interface_id')) {
await queryInterface.addIndex(TABLE_NAME, { await queryInterface.addIndex(TABLE_NAME, {
name: 'idx_logistics_interface_id', name: 'idx_logistics_interface_id',
fields: ['logistics_interface_id'], fields: [ 'logistics_interface_id' ],
}); });
} }
if (!indexNameSet.has('idx_warehouse_id_create_at')) { if (!indexNameSet.has('idx_warehouse_id_create_at')) {
await queryInterface.addIndex(TABLE_NAME, { await queryInterface.addIndex(TABLE_NAME, {
name: 'idx_warehouse_id_create_at', name: 'idx_warehouse_id_create_at',
fields: ['warehouse_id', 'create_at'], fields: [ 'warehouse_id', 'create_at' ],
}); });
} }
}, },

View File

@ -31,7 +31,7 @@ module.exports = {
}, },
down: async queryInterface => { down: async queryInterface => {
const columns = ['password', 'username']; const columns = [ 'password', 'username' ];
for (const col of columns) { for (const col of columns) {
const tableInfo = await queryInterface.describeTable(TABLE_NAME); const tableInfo = await queryInterface.describeTable(TABLE_NAME);
if (tableInfo[col]) { if (tableInfo[col]) {

View File

@ -11,7 +11,7 @@ const TABLE_NAME = 'wms_order_express';
*/ */
async function backfill(queryInterface) { async function backfill(queryInterface) {
// 获取所有不同的 warehouse_id // 获取所有不同的 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` `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) { for (const row of warehouses) {
const warehouseId = row.warehouse_id; const warehouseId = row.warehouse_id;
const tableTypes = [ const tableTypes = [
`wms_order_delivery_${warehouseId}`, // current(配送表 / 待处理表) `wms_order_delivery_${warehouseId}`, // current(配送表 / 待处理表)
`wms_order_delivery_${warehouseId}_history`, // history `wms_order_delivery_${warehouseId}_history`, // history
`wms_order_delivery_${warehouseId}_dispatch`, // dispatch `wms_order_delivery_${warehouseId}_dispatch`, // dispatch
]; ];
for (const deliveryTable of tableTypes) { for (const deliveryTable of tableTypes) {
try { try {
const [result] = await queryInterface.sequelize.query(` const [ result ] = await queryInterface.sequelize.query(`
UPDATE ${TABLE_NAME} e UPDATE ${TABLE_NAME} e
INNER JOIN ${deliveryTable} d ON e.order_id = d.id AND e.warehouse_id = d.warehouse_id INNER JOIN ${deliveryTable} d ON e.order_id = d.id AND e.warehouse_id = d.warehouse_id
SET e.store_id = d.store_id SET e.store_id = d.store_id

View File

@ -10,7 +10,7 @@ const TABLE_NAME = 'wms_order_express';
* @return {Promise<void>} 无返回值。 * @return {Promise<void>} 无返回值。
*/ */
async function backfill(queryInterface) { 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` `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) { for (const deliveryTable of tableTypes) {
try { try {
const [result] = await queryInterface.sequelize.query(` const [ result ] = await queryInterface.sequelize.query(`
UPDATE ${TABLE_NAME} e UPDATE ${TABLE_NAME} e
INNER JOIN ${deliveryTable} d ON e.order_id = d.id AND e.warehouse_id = d.warehouse_id 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), SET e.delivery_order_code = COALESCE(e.delivery_order_code, d.delivery_order_code),

View File

@ -29,7 +29,7 @@ module.exports = {
} }
}, },
down: async (queryInterface) => { down: async queryInterface => {
const tableInfo = await queryInterface.describeTable('wms_inbox_group'); const tableInfo = await queryInterface.describeTable('wms_inbox_group');
if (tableInfo.express_interfaces) { if (tableInfo.express_interfaces) {

View File

@ -22,7 +22,7 @@ module.exports = {
// 检查已有索引(通过尝试添加,重复则忽略) // 检查已有索引(通过尝试添加,重复则忽略)
try { try {
await queryInterface.addIndex('wms_inbox_message', { 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', name: 'idx_warehouse_group_created',
}); });
console.log('[idx] wms_inbox_message.idx_warehouse_group_created 已创建'); console.log('[idx] wms_inbox_message.idx_warehouse_group_created 已创建');
@ -37,7 +37,7 @@ module.exports = {
// ── wms_inbox_group 索引 ── // ── wms_inbox_group 索引 ──
try { try {
await queryInterface.addIndex('wms_inbox_group', { await queryInterface.addIndex('wms_inbox_group', {
fields: ['group_id'], fields: [ 'group_id' ],
name: 'idx_group_id', name: 'idx_group_id',
}); });
console.log('[idx] wms_inbox_group.idx_group_id 已创建'); console.log('[idx] wms_inbox_group.idx_group_id 已创建');
@ -51,7 +51,7 @@ module.exports = {
try { try {
await queryInterface.addIndex('wms_inbox_group', { await queryInterface.addIndex('wms_inbox_group', {
fields: ['warehouse_id', 'group_id'], fields: [ 'warehouse_id', 'group_id' ],
name: 'idx_warehouse_group_id', name: 'idx_warehouse_group_id',
}); });
console.log('[idx] wms_inbox_group.idx_warehouse_group_id 已创建'); console.log('[idx] wms_inbox_group.idx_warehouse_group_id 已创建');

View File

@ -13,13 +13,13 @@ module.exports = {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
const methods = [ const methods = [
[495, 'inbox.group.list'], [ 495, 'inbox.group.list' ],
[496, 'inbox.group.disable'], [ 496, 'inbox.group.disable' ],
[497, 'inbox.group.update'], [ 497, 'inbox.group.update' ],
[498, 'inbox.group.messages'], [ 498, 'inbox.group.messages' ],
]; ];
for (const [id, method] of methods) { for (const [ id, method ] of methods) {
await queryInterface.sequelize.query(` 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) 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()) VALUES (${id}, '${method}', NULL, '${method}', NULL, 'API:${method}', NULL, 0, 0, NULL, 'api', 0, 1, NOW(), NOW())

View File

@ -18,7 +18,7 @@ module.exports = {
}, },
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
down: async (queryInterface) => { down: async queryInterface => {
const tableInfo = await queryInterface.describeTable('wms_inbox_message'); const tableInfo = await queryInterface.describeTable('wms_inbox_message');
if (tableInfo.ai_thoughts) { if (tableInfo.ai_thoughts) {
await queryInterface.removeColumn('wms_inbox_message', 'ai_thoughts'); await queryInterface.removeColumn('wms_inbox_message', 'ai_thoughts');

View File

@ -29,7 +29,7 @@ module.exports = {
} }
}, },
down: async (queryInterface) => { down: async queryInterface => {
const columns = await queryInterface.describeTable(TABLE); const columns = await queryInterface.describeTable(TABLE);
if (columns.express_code) { if (columns.express_code) {

View File

@ -12,16 +12,16 @@
* 授权角色:经理(8)、仓库组-主管(26)、客服组-主管(28)、生产组-主管(29)、客服组-员工(30) * 授权角色:经理(8)、仓库组-主管(26)、客服组-主管(28)、生产组-主管(29)、客服组-员工(30)
*/ */
module.exports = { module.exports = {
up: async (queryInterface) => { up: async queryInterface => {
// ===== 第一步:写入权限行 ===== // ===== 第一步:写入权限行 =====
const perms = [ const perms = [
[504, 'storage.stockout.list', '出库单列表'], [ 504, 'storage.stockout.list', '出库单列表' ],
[505, 'storage.stockout.listItems', '出库单明细'], [ 505, 'storage.stockout.listItems', '出库单明细' ],
[506, 'storage.stockout.confirm', '出库单确认'], [ 506, 'storage.stockout.confirm', '出库单确认' ],
[507, 'storage.stockout.updateExpress', '更新运单号'], [ 507, 'storage.stockout.updateExpress', '更新运单号' ],
]; ];
for (const [id, method, desc] of perms) { for (const [ id, method, desc ] of perms) {
await queryInterface.sequelize.query(` 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) 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()) 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 roleIds = [ 8, 26, 28, 29, 30 ]; // 经理 + 各主管 + 客服组-员工
const newPermIds = [504, 505, 506, 507]; const newPermIds = [ 504, 505, 506, 507 ];
for (const roleId of roleIds) { for (const roleId of roleIds) {
for (const permId of newPermIds) { 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'; const permIdStr = '504, 505, 506, 507';
for (const roleId of roleIds) { for (const roleId of roleIds) {

View File

@ -38,7 +38,7 @@ module.exports = {
} }
}, },
down: async (queryInterface) => { down: async queryInterface => {
const columns = await queryInterface.describeTable(TABLE); const columns = await queryInterface.describeTable(TABLE);
if (columns.express_name) { if (columns.express_name) {

View File

@ -3,7 +3,7 @@
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
// Query 3 关联查询:delivery_order_code + store_id 联合索引(最高频缺失索引) // 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', name: 'idx_delivery_code_store',
}); });
}, },

View File

@ -19,11 +19,11 @@ const mysql = projectRequire('mysql2/promise');
const CS_CHAIN_ROLES = [ const CS_CHAIN_ROLES = [
{ id: 30, code: '04', name: '客服组-员工' }, { id: 30, code: '04', name: '客服组-员工' },
{ id: 28, code: '05', 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) { 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 = ?', 'SELECT id, name, meta_title, type, path FROM wms_permission WHERE id = ?',
[permId] [ permId ]
); );
return rows[0] || null; return rows[0] || null;
} }
@ -71,9 +71,9 @@ async function grantPermission(conn, permId, envLabel) {
const results = []; const results = [];
for (const role of CS_CHAIN_ROLES) { 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', '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) { if (rows.length === 0) {
@ -94,7 +94,7 @@ async function grantPermission(conn, permId, envLabel) {
try { try {
perms = JSON.parse(record.permissions); perms = JSON.parse(record.permissions);
} catch { } catch {
results.push({ role, status: 'error', msg: `permissions JSON 解析失败` }); results.push({ role, status: 'error', msg: 'permissions JSON 解析失败' });
continue; continue;
} }

View File

@ -19,7 +19,7 @@ const mysql = projectRequire('mysql2/promise');
const CS_CHAIN_ROLES = [ const CS_CHAIN_ROLES = [
{ id: 30, code: '04', name: '客服组-员工' }, { id: 30, code: '04', name: '客服组-员工' },
{ id: 28, code: '05', 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 = []; const results = [];
for (const role of CS_CHAIN_ROLES) { 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', '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) { if (rows.length === 0) {
@ -127,7 +127,7 @@ async function main() {
console.log('═══════════════════════════════════════'); console.log('═══════════════════════════════════════');
console.log(` 权限 ID: ${permIdNum}`); console.log(` 权限 ID: ${permIdNum}`);
console.log(` 目标角色: ${CS_CHAIN_ROLES.map(r => `${r.name}(${r.id})`).join(' → ')}`); 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'); console.log('═══════════════════════════════════════\n');
// ── 开发环境:查询权限信息 ── // ── 开发环境:查询权限信息 ──
@ -139,9 +139,9 @@ async function main() {
process.exit(1); 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 = ?', 'SELECT id, name, meta_title, type, path FROM wms_permission WHERE id = ?',
[permIdNum] [ permIdNum ]
); );
if (permRows.length > 0) { if (permRows.length > 0) {

View File

@ -7,6 +7,7 @@ const PendingOrderService = require('../../../../../app/service/systemMethods/or
* 创建 manualWaybill 操作日志回归测试上下文。 * 创建 manualWaybill 操作日志回归测试上下文。
* *
* 仅覆盖 operationLog.createOperationLog 的 businessId 传入值。 * 仅覆盖 operationLog.createOperationLog 的 businessId 传入值。
* @param options
*/ */
function createManualWaybillLogHarness(options = {}) { function createManualWaybillLogHarness(options = {}) {
const calls = { const calls = {
@ -103,14 +104,14 @@ function createManualWaybillLogHarness(options = {}) {
}, },
}); });
service.buildOrderWhere = (orderIds) => ({ service.buildOrderWhere = orderIds => ({
id: { [ctx.app.Sequelize.Op.in]: orderIds }, id: { [ctx.app.Sequelize.Op.in]: orderIds },
warehouse_id: warehouseId, warehouse_id: warehouseId,
}); });
service.success = (msg, data) => ({ code: 0, msg, data }); service.success = (msg, data) => ({ code: 0, msg, data });
service.syncOrderIds = (payload) => { service.syncOrderIds = payload => {
calls.syncOrderIdsPayload = payload; calls.syncOrderIdsPayload = payload;
return Promise.resolve(); return Promise.resolve();
}; };