WMS_MAIN/app/model/express_interface.js
liufumingren 2c615cb4f8 feat(expressInterface): 快递接口新增物品描述 goods_description 并用于菜鸟面单
- wms_express_interface 新增 goods_description VARCHAR(255) NULL(迁移 20261118200000)
- create/update 支持 goods_description(兼容 goodsDescription),最长 255 字符、允许为空
- list / listByWarehousePlatformCode 返回该字段
- 菜鸟电子面单 package_info.goods_description 改为读取接口配置,未配置时回退「化妆品」
- 同步 methods/system.json 与变更记录

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-18 19:28:39 +08:00

266 lines
5.9 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';
/**
* 定义快递接口配置模型。
* @param {Object} app Egg 应用对象。
* @return {Object} 快递接口配置模型。
*/
module.exports = app => {
const { INTEGER, STRING, BIGINT, TINYINT, JSON } = app.Sequelize;
const ExpressInterface = app.model.define('express_interface', {
id: {
type: INTEGER(11).UNSIGNED,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '主键ID',
},
name: {
type: STRING(255),
allowNull: true,
comment: '接口名称',
},
express_code: {
type: STRING(255),
allowNull: false,
comment: '快递编码',
},
platform_code: {
type: STRING(50),
allowNull: false,
comment: '平台编码',
},
sys_express_code: {
type: STRING(50),
allowNull: false,
comment: '系统快递编码',
},
warehouse_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '仓库编码',
},
shop_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '店铺ID',
},
platform_shop_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '平台店铺ID',
},
template_id: {
type: STRING(50),
allowNull: true,
comment: '模板ID',
},
paymode: {
type: INTEGER(11),
allowNull: true,
comment: '付款方式',
},
brandno: {
type: STRING(255),
allowNull: true,
comment: '品牌编码',
},
providertype: {
type: STRING(50),
allowNull: true,
comment: '服务商类型编码',
},
providerid: {
type: INTEGER(11),
allowNull: true,
comment: '服务商ID',
},
sender_name: {
type: STRING(50),
allowNull: true,
comment: '寄件人',
},
sender_tel: {
type: STRING(11),
allowNull: true,
comment: '寄件电话',
},
weight: {
type: INTEGER(11),
allowNull: true,
comment: '排序',
},
token: {
type: STRING(500),
allowNull: true,
comment: '令牌',
},
viewer: {
type: STRING(50),
allowNull: true,
comment: '验视员',
},
client_id: {
type: STRING(50),
allowNull: true,
comment: '客户id',
},
is_share: {
type: TINYINT(1),
allowNull: true,
defaultValue: 0,
comment: '是否分享接口',
},
share_id: {
type: INTEGER(11).UNSIGNED,
allowNull: true,
comment: '分享id',
},
can_use_count: {
type: INTEGER(11),
allowNull: true,
defaultValue: 0,
comment: '可用数量',
},
province_name: {
type: STRING(255),
allowNull: true,
comment: '寄件人名称',
},
city_name: {
type: STRING(255),
allowNull: true,
comment: '寄件人城市',
},
district_name: {
type: STRING(255),
allowNull: true,
comment: '寄件人区/县',
},
site_code: {
type: STRING(255),
allowNull: true,
comment: '网点编码',
},
product_type: {
type: STRING(50),
allowNull: true,
comment: '产品编码',
},
goods_description: {
type: STRING(255),
allowNull: true,
comment: '物品描述',
},
weight_type: {
type: INTEGER(10),
allowNull: true,
comment: '重量类型',
},
shop_name: {
type: STRING(255),
allowNull: true,
comment: '平台店铺',
},
address: {
type: STRING(255),
allowNull: true,
comment: '地址',
},
town_name: {
type: STRING(255),
allowNull: true,
comment: '寄件人街道',
},
ispickup: {
type: TINYINT(1),
allowNull: true,
defaultValue: 0,
comment: '是否上门取件',
},
is_hide_goods: {
type: TINYINT(1),
allowNull: true,
defaultValue: 0,
comment: '是否隐藏物品信息',
},
is_enabled: {
type: TINYINT(1),
allowNull: true,
defaultValue: 1,
comment: '是否启用(1=启用,0=停用)',
},
shipperno: {
type: STRING(255),
allowNull: true,
comment: '寄件网点编码',
},
template_url: {
type: STRING(500),
allowNull: true,
comment: '打印模板链接',
},
ext_data: {
type: JSON,
allowNull: true,
comment: '扩展信息',
},
}, {
tableName: 'wms_express_interface',
freezeTableName: true,
underscored: true,
timestamps: false,
paranoid: false,
comment: '快递接口配置表',
indexes: [
{
name: 'idx_warehouse_id',
fields: [ 'warehouse_id' ],
},
],
});
/**
* 定义快递接口与系统快递、店铺、打印平台的关联关系。
*
* 说明:
* - `wms_express_interface.sys_express_code` 对应 `wms_express.code`
* - `wms_express_interface.shop_id` 对应 `wms_shops.id`
* - `wms_express_interface.platform_code` 对应 `wms_print_platform.platform_code`
*/
ExpressInterface.associate = function() {
const { Express, Shop, PrintPlatform } = app.model;
if (Express && typeof ExpressInterface.belongsTo === 'function') {
ExpressInterface.belongsTo(Express, {
foreignKey: 'sys_express_code',
targetKey: 'code',
as: 'express',
constraints: false,
});
}
if (Shop && typeof ExpressInterface.belongsTo === 'function') {
ExpressInterface.belongsTo(Shop, {
foreignKey: 'shop_id',
targetKey: 'id',
as: 'shop',
constraints: false,
});
}
if (PrintPlatform && typeof ExpressInterface.belongsTo === 'function') {
ExpressInterface.belongsTo(PrintPlatform, {
foreignKey: 'platform_code',
targetKey: 'platform_code',
as: 'printPlatform',
constraints: false,
});
}
};
return ExpressInterface;
};