@ -166,6 +166,8 @@ class GameController extends ThinkController
{
if (IS_POST) {
$gameService = new GameService();
$_POST['introduction'] = str_replace(array("\r\n", "\r", "\n"), "~~", $_POST['introduction']);
if ($_POST['game_name'] == '') {
$this->error('游戏名称不能为空!');
@ -184,6 +186,9 @@ class GameController extends ThinkController
return $this->error("请填写正确的极速版下载链接");
}
}
if ($_POST['unique_code'] & & $gameService->isUniqueCodeExists($_POST['unique_code'])) {
return $this->error("聚合游戏标识已存在");
}
$_POST['relation_game_name'] = $_POST['game_name'];
if ($_POST['sdk_version'] == 1) {
unset($_POST['ios_game_address']);
@ -217,7 +222,6 @@ class GameController extends ThinkController
$_POST['discount'] == '' ? $_POST['discount'] = 10 : $_POST['discount'];
$_POST['short'] = $short;
$gameService = new GameService();
$_POST['download_ways'] = $gameService->getDownLoadWaysValue($downloadWays);
$game = D(self::model_name);//M('$this->$model_name','tab_');
@ -344,32 +348,10 @@ class GameController extends ThinkController
public function edit($id = null)
{
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'])) {
$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('设置会长权限成功');
$game = M('game', 'tab_')->where(['id' => $id])->find();
if (!$game) {
$this->error('游戏不存在!');
exit;
}
if ($_POST['game_score'] < 0 | | $ _POST [ ' game_score ' ] > 5) {
$this->error('游戏评分只能为0-5之间的数字! ');
@ -389,6 +371,11 @@ class GameController extends ThinkController
return $this->error("请填写正确的极速版下载链接");
}
}
$gameService = new GameService();
if ($_POST['unique_code'] & & $gameService->isUniqueCodeExists($_POST['unique_code'], $game['relation_game_id'], 'relation_game_id')) {
return $this->error("聚合游戏标识已存在");
}
/*if($_POST['apply_status']==0& & $_POST['game_status']==1){
$this->error('游戏未审核不允许显示');//游戏添加完成
}*/
@ -400,15 +387,14 @@ class GameController extends ThinkController
$_POST['display_site'] = '';
}
$content = $_POST['content'];
$gameRatio = M('Game', 'tab_')->where(array('id' => I('post.id', 0)))->getField('ratio');//游戏推广分成比例
$game = D(self::model_name);//M('$this->$model_name','tab_');
$gameModel = D(self::model_name);//M('$this->$model_name','tab_');
$_POST['discount'] == '' ? $_POST['discount'] = 10 : $_POST['discount'];
$_POST['detail_content'] = $content;
$_POST['pay_config'] = json_encode($_POST['pay_config']);
$gameService = new GameService();
$_POST['download_ways'] = $gameService->getDownLoadWaysValue($downloadWays);
unset($_POST['apply_auth']);
$res = $game->update();
$res = $gameModel ->update();
$id = $res["id"];
$sibling = D("Game")->find($id);
@ -425,36 +411,37 @@ class GameController extends ThinkController
];
$gameService->saveBaseGame($baseData);
$phone['apply_auth'] = $sibling['apply_auth'];
$phone['game_type_id'] = $sibling['game_type_id'];
$phone['dow_num'] = $sibling['dow_num'];
$phone['game_type_name'] = $sibling['game_type_name'];
$phone['category'] = $sibling['category'];
$phone['recommend_status'] = $sibling['recommend_status'];
//$phone['game_status']= $sibling['game_status'];
$phone['sort'] = $sibling['sort'];
$phone['game_score'] = $sibling['game_score'];
$phone['features'] = $sibling['features'];
$phone['flooring_page_imgs'] = $sibling['flooring_page_imgs'];
$phone['introduction'] = $sibling['introduction'];
$phone['icon'] = $sibling['icon'];
$phone['cover'] = $sibling['cover'];
$phone['screenshot'] = $sibling['screenshot'];
$phone['material_url'] = $sibling['material_url'];
$phone['game_detail_cover'] = $sibling['game_detail_cover'];
$phone['first_level_name'] = $sibling['first_level_name'];
$phone['second_level_name'] = $sibling['second_level_name'];
$phone['third_level_name'] = $sibling['third_level_name'];
$phone['first_level'] = $sibling['first_level'];
$phone['second_level'] = $sibling['second_level'];
$phone['third_level'] = $sibling['third_level'];
$phone['display_site'] = $sibling['display_site'];
$phone['back_describe'] = $sibling['back_describe'];
$phone['dow_icon'] = $sibling['dow_icon'];
$phone['back_map'] = $sibling['back_map'];
$phone['flooring_page_video'] = $sibling['flooring_page_video'];
$phone['flooring_page_video_cover'] = $sibling['flooring_page_video_cover'];
M('Game', 'tab_')->data($phone)->where(array('id' => $another['id']))->save();
$otherData = [];
$otherData['apply_auth'] = $sibling['apply_auth'];
$otherData['game_type_id'] = $sibling['game_type_id'];
$otherData['dow_num'] = $sibling['dow_num'];
$otherData['game_type_name'] = $sibling['game_type_name'];
$otherData['category'] = $sibling['category'];
$otherData['recommend_status'] = $sibling['recommend_status'];
$otherData['sort'] = $sibling['sort'];
$otherData['game_score'] = $sibling['game_score'];
$otherData['features'] = $sibling['features'];
$otherData['flooring_page_imgs'] = $sibling['flooring_page_imgs'];
$otherData['introduction'] = $sibling['introduction'];
$otherData['icon'] = $sibling['icon'];
$otherData['cover'] = $sibling['cover'];
$otherData['screenshot'] = $sibling['screenshot'];
$otherData['material_url'] = $sibling['material_url'];
$otherData['game_detail_cover'] = $sibling['game_detail_cover'];
$otherData['first_level_name'] = $sibling['first_level_name'];
$otherData['second_level_name'] = $sibling['second_level_name'];
$otherData['third_level_name'] = $sibling['third_level_name'];
$otherData['first_level'] = $sibling['first_level'];
$otherData['second_level'] = $sibling['second_level'];
$otherData['third_level'] = $sibling['third_level'];
$otherData['display_site'] = $sibling['display_site'];
$otherData['back_describe'] = $sibling['back_describe'];
$otherData['dow_icon'] = $sibling['dow_icon'];
$otherData['back_map'] = $sibling['back_map'];
$otherData['unique_code'] = $sibling['unique_code'];
$otherData['flooring_page_video'] = $sibling['flooring_page_video'];
$otherData['flooring_page_video_cover'] = $sibling['flooring_page_video_cover'];
M('Game', 'tab_')->data($otherData)->where(array('id' => $another['id']))->save();
//同时修改代充游戏折扣
$set_fidel['status'] = 1;
$set_fidel['game_id'] = $id;
@ -462,7 +449,7 @@ class GameController extends ThinkController
$promoteModel = new \Admin\Model\PromoteWelfareModel();
$promoteModel->set_game_discount($set_fidel);
if (!$res) {
$this->error($game->getError());
$this->error($gameModel ->getError());
} else {
\Think\Log::actionLog('Game/edit', 'Game', 1);
addOperationLog(array(