From 3d33861afde51284bc0af2f2b9d4c179e8613995 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Mon, 3 Aug 2026 03:26:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(inbox):=20store=5Fid=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=AD=BE=E7=BA=A6=E8=A1=A8=E6=A0=A1=E9=AA=8C=EF=BC=88StoreWare?= =?UTF-8?q?house=20auth=5Fstatus=3D2=20+=20warehouse=5Fuse=5Fstatus=3D1?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/inbox/receiver.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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,