From c5bc21cb36de2de345b9e7c7d2cd0a81409bc835 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Wed, 23 Dec 2020 20:14:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B8=B8=E6=88=8F=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ExportController.class.php | 406 +++++++++--------- .../Admin/View/Finance/gameStatistics.html | 12 +- 2 files changed, 204 insertions(+), 214 deletions(-) diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 131d99eca..1258e596f 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -8352,212 +8352,212 @@ class ExportController extends Controller /** *充值-》财务管理-》游戏统计-》导出 */ - public function exportGameStatistics() { - $month = I("count_date"); - $xlsName = $month . '游戏统计导出'; - - $xlsCell = array( - array('game_name','游戏'), - array('sdk_version','设备类型'), - array('game_type_name','游戏类型'), - array('partner_name','合作公司'), - array('cash_count','游戏现金金额'), - array('balance_coin_count','平台币直充支出'), - array('inside_cash_count','内充支出'), - array('all_cash_count','游戏内充值合计'), - array('notice_fail_count','联运通知失败合计'), - array('agg_wm_amount','聚合万盟数据'), - array('agg_wm_failed_amount','聚合万盟通知失败'), - array('test_amount','聚合平台测试订单'), - array('agg_amount','聚合其他渠道数据'), - array('agg_failed_amount','聚合其他渠道通知失败订单'), - ); - - $map = []; - - $searchGameIds = null; - $game_ids = array_column(getGameByName(I("game_name"), I("sdk_type")), 'id'); - $gameWhere = []; - $testStrWhere = '1=1'; - if ($game_ids) { - $map['s.game_id'] = ['in', $game_ids]; - $gameWhere['id'] = ['in', $game_ids]; - } - - - if (!empty(I('partner_id'))) { - $map['g.partner_id'] = I('partner_id'); - $gameWhere['partner_id'] = I('partner_id'); - } - - if (!empty(I('timestart'))) { - $timestart = strtotime(I('timestart')); - $map['_string'] = "s.payed_time >= {$timestart}"; - $testStrWhere .= " and pay_time >= {$timestart}"; - } - - if (!empty(I('timeend'))) { - $timeend = strtotime(I('timeend') . ' 23:59:59'); - if (!empty($map['_string'])) { - $map['_string'] .= " and "; - } - $map['_string'] .= " s.pay_time <= {$timeend}"; - $testStrWhere .= " and pay_time <= {$timeend}"; - } - - if (!empty(I('game_type_id'))) { - $map['g.game_type_id'] = I('game_type_id'); - $gameWhere['game_type_id'] = I('game_type_id', 0); - } + // public function exportGameStatistics() { + // $month = I("count_date"); + // $xlsName = $month . '游戏统计导出'; + + // $xlsCell = array( + // array('game_name','游戏'), + // array('sdk_version','设备类型'), + // array('game_type_name','游戏类型'), + // array('partner_name','合作公司'), + // array('cash_count','游戏现金金额'), + // array('balance_coin_count','平台币直充支出'), + // array('inside_cash_count','内充支出'), + // array('all_cash_count','游戏内充值合计'), + // array('notice_fail_count','联运通知失败合计'), + // array('agg_wm_amount','聚合万盟数据'), + // array('agg_wm_failed_amount','聚合万盟通知失败'), + // array('test_amount','聚合平台测试订单'), + // array('agg_amount','聚合其他渠道数据'), + // array('agg_failed_amount','聚合其他渠道通知失败订单'), + // ); + + // $map = []; + + // $searchGameIds = null; + // $game_ids = array_column(getGameByName(I("game_name"), I("sdk_type")), 'id'); + // $gameWhere = []; + // $testStrWhere = '1=1'; + // if ($game_ids) { + // $map['s.game_id'] = ['in', $game_ids]; + // $gameWhere['id'] = ['in', $game_ids]; + // } + + + // if (!empty(I('partner_id'))) { + // $map['g.partner_id'] = I('partner_id'); + // $gameWhere['partner_id'] = I('partner_id'); + // } + + // if (!empty(I('timestart'))) { + // $timestart = strtotime(I('timestart')); + // $map['_string'] = "s.payed_time >= {$timestart}"; + // $testStrWhere .= " and pay_time >= {$timestart}"; + // } + + // if (!empty(I('timeend'))) { + // $timeend = strtotime(I('timeend') . ' 23:59:59'); + // if (!empty($map['_string'])) { + // $map['_string'] .= " and "; + // } + // $map['_string'] .= " s.pay_time <= {$timeend}"; + // $testStrWhere .= " and pay_time <= {$timeend}"; + // } + + // if (!empty(I('game_type_id'))) { + // $map['g.game_type_id'] = I('game_type_id'); + // $gameWhere['game_type_id'] = I('game_type_id', 0); + // } - $searchGameIds = M('game', 'tab_')->where($gameWhere)->getField('id', true); - - $xlsData = D("spend")->gameStatistics($map); - - $uniqueCodes = array_column($xlsData, 'unique_code'); - $gameIds = array_column($xlsData, 'game_id'); - $uniqueCodes = array_filter($uniqueCodes, function($value) { - if ($value) { - return true; - } - return false; - }); + // $searchGameIds = M('game', 'tab_')->where($gameWhere)->getField('id', true); + + // $xlsData = D("spend")->gameStatistics($map); + + // $uniqueCodes = array_column($xlsData, 'unique_code'); + // $gameIds = array_column($xlsData, 'game_id'); + // $uniqueCodes = array_filter($uniqueCodes, function($value) { + // if ($value) { + // return true; + // } + // return false; + // }); - $gameSets = M('game_set', 'tab_')->field(['game_id', 'pay_notify_url'])->select(); - $gameSets = index_by_column('game_id', $gameSets); - - $searchGameCodes = []; - $testList = []; - $testWhere = [ - 'game_id' => 0, - '_string' => $testStrWhere, - ]; - if (count($searchGameIds) > 0) { - $searchGameCodes = M('game', 'tab_')->where(['id' => ['in', $searchGameIds], 'unique_code' => ['neq', '']])->getField('unique_code', true); - $searchGameCodes = array_unique($searchGameCodes); - $testWhere['game_id'] = ['in', $searchGameIds]; - - $testRows = M('test_order', 'tab_') - ->field(['game_id', 'sum(pay_amount) amount']) - ->where($testWhere) - ->group('game_id') - ->select(); - foreach ($testRows as $testRow) { - $testList[$testRow['game_id']] = round(floatval($testRow['amount']), 2); - } - } + // $gameSets = M('game_set', 'tab_')->field(['game_id', 'pay_notify_url'])->select(); + // $gameSets = index_by_column('game_id', $gameSets); + + // $searchGameCodes = []; + // $testList = []; + // $testWhere = [ + // 'game_id' => 0, + // '_string' => $testStrWhere, + // ]; + // if (count($searchGameIds) > 0) { + // $searchGameCodes = M('game', 'tab_')->where(['id' => ['in', $searchGameIds], 'unique_code' => ['neq', '']])->getField('unique_code', true); + // $searchGameCodes = array_unique($searchGameCodes); + // $testWhere['game_id'] = ['in', $searchGameIds]; + + // $testRows = M('test_order', 'tab_') + // ->field(['game_id', 'sum(pay_amount) amount']) + // ->where($testWhere) + // ->group('game_id') + // ->select(); + // foreach ($testRows as $testRow) { + // $testList[$testRow['game_id']] = round(floatval($testRow['amount']), 2); + // } + // } - $client = new AggregateClient(); - $result = $client->api('game-data', [ - 'unique_codes' => $uniqueCodes, - 'started_at' => I('timestart', ''), - 'ended_at' => I('timeend', ''), - 'search_games' => $searchGameCodes, - 'device_type' => I("sdk_type", 0), - ]); - - $aggData = []; - $aggWmData = []; - $aggFailData = []; - $aggWmFailData = []; - $aggTotal = '0.00'; - $aggWmTotal = '0.00'; - $aggFailTotal = '0.00'; - $aggWmFailTotal = '0.00'; - if ($result['code'] == '0000') { - $aggData = $result['data']['records'] ?? []; - $aggWmData = $result['data']['wm_records'] ?? []; - $aggFailData = $result['data']['fail_records'] ?? []; - $aggWmFailData = $result['data']['wm_fail_records'] ?? []; - $aggTotal = $result['data']['total'] ?? '0.00'; - $aggWmTotal = $result['data']['wm_total'] ?? '0.00'; - $aggFailTotal = $result['data']['fail_total'] ?? '0.00'; - $aggWmFailTotal = $result['data']['wm_fail_total'] ?? '0.00'; - } - - $exceptIds = getAggExceptIds($gameSets); - - foreach ($xlsData as $key => $value) { - $aggAmount = '0.00'; - $aggWmAmount = '0.00'; - $aggFailAmount = '0.00'; - $aggWmFailAmount = '0.00'; - $testAmount = '0.00'; - $deviceType = $value['sdk_version'] == 1 ? 'android' : 'ios'; - if ($value['unique_code']) { - if (isset($aggData[$value['unique_code']]) && isset($aggData[$value['unique_code']][$deviceType])) { - $aggAmount = number_format($aggData[$value['unique_code']][$deviceType], 2, '.', ''); - } - if (isset($aggWmData[$value['unique_code']]) && isset($aggWmData[$value['unique_code']][$deviceType])) { - $aggWmAmount = number_format($aggWmData[$value['unique_code']][$deviceType], 2, '.', ''); - } - if (isset($aggFailData[$value['unique_code']]) && isset($aggFailData[$value['unique_code']][$deviceType])) { - $aggFailAmount = number_format($aggFailData[$value['unique_code']][$deviceType], 2, '.', ''); - } - if (isset($aggWmFailData[$value['unique_code']]) && isset($aggWmFailData[$value['unique_code']][$deviceType])) { - $aggWmFailAmount = number_format($aggWmFailData[$value['unique_code']][$deviceType], 2, '.', ''); - } - - } - $xlsData[$key]['agg_amount'] = $aggAmount; - $xlsData[$key]['agg_wm_amount'] = $aggWmAmount; - $xlsData[$key]['agg_failed_amount'] = $aggFailAmount; - $xlsData[$key]['agg_wm_failed_amount'] = $aggWmFailAmount; - if (isset($gameSets[$value['game_id']]) && isAggGame($gameSets[$value['game_id']]['pay_notify_url'])) { - $xlsData[$key]['cash_count'] = $value['cash_count'] = 0; - $xlsData[$key]['balance_coin_count'] = $value['balance_coin_count'] = 0; - $xlsData[$key]['inside_cash_count'] = $value['inside_cash_count'] = 0; - $testAmount = $testList[$value['game_id']] ?? '0.00'; - } - - $xlsData[$key]['test_amount'] = $testAmount; - // $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) { - $xlsData[$key]['sdk_version'] = '安卓'; - } else if ($value['sdk_version'] == 2) { - $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) . ")"; - } - } - - $testWhere['_string'] .= ' and game_id in(' . implode(',', $exceptIds) . ')'; - - $testAllAmount = M('test_order', 'tab_')->where($testWhere)->sum('pay_amount'); - - $totalData = D("spend")->totalGameStatistics($map); - - $sumCash = $totalData['cash_count']; - $sumBalance = $totalData['balance_coin_count']; - $sumInside = $totalData['inside_cash_count']; - $sumNoticeFail = $totalData['notice_fail_count']? $totalData['notice_fail_count']:0; - $sumAll = $sumCash + $sumBalance + $sumInside; - $sumData = [ - [ - 'game_name'=>'总计', - 'cash_count'=>$sumCash, - 'balance_coin_count'=>$sumBalance, - 'inside_cash_count'=>$sumInside, - 'all_cash_count'=>$sumAll, - 'notice_fail_count'=>$sumNoticeFail, - 'agg_wm_amount' => $aggWmTotal, - 'agg_wm_failed_amount' => $aggWmFailTotal, - 'test_amount' => round(floatval($testAllAmount), 2), - 'agg_amount' => $aggTotal, - 'agg_failed_amount' => $aggFailTotal, - ] - ]; - $xlsData = array_merge($xlsData,$sumData); - $this->exportAddOperationLog("Finance/gameStatistics","充值-财务管理-游戏统计-导出"); - $this->exportExcel($xlsName, $xlsCell, $xlsData); - } + // $client = new AggregateClient(); + // $result = $client->api('game-data', [ + // 'unique_codes' => $uniqueCodes, + // 'started_at' => I('timestart', ''), + // 'ended_at' => I('timeend', ''), + // 'search_games' => $searchGameCodes, + // 'device_type' => I("sdk_type", 0), + // ]); + + // $aggData = []; + // $aggWmData = []; + // $aggFailData = []; + // $aggWmFailData = []; + // $aggTotal = '0.00'; + // $aggWmTotal = '0.00'; + // $aggFailTotal = '0.00'; + // $aggWmFailTotal = '0.00'; + // if ($result['code'] == '0000') { + // $aggData = $result['data']['records'] ?? []; + // $aggWmData = $result['data']['wm_records'] ?? []; + // $aggFailData = $result['data']['fail_records'] ?? []; + // $aggWmFailData = $result['data']['wm_fail_records'] ?? []; + // $aggTotal = $result['data']['total'] ?? '0.00'; + // $aggWmTotal = $result['data']['wm_total'] ?? '0.00'; + // $aggFailTotal = $result['data']['fail_total'] ?? '0.00'; + // $aggWmFailTotal = $result['data']['wm_fail_total'] ?? '0.00'; + // } + + // $exceptIds = getAggExceptIds($gameSets); + + // foreach ($xlsData as $key => $value) { + // $aggAmount = '0.00'; + // $aggWmAmount = '0.00'; + // $aggFailAmount = '0.00'; + // $aggWmFailAmount = '0.00'; + // $testAmount = '0.00'; + // $deviceType = $value['sdk_version'] == 1 ? 'android' : 'ios'; + // if ($value['unique_code']) { + // if (isset($aggData[$value['unique_code']]) && isset($aggData[$value['unique_code']][$deviceType])) { + // $aggAmount = number_format($aggData[$value['unique_code']][$deviceType], 2, '.', ''); + // } + // if (isset($aggWmData[$value['unique_code']]) && isset($aggWmData[$value['unique_code']][$deviceType])) { + // $aggWmAmount = number_format($aggWmData[$value['unique_code']][$deviceType], 2, '.', ''); + // } + // if (isset($aggFailData[$value['unique_code']]) && isset($aggFailData[$value['unique_code']][$deviceType])) { + // $aggFailAmount = number_format($aggFailData[$value['unique_code']][$deviceType], 2, '.', ''); + // } + // if (isset($aggWmFailData[$value['unique_code']]) && isset($aggWmFailData[$value['unique_code']][$deviceType])) { + // $aggWmFailAmount = number_format($aggWmFailData[$value['unique_code']][$deviceType], 2, '.', ''); + // } + + // } + // $xlsData[$key]['agg_amount'] = $aggAmount; + // $xlsData[$key]['agg_wm_amount'] = $aggWmAmount; + // $xlsData[$key]['agg_failed_amount'] = $aggFailAmount; + // $xlsData[$key]['agg_wm_failed_amount'] = $aggWmFailAmount; + // if (isset($gameSets[$value['game_id']]) && isAggGame($gameSets[$value['game_id']]['pay_notify_url'])) { + // $xlsData[$key]['cash_count'] = $value['cash_count'] = 0; + // $xlsData[$key]['balance_coin_count'] = $value['balance_coin_count'] = 0; + // $xlsData[$key]['inside_cash_count'] = $value['inside_cash_count'] = 0; + // $testAmount = $testList[$value['game_id']] ?? '0.00'; + // } + + // $xlsData[$key]['test_amount'] = $testAmount; + // // $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) { + // $xlsData[$key]['sdk_version'] = '安卓'; + // } else if ($value['sdk_version'] == 2) { + // $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) . ")"; + // } + // } + + // $testWhere['_string'] .= ' and game_id in(' . implode(',', $exceptIds) . ')'; + + // $testAllAmount = M('test_order', 'tab_')->where($testWhere)->sum('pay_amount'); + + // $totalData = D("spend")->totalGameStatistics($map); + + // $sumCash = $totalData['cash_count']; + // $sumBalance = $totalData['balance_coin_count']; + // $sumInside = $totalData['inside_cash_count']; + // $sumNoticeFail = $totalData['notice_fail_count']? $totalData['notice_fail_count']:0; + // $sumAll = $sumCash + $sumBalance + $sumInside; + // $sumData = [ + // [ + // 'game_name'=>'总计', + // 'cash_count'=>$sumCash, + // 'balance_coin_count'=>$sumBalance, + // 'inside_cash_count'=>$sumInside, + // 'all_cash_count'=>$sumAll, + // 'notice_fail_count'=>$sumNoticeFail, + // 'agg_wm_amount' => $aggWmTotal, + // 'agg_wm_failed_amount' => $aggWmFailTotal, + // 'test_amount' => round(floatval($testAllAmount), 2), + // 'agg_amount' => $aggTotal, + // 'agg_failed_amount' => $aggFailTotal, + // ] + // ]; + // $xlsData = array_merge($xlsData,$sumData); + // $this->exportAddOperationLog("Finance/gameStatistics","充值-财务管理-游戏统计-导出"); + // $this->exportExcel($xlsName, $xlsCell, $xlsData); + // } // public function gameStatisticsDetail() { // $game_name = I("game_name"); diff --git a/Application/Admin/View/Finance/gameStatistics.html b/Application/Admin/View/Finance/gameStatistics.html index 8be9c3d0b..5092737af 100644 --- a/Application/Admin/View/Finance/gameStatistics.html +++ b/Application/Admin/View/Finance/gameStatistics.html @@ -154,17 +154,7 @@ style="width: 100px;border: #3C95C8 solid 1px;">搜索 - 导出 + 导出