| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace addons\ScoreBonus\console\migrations;
- use yii\db\Migration;
- /**
- * Class M250519013327CreateQimallAddonsScoreBonusCapitalPool
- */
- class M250609143327CreateQimallAddonsScoreBonusWeight extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- $sql = <<<SQL
- CREATE TABLE `qimall_addons_score_bonus_user_weight` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `mall_id` int(11) NOT NULL DEFAULT '0',
- `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
- `weight` int(11) NOT NULL DEFAULT '0' COMMENT '权重',
- `total_income` decimal(10,2) DEFAULT '0.00' COMMENT '累计收入',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` int(11) NOT NULL DEFAULT '0',
- `updated_at` int(11) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='积分分红用户权重';
- CREATE TABLE `qimall_addons_score_bonus_user_weight_log` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `mall_id` int(11) NOT NULL DEFAULT '0',
- `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
- `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类型:1直推会员',
- `before_weight` int(11) NOT NULL DEFAULT '0' COMMENT '修改前权重',
- `change_weight` int(11) NOT NULL DEFAULT '0' COMMENT '修改权重数量',
- `after_weight` int(11) NOT NULL DEFAULT '0' COMMENT '修改后权重',
- `desc` varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` int(11) NOT NULL DEFAULT '0',
- `updated_at` int(11) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`) USING BTREE
- ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='积分分红用户权重日志';
- CREATE TABLE `qimall_addons_score_bonus_weight_contributions` (
- `id` INT(11) NOT NULL AUTO_INCREMENT,
- `mall_id` INT(11) NOT NULL DEFAULT 0,
- `parent_user_id` INT(11) NOT NULL COMMENT '获得权重的上级USER_ID',
- `child_user_id` INT(11) NOT NULL COMMENT '产生贡献的下级USER_ID',
- `user_level` VARCHAR(20) NOT NULL COMMENT '触发贡献的用户级别',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` int(11) NOT NULL DEFAULT '0',
- `updated_at` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`),
- UNIQUE KEY `idx_unique_contribution` (`parent_user_id`, `child_user_id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='积分分红权重贡献记录表';
- ALTER TABLE `qimall_addons_score_bonus`
- ADD COLUMN `settle_method` tinyint(1) NOT NULL DEFAULT '0' COMMENT '结算方式: 0积分占比分配 1权重占比分配',
- ADD COLUMN `total_weight` INT(11) NOT NULL DEFAULT '0' COMMENT '总权重';
- ALTER TABLE `qimall_addons_score_bonus_reward_log`
- ADD COLUMN `weight` INT(11) NOT NULL DEFAULT '0' COMMENT '结算时用户权重';
- SQL;
- $this->execute($sql);
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M250519013327CreateQimallAddonsScoreBonusCapitalPool cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M250519013327CreateQimallAddonsScoreBonusCapitalPool cannot be reverted.\n";
- return false;
- }
- */
- }
|