123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- /* 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;
- };
|