From 1a4bdc424addb7bac3e2569641bc0f179ab3deb5 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Mon, 2 Dec 2019 22:02:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=B9=B3=E5=8F=B0->?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=AE=A1=E7=90=86->=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2--=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Controller/QueryController.class.php | 69 ++++++++++++------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index c3921b8fe..877e15f42 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -94,7 +94,7 @@ class QueryController extends BaseController $income = '0.00'; if (intval($endTime - $begTime) / (24 * 3600) <= 31) { $data = M('Spend', 'tab_') - ->field('tab_spend.*,tab_promote.account as pro_account,tab_promote.real_name as pro_real_name,tab_promote.chain as chain') + ->field('tab_spend.*,tab_promote.account as pro_account,tab_promote.real_name as pro_real_name,tab_promote.chain as chain,tab_promote.level,tab_promote.parent_id') ->join('tab_game on tab_spend.game_id = tab_game.id') ->join('left join tab_promote on tab_spend.promote_id = tab_promote.id') ->where($map) @@ -116,32 +116,49 @@ class QueryController extends BaseController ->find()['income']; } if (!empty($data)) { + $promoteIdData = []; + foreach ($data as $list) { + switch ($list['level']) { + case 3: + $promoteIdData[] = $list['parent_id']; + break; + case 4: + $promoteIdData[] = $list['parent_id']; + $chain = trim($list['chain'], '/'); + $chainArr = explode('/', $chain); + $promoteIdData[] = $chainArr[1]; + break; + } + } + $promoteData = []; + if (!empty($promoteIdData)) { + $promoteIdData = array_unique($promoteIdData); + $promoteData = M('promote', 'tab_')->where(array('id' => ['in',$promoteIdData]))->getField('id,account,real_name'); + } foreach ($data as &$list) { - $list['p_p_pro_account'] = $list['pro_account']; - $list['p_p_pro_real_name'] = $list['pro_real_name']; - $list['p_pro_account'] = $list['pro_account']; - $list['p_pro_real_name'] = $list['pro_real_name']; - if (!empty($list['chain'])) { - $chain = trim($list['chain'], '/'); - $chainArr = explode('/', $chain); - if (!empty($chainArr[1])) { - $thisPromoteData1 = D('Promote') - ->field('account,real_name') - ->where(array('id' => $chainArr[1])) - ->find(); - $list['p_p_pro_account'] = $thisPromoteData1['account']; //部门长 - $list['p_p_pro_real_name'] = $thisPromoteData1['real_name']; - } - if (!empty($chainArr[2])) { - $thisPromoteData2 = D('Promote') - ->field('account,real_name') - ->where(array('id' => $chainArr[2])) - ->find(); - $list['p_pro_account'] = $thisPromoteData2['account']; //组长 - $list['p_pro_real_name'] = $thisPromoteData2['real_name']; - } - - + switch ($list['level']) { + case 1: + case 2: + $list['p_p_pro_account'] = $list['pro_account']; + $list['p_p_pro_real_name'] = $list['pro_real_name']; + $list['p_pro_account'] = $list['pro_account']; + $list['p_pro_real_name'] = $list['pro_real_name']; + break; + case 3: + $list['p_p_pro_account'] = $promoteData[$list['parent_id']]['account']; + $list['p_p_pro_real_name'] = $promoteData[$list['parent_id']]['real_name']; + $list['p_pro_account'] = $list['pro_account']; + $list['p_pro_real_name'] = $list['pro_real_name']; + break; + case 4: + $promoteIdData[] = $list['parent_id']; + $chain = trim($list['chain'], '/'); + $chainArr = explode('/', $chain); + $list['p_p_pro_account'] = $promoteData[$chainArr[1]]['account']; + $list['p_p_pro_real_name'] = $promoteData[$chainArr[1]]['real_name']; + $list['p_pro_account'] = $promoteData[$list['parent_id']]['account']; + $list['p_pro_real_name'] = $promoteData[$list['parent_id']]['real_name']; + break; } $list['user_account'] = substr($list['user_account'], 0, 2) . '******' . substr($list['user_account'], 8); From c8d515a0ee2c261e7d07be5f000db20117362569 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Mon, 2 Dec 2019 22:53:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=B9=B3=E5=8F=B0->?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=AE=A1=E7=90=86->=E5=85=85=E5=80=BC?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6--=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Home/Controller/QueryController.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 877e15f42..d928c9914 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1845,7 +1845,7 @@ class QueryController extends BaseController $field = $fieldUC . ',' . $fieldUI; $subQuery = M('user_play_data_count', 'tab_')->alias('uc') ->field($field) - ->join('left join tab_user_play_info as ui on ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id') + ->join('left join tab_user_play_info as ui on ui.user_id = uc.user_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(); @@ -1854,7 +1854,7 @@ class QueryController extends BaseController ->order($orderBy); $total = M('user_play_data_count', 'tab_')->alias('uc') ->field($fieldUC) - ->join('left join tab_user_play_info as ui on ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id') + ->join('left join tab_user_play_info as ui on ui.user_id = uc.user_id and ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id') ->where($map) ->find();