oms/backend/app/model/externalPrintAccount.js
liufumingren eaf957ed14 feat(express): 外部打单快递接口、自定义快递编码与回 OMS 取号
- 外部打单平台快递接口:按账号同步平台模板、绑定快递编码、查看模板明细;打开列表只读库,仅「从平台同步数据」时拉取
- 系统管理新增自定义快递编码字典,订单改快递 / 物流下拉合并系统与自定义编码,推送奇门沿用订单上的编码
- 新增 OpenAPI deliveryorder.getwaybill:WMS 批量回取号(单次≤100、并发4、逐单结果),快递编码只取 WMS 报文,取消/作废/归档返回失败,已取号直接复用
- 新增 openapi_request_idempotency 请求级幂等:request_id 回放、报文摘要校验、30 分钟 stale 接管、7 天定时清理
- 外部打单平台订单按平台 fetch_waybill_no 下发 need_oms_waybill,推送时实时判定并回写单据
- 店铺、打单账号平台配置与「平台+编码→模板」绑定走 Redis 缓存,绑定/账号变更主动失效,避免批量推送与取号逐单查库

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-04 04:10:37 +08:00

37 lines
2.0 KiB
JavaScript
Raw Permalink 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';
/**
* 外部打单账号模型,对应 external_print_accounts 表。
* 一个主体在同一平台上可配置多个账号,账号密码供服务端调用外部打单平台使用;
* 密码不通过接口下发(列表/详情只返回 has_password),避免泄露。
* @param {Egg.Application} app egg application
* @return {object} externalPrintAccount model
*/
module.exports = app => {
const { BIGINT, STRING, TEXT, TINYINT, DATE } = app.Sequelize;
const ExternalPrintAccount = app.model.define('external_print_account', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
principal_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属主体ID' },
platform_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属外部打单平台ID' },
account: { type: STRING(100), allowNull: false, comment: '外部打单平台登录账号' },
password: { type: STRING(255), allowNull: false, comment: '外部打单平台登录密码(服务端调用平台时使用,接口不回显)' },
cookie: { type: TEXT, comment: '外部打单平台会话 cookie(服务端登录后写回,接口不回显)' },
token: { type: STRING(255), comment: '外部打单平台登录 Token(服务端登录后写回,接口不回显)' },
login_status: { type: TINYINT, allowNull: false, defaultValue: 0, comment: '登录状态:1已登录 0未登录/已失效' },
created_at: { type: DATE, comment: '创建时间' },
updated_at: { type: DATE, comment: '更新时间' },
});
ExternalPrintAccount.associate = () => {
app.model.ExternalPrintAccount.belongsTo(app.model.ExternalPrintPlatform, { foreignKey: 'platform_id', as: 'platform' });
app.model.ExternalPrintAccount.belongsTo(app.model.Principal, { foreignKey: 'principal_id', as: 'principal' });
app.model.ExternalPrintAccount.hasMany(app.model.ExternalPrintExpressInterface, {
foreignKey: 'account_id',
as: 'expressInterfaces',
});
};
return ExternalPrintAccount;
};