From 9152a3ef59abd0dfb2756a1eede45128de1f19cd Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Tue, 14 Jan 2020 14:06:25 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/GameController.class.php | 76 +++++++ Application/Admin/View/Game/edit.html | 202 ++++++++++++++++++ Data/update.sql | 13 ++ 3 files changed, 291 insertions(+) diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index c7fbef940..19a97ebcf 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -17,6 +17,8 @@ use BaiduBce\Services\Bos\CannedAcl; use BaiduBce\Services\Bos\BosOptions; use BaiduBce\Auth\SignOptions; use BaiduBce\Log\LogFactory; +use Admin\Model\AuthRuleModel; +use Admin\Model\AuthGroupModel; /** * 后台首页控制器 @@ -290,6 +292,17 @@ class GameController extends ThinkController public function edit($id = null) { if (IS_POST) { + if(!empty($_REQUEST['promote_data'])) { + $promote_data = json_decode($_REQUEST['promote_data'],TRUE); + $game_appid = $_REQUEST['game_appid']; + $gameId = M('game','tab_')->where(['game_appid' => $game_appid])->getField('id'); + $gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gameId])->select(); + $dataList = array(); + foreach($promote_data as $key => $promoteInfo) { + $dataList[] = ['promote_id' => intval($promoteInfo['value']),'game_id' => intval($gameId),'status'=>$gameInfo[0]['game_status'],'create_time'=>time()]; + } + M('sociaty_games','tab_')->addAll($dataList); + } if ($_POST['game_score'] <0 || $_POST['game_score'] > 5) { $this->error('游戏评分只能为0-5之间的数字!'); exit; @@ -413,6 +426,11 @@ class GameController extends ThinkController $this->m_title = '游戏列表'; $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Game/lists', 'status' => 1])->find()); $this->assign('game_ratio',$game_ratio); + $auth_group = M('AuthGroup')->where( array('status'=>array('egt','0'),'module'=>'admin','type'=>AuthGroupModel::TYPE_ADMIN) ) + ->getfield('id,id,title,rules'); + $empower_type = M('AuthGroup')->field('data_empower_type')->where(array('id'=>1))->find(); + $this->assign('data_empower_type', $empower_type['data_empower_type']); + $this->assign('auth_group', $auth_group); $this->display(); } } @@ -889,4 +907,62 @@ class GameController extends ThinkController //M('cp_game_ratio', 'tab_')->where("id=".$_POST['data_id'])->data(array("is_del"=>"1","update_time"=>time()))->save(); echo(json_encode(array("result"=>"1","desc"=>"删除成功"))); } + + + public function uploadExcel1() { + Vendor("PHPExcel.PHPExcel"); + if(@is_uploaded_file($_FILES['file']['tmp_name'])){ + $upfile = $_FILES["file"]; + $name = $upfile["name"]; + $type = $upfile["type"]; + $size = $upfile["size"]; + $tmp_name = $upfile["tmp_name"]; + $savePath = $_SERVER['DOCUMENT_ROOT'].__ROOT__.'/Uploads/Excel/'; + move_uploaded_file($tmp_name,$savePath.$name); + $file_name = $savePath.$name; + $error=$upfile["error"];//上传后系统返回的值 + // print($file_name); + $extension = strtolower( pathinfo($file_name, PATHINFO_EXTENSION) ); + if($extension == 'xlsx') { + $objReader = \PHPExcel_IOFactory::createReader('excel2007'); + }else { + $objReader = \PHPExcel_IOFactory::createReader('Excel5');//创建读取实例 + } + $objPHPExcel = $objReader->load($file_name,$encode='utf-8');//加载文件 + $sheet = $objPHPExcel->getSheet(0); + $highestRow = $sheet->getHighestRow(); + $highestColumn = $sheet->getHighestColumn(); + $dataList = []; + for($i=2;$i<=$highestRow;$i++) + { + $promote_id = $objPHPExcel->getActiveSheet()->getCell("B".$i)->getValue(); + $promoteInfo = M('promote','tab_')->field('account')->where(['id' => $promote_id ])->find(); + + if(empty($promoteInfo)) { + break; + } + $game_id = $objPHPExcel->getActiveSheet()->getCell("C".$i)->getValue(); + $gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$game_id])->select(); + if(empty($gameInfo)) { + break; + } + $time = time(); + $dataList[] = ['promote_id'=>$promote_id,'game_id'=>$game_id,'status'=>$gameInfo[0]['game_status'],'create_time'=>$time]; + } + M('sociaty_games','tab_')->addAll($dataList); + $this->ajaxReturn(json_encode($dataList)); + + } + } + + function getRootPromote() { + $promoteData = M('promote','tab_')->field('id as value,account as title')->where(array('level'=>1,'chain'=>'/'))->select(); + $data_president = M('AuthGroup')->field('data_president')->where(array('id'=>1))->find(); + + $promoteData = array_merge([0=>['value'=>'-1','title'=>'官方渠道']],$promoteData); + + $returnData = array('data_president'=>$data_president['data_president'],'list'=>$promoteData); + $this->ajaxReturn(json_encode($returnData)); + } + } diff --git a/Application/Admin/View/Game/edit.html b/Application/Admin/View/Game/edit.html index cd02fe912..56c0b7f48 100644 --- a/Application/Admin/View/Game/edit.html +++ b/Application/Admin/View/Game/edit.html @@ -44,6 +44,7 @@
  • 参数配置
  • H5分享页面
  • 用户等级设置
  • +
  • 推广配置
  • 编辑游戏【{$data.relation_game_name}】

    说明:查看和编辑游戏的基础信息、下载设置、参数信息等。

    @@ -939,7 +940,57 @@ + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    推广限制 + 全部会长可申请 + 部分会长可申请 +
    +
    +
    + + + +
    @@ -968,7 +1019,152 @@ + + + + diff --git a/Data/update.sql b/Data/update.sql index df2614a60..cc96f7fdf 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -1073,3 +1073,16 @@ CREATE TABLE `sys_document_pop_rules` ( `operater_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作者ID', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + + +--会长设置推广配置-- + +CREATE TABLE `tab_sociaty_games` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `promote_id` int(11) NOT NULL COMMENT '会长ID', + `game_id` int(11) NOT NULL COMMENT '游戏ID', + `status` tinyint(1) NOT null DEFAULT '0' COMMENT '状态 0 禁用 1 启用', + `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间', + `update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT '工会授权游戏'; \ No newline at end of file From d2b7e91a64cd0cbcc811732b2ab381ae6379d784 Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Wed, 15 Jan 2020 16:46:02 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/GameController.class.php | 21 +++++++++++++++++-- Application/Admin/View/Game/edit.html | 13 ++++++------ Data/update.sql | 11 ++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index 19a97ebcf..eb6b0b898 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -935,13 +935,13 @@ class GameController extends ThinkController $dataList = []; for($i=2;$i<=$highestRow;$i++) { - $promote_id = $objPHPExcel->getActiveSheet()->getCell("B".$i)->getValue(); + $promote_id = $objPHPExcel->getActiveSheet()->getCell("A".$i)->getValue(); $promoteInfo = M('promote','tab_')->field('account')->where(['id' => $promote_id ])->find(); if(empty($promoteInfo)) { break; } - $game_id = $objPHPExcel->getActiveSheet()->getCell("C".$i)->getValue(); + $game_id = $objPHPExcel->getActiveSheet()->getCell("B".$i)->getValue(); $gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$game_id])->select(); if(empty($gameInfo)) { break; @@ -965,4 +965,21 @@ class GameController extends ThinkController $this->ajaxReturn(json_encode($returnData)); } + //下载模板 + public function downloadDemo() { + $game_id = $_REQUEST['game_id']; + $game_name = M('game','tab_')->where(['id'=>$game_id])->getField('game_name'); + $data[] = [ + 'promoteid' => 99, + 'game_id' => $game_id, + 'game_name' => $game_name + ]; + $field = array( + "promoteid"=>"会长ID", + "game_id"=>"游戏ID(无需修改,已默认当前游戏)", + "game_name"=>"游戏名称(无需修改,已默认当前游戏)" + ); + data2csv($data,"模板",$field); + } + } diff --git a/Application/Admin/View/Game/edit.html b/Application/Admin/View/Game/edit.html index 56c0b7f48..f0c2dc058 100644 --- a/Application/Admin/View/Game/edit.html +++ b/Application/Admin/View/Game/edit.html @@ -968,7 +968,7 @@ EXCEL模板 - 下载模板 + 下载模板 @@ -985,12 +985,13 @@ +
    + + + +
    -
    - - - - +
    diff --git a/Data/update.sql b/Data/update.sql index cc96f7fdf..da4cfb6d1 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -1077,6 +1077,17 @@ CREATE TABLE `sys_document_pop_rules` ( --会长设置推广配置-- +CREATE TABLE `tab_sociaty_games` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `promote_id` int(11) NOT NULL COMMENT '会长ID', + `game_id` int(11) NOT NULL COMMENT '游戏ID', + `status` tinyint(1) NOT null DEFAULT '0' COMMENT '状态 0 禁用 1 启用', + `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间', + `update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT '工会授权游戏'; + +--会长推广配置-- CREATE TABLE `tab_sociaty_games` ( `id` int(11) NOT NULL AUTO_INCREMENT, `promote_id` int(11) NOT NULL COMMENT '会长ID', From 79f9801351d0a0df76ac8f16c24629c0dc160262 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Thu, 16 Jan 2020 17:36:58 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=90=BD=E5=9C=B0?= =?UTF-8?q?=E9=A1=B5/=E4=B8=8B=E8=BD=BD=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Base/Service/ApplyService.class.php | 12 ++++++++ .../Home/Controller/ApplyController.class.php | 29 +++++++++++++------ .../Home/Controller/HomeController.class.php | 10 ++++++- .../Controller/PackageController.class.php | 12 +++++++- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/Application/Base/Service/ApplyService.class.php b/Application/Base/Service/ApplyService.class.php index 5590f5924..3a963339e 100644 --- a/Application/Base/Service/ApplyService.class.php +++ b/Application/Base/Service/ApplyService.class.php @@ -197,4 +197,16 @@ class ApplyService { parse_str($items['query'], $params); return $params; } + + public function checkSociatyPerm($promote, $game) + { + $promoteService = new PromoteService(); + $topPromote = $promoteService->getTopPromote($promote); + $record = M('sociaty_games', 'tab_')->where(['game_id' => $game['id'], 'promote_id' => $topPromote['id']])->find(); + if ($record['status'] == 1) { + return true; + } else { + return false; + } + } } \ No newline at end of file diff --git a/Application/Home/Controller/ApplyController.class.php b/Application/Home/Controller/ApplyController.class.php index 18b02e1b3..c781cdaab 100644 --- a/Application/Home/Controller/ApplyController.class.php +++ b/Application/Home/Controller/ApplyController.class.php @@ -66,11 +66,11 @@ class ApplyController extends BaseController { $loginPromote = $this->getLoginPromote(); - $promoteId = empty(I('promote_id')) ? $loginPromote['id'] : I('promote_id');//搜索的渠道ID - $promoteRole = empty(I('promote_role')) ? 1 : I('promote_role');//渠道角色 - $parentPromoteId = getParentPromoteId($promoteId);//上级渠道ID - $grandPromoteId = getGrandPromoteId($promoteId);//本账号会长渠道ID - $childGameAddPermission = getChildGameAddPermission($grandPromoteId);//游戏添加权限 + $promoteId = empty(I('promote_id')) ? $loginPromote['id'] : I('promote_id'); //搜索的渠道ID + $promoteRole = empty(I('promote_role')) ? 1 : I('promote_role'); //渠道角色 + $parentPromoteId = getParentPromoteId($promoteId); //上级渠道ID + $grandPromoteId = getGrandPromoteId($promoteId); //本账号会长渠道ID + $childGameAddPermission = getChildGameAddPermission($grandPromoteId); //游戏添加权限 $map['tab_game.online_status'] = 1;//开发者游戏上线状态 $map['tab_game.down_port'] = 1;//游戏端口 第三方接口不能申请 @@ -1622,17 +1622,28 @@ class ApplyController extends BaseController $gameData['sdk_name'] = getSDKTypeName($gameData['sdk_version']); - $promoteIds = getAllPromoteListByType($promoteType); + $promotes = getAllPromoteListByType($promoteType); + + M('apply', 'tab_')->where(array('game_id' => $gameId, 'promote_id' => $value['id'], 'offline_status' => 0))->count('id'); $newPromoteData = []; - if (count($promoteIds) > 0) { - foreach ($promoteIds as $value) { + if (count($promotes) > 0) { + + $promoteIds = array_column($promotes, 'id'); + $oldIds = M('apply', 'tab_')->where(['game_id' => $gameId, 'promote_id' => ['in', $promoteIds], 'offline_status' => 0])->getField('id', true); + $newPromoteIds = array_diff($promoteIds, $oldIds); + foreach ($promotes as $promote) { + if (in_array($promote['id'], $newPromoteIds)) { + $newPromoteData[] = $promote; + } + } + /* foreach ($promoteIds as $value) { $thisPromote = M('apply', 'tab_')->where(array('game_id' => $gameId, 'promote_id' => $value['id'], 'offline_status' => 0))->count('id'); if (!$thisPromote) { $newPromoteData[] = $value; } - } + } */ } $data['game_data'] = $gameData; diff --git a/Application/Home/Controller/HomeController.class.php b/Application/Home/Controller/HomeController.class.php index aaed98006..0d2991cbf 100644 --- a/Application/Home/Controller/HomeController.class.php +++ b/Application/Home/Controller/HomeController.class.php @@ -154,8 +154,8 @@ class HomeController extends Controller $this->error('该链接已被禁'); } + $applyService = new ApplyService(); if ($code != '') { - $applyService = new ApplyService(); $data = $applyService->decodeApplyCode($code); $result = $applyService->checkApplyCode($data, ApplyService::ENCRYPT_TYPE_LANDING_PAGE); if (!$result['status']) { @@ -194,6 +194,11 @@ 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 (!$applyService->checkSociatyPerm($promote, $game)) { + $this->error('该链接已经停止使用'); + } + if ($game['sdk_version'] == 1 && $isIOS) { $map = []; $map['relation_game_id'] = $game['relation_game_id']; @@ -208,6 +213,9 @@ class HomeController extends Controller $apply = M('apply', 'tab_')->field(['game_id', 'enable_status', 'promote_id']) ->where(['promote_id' => $promoteId, 'game_id' => $game['id']]) ->find(); + if (!$apply) { + $this->error('该链接已经停止使用'); + } $game['icon'] = get_cover($game['icon'], 'path'); $gameSource = M('GameSource', 'tab_')->field(['create_time', 'org_plist_url', 'is_new_sdk'])->where(array('game_id' => $game['id']))->find(); diff --git a/Application/Home/Controller/PackageController.class.php b/Application/Home/Controller/PackageController.class.php index 09f329745..09f09ed18 100644 --- a/Application/Home/Controller/PackageController.class.php +++ b/Application/Home/Controller/PackageController.class.php @@ -40,8 +40,9 @@ class PackageController extends Controller if ($isBlack) { $this->redirect("package/downloadError", ['message' => '该链接已被禁']); } + + $applyService = new ApplyService(); if ($code != '') { - $applyService = new ApplyService(); $data = $applyService->decodeApplyCode($code); $result = $applyService->checkApplyCode($data, ApplyService::ENCRYPT_TYPE_DOWNLOAD); if (!$result['status']) { @@ -59,7 +60,16 @@ class PackageController extends Controller $map['promote_id'] = $promoteId; $columns = ['game_id', 'promote_id', 'promote_account', 'pack_url', 'plist_url', 'status', 'enable_status']; $apply = M('apply','tab_')->field($columns)->where($map)->find(); + if (!$apply) { + $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'])->where(['id' => $apply['game_id']])->find(); + if (!$applyService->checkSociatyPerm($promote, $game)) { + $this->redirect("package/downloadError", ['message' => '该链接已经停止使用']); + } + if (Request::isMobile()) { if (!Request::isAndroid() && $game['sdk_version'] == 1) { From b9ddc1aafb2bb44bd6ea841416a2f06afc76daf6 Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Fri, 17 Jan 2020 09:57:56 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/GameController.class.php | 117 +++++++++++++----- Application/Admin/View/Game/edit.html | 111 ++++++++++++++--- 2 files changed, 186 insertions(+), 42 deletions(-) diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index eb6b0b898..72840d89f 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -289,19 +289,45 @@ class GameController extends ThinkController } } + public function delSociatyGames() { + $res = ['code' => 10000]; + $id = $_REQUEST['id']; + $delRest = M('sociaty_games','tab_')->where(['id'=>$id])->delete(); + if($delRest) { + $res['code'] = 10001; + $this->ajaxReturn($res); + } + } + public function edit($id = null) { if (IS_POST) { - if(!empty($_REQUEST['promote_data'])) { - $promote_data = json_decode($_REQUEST['promote_data'],TRUE); + if(!empty($_REQUEST['apply_auth'])) { + $gameData['apply_auth'] = $_REQUEST['apply_auth']; $game_appid = $_REQUEST['game_appid']; $gameId = M('game','tab_')->where(['game_appid' => $game_appid])->getField('id'); - $gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gameId])->select(); - $dataList = array(); - foreach($promote_data as $key => $promoteInfo) { - $dataList[] = ['promote_id' => intval($promoteInfo['value']),'game_id' => intval($gameId),'status'=>$gameInfo[0]['game_status'],'create_time'=>time()]; + M('game','tab_')->where(['id'=>$gameId])->save($gameData); + if($_REQUEST['apply_auth'] == 1) { + M('sociaty_games','tab_')->where(['game_id'=>$gameId])->delete(); } - M('sociaty_games','tab_')->addAll($dataList); + if(!empty($_REQUEST['promote_data'])) { + $promote_data = json_decode($_REQUEST['promote_data'],TRUE); + $game_appid = $_REQUEST['game_appid']; + $gameId = M('game','tab_')->where(['game_appid' => $game_appid])->getField('id'); + $gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gameId])->select(); + $dataList = array(); + foreach($promote_data as $key => $promoteInfo) { + $isSociaty = M('sociaty_games','tab_')->where(['promote_id'=>intval($promoteInfo['value']),'game_id'=>intval($gameId)])->getField('id'); + if(!empty($isSociaty)) { + // $this->error("选择会长中有已存在会长"); + }else { + $dataList[] = ['promote_id' => intval($promoteInfo['value']),'game_id' => intval($gameId),'status'=>$gameInfo[0]['game_status'],'create_time'=>time()]; + } + + } + M('sociaty_games','tab_')->addAll($dataList); + } + // $_REQUEST['apply_auth'] == 1 ? $this->success('开放全部会长权限成功') : $this->success('设置会长权限成功'); } if ($_POST['game_score'] <0 || $_POST['game_score'] > 5) { $this->error('游戏评分只能为0-5之间的数字!'); @@ -415,7 +441,30 @@ class GameController extends ThinkController $data['icon_data'] = explode(',', $data['icon']); } - + $apply_auth = M('game','tab_')->where(['id'=>$id])->getField('apply_auth'); + $this->assign('apply_auth',$apply_auth); + $sociatyGames = M('sociaty_games','tab_')->where(['game_id'=>$id])->select(); + $sociatyGamesData = []; + if(!empty($sociatyGames)) { + foreach($sociatyGames as $key => $value) { + $sociatyGamesData[$key]['id'] = $value['id']; + if($value['promote_id'] == -1) { + $sociatyGamesData[$key]['promoteAccount'] = "官方渠道"; + }else { + $promoteAccount = M('promote','tab_')->where(['id'=>$value['promote_id']])->getField('account'); + $sociatyGamesData[$key]['promoteAccount'] = $promoteAccount; + } + $sociatyGamesData[$key]['create_time'] = date('Y-m-d H:i:s',$value['create_time']); + $applyStatus = M('apply','tab_')->field('id')->where(['game_id'=>$value['game_id'],'status'=>1])->select(); + if(empty($applyStatus)) { + $sociatyGamesData[$key]['isPromote'] = "否"; + }else { + $sociatyGamesData[$key]['isPromote'] = "是"; + } + } + } + $this->assign('sociatygames',$sociatyGamesData); + $data['introduction'] = str_replace("~~", "\r\n", $data['introduction']); $this->assign('data', $data); $this->assign('game_id', $id); @@ -911,6 +960,7 @@ class GameController extends ThinkController public function uploadExcel1() { Vendor("PHPExcel.PHPExcel"); + $gid = $_REQUEST['game_id']; if(@is_uploaded_file($_FILES['file']['tmp_name'])){ $upfile = $_FILES["file"]; $name = $upfile["name"]; @@ -921,10 +971,11 @@ class GameController extends ThinkController move_uploaded_file($tmp_name,$savePath.$name); $file_name = $savePath.$name; $error=$upfile["error"];//上传后系统返回的值 - // print($file_name); $extension = strtolower( pathinfo($file_name, PATHINFO_EXTENSION) ); if($extension == 'xlsx') { $objReader = \PHPExcel_IOFactory::createReader('excel2007'); + }elseif($extension == 'csv') { + $objReader = \PHPExcel_IOFactory::createReader('csv'); }else { $objReader = \PHPExcel_IOFactory::createReader('Excel5');//创建读取实例 } @@ -933,24 +984,38 @@ class GameController extends ThinkController $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $dataList = []; + $outPromote = []; //录入出错的会长 + $outGame = []; //录入出错的游戏 + $keyPro = 0; + $keyGame = 0; + $keyData = 0; for($i=2;$i<=$highestRow;$i++) { - $promote_id = $objPHPExcel->getActiveSheet()->getCell("A".$i)->getValue(); - $promoteInfo = M('promote','tab_')->field('account')->where(['id' => $promote_id ])->find(); - + $promoteAccount = $objPHPExcel->getActiveSheet()->getCell("A".$i)->getValue(); + $promoteInfo = M('promote','tab_')->field('id')->where(['account' => $promoteAccount ])->find(); + if($promote_id == -1) {$promoteInfo['account'] = "官方渠道"; } if(empty($promoteInfo)) { - break; - } - $game_id = $objPHPExcel->getActiveSheet()->getCell("B".$i)->getValue(); - $gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$game_id])->select(); - if(empty($gameInfo)) { - break; + $outPromote[$keyPro]['promote_account'] = $promoteAccount; + $keyPro += 1; + }else { + $promote_id = $promoteInfo['id']; } + $gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gid])->select(); $time = time(); - $dataList[] = ['promote_id'=>$promote_id,'game_id'=>$game_id,'status'=>$gameInfo[0]['game_status'],'create_time'=>$time]; + $isSociaty = M('sociaty_games','tab_')->where(['promote_id'=>$promote_id,'game_id'=>$gid])->getField('id'); + if(empty($isSociaty) && !empty($gameInfo) && !empty($promoteInfo)) { + $dataList[$keyData] = ['promote_id'=>$promote_id,'game_id'=>$gid,'status'=>$gameInfo[0]['game_status'],'create_time'=>$time]; + $successAccount[$keyData] = ['account'=>$promoteAccount]; + $keyData += 1; + } + } - M('sociaty_games','tab_')->addAll($dataList); - $this->ajaxReturn(json_encode($dataList)); + $backData['outPromote'] = $outPromote; + $backData['datalist'] = $successAccount; + M('sociaty_games','tab_')->addAll($dataList); + $gameData['apply_auth'] = 2; + M('game','tab_')->where(['id'=>$gid])->save($gameData); + $this->ajaxReturn(json_encode($backData,TRUE)); } } @@ -970,16 +1035,12 @@ class GameController extends ThinkController $game_id = $_REQUEST['game_id']; $game_name = M('game','tab_')->where(['id'=>$game_id])->getField('game_name'); $data[] = [ - 'promoteid' => 99, - 'game_id' => $game_id, - 'game_name' => $game_name + 'promoteid' => "官方渠道", ]; $field = array( - "promoteid"=>"会长ID", - "game_id"=>"游戏ID(无需修改,已默认当前游戏)", - "game_name"=>"游戏名称(无需修改,已默认当前游戏)" + "promoteid"=>"会长账号", ); - data2csv($data,"模板",$field); + data2csv($data,'【'.$game_name.'】'.'模板',$field); } } diff --git a/Application/Admin/View/Game/edit.html b/Application/Admin/View/Game/edit.html index f0c2dc058..df524dd4c 100644 --- a/Application/Admin/View/Game/edit.html +++ b/Application/Admin/View/Game/edit.html @@ -944,13 +944,47 @@
    - + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    会长账号添加时间是否已进行推广操作
    aOh! 暂时还没有内容!
    {$data['promoteAccount']}{$data['create_time']}{$data['isPromote']}移除
    该游戏未设置会长权限,现面对所有会长开放!
    +
    +
    + @@ -978,7 +1012,7 @@ @@ -1078,6 +1112,7 @@