diff --git a/app/service/inbox/receiver.js b/app/service/inbox/receiver.js index 828be7f..b68014e 100644 --- a/app/service/inbox/receiver.js +++ b/app/service/inbox/receiver.js @@ -68,6 +68,7 @@ function isInternalIp(ip) { * @param {string} urlStr 目标URL�? * @throws {Error} URL 不合法时抛出�? */ +// eslint-disable-next-line no-unused-vars function validateTargetUrl(urlStr) { if (!urlStr || typeof urlStr !== 'string') { throw new Error('target_url 不能为空'); @@ -216,6 +217,23 @@ class InboxReceiverService extends Service { } // 写库 + + // store_id 签约校验,若传入 store_id,必须存在有效合约关系 + const storeId = data.store_id ? Number(data.store_id) : null; + if (storeId && Number.isFinite(storeId) && storeId > 0) { + const contract = await ctx.model.StoreWarehouse.findOne({ + where: { + store_id: storeId, + warehouse_id: warehouseId, + auth_status: 2, + warehouse_use_status: 1, + }, + attributes: [ 'id' ], + }); + if (!contract) { + throw new Error(`store_id=${storeId} 与仓库 ${warehouseId} 无有效签约关系`); + } + } const record = await InboxMessage.create({ ext_id: extId, warehouse_id: warehouseId,