'use strict'; module.exports = app => { const { INTEGER, STRING, BIGINT, TINYINT } = 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: '仓库编码', }, 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: '产品编码', }, 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: '是否上门取件', }, shipperno: { type: STRING(255), 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`。 */ ExpressInterface.associate = function() { const { Express } = app.model; if (Express && typeof ExpressInterface.belongsTo === 'function') { ExpressInterface.belongsTo(Express, { foreignKey: 'sys_express_code', targetKey: 'code', as: 'express', constraints: false, }); } }; return ExpressInterface; };