| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- # encoding:utf-8
- # 产品相关表
- class CreateProducts < ActiveRecord::Migration
- def up
- #平台栏目类别
- create_table :platform_cats do |t|
- t.string :name, :default => '', :null => false, :limit => 10
- #排序
- t.integer :position, :default => 1, :null => false
- t.string :ancestry, :limit => 20, :default => '', :null => false
- #配置不同的平台,录入产品时init,微信端首页wx_home
- t.column :platform, :string, :limit => 20, :default => '', :null => false
- t.column :url, :string, :limit => 4096, :default => '',:null => false
- t.column :state, :boolean, :default => true, :null => false
- #打标签hot、new等
- t.column :mark, :string, :limit => 10, :default => '', :null => false
- #
- t.column :cover_click, :string, :limit => 4096, :default => '',:null => false
- #icon 样式配置
- t.column :icon, :string, :limit => 10, :default => '', :null => false
- #控制字体颜色
- t.column :font_color, :string, :limit => 10, :default => '', :null => false
- t.column :remark, :string, :limit => 225, :default => '', :null => false
- #预留字段
- t.column :remark1, :string, :limit => 225, :default => '', :null => false
- t.column :remark2, :string, :limit => 225, :default => '', :null => false
- #如果是推单品的,则记录产品ID
- t.column :product_id, :integer, :default => 0, :null => false
- end
- add_index :platform_cats, :position
- add_index :platform_cats, :ancestry
- add_index :platform_cats, :platform
- #商品表
- create_table :products do |t|
- #商家用户
- t.column :merchant_id, :integer
- #商品名称
- t.column :name, :string, :limit => 100, :null => false
- #类别id
- t.column :category_id, :integer
- #商品详情
- #modify string->text
- t.text :detail, :null => false
- #外部现金价格(分)
- t.column :price, :integer, :null=>false
- #内部提货券价格(分)
- t.column :robo_balance_price, :integer, :null => false
- #外部提货券价格(分)
- t.column :mall_balance_price, :integer, :null => false
- #采购价格(分)
- t.column :buy_price, :integer, :null=>false
- #商品类型 直营:direct_sale, 代销: user_sale
- t.column :ptype, :string, :limit=>32, :default=>"direct_sale"
- #用户挂单结算价(分)
- t.column :user_sale_price, :integer, :null=>false, :default=>0
- #库存(份)
- t.column :count, :integer, :null=>false, :default=>1
- #零表示不推荐,大于零的推荐,越大越靠前
- t.column :recommend, :integer, :limit => 11, :default => 0
- #是否上架
- t.column :status, :boolean, :default => false
- #是否是精准扶贫
- t.column :is_support_poor, :boolean, :default => false
- #虚拟销售量
- t.column :virtual_sold_count, :integer, :limit => 11, :default =>0
- #限购数量
- t.column :purchase_limit_count, :integer, :null=> false, :default => 0
- #特殊时段告知用户订单处理发货时段
- #停止发货时间
- t.column :deliver_stop_at, :datetime
- #开始发货时间
- t.column :deliver_start_at, :datetime
- #分享文案
- t.string :share_content, :limit => 50
- #分享图片
- t.string :share_img
- #仅限新人
- t.column :is_only_new, :boolean, :default=>0
- t.column :seckill_start, :datetime
- t.column :seckill_end, :datetime
- t.column :seckill_price, :integer
- t.column :specification, :string
- t.column :no_delivery_area, :string, :default => "西藏、新疆、内蒙、宁夏、青海、甘肃"
- t.timestamps
- end
- add_index :products, :category_id
- #商品图片
- create_table :product_pictures do |t|
- #产品ID
- t.column :product_id, :string, :limit => 20, :null => false
- #图片路径
- t.column :img, :string, :null => false
- #图片类型 0:轮播图,1:详情图
- t.column :pic_type, :tinyint, :null=>false, :default=>0
- #排序
- t.column :sort, :integer, :null=> false, :default=>0
- t.timestamps
- end
- add_index :product_pictures, :product_id
- #商品类别
- create_table :product_cats do |t|
- t.string :name, :null => false, :limit => 20
- t.integer :position
- t.string :ancestry, :limit => 20
- t.boolean :status, default: true
- end
- add_index :product_cats, :position
- add_index :product_cats, :ancestry
- add_index :product_cats, :name
- #商品订单表
- create_table :orders do |t|
- #订单号
- t.column :order_id, :string, :null=>false
- #订单类型 0:普通订单, 1:代销订单, 2:自用订单
- t.column :order_type, :tinyint, :default=>0
- # #关联代销订单号
- # t.column :sale_order_id, :string
- #粮仓ID, 自用和代销时记录关联粮仓ID
- t.column :granary_id, :integer, :default=>0
- #商品id
- t.column :product_id, :integer, :null=>false
- #用户id
- t.column :user_id, :integer, :null=>false
- #微信用户id
- t.column :wx_user_id, :integer, :null=>false
- #份数
- t.column :count, :integer, :null=>false
- # 支付时商品的提货券单价
- t.column :unit_robo_balance_price, :integer, :null=>false
- # 支付时商品的现金单价
- t.column :unit_price, :integer, :null=>false
- #订单总价(单位) 根据支付方式来显示金钱分还是提货券还是提货券
- t.column :total_price, :integer, :null=>false
- #支付总价(单位) 根据支付方式来显示金钱分还是提货券还是提货券
- t.column :paied_price, :integer, :default=>0
- #进货总价(分)除以100就是元
- t.column :buy_price, :integer, :default=>0
- #支付时间
- t.column :paied_at, :integer, :default=>0
- #流水号
- t.column :trade_no, :string
- #状态
- t.column :status, :string
- #支付方式:微信、提货券、提货券; weixinpay, balance, integral
- t.column :pay_way, :string
- #支付来源: 公众号 gzh、小程序 xcx、第五创系统d5c_sys
- t.column :source, :string
- #电话
- t.column :tel, :string
- #地址
- t.column :address, :string
- #联系人
- t.column :contact, :string
- #快递公司
- t.column :express_company, :string
- #快递单号
- t.column :express_order_no, :string
- #备注
-
- # 7天自动收货功能=====================
- t.column :remark, :string
- # 发货时间
- t.column :dispatch_time, :datetime
- # 收货时间
- t.column :receive_time, :datetime
- #抽奖或者筹中筹的下单标识
- t.column :order_remark, :string
- # 退款功能============================
- # 平台退款
- t.column :platform_refund_amount, :integer, :default => 0
- # 商家退款
- t.column :merchant_refund_amount, :integer, :default => 0
- # 是否部分退款
- t.column :is_part_refund, :boolean, :default => false
- # 销售专题添加抽奖功能================
- # 是否参与销售专题抽奖
- t.boolean :is_join_subject_prize, :null => false, :default => false
- # 销售专题id
- t.column :product_sale_subject_id, :integer, :null => false, :default => 0
- t.timestamps
- end
- add_index :orders, :order_id
- add_index :orders, :user_id
- add_index :orders, :granary_id
- end
- end
|