/* indent size: 2 */ // eslint-disable-next-line strict module.exports = app => { const DataTypes = app.Sequelize; const Model = app.model.define('Orders', { order_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: false, primaryKey: true, autoIncrement: true, }, order_sn: { type: DataTypes.CHAR(22), allowNull: true, }, order_status: { type: DataTypes.INTEGER(3).UNSIGNED, allowNull: true, }, pay_sn: { type: DataTypes.STRING(255), allowNull: true, }, user_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, inviter_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, commission_log_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, order_amount: { type: DataTypes.FLOAT, allowNull: true, }, user_remarks: { type: DataTypes.STRING(255), allowNull: true, }, seller_remarks: { type: DataTypes.STRING(255), allowNull: true, }, consignee: { type: DataTypes.STRING(255), allowNull: true, }, province_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, city_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, county_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, address: { type: DataTypes.STRING(255), allowNull: true, }, mobile: { type: DataTypes.STRING(255), allowNull: true, }, shipping_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, pay_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, shipping_fee: { type: DataTypes.FLOAT, allowNull: true, }, surplus_amout: { type: DataTypes.FLOAT, allowNull: true, }, activity_id: { type: DataTypes.INTEGER(11), allowNull: true, }, activity_name: { type: DataTypes.STRING(255), allowNull: true, }, activity_desc: { type: DataTypes.STRING(255), allowNull: true, }, is_urge: { type: DataTypes.INTEGER(3).UNSIGNED, allowNull: true, }, is_express: { type: DataTypes.INTEGER(1).UNSIGNED, allowNull: true, }, dining_coin_send: { type: DataTypes.INTEGER(1).UNSIGNED, allowNull: true, }, express_sn: { type: DataTypes.STRING(255), allowNull: true, }, deliver_desc: { type: DataTypes.STRING(255), allowNull: true, }, express_id: { type: DataTypes.INTEGER(10).UNSIGNED, allowNull: true, }, deliver_time: { type: DataTypes.DATE, }, query_time: { type: DataTypes.DATE, }, success_time: { type: DataTypes.DATE, }, create_time: { type: DataTypes.DATE, }, }, { tableName: 'szj_orders', }); Model.associate = function() { // 关联用户表 Model.belongsTo(app.model.Users, { foreignKey: 'user_id', targetKey: 'user_id', as: 'users' }); Model.belongsTo(app.model.Users, { foreignKey: 'inviter_id', targetKey: 'user_id', as: 'inviter' }); // 关联订单商品表 Model.hasMany(app.model.OrdersProducts, { foreignKey: 'order_id', targetKey: 'order_id', as: 'orders_products' }); // 关闭支付类型表 Model.belongsTo(app.model.PaysConfig, { foreignKey: 'pay_id', targetKey: 'pay_id', as: 'pays_config' }); // 关联订单支付表 Model.belongsTo(app.model.Payments, { foreignKey: 'pay_sn', targetKey: 'out_trade_no', as: 'payments' }); }; // 同步:没有就新建,有就不变 Model.sync(); return Model; };