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] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=B9=B3=E5=8F=B0->=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=AE=A1=E7=90=86->=E8=AE=A2=E5=8D=95=E6=9F=A5?= =?UTF-8?q?=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);