@ -289,9 +289,27 @@ 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)
public function edit($id = null)
{
{
if (IS_POST) {
if (IS_POST) {
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');
M('game','tab_')->where(['id'=>$gameId])->save($gameData);
if($_REQUEST['apply_auth'] == 1) {
M('sociaty_games','tab_')->where(['game_id'=>$gameId])->delete();
}
if(!empty($_REQUEST['promote_data'])) {
if(!empty($_REQUEST['promote_data'])) {
$promote_data = json_decode($_REQUEST['promote_data'],TRUE);
$promote_data = json_decode($_REQUEST['promote_data'],TRUE);
$game_appid = $_REQUEST['game_appid'];
$game_appid = $_REQUEST['game_appid'];
@ -299,10 +317,18 @@ class GameController extends ThinkController
$gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gameId])->select();
$gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gameId])->select();
$dataList = array();
$dataList = array();
foreach($promote_data as $key => $promoteInfo) {
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()];
$dataList[] = ['promote_id' => intval($promoteInfo['value']),'game_id' => intval($gameId),'status'=>$gameInfo[0]['game_status'],'create_time'=>time()];
}
}
}
M('sociaty_games','tab_')->addAll($dataList);
M('sociaty_games','tab_')->addAll($dataList);
}
}
// $_REQUEST['apply_auth'] == 1 ? $this->success('开放全部会长权限成功') : $this->success('设置会长权限成功');
}
if ($_POST['game_score'] < 0 | | $ _POST [ ' game_score ' ] > 5) {
if ($_POST['game_score'] < 0 | | $ _POST [ ' game_score ' ] > 5) {
$this->error('游戏评分只能为0-5之间的数字! ');
$this->error('游戏评分只能为0-5之间的数字! ');
exit;
exit;
@ -415,6 +441,29 @@ class GameController extends ThinkController
$data['icon_data'] = explode(',', $data['icon']);
$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']);
$data['introduction'] = str_replace("~~", "\r\n", $data['introduction']);
$this->assign('data', $data);
$this->assign('data', $data);
@ -911,6 +960,7 @@ class GameController extends ThinkController
public function uploadExcel1() {
public function uploadExcel1() {
Vendor("PHPExcel.PHPExcel");
Vendor("PHPExcel.PHPExcel");
$gid = $_REQUEST['game_id'];
if(@is_uploaded_file($_FILES['file']['tmp_name'])){
if(@is_uploaded_file($_FILES['file']['tmp_name'])){
$upfile = $_FILES["file"];
$upfile = $_FILES["file"];
$name = $upfile["name"];
$name = $upfile["name"];
@ -921,10 +971,11 @@ class GameController extends ThinkController
move_uploaded_file($tmp_name,$savePath.$name);
move_uploaded_file($tmp_name,$savePath.$name);
$file_name = $savePath.$name;
$file_name = $savePath.$name;
$error=$upfile["error"];//上传后系统返回的值
$error=$upfile["error"];//上传后系统返回的值
// print($file_name);
$extension = strtolower( pathinfo($file_name, PATHINFO_EXTENSION) );
$extension = strtolower( pathinfo($file_name, PATHINFO_EXTENSION) );
if($extension == 'xlsx') {
if($extension == 'xlsx') {
$objReader = \PHPExcel_IOFactory::createReader('excel2007');
$objReader = \PHPExcel_IOFactory::createReader('excel2007');
}elseif($extension == 'csv') {
$objReader = \PHPExcel_IOFactory::createReader('csv');
}else {
}else {
$objReader = \PHPExcel_IOFactory::createReader('Excel5');//创建读取实例
$objReader = \PHPExcel_IOFactory::createReader('Excel5');//创建读取实例
}
}
@ -933,24 +984,38 @@ class GameController extends ThinkController
$highestRow = $sheet->getHighestRow();
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$highestColumn = $sheet->getHighestColumn();
$dataList = [];
$dataList = [];
$outPromote = []; //录入出错的会长
$outGame = []; //录入出错的游戏
$keyPro = 0;
$keyGame = 0;
$keyData = 0;
for($i=2;$i< =$highestRow;$i++)
for($i=2;$i< =$highestRow;$i++)
{
{
$promote_id = $objPHPExcel->getActiveSheet()->getCell("A".$i)->getValue();
$promoteAccount = $objPHPExcel->getActiveSheet()->getCell("A".$i)->getValue();
$promoteInfo = M('promote','tab_')->field('account')->where(['id' => $promote_id ])->find();
$promoteInfo = M('promote','tab_')->field('id')->where(['account' => $promoteAccount ])->find();
if($promote_id == -1) {$promoteInfo['account'] = "官方渠道"; }
if(empty($promoteInfo)) {
if(empty($promoteInfo)) {
break;
$outPromote[$keyPro]['promote_account'] = $promoteAccount;
}
$keyPro += 1;
$game_id = $objPHPExcel->getActiveSheet()->getCell("B".$i)->getValue();
}else {
$gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$game_id])->select();
$promote_id = $promoteInfo['id'];
if(empty($gameInfo)) {
break;
}
}
$gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gid])->select();
$time = time();
$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;
}
}
}
$backData['outPromote'] = $outPromote;
$backData['datalist'] = $successAccount;
M('sociaty_games','tab_')->addAll($dataList);
M('sociaty_games','tab_')->addAll($dataList);
$this->ajaxReturn(json_encode($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_id = $_REQUEST['game_id'];
$game_name = M('game','tab_')->where(['id'=>$game_id])->getField('game_name');
$game_name = M('game','tab_')->where(['id'=>$game_id])->getField('game_name');
$data[] = [
$data[] = [
'promoteid' => 99,
'promoteid' => "官方渠道",
'game_id' => $game_id,
'game_name' => $game_name
];
];
$field = array(
$field = array(
"promoteid"=>"会长ID",
"promoteid"=>"会长账号",
"game_id"=>"游戏ID(无需修改,已默认当前游戏)",
"game_name"=>"游戏名称(无需修改,已默认当前游戏)"
);
);
data2csv($data,"模板" ,$field);
data2csv($data,'【'.$game_name.'】'.'模板',$field);
}
}
}
}