出站回调:
- 新增 warehouse_notify.json 文档(notify.ping/notify.reply),与 warehouse.json 互跳
- 回调体统一 { method, code, data },method 放 query,body 为业务数据
- MD5 签名: sign=MD5(appSecret+timestamp+bodyJson)
- 回调响应: {code:200} 成功,非200/非code:200 视为失败
- docs 页面支持模拟推送调试
搜索增强(searchStock/searchWarehouseStock):
- 直接查 stock_warehouse,不再依赖 stock_store
- 新增字段: gross_weight/box_spec/packing_requirements/prohibited_type
- 管理标识: is_sn_mgmt/is_shelf_life_mgmt/is_batch_mgmt
- 条码关联: wms_stock_barcodes
- 图片: wms_file_reference(business_type=stock)+wms_file,返回数组
- id 修正为 stock_warehouse.id
推送状态完善:
- handleApiMessage 增加 push_status 更新(2成功/3失败)
- 未配回调地址 → push_status=3 + error 原因
- 回调异常 catch 也更新 push_status=3 + 写日志
- 出站日志写入 wms_warehouse_log 表(WN-前缀)
消息列表:
- keyword 兼容 content/keyword,支持数组
- keyword 搜索 content/group_name/user_name 三列
- 支持 where+operator 结构化查询(parseWhereConditions)
- storeId=-1 查询无货主消息; storeId=0→IS NULL
- 日期范围: startDate/endDate
其他:
- silent 动作: AI 识别无需回复时跳过回执
- ai_enabled 灰度开关(群级)
- bindCode 文档修正
- store_name 改用 StoreWarehouse.store_remask
58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
'use strict';
|
||
|
||
const MainService = require('../main');
|
||
|
||
/**
|
||
* 仓库开放 API — 站内信模块处理器。
|
||
* 接收仓库级外部适配器推送的 inbox.push 请求,
|
||
* 统一委托 app/service/inbox/receiver.receive 处理写库与异步推送。
|
||
*/
|
||
class WarehouseInboxService extends MainService {
|
||
/**
|
||
* 仓库 API 消息入站入口。
|
||
* warehouse_id 从验签后上下文注入,禁止外部传入。
|
||
* @param {Object} options 请求参数。
|
||
* @param {Object} options.body 请求体。
|
||
* @return {Promise<Object>} 入站结果。
|
||
*/
|
||
async push({ body = {} } = {}) {
|
||
const { ctx } = this;
|
||
const { warehouseId, appKey } = this.getInfo();
|
||
|
||
// 安全边界:warehouse_id 一律从验签后上下文获取
|
||
if (!warehouseId) {
|
||
throw new Error('缺少仓库信息');
|
||
}
|
||
|
||
// 安全边界:校验必填参数
|
||
if (!body.requestId || !String(body.requestId).trim()) {
|
||
throw new Error('requestId 不能为空');
|
||
}
|
||
|
||
// 构造 ext_id
|
||
const extId = `api:${String(appKey || 'unknown')}:${String(body.requestId).trim()}`;
|
||
|
||
// 构造入站数据并委托给 inbox receiver
|
||
const result = await ctx.service.inbox.receiver.receive({
|
||
ext_id: extId,
|
||
warehouse_id: warehouseId,
|
||
direction: 'inbound',
|
||
parent_id: body.parentId || null,
|
||
source_type: 'api',
|
||
source_extra: String(appKey || ''),
|
||
target_type: body.targetType || 'im',
|
||
group_name: body.groupName || null,
|
||
user_name: body.userName || null,
|
||
group_id: body.groupId || null,
|
||
user_id: body.userId || null,
|
||
content: body.content || null,
|
||
ext_data: body.extData || null,
|
||
flags: body.flags || {},
|
||
});
|
||
|
||
return result;
|
||
}
|
||
}
|
||
|
||
module.exports = WarehouseInboxService;
|