From afad195062d4a4d0afa423ba2bb40d3750ee6a6c Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Tue, 29 Sep 2020 18:36:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/PromoteGradeService.class.php | 116 +++++++++ .../PromoteGradeController.class.php | 106 ++++++++ .../Home/View/default/PromoteGrade/index.html | 162 ++++++++++++ .../View/default/PromoteGrade/setting.html | 233 ++++++++++++++++++ .../View/default/PromoteGrade/settings.html | 72 ++++++ Data/update.sql | 12 +- 6 files changed, 700 insertions(+), 1 deletion(-) create mode 100644 Application/Base/Service/PromoteGradeService.class.php create mode 100644 Application/Home/Controller/PromoteGradeController.class.php create mode 100644 Application/Home/View/default/PromoteGrade/index.html create mode 100644 Application/Home/View/default/PromoteGrade/setting.html create mode 100644 Application/Home/View/default/PromoteGrade/settings.html diff --git a/Application/Base/Service/PromoteGradeService.class.php b/Application/Base/Service/PromoteGradeService.class.php new file mode 100644 index 000000000..5ef4fbe15 --- /dev/null +++ b/Application/Base/Service/PromoteGradeService.class.php @@ -0,0 +1,116 @@ + 0) { + $setting = M('promote_grade_setting', 'tab')->where(['id' => $id])->find(); + if (is_null($setting)) { + throw new \Exception('记录不存在'); + } + if ($setting['company_id'] != $promote['company_id']) { + throw new \Exception('不允许修改其他公司的配置'); + } + } + + $config = []; + $config['reach_level'] = $params['level']; + $config['grades'] = $params['grades']; + + $data = []; + $data['company_id'] = $promote['company_id']; + $data['status'] = 1; + $data['config'] = json_encode($config); + $data['create_time'] = time(); + $data['update_time'] = time(); + M('promote_grade_setting', 'tab_')->add($data); + M('promote_grade_setting', 'tab_')->where(['id' => $id])->save($data); + } + + private function checkGrades($grades) + { + + } + + public function hadSetting($promote) + { + $setting = M('promote_grade_setting', 'tab_')->field(['id'])->where(['status' => 1, 'company_id' => $promote['company_id']])->find(); + if ($setting) { + return true; + } + return false; + } + + public function searchGradeByPromotes($promotes, $params) + { + /** + * @todo 通过设置获取 + */ + $settingLevel = 50; + $month = $params['month'] ?? date('Y-m'); + + $promoteIds = array_column($promotes, 'id'); + $beginTime = strtotime($month . '-01 00:00:00'); + $endTime = strtotime($month . '-01 00:00:00') + 24*3600 - 1; + + $betweenTime = [$beginTime, $endTime]; + + $userSubSql = M('user', 'tab_') + ->field(['id']) + ->where(['register_time' => ['between', $betweenTime], 'promote_id' => ['in', $promoteIds]]) + ->group('promote_id') + ->select(false); + + $accountItems = M('user_play_info', 'tab_') + ->field(['promote_id', 'count(DISTINCT user_id) num']) + ->where([ + 'role_level' => ['egt', $settingLevel], + 'create_time' => ['between', $betweenTime], + 'promote_id' => ['in', $promoteIds], + '_string' => 'user_id in (' . $userSubSql . ')' + ]) + ->group('promote_id') + ->select(); + $accountItems = index_by_column('promote_id', $accountItems); + + $amountItems = M('spend', 'tab_') + ->field(['promote_id', 'sum(pay_amount) amount']) + ->where([ + 'pay_time' => ['between', $betweenTime], + 'pay_status' => 1, 'promote_id' => ['in', $promoteIds], + '_string' => 'user_id in (' . $userSubSql . ')' + ]) + ->group('promote_id') + ->select(); + $amountItems = index_by_column('promote_id', $amountItems); + + $records = []; + foreach ($promotes as $promote) { + $amountItem = $amountItems[$promote['id']] ?? null; + $accountItem = $accountItems[$promote['id']] ?? null; + $records[] = [ + 'amount' => $amountItem ? $amountItem['amount'] : 0, + 'num' => $accountItem ? $accountItem['num'] : 0, + 'real_name' => $promote['real_name'], + 'account' => $promote['account'], + 'promote_group' => $promote['promote_group'] + ]; + } + return $records; + } +} \ No newline at end of file diff --git a/Application/Home/Controller/PromoteGradeController.class.php b/Application/Home/Controller/PromoteGradeController.class.php new file mode 100644 index 000000000..22f6aaf1d --- /dev/null +++ b/Application/Home/Controller/PromoteGradeController.class.php @@ -0,0 +1,106 @@ +getLoginPromote(); + + /* $promoteGradeService = new PromoteGradeService(); + if (!$promoteGradeService->hadSetting($loginPromote)) { + return $this->error('未设置评级规则'); + } */ + + $time = I('time', date('Y-m-d')); + if (!empty($time)) { + $defaultTime = $time; + } else { + $defaultTime = date('Y-m-d', time()); + } + $parentId = I('parent_id', 0); + $promoteId = I('promote_id', 0); + $status = I('status', 0); + $searchLevel = 0; + $searchLevelName = ''; + $currentDisplay = ''; + $prevParentId = 0; + + $promoteService = new PromoteService(); + + $parent = null; + if ($parentId > 0) { + $parent = M('promote', 'tab_')->where(['id' => $parentId])->find(); + $currentDisplay = $promoteService->getLevelName($parent['level']) . '推广'; + $prevParentId = $parent['parent_id'] == $loginPromote['parent_id'] ? 0 : $parent['parent_id']; + } else { + $parent = $loginPromote; + $currentDisplay = '自己'; + } + + $subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'group_remark'])->where(['parent_id' => $parent['id']])->select(); + + $map = ['parent_id' => $parent['id']]; + if ($promoteId > 0) { + $map['id'] = $promoteId; + } + + $query = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level', 'chain'])->where($map); + list($promotes, $pagination, $count) = $this->paginate($query); + + $records = $promoteGradeService->searchGradeByPromotes($promotes, [ + 'month' => $month, + ]); + + $this->meta_title = '团队评级'; + + $this->assign('records', $records); + $this->assign('prevParentId', $prevParentId); + $this->assign('searchLevelName', $searchLevelName); + $this->assign('subPromotes', $subPromotes); + + $this->assign('records', $records); + $this->assign('pagination', $pagination); + $this->display(); + + } + + public function settings() + { + $loginPromote = $this->getLoginPromote(); + $items = M('promote_grade_setting', 'tab_')->where(['company_id' => $loginPromote['company_id']])->select(); + + $records = []; + foreach ($items as $key => $item) { + $i = 0; + $config = json_decode($item['config'], true); + $gradeCount = count($config['grades']); + foreach ($config['grades'] as $grade) { + $records['id'] = $item['id']; + $records['grade_count'] = $item['id']; + $records['reach_level'] = $config['reach_level']; + $records['grade_name'] = $grade['name']; + $records['grade_value'] = $grade['symbol'] . $grade['value']; + } + } + + $this->assign('records', $records); + $this->display(); + } + + public function setting() + { + $this->display(); + } + + public function saveSetting() + { + var_dump(I('post.')); + } +} \ No newline at end of file diff --git a/Application/Home/View/default/PromoteGrade/index.html b/Application/Home/View/default/PromoteGrade/index.html new file mode 100644 index 000000000..d713d13b0 --- /dev/null +++ b/Application/Home/View/default/PromoteGrade/index.html @@ -0,0 +1,162 @@ + + + + + + +
+
+
+
当前位置:评级管理>团队评级
+
+ + 团队评级 +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
账号(姓名)等级当月玩家达标个数当月注册充值总额操作

暂无数据

{$record.account}({$record.real_name} + + /{$record.promote_group} + + ) + + [{$record['current_display']}] + + {$record.create_role_count}{$record.create_role_user_count}{$record.new_create_role_user_count} + + 查看下级 + +
+ +
+
+ + 导出 + + {$pagination} +
+
+
+
+ +
+
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/Application/Home/View/default/PromoteGrade/setting.html b/Application/Home/View/default/PromoteGrade/setting.html new file mode 100644 index 000000000..1f360a1c4 --- /dev/null +++ b/Application/Home/View/default/PromoteGrade/setting.html @@ -0,0 +1,233 @@ + + + + + + +
+
+
+
当前位置:评级管理>评级设定
+
+ + 评级设定 +
+
+
+
+ + + + + + + + + + + + + + + + + + +
* 评级规则名称: + +
* 玩家角色达标等级: + +
*等级设定: +
+ +
+ +
+ +
+
+ + 返回 +
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/Application/Home/View/default/PromoteGrade/settings.html b/Application/Home/View/default/PromoteGrade/settings.html new file mode 100644 index 000000000..d1ad480a6 --- /dev/null +++ b/Application/Home/View/default/PromoteGrade/settings.html @@ -0,0 +1,72 @@ + + + + + + +
+
+
+
当前位置:评级管理>团队评级
+
+ + 团队评级 +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
ID当月注册玩家角色达标等级系数值等级名称操作

暂无数据

操作
+
+
+
+
+ +
+
+
+
+ + + + + + \ No newline at end of file diff --git a/Data/update.sql b/Data/update.sql index 200f13b31..d7d5a45f9 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -2626,4 +2626,14 @@ CREATE TABLE `tab_aggregate_statement_pool` ( ALTER TABLE `tab_company_info` ADD COLUMN `invoice_item` varchar(255) NULL DEFAULT '' COMMENT '开票内容' AFTER `fax_ratio`, -ADD COLUMN `invoice_type` varchar(255) NULL DEFAULT '' COMMENT '开票类型' AFTER `invoice_item`; \ No newline at end of file +ADD COLUMN `invoice_type` varchar(255) NULL DEFAULT '' COMMENT '开票类型' AFTER `invoice_item`; + +CREATE TABLE `tab_promote_grade_setting` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `company_id` int(11) NOT NULL COMMENT '推广公司ID', + `config` varchar(255) NOT NULL COMMENT '配置', + `status` tinyint(11) NOT NULL DEFAULT '0' COMMENT '状态', + `create_time` int(11) NOT NULL DEFAULT '0', + `update_time` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='推广评级设定'; \ No newline at end of file