123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /* eslint-disable strict */
- /* indent size: 2 */
- module.exports = app => {
- const DataTypes = app.Sequelize;
- const Model = app.model.define('OrdersProducts', {
- rec_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: false,
- primaryKey: true,
- autoIncrement: true,
- },
- order_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: true,
- },
- product_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: true,
- },
- category_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: true,
- },
- product_name: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- product_sn: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- product_image: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- product_count: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: true,
- },
- shop_price: {
- type: DataTypes.FLOAT,
- allowNull: true,
- },
- goods_type: {
- type: DataTypes.INTEGER(1).UNSIGNED,
- allowNull: true,
- },
- activity_id: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: true,
- },
- activity_name: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- activity_desc: {
- type: DataTypes.STRING(255),
- allowNull: true,
- },
- is_deliver: {
- type: DataTypes.INTEGER(1).UNSIGNED,
- allowNull: true,
- },
- deliver_count: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: true,
- },
- total_price: {
- type: DataTypes.FLOAT,
- allowNull: true,
- },
- create_time: {
- type: DataTypes.DATE,
- allowNull: true,
- },
- volume: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: false,
- },
- price: {
- type: DataTypes.FLOAT,
- allowNull: true,
- },
- dinning_coin_amount: {
- type: DataTypes.INTEGER(10).UNSIGNED,
- allowNull: true,
- },
- dining_partner_id: {
- type: DataTypes.INTEGER(8),
- allowNull: true,
- },
- }, {
- tableName: 'szj_orders_products',
- });
- Model.associate = function() {
- // 关联订单表
- Model.belongsTo(app.model.Orders, { foreignKey: 'order_id', targetKey: 'order_id', as: 'orders' });
- // 关联商品表
- Model.belongsTo(app.model.Products, { foreignKey: 'product_id', targetKey: 'product_id', as: 'products' });
- // 关联评价表
- Model.belongsTo(app.model.ProductComment, {
- foreignKey: 'product_id',
- targetKey: 'product_id',
- as: 'product_comment',
- });
- };
- // 同步:没有就新建,有就不变
- Model.sync();
- return Model;
- };
|