WMS_MAIN/app/model/after_sale_detail.js
liufumingren b436b6dd9e feat: 拦截链路全流程完善 — 新增interceptScan + 运单表同步 + 工单通知
新增:
- order.recheckOrder.interceptScan: 拦截扫描接口,入参运单号,查express标记退回,处理工单,更新订单拦截状态
- afterSale.createInterceptWorkOrdersAndNotify: 共享方法,幂等创建工单+通知快递群

修复:
- confirmIntercept: 补运单is_back同步(仅限is_intercept=Y),补工单创建+通知
- batchIntercept: 补运单is_intercept同步,补工单创建+通知
- batchUnintercept: 补运单is_intercept/is_back清除
- Qimen/OpenAPI cancel: 补运单is_intercept同步,补工单创建+通知
- interceptScan: 删除死查询,加空指针兜底

文档:
- methods/system.json: interceptScan + confirmIntercept 完整API文档
- methods/changes/system.json: 变更记录
2026-08-12 20:47:19 +08:00

145 lines
3.7 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';
/**
* 售后进度步骤表 Model,基于 `wms_after_sale_detail` 表。
* @param {import('egg').Application} app Egg 应用实例
* @return {import('sequelize').ModelCtor<import('sequelize').Model>} 售后进度步骤 Model(含常量挂载)
*/
module.exports = app => {
const { STRING, BIGINT, TEXT, DATE } = app.Sequelize;
// ============================
// 枚举常量定义
// ============================
/**
* 步骤状态枚举(与 wms_after_sale.status 一致)。
*/
const STEP_STATUS = {
pending: '待处理',
processing: '处理中',
pending_feedback: '等待外部反馈',
completed: '已完成',
closed: '已关闭',
cancelled: '已取消',
};
// ============================
// Model 定义
// ============================
const AfterSaleDetail = app.model.define('after_sale_detail', {
/** 主键 */
id: {
type: BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
comment: '主键',
},
/** 关联售后主表ID */
after_sale_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '关联售后主表ID(wms_after_sale.id)',
},
/** 步骤记录时售后主表的状态 */
step_status: {
type: STRING(20),
allowNull: false,
defaultValue: 'processing',
comment: '步骤记录时售后主表的状态,与 wms_after_sale.status 一致: pending | processing | pending_feedback | completed | closed | cancelled',
},
/** 操作人账户ID */
operator_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '操作人账户ID(关联 accounts 表);外部系统回调/自动触发的步骤可为空',
},
/** 操作人信息快照 */
operator_snapshot: {
type: TEXT,
allowNull: true,
comment: '操作人信息快照(JSON),如 {"name":"张三","role":"客服"},防止账户删除后历史丢失',
},
/** 操作动作描述 */
action: {
type: STRING(100),
allowNull: true,
comment: '操作动作描述,如"确认收货"、"审核驳回"、"发起退款"',
},
/** 处理备注 */
remark: {
type: TEXT,
allowNull: true,
comment: '处理备注',
},
/** 步骤开始时间 */
started_at: {
type: DATE,
allowNull: true,
comment: '步骤开始时间',
},
/** 步骤完成时间 */
completed_at: {
type: DATE,
allowNull: true,
comment: '步骤完成时间',
},
/** 创建时间 */
created_at: {
type: DATE,
allowNull: true,
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
comment: '创建时间',
},
/** 更新时间 */
updated_at: {
type: DATE,
allowNull: true,
comment: '更新时间',
},
/** 软删除时间 */
deleted_at: {
type: DATE,
allowNull: true,
comment: '软删除时间',
},
}, {
tableName: 'wms_after_sale_detail',
comment: '售后进度步骤表',
timestamps: false,
indexes: [
{
name: 'idx_after_sale_id',
fields: [ 'after_sale_id' ],
},
{
name: 'idx_operator_id',
fields: [ 'operator_id' ],
},
],
});
// ============================
// 关联关系
// ============================
AfterSaleDetail.associate = function() {
const { AfterSale, AfterSaleDetail } = app.model;
// 关联售后主表(多对一)
AfterSaleDetail.belongsTo(AfterSale, {
foreignKey: 'after_sale_id',
as: 'afterSale',
});
};
// ============================
// 常量挂载到 Model
// ============================
AfterSaleDetail.STEP_STATUS = STEP_STATUS;
return AfterSaleDetail;
};