From 6f8b93a26bd4128a53eecfe98602fe0856c8ed50 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Jul 2020 14:21:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/FinanceController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php index a3ff36ba7..1faf16f15 100644 --- a/Application/Admin/Controller/FinanceController.class.php +++ b/Application/Admin/Controller/FinanceController.class.php @@ -744,7 +744,7 @@ class FinanceController extends ThinkController }); $client = new AggregateClient(); - $result = $client->api('game-data', ['unique_codes' => $uniqueCodes]); + $result = $client->api('game-data', ['unique_codes' => $uniqueCodes, 'started_at' => I('timestart', ''), 'ended_at' => I('timeend', '')]); $aggData = []; $aggTotal = '0.00'; if ($result['code'] == '0000') { From e0f71b67c5852bff49a4ec5f5c96e4f2a51dbdd1 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Jul 2020 16:11:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ConsoleController.class.php | 2 +- .../Controller/ExportController.class.php | 52 +++++++++++++++++++ .../Controller/SpendController.class.php | 11 +++- Application/Admin/View/Spend/lists.html | 7 +++ 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index de5677ddc..35305e7ef 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -127,7 +127,7 @@ class ConsoleController extends Think { public function testAggregate() { $client = new AggregateClient(); - $result = $client->api('game-data', ['unique_codes' => ['abc']]); + $result = $client->api('game-data', ['unique_codes' => ['xmjs'], 'started_at' => '2020-06-27', 'ended_at' => '2020-07-27']); var_dump($result); } diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 2f9d589e1..cfbb43e4e 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -4,6 +4,7 @@ namespace Admin\Controller; use Think\Controller; use GuzzleHttp\Client; use Admin\Model\PromoteModel; +use Base\Tool\AggregateClient; class ExportController extends Controller { @@ -1174,6 +1175,16 @@ class ExportController extends Controller $order = ' pay_time desc '; } + if (I('platform_type', 0) != 0) { + $sy = I('platform_type', 0) == 1 ? '=' : '<>'; + $platformWhere = 'exists (select 1 from tab_game where id = tab_spend.game_id and unique_code ' . $sy . ' "")'; + if (isset($map['_string']) && $map['_string']) { + $map['_string'] = $map['_string'] . ' and ' . $platformWhere; + } else { + $map['_string'] = $platformWhere; + } + } + // if (intval(($endTime + 1) - $startTime) / (24 * 3600) <= 31) { // $map1 = $map; // $map1['pay_status'] = 1; @@ -8149,6 +8160,7 @@ class ExportController extends Controller array('balance_coin_count','平台币直充支出'), array('inside_cash_count','内充支出'), array('all_cash_count','游戏内充值合计'), + array('agg_amount','聚合平台数据'), array('notice_fail_count','通知失败合计'), ); @@ -8181,7 +8193,38 @@ class ExportController extends Controller } $xlsData = D("spend")->gameStatistics($map); + + $uniqueCodes = array_column($xlsData, '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, 'started_at' => I('timestart', ''), 'ended_at' => I('timeend', '')]); + $aggData = []; + $aggTotal = '0.00'; + if ($result['code'] == '0000') { + $aggData = $result['data']['records']; + $aggTotal = $result['data']['total']; + } + + $exceptIds = []; foreach ($xlsData 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, '.', ''); + } + $xlsData[$key]['agg_amount'] = $aggAmount; + if ($aggAmount != '0.00') { + $value['cash_count'] = 0; + $value['balance_coin_count'] = 0; + $value['inside_cash_count'] = 0; + $exceptIds[] = $value['game_id']; + } // $xlsData[$key]['game_name'] = substr($value["game_name"],0,strrpos($value["game_name"],'(')); $xlsData[$key]['all_cash_count'] = $value['cash_count'] + $value['balance_coin_count'] + $value['inside_cash_count']; if ($value['sdk_version'] == 1) { @@ -8190,6 +8233,14 @@ class ExportController extends Controller $xlsData[$key]['sdk_version'] = '苹果'; } } + + 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']; @@ -8203,6 +8254,7 @@ class ExportController extends Controller 'balance_coin_count'=>$sumBalance, 'inside_cash_count'=>$sumInside, 'all_cash_count'=>$sumAll, + 'agg_amount' => $aggTotal, 'notice_fail_count'=>$sumNoticeFail]]; $xlsData = array_merge($xlsData,$sumData); $this->exportAddOperationLog("Finance/gameStatistics","充值-财务管理-游戏统计-导出"); diff --git a/Application/Admin/Controller/SpendController.class.php b/Application/Admin/Controller/SpendController.class.php index fc537e30a..aaa926a04 100644 --- a/Application/Admin/Controller/SpendController.class.php +++ b/Application/Admin/Controller/SpendController.class.php @@ -107,7 +107,16 @@ class SpendController extends ThinkController } else { $order = ' pay_time desc '; } - + if (I('platform_type', 0) != 0) { + $sy = I('platform_type', 0) == 1 ? '=' : '<>'; + $platformWhere = 'exists (select 1 from tab_game where id = tab_spend.game_id and unique_code ' . $sy . ' "")'; + if (isset($map['_string']) && $map['_string']) { + $map['_string'] = $map['_string'] . ' and ' . $platformWhere; + } else { + $map['_string'] = $platformWhere; + } + } + // if (intval(($endTime + 1) - $startTime) / (24 * 3600) <= 31) { // $map1 = $map; // $map1['pay_status'] = 1; diff --git a/Application/Admin/View/Spend/lists.html b/Application/Admin/View/Spend/lists.html index d2a73e5be..fd938663e 100644 --- a/Application/Admin/View/Spend/lists.html +++ b/Application/Admin/View/Spend/lists.html @@ -132,6 +132,13 @@ +
+ +
From ff47282287992cb5850fcaa2e290898fb159a868 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 27 Jul 2020 16:39:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/ConsoleController.class.php | 2 +- Application/Admin/Controller/FinanceController.class.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index 35305e7ef..771cf52d1 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -127,7 +127,7 @@ class ConsoleController extends Think { public function testAggregate() { $client = new AggregateClient(); - $result = $client->api('game-data', ['unique_codes' => ['xmjs'], 'started_at' => '2020-06-27', 'ended_at' => '2020-07-27']); + $result = $client->api('game-data', ['unique_codes' => ['w123'], 'started_at' => '2019-06-27', 'ended_at' => '2020-07-27']); var_dump($result); } diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php index 1faf16f15..628198933 100644 --- a/Application/Admin/Controller/FinanceController.class.php +++ b/Application/Admin/Controller/FinanceController.class.php @@ -761,9 +761,9 @@ class FinanceController extends ThinkController $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; + $data[$key]['cash_count'] = $value['cash_count'] = 0; + $data[$key]['balance_coin_count'] = $value['balance_coin_count'] = 0; + $data[$key]['inside_cash_count'] = $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,'.','');