oms/backend/app/model/waybillFetchRecord.js
liufumingren 5d424f2c98 取号响应改用 pdf_base64 返回面单 PDF
- dxm.fetchWaybillNo 改为返回 pdf_base64(纯 base64,不带 data: 前缀),不再塞进 printinfo
- waybillGet 透传 pdf_base64 给 WMS(printinfo 仍留给店管家等 JSON/加密串口径的平台)
- waybill_fetch_records 新增 pdf_base64 列(迁移,TEXT medium);
  result_data 里只留 pdf_base64_length 避免同一张 PDF 存三份,重放时从列补回
- 文档补:WMS 取号响应新增 pdf_base64 字段(含 WMS 落库/打印建议)、店小秘 6.1 存储口径
- 补 4 条单测(dxm 返回 pdf_base64、PDF 失败降级、取号透传、重放补回)
- 实测真实账号:运单号 3CAB6111900043,pdf_base64 88,796 字符,解码为 %PDF-1.4

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-24 02:17:21 +08:00

55 lines
3.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 取号明细记录模型,对应 waybill_fetch_records。
*
* 每次实际调用平台取号都写一条,保存打单平台原始返回、完整结果及包裹序号。
* 已有运单号的幂等重放不新增平台取号记录。
* 仅做留痕,不参与业务状态流转(取号与订单表暂不关联)。
* @param {Egg.Application} app egg application
* @return {object} waybillFetchRecord model
*/
module.exports = app => {
const { BIGINT, STRING, INTEGER, 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: '本次取号的快递编码' },
package_index: { type: INTEGER.UNSIGNED, comment: '包裹序号(0 基);历史记录可能为空' },
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 数组)' },
result_data: { type: TEXT('medium'), comment: '完整的逐单返回结果(JSON)' },
printinfo: { type: TEXT('medium'), comment: '面单打印数据(平台原样返回)' },
pdf_base64: { type: TEXT('medium'), comment: '面单 PDF 内容(base64,不含 data: 前缀;店小秘等 PDF 面单平台)' },
signature: { type: TEXT('medium'), comment: '面单签名(平台原样返回)' },
print_history_ids: {
type: TEXT,
comment: '打印记录(平台 PrintHistoryIds,JSON 数组:id/pid/waybill_code/batch_index),重打/作废用',
},
cai_niao_auth_info_id: {
type: BIGINT.UNSIGNED,
comment: '菜鸟授权网点ID(=店铺唯一标识,重取打印数据时按它+运单号定位)',
},
dbname: { type: STRING(100), comment: '实际命中的打单平台分区(重取打印数据要带同一个 dbname)' },
platform_host: { type: STRING(100), 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;
};