From 2b1980bfbd0c26e05185fe90f4c24c03a0ba9ea8 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Sat, 10 Oct 2020 19:30:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/FinanceController.class.php | 1 - Application/Admin/Model/SpendModel.class.php | 70 ++++++++++++++----- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php index b4578608c..293b449c1 100644 --- a/Application/Admin/Controller/FinanceController.class.php +++ b/Application/Admin/Controller/FinanceController.class.php @@ -809,7 +809,6 @@ class FinanceController extends ThinkController $aggAmount = number_format($aggData[$value['unique_code']][$deviceType], 2, '.', ''); $aggFailAmount = number_format($aggFailData[$value['unique_code']][$deviceType], 2, '.', ''); } - // if ($aggAmount != '0.00') { if (isset($gameSets[$value['game_id']]) && isAggGame($gameSets[$value['game_id']]['pay_notify_url'])) { $data[$key]['cash_count'] = $value['cash_count'] = 0; $data[$key]['balance_coin_count'] = $value['balance_coin_count'] = 0; diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index 63514e6b1..2d9c51ed7 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -831,6 +831,20 @@ class SpendModel extends Model return $sum; } + private function getGameMapByGameStatMap($map) + { + $gameMap = []; + if (isset($map['s.game_id'])) { + $gameMap['id'] = $map['s.game_id']; + } + if (isset($map['g.partner_id'])) { + $gameMap['partner_id'] = $map['g.partner_id']; + } + if (isset($map['g.game_type_id'])) { + $gameMap['game_type_id'] = $map['g.game_type_id']; + } + return $gameMap; + } /** *获取游戏统计列表数据 @@ -840,6 +854,18 @@ class SpendModel extends Model */ public function gameStatistics($map, $row = 0, $page = 1) { + $gameMap = $this->getGameMapByGameStatMap($map); + $gameQuery = M('game', 'tab_')->field(['id', 'relation_game_name', 'unique_code', 'partner_id', 'game_type_name', 'sdk_version'])->where($gameMap); + if ($row) { + $gameQuery->page($page,$row); + } + $games = $gameQuery->select(); + $partners = []; + if (count($games)) { + $map['s.game_id'] = ['in', array_column($games, 'id')]; + $partners = M('partner', 'tab_')->field(['id', 'partner'])->where(['id' => ['in', array_column($games, 'partner_id')]])->select(); + $partners = index_by_column('id', $partners); + } $noticeFailData = M("Spend s use index(game_time)","tab_") ->field("SUM(pay_amount) as notice_fail_count,game_id") @@ -862,26 +888,38 @@ SUM(CASE WHEN pay_way = -1 and s.pay_status = 1 and pay_game_status = 1 THEN pay // ->where("(s.pay_status = 1 and pay_game_status = 1) or (s.pay_status = 1 and pay_game_status = 0)") ->where($map) ->group('s.game_id'); - if ($row) { + /* if ($row) { $query = $query->page($page,$row); - } + } */ $data = $query->select(); -// var_dump($data);die(); - return $data; + $data = index_by_column('game_id', $data); + $records = []; + foreach ($games as $game) { + if (isset($data[$game['id']])) { + $records[] = $data[$game['id']]; + } else { + $partner = $partners[$game['partner_id']] ?? null; + $records[] = [ + 'game_id' => $game['id'], + 'game_name' => $game['relation_game_name'], + 'unique_code' => $game['unique_code'], + 'partner_name' => $partner ? $partner['partner'] : '无', + 'game_type_name' => $game['game_type_name'], + 'cash_count' => 0, + 'balance_coin_count' => 0, + 'inside_cash_count' => 0, + 'sdk_version' => $game['sdk_version'], + 'notice_fail_count' => 0 + ]; + } + } + + return $records; } public function gameStatisticsCount($map) { - - $query = M("Spend s use index(game_time)","tab_") - ->field("game_id") - ->join('LEFT JOIN tab_game as g ON s.game_id=g.id') - ->join('LEFT JOIN tab_partner as p ON g.partner_id=p.id') - ->where(['s.pay_status' => 1]) - ->where($map) - ->group('s.game_id'); - $data = $query->select(); - - return count($data); + $gameMap = $this->getGameMapByGameStatMap($map); + return M('game', 'tab_')->where($gameMap)->count(); } /** @@ -889,8 +927,6 @@ SUM(CASE WHEN pay_way = -1 and s.pay_status = 1 and pay_game_status = 1 THEN pay */ public function totalGameStatistics($map, $join = true) { - - $noticeFailData = M("Spend s use index(game_time)","tab_") ->field("SUM(pay_amount) as notice_fail_count,game_id") ->join('LEFT JOIN tab_game as g ON s.game_id=g.id')