From 965ad46dce0e36009bb1e16557f305c2b213a91b Mon Sep 17 00:00:00 2001 From: zhengchanglong Date: Mon, 25 Nov 2019 20:27:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=85=85=E5=80=BC=E6=B1=87=E6=80=BB?= =?UTF-8?q?=E5=AF=BC=E5=87=BABUG=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/RechargeSumController.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Controller/RechargeSumController.class.php b/Application/Admin/Controller/RechargeSumController.class.php index 3c6b68fa8..a39b95b79 100644 --- a/Application/Admin/Controller/RechargeSumController.class.php +++ b/Application/Admin/Controller/RechargeSumController.class.php @@ -105,7 +105,7 @@ class RechargeSumController extends ThinkController } $count = count($data); - + $export_data = $data; $page = set_pagination($count, $row); if ($page) { $this->assign('_page', $page); @@ -122,7 +122,7 @@ class RechargeSumController extends ThinkController //判断是否执行导出 if (I('export') == 1) { - $this->exportSum($data); + $this->exportSum($export_data); } $this->assign('meta_title', "充值汇总"); $this->assign('list_data', $data); From 02ea000f2aa84a8142de576c4439257eddd12869 Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Mon, 25 Nov 2019 20:29:59 +0800 Subject: [PATCH 2/2] charge --- .../Controller/DownloadController.class.php | 97 ++++++++----------- 1 file changed, 41 insertions(+), 56 deletions(-) diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index 30745ad83..281cdee41 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -1289,25 +1289,12 @@ class DownloadController extends BaseController { $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); - $map2[] = [ - '_logic' => 'or', - 'id' => $queryPromote['id'], - 'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'] - ]; + $map2['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']; $ids = M('promote', 'tab_')->where($map2)->getField('id', true); - if(empty($ids)) { - $ids = array(); - } - if(empty($levelPromote)) { - array_push($ids,PID); - } - // array_push($ids,$queryPromote['id']); - if (!empty($ids)) { - $map['promote_id'] = ['in',$ids]; - - }else { - $map['_string'] = '1<>1'; - } + $ids[] = $queryPromote['id']; + + $map = ['promote_id' => ['in', $ids]]; + $subMap = ['promote_id' => ['in', $ids]]; if ($gameId != 0) { $gameMap['relation_game_id'] = $gameId; @@ -1315,7 +1302,9 @@ class DownloadController extends BaseController { $gameMap['sdk_version'] = $sdkVersion; } $gameId1 = M('game', 'tab_')->where($gameMap)->getField('id', true); + $map['game_id'] = ['in', $gameId1]; + $subMap['game_id'] = ['in', $gameId1]; } if ($serverId != 0) { $map['server_id'] = $serverId; @@ -2816,21 +2805,33 @@ class DownloadController extends BaseController { $subMap = []; if(!empty($map['game_id'])) { $subMap['game_id'] = $map['game_id']; + $map['uc.game_id'] = $map['game_id']; + unset($map['game_id']); } if(!empty($map['server_id'])) { $subMap['server_id'] = $map['server_id']; + $map['ui.server_id'] = $map['server_id']; + unset($map['server_id']); + } + if(!empty($map['role_name'])) { + $map['ui.role_name'] = $map['role_name']; + unset($map['role_name']); + } + + if(!empty($map['user_account'])) { + $map['ui.user_account'] = $map['user_account']; + unset($map['user_account']); + } + if(!empty($map['promote_id'])) { + $map['uc.promote_id'] = $map['promote_id']; + unset($map['promote_id']); } $costBegin = $map['costbegin']; $costEnd = $map['costend']; unset($map['costbegin']); unset($map['costend']); - + $nowTime = strtotime(date('Y-m-d 00:00:00', time())); $subMap['create_time'] = ['between', [$map['begintime'], $map['endtime'] - 1]]; - $roleIdMap = $subMap; - $roleIds = M('user_play_data_count', 'tab_')->where($roleIdMap)->group('role_id')->getField('role_id', true); - if (count($roleIds) > 0) { - $map['role_id'] = ['in', $roleIds]; - } if ($costBegin != '' || $costEnd != '') { $having = ''; if ($costBegin != '' && $costEnd != '') { @@ -2845,40 +2846,24 @@ class DownloadController extends BaseController { ->group('game_id,server_id,role_id') ->having($having) ->buildSql(); - $map['_string'] = 'role_id in (' . $subQuery . ')'; - } - $spendMap['uc.create_time'] = ['between', [$map['begintime'], $map['endtime'] - 1]]; - $spendMap['_string'] = 'uc.game_id = tab_user_play_info.game_id and uc.server_id = tab_user_play_info.server_id and uc.role_id = tab_user_play_info.role_id'; - // $map['create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')) - 6*24*3600, strtotime(date('Y-m-d 23:59:59'))]]; - $sqlCost = M('user_play_data_count', 'tab_')->alias('uc') - ->field('sum(uc.recharge_cost) cost') - ->where($spendMap) - ->buildSql(); - - $sqlCount = M('user_play_data_count', 'tab_')->alias('uc') - ->field('sum(uc.recharge_count) count') - ->where($spendMap) - ->buildSql(); - - $spendMap['uc.create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; - - $sqlTodayCost = M('user_play_data_count', 'tab_')->alias('uc') - ->field('sum(uc.recharge_count) count') - ->where($spendMap) - ->buildSql(); + $map['_string'] = 'ui.role_id in (' . $subQuery . ')'; + } + $map['uc.create_time'] = ['between', [$map['begintime'], $map['endtime'] - 1]]; unset($map['begintime']); unset($map['endtime']); - $subQuery = M('user_play_info', 'tab_') - ->field("*,$sqlCost as recharge_cost,$sqlCount as recharge_count,$sqlTodayCost as recharge_cost_today") - ->where($map) - ->having('recharge_cost > 0') - ->order('play_time desc') - ->buildSql(); - $roles = M()->field(' * ') - ->table($subQuery) - ->alias('a') - ->order('play_time desc') - ->select(); + //$spendMap['_string'] = 'uc.game_id = tab_user_play_info.game_id and uc.server_id = tab_user_play_info.server_id and uc.role_id = tab_user_play_info.role_id'; + $fieldUC = "sum(uc.recharge_cost) recharge_cost,sum(uc.recharge_count) recharge_count,sum(if(uc.create_time = {$nowTime},uc.recharge_cost,0)) as recharge_cost_today"; + $fieldUI = "ui.user_account,ui.game_name,ui.role_name,ui.role_level,ui.server_name,ui.play_time,ui.play_ip,ui.promote_account,ui.sdk_version"; + $field = $fieldUC . ',' . $fieldUI; + $subQuery = M('user_play_data_count', 'tab_')->alias('uc') + ->field($field) + ->join('tab_user_play_info as ui on ui.promote_id = uc.promote_id and ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id') + ->where($map) + ->group('uc.role_id,uc.server_id,uc.game_id') + ->buildSql(); + $roles = M()->alias('record') + ->table($subQuery) + ->select(); foreach ($roles as $role) { $records[] = [ 'user_account' => encryption($role['user_account']),