From dae2dd5fd928d61206396423cc6d4f7f7dfef6bc Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Fri, 6 Mar 2020 19:20:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B8=B8=E6=88=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/DevelopersController.class.php | 6 ++-- .../Admin/Controller/GameController.class.php | 36 +++++++++++++++---- Application/Admin/Model/GameModel.class.php | 3 +- .../Base/Service/GameService.class.php | 30 ++++++++++++++++ Data/update.sql | 24 ++++++++++++- 5 files changed, 88 insertions(+), 11 deletions(-) diff --git a/Application/Admin/Controller/DevelopersController.class.php b/Application/Admin/Controller/DevelopersController.class.php index 8b0ae7da8..3cf7873b7 100644 --- a/Application/Admin/Controller/DevelopersController.class.php +++ b/Application/Admin/Controller/DevelopersController.class.php @@ -175,7 +175,7 @@ class DevelopersController extends ThinkController { if(!$res){ $this->error($game->getError()); } else { - $this->success($res['id'] ? '更新成功' : '新增成功', U('game')); + $this->success($_POST['id'] ? '更新成功' : '新增成功', U('game')); } } else { @@ -300,7 +300,7 @@ class DevelopersController extends ThinkController { if(!$res){ $this->error($game->getError()); }else{ - $this->success($res['id']?'更新成功':'新增成功',U('game')); + $this->success($_POST['id']?'更新成功':'新增成功',U('game')); } }else{ $this->meta_title = '新增游戏'; @@ -338,7 +338,7 @@ class DevelopersController extends ThinkController { //增加合同信息 $Contract = new ContractModel(); $Contract->addContract($game_id,$res['developers']); - $this->success($res['id']?'更新成功':'新增成功',U('game')); + $this->success($_POST['id']?'更新成功':'新增成功',U('game')); } }else{ $_REQUEST['id'] || $this->error('id不能为空'); diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index 3004b3d80..a248c7e05 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -204,7 +204,6 @@ class GameController extends ThinkController $_POST['detail_content'] = ''; } - $pinyin = new \Think\Pinyin(); $num = mb_strlen($_POST['game_name'], 'UTF8'); $short = ''; @@ -224,6 +223,14 @@ class GameController extends ThinkController if (!$res) { $this->error($game->getError()); } else { + + $baseData = [ + 'id' => $res['id'], + 'name' => str_replace('(安卓版)', '', str_replace('(苹果版)', '', $_POST['game_name'])), + 'sdk_version' => $_POST['sdk_version'], + ]; + $gameService->saveBaseGame($baseData); + \Think\Log::actionLog('Game/add', 'Game', 1); //操作日志 addOperationLog(array( @@ -231,7 +238,7 @@ class GameController extends ThinkController "key"=>$_POST['game_name'], "url"=>U("Game/lists",array("game_name"=>$_POST['game_name'])) )); - $this->success($res['id'] ? '更新成功' : '新增成功', U('lists')); + $this->success($_POST['id'] ? '更新成功' : '新增成功', U('lists')); } } else { if ($_GET['type'] == 1 || $_GET['type'] == "") { @@ -242,8 +249,6 @@ class GameController extends ThinkController $this->m_title = '游戏列表'; $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Game/lists', 'status' => 1])->find()); - - $this->display(); } } @@ -288,12 +293,22 @@ class GameController extends ThinkController if (!$res) { $this->error($game->getError()); } else { + + $gameService = new GameService(); + $baseData = [ + 'id' => $res['id'], + 'name' => str_replace('(安卓版)', '', str_replace('(苹果版)', '', $_POST['game_name'])), + 'sdk_version' => $_POST['sdk_version'], + 'relation_game_id' => $_POST['relation_game_id'], + ]; + $gameService->saveBaseGame($baseData); + addOperationLog(array( "op_type"=>0, "key"=>$_POST['game_name'], "url"=>U("Game/lists",array("game_name"=>$_POST['game_name'])) )); - $this->success($res['id'] ? '更新成功' : '新增成功', U('lists')); + $this->success($_POST['id'] ? '更新成功' : '新增成功', U('lists')); } } else { $_REQUEST['id'] || $this->error('id不能为空'); @@ -399,6 +414,15 @@ class GameController extends ThinkController $sid = $sibling['id']; $map['id'] = array('neq', $sid); $another = D("Game")->where($map)->find(); //获取另一个所有 + + $baseData = [ + 'id' => $id, + 'name' => str_replace('(安卓版)', '', str_replace('(苹果版)', '', $sibling['game_name'])), + 'relation_game_id' => $another ? $another['id'] : 0, + 'sdk_version' => $sibling['sdk_version'], + ]; + $gameService->saveBaseGame($baseData); + $phone['apply_auth'] = $sibling['apply_auth']; $phone['game_type_id'] = $sibling['game_type_id']; $phone['dow_num'] = $sibling['dow_num']; @@ -444,7 +468,7 @@ class GameController extends ThinkController "key"=>$sibling ['game_name'], "url"=>U("Game/lists",array("game_name"=>$sibling ['game_name'])) )); - $this->success($res['id'] ? '更新成功' : '新增成功', U('lists', array('type' => I('post.type'), 'p' => I('request.p')))); + $this->success($_POST['id'] ? '更新成功' : '新增成功', U('lists', array('type' => I('post.type'), 'p' => I('request.p')))); } } else { diff --git a/Application/Admin/Model/GameModel.class.php b/Application/Admin/Model/GameModel.class.php index 7a7afb347..34bf62d73 100644 --- a/Application/Admin/Model/GameModel.class.php +++ b/Application/Admin/Model/GameModel.class.php @@ -142,12 +142,13 @@ class GameModel extends Model{ return false; }else{ if(!isset($data['relation_game_id'])){ - $relation=M('Game','tab_')->where(array('id'=>$id))->save(array('relation_game_id'=>$id)); + $relation = M('Game','tab_')->where(array('id'=>$id))->save(array('relation_game_id'=>$id)); if(!$relation){ $this->error('关联id添加失败');//游戏添加完成 } } } + $data['id'] = $id; } else { //更新数据 $status = $this->save(); //更新基础内容 if(false === $status){ diff --git a/Application/Base/Service/GameService.class.php b/Application/Base/Service/GameService.class.php index 6733df0e3..8b67cc552 100644 --- a/Application/Base/Service/GameService.class.php +++ b/Application/Base/Service/GameService.class.php @@ -16,4 +16,34 @@ class GameService { } return $value; } + + public function saveBaseGame($params) + { + $baseGame = null; + $conditions = []; + + $data = [ + 'name' => $params['name'] + ]; + + $gameIds = [$params['id']]; + if (isset($params['relation_game_id']) && $params['relation_game_id']) { + $gameIds[] = $params['relation_game_id']; + } + $conditions['_logic'] = 'or'; + $conditions['android_game_id'] = ['in', $gameIds]; + $conditions['ios_game_id'] = ['in', $gameIds]; + if ($params['sdk_version'] == 1) { + $data['android_game_id'] = $params['id']; + } elseif ($params['sdk_version'] == 2) { + $data['ios_game_id'] = $params['id']; + } + + $baseGame = M('base_game', 'tab_')->where($conditions)->find(); + if (!$baseGame) { + return M('base_game', 'tab_')->add($data); + } else { + return M('base_game', 'tab_')->where(['id' => $baseGame['id']])->save($data); + } + } } \ No newline at end of file diff --git a/Data/update.sql b/Data/update.sql index f6537638b..e84323c12 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -1444,4 +1444,26 @@ CREATE TABLE `tab_promote_game_available_balance` ( -- 2020-03-05 zyx spend添加索引 ALTER TABLE `tab_spend` ADD INDEX `pay_channel`(`pay_way`, `pay_status`, `game_id`) USING BTREE, -ADD INDEX `pay_channel_type`(`pay_status`, `pay_way`) USING BTREE; \ No newline at end of file +ADD INDEX `pay_channel_type`(`pay_status`, `pay_way`) USING BTREE; + +CREATE TABLE `tab_user_data` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `user_id` int(11) not null COMMENT '用户ID', + `pay_amount` decimal(12, 2) not null DEFAULT '0.00' COMMENT '累计支付金额', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户数据表'; + +CREATE TABLE `tab_game_data` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `game_id` int(11) not null COMMENT '游戏ID', + `pay_amount` decimal(12, 2) not null DEFAULT '0.00' COMMENT '累计充值金额', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='游戏数据表'; + +CREATE TABLE `tab_base_game` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(150) not null COMMENT '游戏名称', + `android_game_id` int(11) not null default 0 COMMENT 'android版ID', + `ios_game_id` int(11) not null default 0 COMMENT 'ios版ID', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户数据表'; \ No newline at end of file