M250609143327CreateQimallAddonsScoreBonusWeight.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace addons\ScoreBonus\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M250519013327CreateQimallAddonsScoreBonusCapitalPool
  6. */
  7. class M250609143327CreateQimallAddonsScoreBonusWeight extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $sql = <<<SQL
  15. CREATE TABLE `qimall_addons_score_bonus_user_weight` (
  16. `id` int(11) NOT NULL AUTO_INCREMENT,
  17. `mall_id` int(11) NOT NULL DEFAULT '0',
  18. `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
  19. `weight` int(11) NOT NULL DEFAULT '0' COMMENT '权重',
  20. `total_income` decimal(10,2) DEFAULT '0.00' COMMENT '累计收入',
  21. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  22. `created_at` int(11) NOT NULL DEFAULT '0',
  23. `updated_at` int(11) NOT NULL DEFAULT '0',
  24. PRIMARY KEY (`id`) USING BTREE
  25. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='积分分红用户权重';
  26. CREATE TABLE `qimall_addons_score_bonus_user_weight_log` (
  27. `id` int(11) NOT NULL AUTO_INCREMENT,
  28. `mall_id` int(11) NOT NULL DEFAULT '0',
  29. `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
  30. `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类型:1直推会员',
  31. `before_weight` int(11) NOT NULL DEFAULT '0' COMMENT '修改前权重',
  32. `change_weight` int(11) NOT NULL DEFAULT '0' COMMENT '修改权重数量',
  33. `after_weight` int(11) NOT NULL DEFAULT '0' COMMENT '修改后权重',
  34. `desc` varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
  35. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  36. `created_at` int(11) NOT NULL DEFAULT '0',
  37. `updated_at` int(11) NOT NULL DEFAULT '0',
  38. PRIMARY KEY (`id`) USING BTREE
  39. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='积分分红用户权重日志';
  40. CREATE TABLE `qimall_addons_score_bonus_weight_contributions` (
  41. `id` INT(11) NOT NULL AUTO_INCREMENT,
  42. `mall_id` INT(11) NOT NULL DEFAULT 0,
  43. `parent_user_id` INT(11) NOT NULL COMMENT '获得权重的上级USER_ID',
  44. `child_user_id` INT(11) NOT NULL COMMENT '产生贡献的下级USER_ID',
  45. `user_level` VARCHAR(20) NOT NULL COMMENT '触发贡献的用户级别',
  46. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  47. `created_at` int(11) NOT NULL DEFAULT '0',
  48. `updated_at` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`),
  49. UNIQUE KEY `idx_unique_contribution` (`parent_user_id`, `child_user_id`)
  50. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='积分分红权重贡献记录表';
  51. ALTER TABLE `qimall_addons_score_bonus`
  52. ADD COLUMN `settle_method` tinyint(1) NOT NULL DEFAULT '0' COMMENT '结算方式: 0积分占比分配 1权重占比分配',
  53. ADD COLUMN `total_weight` INT(11) NOT NULL DEFAULT '0' COMMENT '总权重';
  54. ALTER TABLE `qimall_addons_score_bonus_reward_log`
  55. ADD COLUMN `weight` INT(11) NOT NULL DEFAULT '0' COMMENT '结算时用户权重';
  56. SQL;
  57. $this->execute($sql);
  58. }
  59. /**
  60. * {@inheritdoc}
  61. */
  62. public function safeDown()
  63. {
  64. echo "M250519013327CreateQimallAddonsScoreBonusCapitalPool cannot be reverted.\n";
  65. return false;
  66. }
  67. /*
  68. // Use up()/down() to run migration code without a transaction.
  69. public function up()
  70. {
  71. }
  72. public function down()
  73. {
  74. echo "M250519013327CreateQimallAddonsScoreBonusCapitalPool cannot be reverted.\n";
  75. return false;
  76. }
  77. */
  78. }