carts.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* indent size: 2 */
  2. // eslint-disable-next-line strict
  3. module.exports = app => {
  4. const DataTypes = app.Sequelize;
  5. const Model = app.model.define('Carts', {
  6. cart_id: {
  7. type: DataTypes.INTEGER(10).UNSIGNED,
  8. allowNull: false,
  9. primaryKey: true,
  10. autoIncrement: true,
  11. },
  12. product_id: {
  13. type: DataTypes.INTEGER(10).UNSIGNED,
  14. allowNull: true,
  15. },
  16. category_id: {
  17. type: DataTypes.INTEGER(10).UNSIGNED,
  18. allowNull: true,
  19. },
  20. pid: {
  21. type: DataTypes.INTEGER(4).UNSIGNED,
  22. allowNull: true,
  23. },
  24. product_count: {
  25. type: DataTypes.INTEGER(10).UNSIGNED,
  26. allowNull: true,
  27. },
  28. is_select: {
  29. type: DataTypes.INTEGER(1).UNSIGNED,
  30. allowNull: true,
  31. },
  32. user_id: {
  33. type: DataTypes.INTEGER(10).UNSIGNED,
  34. allowNull: true,
  35. },
  36. random_key: {
  37. type: DataTypes.STRING(10),
  38. allowNull: true,
  39. },
  40. update_time: {
  41. type: DataTypes.TIME,
  42. },
  43. create_time: {
  44. type: DataTypes.DATE,
  45. allowNull: true,
  46. },
  47. volume: {
  48. type: DataTypes.INTEGER(10).UNSIGNED,
  49. allowNull: false,
  50. },
  51. price: {
  52. type: DataTypes.FLOAT,
  53. allowNull: true,
  54. },
  55. dinning_coin_amount: {
  56. type: DataTypes.INTEGER(10).UNSIGNED,
  57. allowNull: true,
  58. },
  59. dining_partner_id: {
  60. type: DataTypes.INTEGER(8),
  61. allowNull: true,
  62. },
  63. }, {
  64. tableName: 'szj_carts',
  65. });
  66. Model.associate = function() {
  67. // 关联商品表
  68. Model.belongsTo(app.model.Products, { foreignKey: 'product_id', targetKey: 'product_id', as: 'products' });
  69. };
  70. // 同步:没有就新建,有就不变
  71. Model.sync();
  72. return Model;
  73. };