优化游戏

master
ELF 5 years ago
parent 31ac6f0a1a
commit dae2dd5fd9

@ -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不能为空');

@ -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 {

@ -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){

@ -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);
}
}
}

@ -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;
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='用户数据表';
Loading…
Cancel
Save