m220227_143428_member_account.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. use yii\db\Migration;
  3. class m220227_143428_member_account extends Migration
  4. {
  5. public function up()
  6. {
  7. /* 取消外键约束 */
  8. $this->execute('SET foreign_key_checks = 0');
  9. /* 创建表 */
  10. $this->createTable('{{%member_account}}', [
  11. 'id' => "int(10) unsigned NOT NULL AUTO_INCREMENT",
  12. 'merchant_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '商户id'",
  13. 'store_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '店铺ID'",
  14. 'member_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '用户id'",
  15. 'member_type' => "tinyint(4) NULL DEFAULT '1' COMMENT '1:会员;2:后台管理员;3:商家管理员'",
  16. 'user_money' => "decimal(10,2) NULL DEFAULT '0.00' COMMENT '当前余额'",
  17. 'accumulate_money' => "decimal(10,2) NULL DEFAULT '0.00' COMMENT '累计余额'",
  18. 'give_money' => "decimal(10,2) NULL DEFAULT '0.00' COMMENT '累计赠送余额'",
  19. 'consume_money' => "decimal(10,2) NULL DEFAULT '0.00' COMMENT '累计消费金额'",
  20. 'frozen_money' => "decimal(10,2) NULL DEFAULT '0.00' COMMENT '冻结金额'",
  21. 'user_integral' => "int(11) NULL DEFAULT '0' COMMENT '当前积分'",
  22. 'accumulate_integral' => "int(11) NULL DEFAULT '0' COMMENT '累计积分'",
  23. 'give_integral' => "int(11) NULL DEFAULT '0' COMMENT '累计赠送积分'",
  24. 'consume_integral' => "decimal(10,2) NULL DEFAULT '0.00' COMMENT '累计消费积分'",
  25. 'frozen_integral' => "int(11) NULL DEFAULT '0' COMMENT '冻结积分'",
  26. 'user_growth' => "int(11) NULL DEFAULT '0' COMMENT '当前成长值'",
  27. 'accumulate_growth' => "int(11) NULL DEFAULT '0' COMMENT '累计成长值'",
  28. 'consume_growth' => "int(10) NULL DEFAULT '0' COMMENT '累计消费成长值'",
  29. 'frozen_growth' => "int(10) NULL DEFAULT '0' COMMENT '冻结成长值'",
  30. 'economize_money' => "decimal(10,2) NULL DEFAULT '0.00' COMMENT '已节约金额'",
  31. 'accumulate_drawn_money' => "decimal(10,2) NULL DEFAULT '0.00' COMMENT '累计提现'",
  32. 'status' => "tinyint(4) NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]'",
  33. 'PRIMARY KEY (`id`)'
  34. ], "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员_账户表'");
  35. /* 索引设置 */
  36. $this->createIndex('member_id','{{%member_account}}','member_id',0);
  37. $this->createIndex('merchant_id','{{%member_account}}','merchant_id, member_type',0);
  38. /* 表数据 */
  39. $this->insert('{{%member_account}}',['id'=>'1','merchant_id'=>'0','store_id'=>'0','member_id'=>'1','member_type'=>'2','user_money'=>'0.00','accumulate_money'=>'0.00','give_money'=>'0.00','consume_money'=>'0.00','frozen_money'=>'0.00','user_integral'=>'0','accumulate_integral'=>'0','give_integral'=>'0','consume_integral'=>'0.00','frozen_integral'=>'0','user_growth'=>'0','accumulate_growth'=>'0','consume_growth'=>'0','frozen_growth'=>'0','economize_money'=>'0.00','accumulate_drawn_money'=>'0.00','status'=>'1']);
  40. /* 设置外键约束 */
  41. $this->execute('SET foreign_key_checks = 1;');
  42. }
  43. public function down()
  44. {
  45. $this->execute('SET foreign_key_checks = 0');
  46. /* 删除表 */
  47. $this->dropTable('{{%member_account}}');
  48. $this->execute('SET foreign_key_checks = 1;');
  49. }
  50. }
粤ICP备19079148号