| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- namespace addons\Agent\console\migrations;
- use common\models\common\CrontabTask;
- use common\models\common\GlobalVarMap;
- use yii\db\Migration;
- /**
- * Class M230915020143AgentMigrate
- */
- class M230915020143AgentMigrate extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- $table = 'qimall_addons_agent_team_achievement';
- $sql = "select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
- $res = $this->db->createCommand($sql)->execute();
- if (empty($res)) {
- $sql = "
- CREATE TABLE `qimall_addons_agent_team_achievement` (
- `id` bigint(18) NOT NULL AUTO_INCREMENT,
- `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城ID',
- `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID',
- `personal_performance` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '个人业绩',
- `team_performance` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '渠道业绩',
- `month` varchar(255) NOT NULL DEFAULT '0.00' COMMENT '月份',
- `rate` decimal(5,2) NOT NULL DEFAULT '0.00' COMMENT '百分比',
- `level` tinyint(1) NOT NULL DEFAULT '0' COMMENT '渠道等级',
- `is_settlement` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否结算',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
- `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `mall_id` (`mall_id`) USING BTREE,
- KEY `user_id` (`user_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='渠道业绩';";
- $this->execute($sql);
- }
- $table = 'qimall_addons_agent_team_achievement_order_log';
- $sql = "select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
- $res = $this->db->createCommand($sql)->execute();
- if (empty($res)) {
- $sql = "
- CREATE TABLE `qimall_addons_agent_team_achievement_order_log` (
- `id` bigint(18) NOT NULL AUTO_INCREMENT,
- `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城ID',
- `order_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单编号',
- `settlement_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '结算类型:0:订单完成结算;1:按月结算',
- `buy_user_id` int(11) NOT NULL DEFAULT '0' COMMENT '购买者id',
- `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '此订单计入给谁的个人业绩',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
- `updated_at` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `mall_id` (`mall_id`) USING BTREE,
- KEY `order_no` (`order_no`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='渠道业绩订单记录';";
- $this->execute($sql);
- }
- $res = CrontabTask::findOne(['command'=>'agent/agent/index']);
- if(empty($res)){
- $sql="INSERT INTO `qimall_crontab_task`( `name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('按月结算渠道业绩额外奖励', 'agent/agent/index', 2, '0 0 0 0 1 *', 0, 1, 1658479952, 1658479952);";
- $this->execute($sql);
- }
- $res = GlobalVarMap::findOne(['name'=>'Agent','type'=>'IncomeMap']);
- if(empty($res)){
- $sql ="INSERT INTO `qimall_global_var_map`(`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES
- ('Agent', '渠道分红', 'IncomeMap', 1, 1, 1654569888, 1654569888);";
- $this->execute($sql);
- }
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M230915020143AgentMigrate cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M230915020143AgentMigrate cannot be reverted.\n";
- return false;
- }
- */
- }
|