- 拉单任务:新增 order_sync_tasks 异步任务池,按店铺逐店拉取外部打单平台订单,前端轮询进度 - 外部发货同步:配送后把发货结果同步回店管家,提供数量统计与批量重试(externalSendSync) - 取号:新增 waybill_fetch_records 记录取号过程,外部快递接口补充菜鸟授权信息 - 补齐相关迁移、订单页同步入口/状态展示,并新增对接说明文档 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
42 lines
2.3 KiB
JavaScript
42 lines
2.3 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 取号明细记录模型,对应 waybill_fetch_records。
|
||
*
|
||
* 每次 `deliveryorder.getwaybill` 逐单取号(成功/复用/失败)都写一条,保存打单平台的原始返回,
|
||
* 以及需要透传给 WMS 的 `printinfo / signature`。
|
||
* 仅做留痕,不参与业务状态流转(取号与订单表暂不关联)。
|
||
* @param {Egg.Application} app egg application
|
||
* @return {object} waybillFetchRecord model
|
||
*/
|
||
module.exports = app => {
|
||
const { BIGINT, STRING, TINYINT, TEXT, DATE } = app.Sequelize;
|
||
|
||
const WaybillFetchRecord = app.model.define('waybill_fetch_record', {
|
||
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
|
||
principal_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '主体ID(来自 app_key)' },
|
||
warehouse_id: { type: BIGINT.UNSIGNED, comment: '仓库ID(来自 app_key)' },
|
||
request_id: { type: STRING(100), comment: '调用方 request_id' },
|
||
delivery_order_code: { type: STRING(100), allowNull: false, comment: 'OMS 发货单号' },
|
||
express_code: { type: STRING(50), comment: '本次取号的快递编码' },
|
||
platform_code: { type: STRING(50), comment: '订单来源平台编码' },
|
||
account_id: { type: BIGINT.UNSIGNED, comment: '外部打单账号ID' },
|
||
template_id: { type: STRING(100), comment: '面单模板ID' },
|
||
status: { type: TINYINT, allowNull: false, defaultValue: 0, comment: '状态:1成功 0失败' },
|
||
waybill_source: { type: STRING(20), comment: '运单号来源:express_print / platform_last' },
|
||
waybill_code: { type: STRING(100), comment: '主运单号' },
|
||
waybill_codes: { type: TEXT, comment: '全部运单号(JSON 数组)' },
|
||
printinfo: { type: TEXT('medium'), comment: '面单打印数据(平台原样返回)' },
|
||
signature: { type: TEXT('medium'), comment: '面单签名(平台原样返回)' },
|
||
raw_response: { type: TEXT('medium'), comment: '平台原始返回(JSON)' },
|
||
error_message: { type: TEXT, comment: '失败原因' },
|
||
created_at: { type: DATE, comment: '创建时间' },
|
||
updated_at: { type: DATE, comment: '更新时间' },
|
||
}, {
|
||
tableName: 'waybill_fetch_records',
|
||
comment: '取号明细记录(平台原始返回留痕)',
|
||
});
|
||
|
||
return WaybillFetchRecord;
|
||
};
|