diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index f88a2a7a6..de5677ddc 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -12,6 +12,7 @@ use GuzzleHttp\Client; use think\Db; use Base\Task\Task; use Base\Service\MarketService; +use Base\Tool\AggregateClient; class ConsoleController extends Think { @@ -123,6 +124,13 @@ class ConsoleController extends Think { } } + public function testAggregate() + { + $client = new AggregateClient(); + $result = $client->api('game-data', ['unique_codes' => ['abc']]); + var_dump($result); + } + public function initMarketAdmin() { $marketService = new MarketService(); diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php index 86b1c3d24..a3ff36ba7 100644 --- a/Application/Admin/Controller/FinanceController.class.php +++ b/Application/Admin/Controller/FinanceController.class.php @@ -4,7 +4,7 @@ namespace Admin\Controller; use OSS\Core\OssException; - +use Base\Tool\AggregateClient; class FinanceController extends ThinkController { @@ -735,9 +735,39 @@ class FinanceController extends ThinkController $startTime = time(); //游戏统计列表 $data = D("spend")->gameStatistics($map, $row, $p); + $uniqueCodes = array_column($data, 'unique_code'); + $uniqueCodes = array_filter($uniqueCodes, function($value) { + if ($value) { + return true; + } + return false; + }); + + $client = new AggregateClient(); + $result = $client->api('game-data', ['unique_codes' => $uniqueCodes]); + $aggData = []; + $aggTotal = '0.00'; + if ($result['code'] == '0000') { + $aggData = $result['data']['records']; + $aggTotal = $result['data']['total']; + } + $endTime = time(); + $exceptIds = []; foreach ($data as $key => $value) { + $aggAmount = '0.00'; + $deviceType = $value['sdk_version'] == 1 ? 'android' : 'ios'; + if ($value['unique_code'] && isset($aggData[$value['unique_code']]) && isset($aggData[$value['unique_code']][$deviceType])) { + $aggAmount = number_format($aggData[$value['unique_code']][$deviceType], 2, '.', ''); + } + if ($aggAmount != '0.00') { + $value['cash_count'] = 0; + $value['balance_coin_count'] = 0; + $value['inside_cash_count'] = 0; + $exceptIds[] = $value['game_id']; + } $data[$key]['all_cash_count'] = number_format($value['cash_count'] + $value['balance_coin_count'] + $value['inside_cash_count'],2,'.',''); + $data[$key]['agg_amount'] = $value['unique_code'] ? $aggAmount : '0.00'; } $count = D("spend")->gameStatisticsCount($map);//列表总数 @@ -751,6 +781,13 @@ class FinanceController extends ThinkController $this->checkListOrCountAuthRestMap($map,[]); //统计合计 + if (count($exceptIds) > 0) { + if (isset($map['_string'])) { + $map['_string'] .= " and s.game_id not in (" . implode(',', $exceptIds) . ")"; + } else { + $map['_string'] = " s.game_id not in (" . implode(',', $exceptIds) . ")"; + } + } $totalData = D("spend")->totalGameStatistics($map); $sumCash = $totalData['cash_count']; @@ -760,6 +797,13 @@ class FinanceController extends ThinkController $sumAll = $sumCash + $sumBalance + $sumInside; $game_types = M("game_type", 'tab_')->field('id, type_name')->select(); + + $aggRate = round($aggTotal/($sumAll + $aggTotal) * 100, 2) . '%'; + $allRate = round($sumAll/($sumAll + $aggTotal) * 100, 2) . '%'; + + $this->assign('aggRate', $aggRate); + $this->assign('allRate', $allRate); + $this->assign('aggTotal', $aggTotal); $this->assign('game_types', $game_types); $this->assign('sumCash', $sumCash); $this->assign('sumBalance', $sumBalance); diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index 4d55b3771..01e7b01cd 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -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_'); @@ -347,32 +351,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之间的数字!'); @@ -392,6 +374,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('游戏未审核不允许显示');//游戏添加完成 }*/ @@ -403,15 +390,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); @@ -428,36 +414,38 @@ 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['select_package_name']= $_POST['select_package_name']; - $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['select_package_name']= $_POST['select_package_name']; + $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; @@ -465,7 +453,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( diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index d338b8aaf..63514e6b1 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -851,7 +851,7 @@ class SpendModel extends Model ->select(false); $query = M("Spend s use index(game_time)","tab_") - ->field("s.game_id,g.relation_game_name game_name,p.partner as partner_name, g.game_type_name, + ->field("s.game_id,g.relation_game_name game_name, g.unique_code, p.partner as partner_name, g.game_type_name, SUM(CASE WHEN pay_way > 0 and s.pay_status = 1 and pay_game_status = 1 THEN pay_amount ELSE 0 END) as cash_count, SUM(CASE WHEN pay_way = 0 and s.pay_status = 1 and pay_game_status = 1 THEN pay_amount ELSE 0 END) as balance_coin_count, SUM(CASE WHEN pay_way = -1 and s.pay_status = 1 and pay_game_status = 1 THEN pay_amount ELSE 0 END) as inside_cash_count,g.sdk_version,notice_fail_count") diff --git a/Application/Admin/View/Finance/gameStatistics.html b/Application/Admin/View/Finance/gameStatistics.html index 52a6cab69..733407269 100644 --- a/Application/Admin/View/Finance/gameStatistics.html +++ b/Application/Admin/View/Finance/gameStatistics.html @@ -175,7 +175,7 @@