oms/backend/app/model/waybillFetchIdempotency.js
liufumingren 4c2cfe1793 修复取号回调的订单级幂等与重放
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-17 17:16:14 +08:00

31 lines
1.6 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';
/**
* 按订单、快递编码和包裹序号保护取号结果,避免不同批次重试重复消耗面单。
* @param {Egg.Application} app egg application
* @return {object} waybillFetchIdempotency model
*/
module.exports = app => {
const { BIGINT, STRING, INTEGER, TINYINT, TEXT, DATE } = app.Sequelize;
const WaybillFetchIdempotency = app.model.define('waybill_fetch_idempotency', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
principal_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '主体ID' },
warehouse_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '仓库ID' },
delivery_order_code: { type: STRING(100), allowNull: false, comment: 'OMS 发货单号' },
express_code: { type: STRING(50), allowNull: false, comment: 'WMS 传入的快递编码' },
package_index: { type: INTEGER.UNSIGNED, allowNull: false, comment: '包裹序号(0 基)' },
request_id: { type: STRING(100), comment: '首次取号的 request_id' },
status: { type: TINYINT, allowNull: false, defaultValue: 0, comment: '状态:0处理中 1成功 2结果待核实' },
result_data: { type: TEXT('medium'), comment: '成功时完整的逐单返回结果(JSON)' },
error_message: { type: TEXT, comment: '结果待核实时的原因' },
created_at: { type: DATE, comment: '创建时间' },
updated_at: { type: DATE, comment: '更新时间' },
}, {
tableName: 'waybill_fetch_idempotencies',
comment: '取号订单级幂等记录',
});
return WaybillFetchIdempotency;
};