20171110030458_create_products.rb 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. # encoding:utf-8
  2. # 产品相关表
  3. class CreateProducts < ActiveRecord::Migration
  4. def up
  5. #平台栏目类别
  6. create_table :platform_cats do |t|
  7. t.string :name, :default => '', :null => false, :limit => 10
  8. #排序
  9. t.integer :position, :default => 1, :null => false
  10. t.string :ancestry, :limit => 20, :default => '', :null => false
  11. #配置不同的平台,录入产品时init,微信端首页wx_home
  12. t.column :platform, :string, :limit => 20, :default => '', :null => false
  13. t.column :url, :string, :limit => 4096, :default => '',:null => false
  14. t.column :state, :boolean, :default => true, :null => false
  15. #打标签hot、new等
  16. t.column :mark, :string, :limit => 10, :default => '', :null => false
  17. #
  18. t.column :cover_click, :string, :limit => 4096, :default => '',:null => false
  19. #icon 样式配置
  20. t.column :icon, :string, :limit => 10, :default => '', :null => false
  21. #控制字体颜色
  22. t.column :font_color, :string, :limit => 10, :default => '', :null => false
  23. t.column :remark, :string, :limit => 225, :default => '', :null => false
  24. #预留字段
  25. t.column :remark1, :string, :limit => 225, :default => '', :null => false
  26. t.column :remark2, :string, :limit => 225, :default => '', :null => false
  27. #如果是推单品的,则记录产品ID
  28. t.column :product_id, :integer, :default => 0, :null => false
  29. end
  30. add_index :platform_cats, :position
  31. add_index :platform_cats, :ancestry
  32. add_index :platform_cats, :platform
  33. #商品表
  34. create_table :products do |t|
  35. #商家用户
  36. t.column :merchant_id, :integer
  37. #商品名称
  38. t.column :name, :string, :limit => 100, :null => false
  39. #类别id
  40. t.column :category_id, :integer
  41. #商品详情
  42. #modify string->text
  43. t.text :detail, :null => false
  44. #外部现金价格(分)
  45. t.column :price, :integer, :null=>false
  46. #内部代金券价格(分)
  47. t.column :robo_balance_price, :integer, :null => false
  48. #外部代金券价格(分)
  49. t.column :mall_balance_price, :integer, :null => false
  50. #采购价格(分)
  51. t.column :buy_price, :integer, :null=>false
  52. #商品类型 直营:direct_sale, 代销: user_sale
  53. t.column :ptype, :string, :limit=>32, :default=>"direct_sale"
  54. #用户挂单结算价(分)
  55. t.column :user_sale_price, :integer, :null=>false, :default=>0
  56. #库存(份)
  57. t.column :count, :integer, :null=>false, :default=>1
  58. #零表示不推荐,大于零的推荐,越大越靠前
  59. t.column :recommend, :integer, :limit => 11, :default => 0
  60. #是否上架
  61. t.column :status, :boolean, :default => false
  62. #是否是精准扶贫
  63. t.column :is_support_poor, :boolean, :default => false
  64. #虚拟销售量
  65. t.column :virtual_sold_count, :integer, :limit => 11, :default =>0
  66. #限购数量
  67. t.column :purchase_limit_count, :integer, :null=> false, :default => 0
  68. #特殊时段告知用户订单处理发货时段
  69. #停止发货时间
  70. t.column :deliver_stop_at, :datetime
  71. #开始发货时间
  72. t.column :deliver_start_at, :datetime
  73. #分享文案
  74. t.string :share_content, :limit => 50
  75. #分享图片
  76. t.string :share_img
  77. #仅限新人
  78. t.column :is_only_new, :boolean, :default=>0
  79. t.column :seckill_start, :datetime
  80. t.column :seckill_end, :datetime
  81. t.column :seckill_price, :integer
  82. t.column :specification, :string
  83. t.column :no_delivery_area, :string, :default => "西藏、新疆、内蒙、宁夏、青海、甘肃"
  84. t.timestamps
  85. end
  86. add_index :products, :category_id
  87. #商品图片
  88. create_table :product_pictures do |t|
  89. #产品ID
  90. t.column :product_id, :string, :limit => 20, :null => false
  91. #图片路径
  92. t.column :img, :string, :null => false
  93. #图片类型 0:轮播图,1:详情图
  94. t.column :pic_type, :tinyint, :null=>false, :default=>0
  95. #排序
  96. t.column :sort, :integer, :null=> false, :default=>0
  97. t.timestamps
  98. end
  99. add_index :product_pictures, :product_id
  100. #商品类别
  101. create_table :product_cats do |t|
  102. t.string :name, :null => false, :limit => 20
  103. t.integer :position
  104. t.string :ancestry, :limit => 20
  105. t.boolean :status, default: true
  106. end
  107. add_index :product_cats, :position
  108. add_index :product_cats, :ancestry
  109. add_index :product_cats, :name
  110. #商品订单表
  111. create_table :orders do |t|
  112. #订单号
  113. t.column :order_id, :string, :null=>false
  114. #订单类型 0:普通订单, 1:代销订单, 2:自用订单
  115. t.column :order_type, :tinyint, :default=>0
  116. # #关联代销订单号
  117. # t.column :sale_order_id, :string
  118. #粮仓ID, 自用和代销时记录关联粮仓ID
  119. t.column :granary_id, :integer, :default=>0
  120. #商品id
  121. t.column :product_id, :integer, :null=>false
  122. #用户id
  123. t.column :user_id, :integer, :null=>false
  124. #微信用户id
  125. t.column :wx_user_id, :integer, :null=>false
  126. #份数
  127. t.column :count, :integer, :null=>false
  128. # 支付时商品的代金券单价
  129. t.column :unit_robo_balance_price, :integer, :null=>false
  130. # 支付时商品的现金单价
  131. t.column :unit_price, :integer, :null=>false
  132. #订单总价(单位) 根据支付方式来显示金钱分还是代金券还是代金券
  133. t.column :total_price, :integer, :null=>false
  134. #支付总价(单位) 根据支付方式来显示金钱分还是代金券还是代金券
  135. t.column :paied_price, :integer, :default=>0
  136. #进货总价(分)除以100就是元
  137. t.column :buy_price, :integer, :default=>0
  138. #支付时间
  139. t.column :paied_at, :integer, :default=>0
  140. #流水号
  141. t.column :trade_no, :string
  142. #状态
  143. t.column :status, :string
  144. #支付方式:微信、代金券、代金券; weixinpay, balance, integral
  145. t.column :pay_way, :string
  146. #支付来源: 公众号 gzh、小程序 xcx、第五创系统d5c_sys
  147. t.column :source, :string
  148. #电话
  149. t.column :tel, :string
  150. #地址
  151. t.column :address, :string
  152. #联系人
  153. t.column :contact, :string
  154. #快递公司
  155. t.column :express_company, :string
  156. #快递单号
  157. t.column :express_order_no, :string
  158. #备注
  159. # 7天自动收货功能=====================
  160. t.column :remark, :string
  161. # 发货时间
  162. t.column :dispatch_time, :datetime
  163. # 收货时间
  164. t.column :receive_time, :datetime
  165. #抽奖或者筹中筹的下单标识
  166. t.column :order_remark, :string
  167. # 退款功能============================
  168. # 平台退款
  169. t.column :platform_refund_amount, :integer, :default => 0
  170. # 商家退款
  171. t.column :merchant_refund_amount, :integer, :default => 0
  172. # 是否部分退款
  173. t.column :is_part_refund, :boolean, :default => false
  174. # 销售专题添加抽奖功能================
  175. # 是否参与销售专题抽奖
  176. t.boolean :is_join_subject_prize, :null => false, :default => false
  177. # 销售专题id
  178. t.column :product_sale_subject_id, :integer, :null => false, :default => 0
  179. t.timestamps
  180. end
  181. add_index :orders, :order_id
  182. add_index :orders, :user_id
  183. add_index :orders, :granary_id
  184. end
  185. end