diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index fe47af006..e4fbc68bb 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -575,6 +575,11 @@ class PlatformController extends ThinkController $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 $arraypage = $page; + + if(!array_key_exists("timestart",$_REQUEST)){ + $this->redirect(ACTION_NAME, array('timestart' => date('Y-m-d',strtotime('-7 day')),"timeend"=>date('Y-m-d'))); + } + if (isset($_REQUEST['row'])) { $row = $_REQUEST['row']; } else { diff --git a/Application/Admin/Controller/PromoteLimitRuleController.class.php b/Application/Admin/Controller/PromoteLimitRuleController.class.php new file mode 100644 index 000000000..839704544 --- /dev/null +++ b/Application/Admin/Controller/PromoteLimitRuleController.class.php @@ -0,0 +1,233 @@ +field(['id'])->where(['company_id' => $companyId, 'level' => 1])->getField('id', true); + if (count($companyPromoteIds) > 0) { + $promoteIds = count($promoteIds) ? array_intersect($companyPromoteIds, $promoteIds) : $companyPromoteIds; + $promoteIds[] = 0; + } else { + $promoteIds = [0]; + } + } + if (count($promoteIds)) { + $conditions['promote_id'] = ['in', $promoteIds]; + } + $query = M('promote_limit_rules', 'tab_')->where($conditions); + + $countQuery = clone $query; + $rules = $query->page($page, $row)->select(); + $count = $countQuery->count(); + + $recordPromotes = []; + $recordCompanys = []; + if (count($rules) > 0) { + $recordPromotes = M('promote', 'tab_')->field(['id', 'account', 'company_id'])->where(['id' => ['in', array_column($rules, 'promote_id')]])->select(); + $recordCompanyIds = array_column($recordPromotes, 'company_id'); + if (count($recordCompanyIds) > 0) { + $recordCompanys = M('promote_company', 'tab_')->field(['id', 'company_name', 'company_belong'])->where(['id' => ['in', $recordCompanyIds]])->select(); + } + $recordPromotes = index_by_column('id', $recordPromotes); + $recordCompanys = index_by_column('id', $recordCompanys); + } + + $companyTypes = [ + 0 => '内团', + 1 => '外团', + 2 => '外团-分发联盟', + 3 => '无' + ]; + + $records = []; + foreach ($rules as $rule) { + $records[] = [ + 'id' => $rule['id'], + 'promote_account' => $recordPromotes[$rule['promote_id']]['account'], + 'company_name' => $recordCompanys[$recordPromotes[$rule['promote_id']]['company_id']]['company_name'], + 'company_belong' => $companyTypes[$recordCompanys[$recordPromotes[$rule['promote_id']]['company_id']]['company_belong']], + 'limit_rule' => $this->getDisplayRule($rule), + ]; + } + $companys = M('promote_company', 'tab_')->field(['id', 'company_name'])->select(); + + $page = set_pagination($count, $row); + if($page) { + $this->assign('_page', $page); + } + $this->assign('records', $records); + $this->assign('companys', $companys); + $this->display(); + } + + private function getDisplayRule($rule) + { + if ($rule['started_at'] === null && $rule['ended_at'] === null) { + return '永久'; + } elseif ($rule['started_at'] === null && $rule['ended_at'] !== null) { + return '从前 至 '.$rule['ended_at']; + } elseif ($rule['started_at'] !== null && $rule['ended_at'] === null) { + return $rule['started_at'] . ' 至 永久'; + } else { + return $rule['started_at'] . ' ~ ' . $rule['ended_at']; + } + } + + public function edit() + { + $this->meta_title = '编辑推广限制'; + $id = I('id', 0); + $companys = M('promote_company', 'tab_')->field(['id', 'company_name'])->select(); + $record = M('promote_limit_rules', 'tab_')->where(['id' => $id])->find(); + $promote = null; + $company = null; + if ($record) { + $promote = M('promote', 'tab_')->where(['id' => $record['promote_id']])->field(['id', 'company_id', 'account'])->find(); + $company = M('promote_company', 'tab_')->where(['id' => $promote['company_id']])->field(['id', 'company_name'])->find(); + } + $this->assign('promote', $promote); + $this->assign('company', $company); + $this->assign('companys', $companys); + $this->assign('record', $record); + $this->display('form'); + } + + public function save() + { + $id = I('id', 0); + $promoteId = I('promote_id', 0); + $startedAt = I('started_at', ''); + $endedAt = I('ended_at', ''); + + $startedAt = $startedAt === '' ? null : $startedAt; + $endedAt = $endedAt === '' ? null : $endedAt; + + if ($startedAt && $endedAt && strtotime($startedAt) > strtotime($endedAt)) { + return $this->error('开始时间不能大于结束时间'); + } + + $record = null; + if ($id > 0) { + $record = M('promote_limit_rules', 'tab_')->where(['id' => $id])->find(); + if (!$record) { + return $this->error('修改记录不存在'); + } + } else { + if (empty($promoteId)) { + return $this->error('请选择会长'); + } + $promoteRecord = M('promote_limit_rules', 'tab_')->where(['promote_id' => $promoteId])->find(); + if ($promoteRecord) { + return $this->error('该会长已经设定限制规则,请前往更新'); + } + } + + if ($record) { + $data = []; + $data['started_at'] = $startedAt; + $data['ended_at'] = $endedAt; + $data['update_time'] = time(); + M('promote_limit_rules', 'tab_')->where(['id' => $id])->save($data); + addOperationLog([ + 'op_type' => 1, + 'key'=> $promoteId . '/' . $startedAt . '/' . $endedAt, + 'op_name' => '修改推广限制', + 'url' => U('PresidentDeposit/edit', ['id'=>$id]), 'menu'=>'推广员-推广员管理-推广限制-修改推广限制' + ]); + } else { + $data = []; + $data['promote_id'] = $promoteId; + $data['started_at'] = $startedAt; + $data['ended_at'] = $endedAt; + $data['create_time'] = time(); + $data['update_time'] = time(); + M('promote_limit_rules', 'tab_')->add($data); + addOperationLog([ + 'op_type' => 0, + 'key'=> $promoteId . '/' . $startedAt . '/' . $endedAt, + 'op_name' => '新增推广限制', + 'url' => U('PresidentDeposit/edit', ['promote_id'=>$promoteId]), 'menu'=>'推广员-推广员管理-推广限制-新增推广限制' + ]); + } + + return $this->success('保存成功', U('records')); + } + + public function delete() + { + $id = I('id', 0); + M('promote_limit_rules', 'tab_')->where(['id' => $id])->delete(); + + addOperationLog([ + 'op_type' => 2, + 'key' => $id, + 'op_name' => '删除会长推广限制', + 'url' => U('PresidentDeposit/delete', ['id' => $id]), + 'menu' => '推广员-推广员管理-推广限制-删除推广限制' + ]); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '删除成功' + ]); + } + + public function batchDelete() + { + $ids = I('ids', []); + if (count($ids) == 0) { + $this->ajaxReturn([ + 'status' => 0, + 'message' => '无选中项' + ]); + } + M('promote_limit_rules', 'tab_')->where(['id' => ['in', $ids]])->delete(); + + addOperationLog([ + 'op_type' => 2, + 'key' => implode(',', $ids), + 'op_name' => '批量删除会长推广限制', + 'url' => U('PresidentDeposit/batchDelete', ['ids' => implode(',', $ids)]), + 'menu' => '推广员-推广员管理-推广限制-批量删除推广限制' + ]); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '删除成功' + ]); + } + + public function getPromotesByCompany() + { + $companyId = I('company_id', 0); + $promotes = M('promote', 'tab_')->field(['id', 'account'])->where(['level' => 1, 'company_id' => $companyId])->select(); + + $this->ajaxReturn([ + 'status' => 1, + 'message' => '获取成功', + 'data' => [ + 'promotes' => $promotes + ] + ]); + } +} diff --git a/Application/Admin/View/PromoteLimitRule/form.html b/Application/Admin/View/PromoteLimitRule/form.html new file mode 100644 index 000000000..2912f2344 --- /dev/null +++ b/Application/Admin/View/PromoteLimitRule/form.html @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
*推广公司: + + {$company.company_name} + + + +
*会长: + + {$promote.account} + + + +
开始时间: + +
结束时间: + +
+
+ +
+ + + 返回 + +
+
+
+
+ + + +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + \ No newline at end of file diff --git a/Application/Admin/View/PromoteLimitRule/records.html b/Application/Admin/View/PromoteLimitRule/records.html new file mode 100644 index 000000000..80a197769 --- /dev/null +++ b/Application/Admin/View/PromoteLimitRule/records.html @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ 搜索 + 添加 + 删除 +
+ +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 推广公司会长账号内外团限制时间操作
aOh! 暂时还没有内容!
+ + {$data.company_name}{$data.promote_account}{$data.company_belong}{$data.limit_rule} +
+ 编辑 + 删除 +
+
+
+
+
+ + + + {$_page|default=''} +
+ + +
+ + + + + + + + \ No newline at end of file diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index a159cc3e8..75b7ff47d 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -1127,4 +1127,28 @@ class PromoteService { return $selfGameIds; } } + + public function checkPromoteLimitRule($promote) + { + $topPromote = $this->getTopPromote($promote); + $rule = M('promote_limit_rules', 'tab_')->where(['promote_id' => $topPromote['id']])->order('created_at desc')->limit(1)->find(); + if ($rule) { + if ($rule['started_at'] === null && $rule['ended_at'] === null) { + return false; + } elseif ($rule['started_at'] === null && $rule['ended_at'] !== null) { + if (time() < strtotime($rule['ended_at'] . ' 23:59:59')) { + return false; + } + } elseif ($rule['started_at'] !== null && $rule['ended_at'] === null) { + if (time() >= strtotime($rule['started_at'] . ' 00:00:00')) { + return false; + } + } else { + if (time() >= strtotime($rule['started_at'] . ' 00:00:00') && time() < strtotime($rule['ended_at'] . ' 23:59:59')) { + return false; + } + } + } + return true; + } } \ No newline at end of file diff --git a/Application/Home/Controller/HomeController.class.php b/Application/Home/Controller/HomeController.class.php index 345c8268a..c1c57599f 100644 --- a/Application/Home/Controller/HomeController.class.php +++ b/Application/Home/Controller/HomeController.class.php @@ -5,6 +5,7 @@ use Think\Controller; use User\Api\MemberApi; use Base\Facade\Request; use Base\Service\ApplyService; +use Base\Service\PromoteService; use Base\Service\PackageDownloadLogService; use Base\Tool\MobileDetect; @@ -170,6 +171,16 @@ class HomeController extends Controller $promoteId = $data['promote_id']; } + $promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find(); + if (!$promote) { + $this->error('该链接已失效'); + } + + $promoteService = new PromoteService(); + if (!$promoteService->checkPromoteLimitRule($promote)) { + $this->error('链接已失效'); + } + $isWechat = Request::isWechat(); $isIOS = Request::isIOS() || Request::isIPadOS(); $isAndroid = Request::isAndroid(); @@ -208,8 +219,6 @@ class HomeController extends Controller $map = ['id' => intval($gameId)]; $game = M('game', 'tab_')->field($columns)->where($map)->find(); - $promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find(); - if ($game['sdk_version'] == 1 && $isIOS) { $map = []; $map['relation_game_id'] = $game['relation_game_id']; diff --git a/Application/Home/Controller/PackageController.class.php b/Application/Home/Controller/PackageController.class.php index 41e70efce..6f664020d 100644 --- a/Application/Home/Controller/PackageController.class.php +++ b/Application/Home/Controller/PackageController.class.php @@ -54,6 +54,16 @@ class PackageController extends Controller $promoteId = $data['promote_id']; } + $promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find(); + if (!$promote) { + $this->error('该链接已失效'); + } + + $promoteService = new PromoteService(); + if (!$promoteService->checkPromoteLimitRule($promote)) { + $this->error('链接已失效'); + } + $map = []; $map['status'] = 1; $map['enable_status'] = 1; @@ -65,7 +75,6 @@ class PackageController extends Controller $this->redirect("package/downloadError", ['message' => '该链接已经停止使用']); } - $promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find(); $game = M('game','tab_')->field(['id', 'game_name', 'sdk_version', 'apply_auth'])->where(['id' => $apply['game_id']])->find(); if (Request::isMobile() || Request::isTablet()) { diff --git a/Data/update.sql b/Data/update.sql index 13bdaac33..7a669a677 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -1988,6 +1988,16 @@ CREATE TABLE `tab_company_lack_statement_info` ( INSERT INTO `tab_tool`( `name`, `title`, `config`, `template`, `type`, `status`, `create_time`) VALUES ('juhedata', '聚合数据', '{\"tpl_id\":\"215303\",\"key\":\"1aa07a33b6d6408e835e416fafcd6f22\",\"limit\":\"\",\"status\":\"1\"}', NULL, 1, 1, 1589361782); INSERT INTO `tab_tool`( `name`, `title`, `config`, `template`, `type`, `status`, `create_time`) VALUES ('juhe_age', '聚合身份认证', '{\"appkey\":\"80427f4769c6938f12a870f51014ddbe\",\"status\":\"1\"}', NULL, 1, 1, 1464164373); +-- 推广规则限制 elf 20200615 +CREATE TABLE `tab_promote_limit_rules` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `promote_id` int(11) NOT NULL COMMENT '会长ID', + `started_at` date DEFAULT NULL COMMENT '开始时间', + `ended_at` date DEFAULT NULL COMMENT '结束时间', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; ALTER TABLE `tab_forbit_ip` ADD COLUMN `type` tinyint(2) NULL DEFAULT 0 COMMENT '类型 0:美国ip白名单 1:苹果第三方支付白名单' AFTER `remarks`; @@ -1998,4 +2008,4 @@ ADD UNIQUE INDEX `userid_type`(`user_id`, `type`) COMMENT '用户id与类型唯 ALTER TABLE `tab_promote` ADD COLUMN `withdraw_show` tinyint(2) NOT NULL DEFAULT 0 COMMENT '推广员提现查看权限 1 有 0 无' AFTER `group_remark`, -ADD COLUMN `withdraw_done` tinyint(2) NOT NULL DEFAULT 0 COMMENT '推广员提现查看权限 1 有 0 无' AFTER `withdraw_show`; \ No newline at end of file +ADD COLUMN `withdraw_done` tinyint(2) NOT NULL DEFAULT 0 COMMENT '推广员提现查看权限 1 有 0 无' AFTER `withdraw_show`;