20180731072646_create_cash_balance_tables.rb 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. class CreateCashBalanceTables < ActiveRecord::Migration
  2. def up
  3. #收益表(回购、代销、邀请佣金)
  4. create_table :cash_balances do |t|
  5. #用户ID
  6. t.column :wx_uid, :integer, :null=>false
  7. #变动金额(分)
  8. t.column :count, :integer, :null=>false
  9. #来源
  10. t.column :source, :string, :limit=>64
  11. #关联ID
  12. t.column :relate_id, :string
  13. #备注
  14. t.column :remark,:string
  15. t.timestamps
  16. end
  17. add_index :cash_balances, :wx_uid
  18. #提现订单表
  19. create_table :take_cash_orders do |t|
  20. # 用户ID
  21. t.column :wx_uid, :integer, :null => false
  22. # 流水号
  23. t.column :order_id, :string, :limit => 64, :null => false
  24. # 交易单号
  25. t.column :trade_no, :string, :limit => 64
  26. # 提现金额
  27. t.column :count, :integer, :limit => 8, :default => 0
  28. # 提现状态 0未支付,1已支付
  29. t.integer :pay_state, :limit => 1, :default => 0
  30. # 审核状态 0未审核,1同意 2拒绝===========================> 提现失败(pay_state:0,audit_state:2), 提现中(pay_state:0,audit_state:0,1), 已完成(pay_state:1, audit_state:1)
  31. t.integer :audit_state, :limit => 1, :default => 0
  32. # 支付时间 s
  33. t.column :paied_at, :integer
  34. # 预计处理时间
  35. t.column :expc_pay_at, :datetime
  36. # 中文描述
  37. t.column :remark, :string
  38. t.timestamps
  39. end
  40. add_index :take_cash_orders, :wx_uid
  41. add_index :take_cash_orders, :order_id
  42. #邀请佣金表
  43. create_table :invite_benefit_orders do |t|
  44. #收益人id
  45. t.column :benefit_wx_uid, :integer, :null=>false
  46. #贡献人id
  47. t.column :wx_uid, :integer, :null=>false
  48. #直接二级贡献人id
  49. t.column :ind_wx_uid, :integer, :null=>false
  50. #佣金金额(分)
  51. t.column :count, :integer, :null=>false
  52. #消费金额(分)
  53. t.column :amount, :integer, :null=>false
  54. #来源
  55. t.column :source, :string, :limit=>64
  56. #关联ID
  57. t.column :relate_id, :string
  58. #是否入账
  59. t.column :is_enter_balance, :boolean, :null=>false, :default=>false
  60. #进账时间
  61. t.column :enter_time, :datetime
  62. #时间戳
  63. t.timestamps
  64. end
  65. add_index :invite_benefit_orders, :benefit_wx_uid
  66. end
  67. def down
  68. drop_table :cash_balances
  69. drop_table :take_cash_orders
  70. drop_table :invite_benefit_orders
  71. end
  72. end