M230922025229AddonsRebate.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace addons\Rebate\console\migrations;
  3. use common\models\common\Addons;
  4. use yii\db\Migration;
  5. /**
  6. * Class M230922025229AddonsRebate
  7. */
  8. class M230922025229AddonsRebate extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $sql="ALTER TABLE qimall_addons_rebate add join_type tinyint(1) not null default 0 comment '0:平台会员;1:推三返一用户';";
  16. $this->execute($sql);
  17. $sql="CREATE TABLE `qimall_addons_rebate_user` (
  18. `id` int(11) NOT NULL AUTO_INCREMENT,
  19. `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
  20. `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
  21. `upgrade_status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '升级类型;0:后台添加;1条件升级;2购物升级;3:注册添加;4:同步添加',
  22. `level` tinyint(3) NOT NULL DEFAULT '0' COMMENT '代理商等级权重',
  23. `before_level` int(11) DEFAULT '0' COMMENT '升级前等级;0为无',
  24. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  25. `created_at` bigint(20) NOT NULL DEFAULT '0',
  26. `updated_at` bigint(20) NOT NULL DEFAULT '0',
  27. `upgrade_at` bigint(20) NOT NULL DEFAULT '0' COMMENT '等级升级时间',
  28. PRIMARY KEY (`id`) USING BTREE,
  29. KEY `user_id` (`user_id`) USING BTREE
  30. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='推三返一用户';";
  31. $this->execute($sql);
  32. $sql="CREATE TABLE `qimall_addons_rebate_user_level` (
  33. `id` int(11) NOT NULL AUTO_INCREMENT,
  34. `mall_id` int(11) NOT NULL COMMENT '商城ID',
  35. `level` int(11) NOT NULL DEFAULT '0',
  36. `name` varchar(45) NOT NULL DEFAULT '' COMMENT '等级名称',
  37. `is_auto_upgrade` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否开启自动升级',
  38. `upgrade_type_condition` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否开启条件升级',
  39. `checked_condition_values` longtext NOT NULL COMMENT '升级条件',
  40. `checked_condition_keys` varchar(1000) NOT NULL DEFAULT '' COMMENT '升级条件选中的key集合',
  41. `condition_type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0 未选择、1满足其一 2、满足所有',
  42. `upgrade_type_goods` tinyint(1) NOT NULL DEFAULT '0' COMMENT '购买升级商品,0关闭,1开启',
  43. `buy_goods_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '购买升级商品触发升级:0订单完成 1下单完成',
  44. `goods_type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '商品升级类型,1- 任意商品 2- 指定商品',
  45. `goods_ids` varchar(3000) NOT NULL DEFAULT '' COMMENT '商品id集合',
  46. `goods_list` text NOT NULL COMMENT '商品列表json',
  47. `explain` varchar(5000) NOT NULL DEFAULT '' COMMENT '等级说明',
  48. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  49. `created_at` int(11) NOT NULL DEFAULT '0',
  50. `updated_at` int(11) NOT NULL DEFAULT '0',
  51. PRIMARY KEY (`id`) USING BTREE,
  52. KEY `mall_id` (`mall_id`) USING BTREE,
  53. KEY `level` (`level`) USING BTREE
  54. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='推三返一等级';";
  55. $this->execute($sql);
  56. Addons::isInstall('Rebate');
  57. }
  58. /**
  59. * {@inheritdoc}
  60. */
  61. public function safeDown()
  62. {
  63. echo "M230922025229AddonsRebate cannot be reverted.\n";
  64. return false;
  65. }
  66. /*
  67. // Use up()/down() to run migration code without a transaction.
  68. public function up()
  69. {
  70. }
  71. public function down()
  72. {
  73. echo "M230922025229AddonsRebate cannot be reverted.\n";
  74. return false;
  75. }
  76. */
  77. }