fix(inbox): store_id 增加签约表校验(StoreWarehouse auth_status=2 + warehouse_use_status=1)
This commit is contained in:
parent
440ace1a5d
commit
3d33861afd
@ -68,6 +68,7 @@ function isInternalIp(ip) {
|
|||||||
* @param {string} urlStr 目标URL<EFBFBD>?
|
* @param {string} urlStr 目标URL<EFBFBD>?
|
||||||
* @throws {Error} URL 不合法时抛出<EFBFBD>?
|
* @throws {Error} URL 不合法时抛出<EFBFBD>?
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
function validateTargetUrl(urlStr) {
|
function validateTargetUrl(urlStr) {
|
||||||
if (!urlStr || typeof urlStr !== 'string') {
|
if (!urlStr || typeof urlStr !== 'string') {
|
||||||
throw new Error('target_url 不能为空');
|
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({
|
const record = await InboxMessage.create({
|
||||||
ext_id: extId,
|
ext_id: extId,
|
||||||
warehouse_id: warehouseId,
|
warehouse_id: warehouseId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user