diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 1ab0c1f48..459ebde40 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -200,7 +200,7 @@ function get_promote_list($select='') { */ function get_all_toppromote(){ $map['status']=1; - $map['parent_id']=0; + $map['level']=['lt', 4]; $list = M("Promote","tab_")->where($map)->select(); if (empty($list)){return '';} return $list; @@ -1364,14 +1364,25 @@ function get_pos_game($type=16){ return $data; } -function get_promote_levels($id=0){ - $data = M('promote','tab_')->field('parent_id,grand_id')->where(array('id'=>$id))->find(); - if($data['parent_id']==0&&$data['grand_id']==0){ - return '一级推广员'; - }elseif($data['parent_id']>0&&$data['grand_id']==0){ - return '二级推广员'; - }elseif($data['parent_id']>0&&$data['grand_id']>0){ - return '三级推广员'; +function get_promote_levels($id = 0) +{ + $data = M('promote', 'tab_')->field('parent_id, level')->where(array('id' => $id))->find(); + switch ($data['level']) { + case '1': + return "一级推广员"; + break; + case '2': + return "二级推广员"; + break; + case '3': + return "三级推广员"; + break; + case '4': + return "四级推广员"; + break; + + default: + return ''; } } diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index 98f059052..5c9666a5c 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -23,7 +23,7 @@ class MemberController extends ThinkController $maps['tab_user.promote_id'] = 0; $hav .= "tab_user.promote_id = 0"; } else{ - $promoter_ids = D("Promote")->where("parent_id={$_REQUEST['promote_id']} or grand_id={$_REQUEST['promote_id']} or id={$_REQUEST['promote_id']}")->field('id')->select(); + $promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select(); if ($promoter_ids) { $maps['tab_user.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))]; $hav .= "tab_user.promote_id in (".implode(',', array_column($promoter_ids, 'id')).") "; diff --git a/Application/Admin/Controller/PromoteController.class.php b/Application/Admin/Controller/PromoteController.class.php index 455386841..c17d531f2 100644 --- a/Application/Admin/Controller/PromoteController.class.php +++ b/Application/Admin/Controller/PromoteController.class.php @@ -86,14 +86,8 @@ unset($_REQUEST['parent_id']); } } - if(I('promote_level') == 1){ - $map['parent_id'] = 0; - }elseif(I('promote_level') == 2){ - $map['parent_id'] = ['neq',0]; - $map['grand_id'] = 0; - }elseif (I('promote_level') == 3) { - $map['parent_id'] = ['neq',0]; - $map['grand_id'] = ['neq',0]; + if (I("promote_level")) { + $map['level'] = I("promote_level"); } $this->m_title = '推广员列表'; diff --git a/Application/Admin/Controller/RechargeSumController.class.php b/Application/Admin/Controller/RechargeSumController.class.php index 8bd895682..02fcff00a 100644 --- a/Application/Admin/Controller/RechargeSumController.class.php +++ b/Application/Admin/Controller/RechargeSumController.class.php @@ -28,6 +28,15 @@ class RechargeSumController extends ThinkController{ $total = ['current'=>0,'sum'=>0]; + if(isset($_REQUEST['promote_id'])){ + if ($_REQUEST['promote_id'] > 0) { + $promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select(); + $promoter_ids ? $rmap['promote_id'] = $map['promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))] : null; + } else { + $rmap['promote_id'] = $map['promote_id'] = 0; + } + } + for($start = $endtime; $start >= $starttime;$start -= 86400) { $startDate = $start; @@ -44,29 +53,6 @@ class RechargeSumController extends ThinkController{ $map['pay_way'] = array('egt',0); } - if(isset($_REQUEST['promote_id'])){ - // switch ($_REQUEST['promote_id']) { - // case 'GUANFANG': - // $map['promote_id'] = 0; - // $rmap['promote_id'] = 0; - // break; - // case 'PROMOTE': - // $map['promote_id'] = array('neq',0); - // $rmap['promote_id'] = array('neq',0); - // break; - // default: - // $map['promote_id'] = $_REQUEST['promote_id']; - // $rmap['promote_id'] = $_REQUEST['promote_id']; - // break; - // } - if ($_REQUEST['promote_id'] > 0) { - $promoter_ids = D("Promote")->where("parent_id={$_REQUEST['promote_id']} or grand_id={$_REQUEST['promote_id']} or id={$_REQUEST['promote_id']}")->field('id')->select(); - $promoter_ids ? $rmap['promote_id'] = $map['promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))] : null; - } else { - $rmap['promote_id'] = $map['promote_id'] = 0; - } - } - //当天注册人数 $registerNum = D('User')->where(array_merge($rmap,array('puid'=>0)))->getField("id",true); diff --git a/Application/Admin/Controller/SpendController.class.php b/Application/Admin/Controller/SpendController.class.php index 688a73315..ec6b90c4a 100644 --- a/Application/Admin/Controller/SpendController.class.php +++ b/Application/Admin/Controller/SpendController.class.php @@ -74,7 +74,7 @@ class SpendController extends ThinkController { if ($_REQUEST['promote_id'] == 0) { $map['promote_id'] = 0; } else { - $map['_complex'] = ['tp.parent_id'=>$_REQUEST['promote_id'], 'tp.grand_id'=>$_REQUEST['promote_id'], 'tp.id'=>$_REQUEST['promote_id'], '_logic' => 'or']; + $map['_complex'] = ['tp.chain'=>['like', "%/{$_REQUEST['promote_id']}/%"], 'tp.id'=>$_REQUEST['promote_id'], '_logic' => 'or']; } $tab_promote_join = "left join tab_promote as tp on tp.id = tab_spend.promote_id"; //unset($_REQUEST['promote_id']); diff --git a/Application/Admin/Controller/UserController.class.php b/Application/Admin/Controller/UserController.class.php index c95dec0b5..c4124f626 100644 --- a/Application/Admin/Controller/UserController.class.php +++ b/Application/Admin/Controller/UserController.class.php @@ -574,7 +574,7 @@ function think_ucenter_md5($str, $key = 'ThinkUCenter'){ if ($_REQUEST['promote_id'] == 0) { $map['promote_id'] = '0'; } else { - $queryStr = "parent_id={$_REQUEST['promote_id']} or grand_id={$_REQUEST['promote_id']} or id={$_REQUEST['promote_id']}"; + $queryStr = "chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}"; $promoter_ids = D("Promote")->where($queryStr)->field('id')->select(); $promoter_ids ? $map['promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))] : null; } diff --git a/Application/Admin/Model/PromoteModel.class.php b/Application/Admin/Model/PromoteModel.class.php index 099349449..d3099116f 100644 --- a/Application/Admin/Model/PromoteModel.class.php +++ b/Application/Admin/Model/PromoteModel.class.php @@ -375,20 +375,18 @@ class PromoteModel extends Model{ public function getPromotersByLevel($level=1) { $result = []; - switch ($level) { - case 1: // 会长 - $result = $this->field("id, nickname, account, real_name")->where("grand_id = 0 and parent_id = 0")->select(); - break; - case 2: // 组长 - $result = $this->field("id, nickname, account, real_name")->where("grand_id = 0 and parent_id > 0")->select(); - break; - case 3: //组员 - $result = $this->field("id, nickname, account, real_name")->where("parent_id > 0 and grand_id > 0")->select(); - break; - } - foreach ($result as &$item) { - $item['nickname'] = "{$item['account']}({$item['real_name']})"; - } + // switch ($level) { + // case 1: // 会长 + // $result = $this->field("id, nickname")->where("grand_id = 0 and parent_id = 0")->select(); + // break; + // case 2: // 组长 + // $result = $this->field("id, nickname")->where("grand_id = 0 and parent_id > 0")->select(); + // break; + // case 3: //组员 + // $result = $this->field("id, nickname")->where("parent_id > 0 and grand_id > 0")->select(); + // break; + // } + $result = $this->field("*")->where("level={$level}")->select(); return $result; } } \ No newline at end of file diff --git a/Application/Admin/View/Member/user_info.html b/Application/Admin/View/Member/user_info.html index 6142d4ff6..92c825e37 100644 --- a/Application/Admin/View/Member/user_info.html +++ b/Application/Admin/View/Member/user_info.html @@ -124,8 +124,9 @@ - @@ -407,7 +408,7 @@ $(function(){ data:{level:$("#promote_level option:selected").val()}, dataType:'json', success:function(response){ - str = ''; + str = ''; // $.each(response.data, function(index, item){ // console.log(item.id); // str += ''; diff --git a/Application/Admin/View/Promote/lists.html b/Application/Admin/View/Promote/lists.html index 533dacbdc..62bfa1f13 100644 --- a/Application/Admin/View/Promote/lists.html +++ b/Application/Admin/View/Promote/lists.html @@ -96,6 +96,7 @@ +
diff --git a/Application/Admin/View/RechargeSum/summation.html b/Application/Admin/View/RechargeSum/summation.html index 585758b64..c761c06cb 100644 --- a/Application/Admin/View/RechargeSum/summation.html +++ b/Application/Admin/View/RechargeSum/summation.html @@ -77,8 +77,9 @@ -
diff --git a/Application/Admin/View/Spend/lists.html b/Application/Admin/View/Spend/lists.html index ca26ce7cb..6d8831616 100644 --- a/Application/Admin/View/Spend/lists.html +++ b/Application/Admin/View/Spend/lists.html @@ -101,8 +101,9 @@ - diff --git a/Application/Admin/View/User/rolelist.html b/Application/Admin/View/User/rolelist.html index 41b135618..00067a910 100644 --- a/Application/Admin/View/User/rolelist.html +++ b/Application/Admin/View/User/rolelist.html @@ -73,8 +73,10 @@ - @@ -249,7 +251,7 @@ $(".select_gallery").select2(); data:{level:$("#promote_level option:selected").val()}, dataType:'json', success:function(response){ - str = ''; + str = ''; // $.each(response.data, function(index, item){ // console.log(item.id); // str += ''; diff --git a/Application/Home/Common/function.php b/Application/Home/Common/function.php index 2805d819e..a15e9e67b 100644 --- a/Application/Home/Common/function.php +++ b/Application/Home/Common/function.php @@ -713,13 +713,23 @@ function sum_promote_total_money($id) function get_promote_levels($id = 0) { - $data = M('promote', 'tab_')->field('parent_id,grand_id')->where(array('id' => $id))->find(); - if ($data['parent_id'] == 0 && $data['grand_id'] == 0) { - return '一级推广员'; - } elseif ($data['parent_id'] > 0 && $data['grand_id'] == 0) { - return '二级推广员'; - } elseif ($data['parent_id'] > 0 && $data['grand_id'] > 0) { - return '三级推广员'; + $data = M('promote', 'tab_')->field('parent_id, level')->where(array('id' => $id))->find(); + switch ($data['level']) { + case '1': + return "一级推广员"; + break; + case '2': + return "二级推广员"; + break; + case '3': + return "三级推广员"; + break; + case '4': + return "四级推广员"; + break; + + default: + return ''; } } diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 03c7f0599..07da8188e 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1113,163 +1113,83 @@ class QueryController extends BaseController $dayList = $this->getDayList($begTime, $endTime + 3600 * 24); $params['dayList'] = $dayList; - $allData['role_num'] = 0; - $allData['user_num'] = 0; - $allData['new_user_num'] = 0; - $allData['new_device_num'] = 0; - $allData['new_ip_num'] = 0; - $allData['login_user_num'] = 0; - $allData['spend_user_num'] = 0; - $allData['spend_num'] = 0; - $allData['spend_all_amount'] = 0; - $allData['spend_cash'] = 0; - $allData['spend_generic'] = 0; - $allData['pay_amount'] = 0; - $allData['spend_discount'] = 0; - $allData['spend_voucher'] = 0; - foreach ($data as &$list) { - $thisDateTime = strtotime($list['day']); - $userPlayInfoWhere['tab_user_play_info.create_time'] = ['between', [$thisDateTime, $thisDateTime + 86399]]; - $userGameLoginWhere['tab_user_game_login_record.login_time'] = ['between', [$thisDateTime, $thisDateTime + 86399]]; - $spendWhere['tab_spend.pay_time'] = ['between', [$thisDateTime, $thisDateTime + 86399]]; - - $list['role_num'] = $userPlayInfoModel - ->join($join) - ->where($userPlayInfoWhere) - ->where($map) - ->order('play_time desc') - ->count();//创角数 - $list['user_num'] = count($userPlayInfoModel - ->join($join) - ->where($userPlayInfoWhere) - ->where($map) - ->group('tab_user_play_info.game_id,tab_user_play_info.user_id') - ->select());//创角用户 - - $newUserNumSql = $userPlayInfoModel - ->table('tab_user_play_info as ti') - ->where($userPlayInfoWhere2) - ->where('ti.user_id = tab_user_play_info.user_id and ti.game_id = tab_user_play_info.game_id and ti.create_time < ' . $thisDateTime) - ->fetchSql(true) - ->count(); - $newUserNumData = $userPlayInfoModel - ->field('tab_user_play_info.create_time,(' . $newUserNumSql . ') as num') - ->join($join) - ->where($userPlayInfoWhere) - ->where($map) - ->group('tab_user_play_info.user_id') - ->having('num = 0') - ->order('tab_user_play_info.id') - ->select(); - $list['new_user_num'] = count($newUserNumData);//新创角用户 - - $newDeviceSql = $userPlayInfoModel - ->table('tab_user_play_info as ti') - ->where($userPlayInfoWhere2) - ->where('ti.create_device_number = tab_user_play_info.create_device_number and ti.game_id = tab_user_play_info.game_id and ti.create_time < ' . $thisDateTime) - ->fetchSql(true) - ->count(); - $newDeviceData = $userPlayInfoModel - ->field('tab_user_play_info.create_time,(' . $newDeviceSql . ') as num') - ->join($join) - ->where($userPlayInfoWhere) - ->where($map) - ->group('tab_user_play_info.create_device_number') - ->having('num = 0') - ->order('tab_user_play_info.id') - ->select(); - $list['new_device_num'] = count($newDeviceData);//新创角设备 - - $newIpNumSql = $userPlayInfoModel - ->table('tab_user_play_info as ti') - ->where($userPlayInfoWhere2) - ->where('ti.create_ip = tab_user_play_info.create_ip and ti.game_id = tab_user_play_info.game_id and ti.create_time < ' . $thisDateTime) - ->fetchSql(true) - ->count(); - $newIpNumData = $userPlayInfoModel - ->field('tab_user_play_info.create_time,(' . $newIpNumSql . ') as num') - ->join($join) - ->where($userPlayInfoWhere) - ->where($map) - ->group('tab_user_play_info.create_ip') - ->having('num = 0') - ->order('tab_user_play_info.id') - ->select(); - $list['new_ip_num'] = count($newIpNumData);//新增创角IP - - $list['login_user_num'] = count(M('UserGameLoginRecord', 'tab_') - ->join($join) - ->where($userGameLoginWhere) - ->where($map) - ->group('tab_user_game_login_record.game_id,tab_user_game_login_record.user_id') - ->select());//登录用户数 - - $list['spend_user_num'] = count(M('Spend', 'tab_') - ->join($join) - ->where($spendWhere) - ->where($map) - ->group('tab_spend.game_id,tab_spend.user_id') - ->select());//充值人数 - $list['spend_num'] = M('Spend', 'tab_') - ->join($join) - ->where($spendWhere) - ->where($map) - ->count();//充值次数 - $list['spend_all_amount'] = M('Spend', 'tab_') - ->join($join) - ->where($spendWhere) - ->where($map) - ->sum('tab_spend.pay_amount');//充值总额 - $list['spend_all_amount'] = empty($list['spend_all_amount']) ? 0 : $list['spend_all_amount']; - - $list['spend_cash'] = M('Spend', 'tab_') - ->join($join) - ->where($spendWhere) - ->where($map) - ->where(array('tab_spend.pay_way' => ['in', '1,2,3,4,5,6'])) - ->sum('tab_spend.pay_amount');//现金充值 - $list['spend_cash'] = empty($list['spend_cash']) ? 0 : $list['spend_cash']; - - $list['spend_generic'] = M('Spend', 'tab_') - ->join($join) - ->where($spendWhere) - ->where($map) - ->where(array('tab_spend.pay_way' => 0)) - ->sum('tab_spend.pay_amount');//通用币 - $list['spend_generic'] = empty($list['spend_generic']) ? 0 : $list['spend_generic']; - - $list['spend_binding'] = M('Spend', 'tab_') - ->join($join) - ->where($spendWhere) - ->where($map) - ->where(array('tab_spend.pay_way' => -1)) - ->sum('tab_spend.pay_amount');//绑定币 - $list['spend_binding'] = empty($list['spend_binding']) ? 0 : $list['spend_binding']; - - $list['spend_discount'] = 0;//折扣币 - $list['spend_voucher'] = 0;//代金券 - - $allData['role_num'] += $list['role_num']; - $allData['user_num'] += $list['user_num']; - $allData['new_user_num'] += $list['new_user_num']; - $allData['new_device_num'] += $list['new_device_num']; - $allData['new_ip_num'] += $list['new_ip_num']; - $allData['login_user_num'] += $list['login_user_num']; - $allData['spend_user_num'] += $list['spend_user_num']; - $allData['spend_num'] += $list['spend_num']; - $allData['spend_all_amount'] = bcadd($allData['spend_all_amount'], $list['spend_all_amount'], 2); - $allData['spend_cash'] = bcadd($allData['spend_cash'], $list['spend_cash'], 2); - $allData['spend_generic'] = bcadd($allData['spend_generic'], $list['spend_generic'], 2); - $allData['spend_binding'] = bcadd($allData['spend_binding'], $list['spend_binding'], 2); - $allData['spend_discount'] = bcadd($allData['spend_discount'], $list['spend_discount'], 2); - $allData['spend_voucher'] = bcadd($allData['spend_voucher'], $list['spend_voucher'], 2); - - $summaryData['role_num'][] = $list['role_num']; - $summaryData['user_num'][] = $list['user_num']; - $summaryData['new_user_num'][] = $list['new_user_num']; - $summaryData['new_device_num'][] = $list['new_device_num']; - $summaryData['spend_user_num'][] = $list['spend_user_num']; - $summaryData['spend_all_amount'][] = $list['spend_all_amount']; + $records = []; + if (intval($endTime - $begTime) / (24 * 3600) <= 30) { + $userRepository = new UserRepository(); + $spendRepository = new SpendRepository(); + $roleNumList = $userRepository->getCreateRoleCountByDay($params);//创角数 + $userNumList = $userRepository->getCreateRoleUserCountByDay($params);//创角用户 + $newUserNumList = $userRepository->getNewCreateRoleUserCountByDay($params);//新创角用户 + $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByDay($params);//新创角设备 + $newIpNumList = $userRepository->getNewCreateRoleIpCountByDay($params);//新创角IP + $loginUserNumList = $userRepository->getLoginCountGroupByDay($params);//登录用户数 + $spendUserNumList = $spendRepository->getPayUserCountGroupByDay($params);//充值人数 + $spendNumList = $spendRepository->getPayCountGroupByDay($params);//充值次数 + $spendAllAmountList = $spendRepository->getPayAmountGroupByDayAndType($params);//充值总额 + $params['pay_way'] = ['in', '1,2,3,4,5,6']; + $spendCashList = $spendRepository->getPayAmountGroupByDayAndType($params);//现金充值 + $params['pay_way'] = 0; + $spendGenericList = $spendRepository->getPayAmountGroupByDayAndType($params);//通用币充值 + $params['pay_way'] = -1; + $spendBindingList = $spendRepository->getPayAmountGroupByDayAndType($params);//绑定币充值 + + $allData['role_num'] = 0; + $allData['user_num'] = 0; + $allData['new_user_num'] = 0; + $allData['new_device_num'] = 0; + $allData['new_ip_num'] = 0; + $allData['login_user_num'] = 0; + $allData['spend_user_num'] = 0; + $allData['spend_num'] = 0; + $allData['spend_all_amount'] = 0; + $allData['spend_cash'] = 0; + $allData['spend_generic'] = 0; + $allData['spend_binding'] = 0; + $allData['spend_discount'] = 0; + $allData['spend_voucher'] = 0; + foreach ($dayList as $day) { + $date = date('Ymd', strtotime($day)); + $records[] = [ + 'day' => $date, + 'role_num' => $roleNumList[$day], + 'user_num' => $userNumList[$day], + 'new_user_num' => $newUserNumList[$day], + 'new_device_num' => $newDeviceNumList[$day], + 'new_ip_num' => $newIpNumList[$day], + 'login_user_num' => $loginUserNumList[$day], + 'spend_user_num' => $spendUserNumList[$day], + 'spend_num' => $spendNumList[$day], + 'spend_all_amount' => $spendAllAmountList[$day], + 'spend_cash' => $spendCashList[$day], + 'spend_generic' => $spendGenericList[$day], + 'spend_binding' => $spendBindingList[$day], + 'spend_discount' => 0, + 'spend_voucher' => 0, + ]; + + $allData['role_num'] += $roleNumList[$day]; + $allData['user_num'] += $userNumList[$day]; + $allData['new_user_num'] += $newUserNumList[$day]; + $allData['new_device_num'] += $newDeviceNumList[$day]; + $allData['new_ip_num'] += $newIpNumList[$day]; + $allData['login_user_num'] += $loginUserNumList[$day]; + $allData['spend_user_num'] += $spendUserNumList[$day]; + $allData['spend_num'] += $spendNumList[$day]; + $allData['spend_all_amount'] = bcadd($allData['spend_all_amount'], $spendAllAmountList[$day], 2); + $allData['spend_cash'] = bcadd($allData['spend_cash'], $spendCashList[$day], 2); + $allData['spend_generic'] = bcadd($allData['spend_generic'], $spendGenericList[$day], 2); + $allData['spend_binding'] = bcadd($allData['spend_binding'], $spendBindingList[$day], 2); + $allData['spend_discount'] = bcadd($allData['spend_discount'], 0, 2); + $allData['spend_voucher'] = bcadd($allData['spend_voucher'], 0, 2); + + $summaryData['date'][] = $date; + $summaryData['role_num'][] = $roleNumList[$day]; + $summaryData['user_num'][] = $userNumList[$day]; + $summaryData['new_user_num'][] = $newUserNumList[$day]; + $summaryData['new_device_num'][] = $newDeviceNumList[$day]; + $summaryData['spend_user_num'][] = $spendUserNumList[$day]; + $summaryData['spend_all_amount'][] = $spendAllAmountList[$day]; + } } $summaryData['date'] = array_reverse($summaryData['date']); @@ -1381,7 +1301,7 @@ class QueryController extends BaseController ->join('tab_game as g on g.id = a.game_id') ->join($serverJoin) ->where($map) - ->count('distinct tab_apply.game_id'); + ->count('distinct a.game_id'); //分页 $parameter['p'] = I('get.p', 1);