model = model('OrdersCollect'); $this->view->assign("typeList", $this->model->getTypeList()); $this->view->assign("flagList", $this->model->getFlagList()); $group = model('AuthGroupAccess')->where('uid',$this->auth->id)->find(); $truegroupId = $group->group_id; if(isset($_GET['channel_id']) && intval($_GET['channel_id'])>0){ $groupObj = model('AuthGroupAccess')->where('uid',$_GET['channel_id'])->find(); if($groupObj){ $thisGroup = $groupObj->group_id; if($thisGroup > 2){ //判断传过来的不是管理员的id if($thisGroup==3){ //如果是渠道商 if($truegroupId <3){ //只有管理员才有此操作 $this->authId = $_GET['channel_id']; $thisChannel = model('Admin')->where('id',$this->authId)->find(); $this->groupId = 3; $this->assign('channelTitle','当前是渠道商('.$thisChannel->nickname.')的数据'); $this->assignconfig('channelstr','?channel_id='.$this->authId); } }else{ if($truegroupId <4){ //管理员或渠道商才有此操作 if($truegroupId == 3){ //如果是从渠道商查来的,判断当前代理商是不是渠道商下属 $isCh = model('AdminExtend')->where(['admin_id'=>$_GET['channel_id'],'create_by'=>$group->uid])->find(); if($isCh){ //如果是当前渠道商的下属 $this->authId = $_GET['channel_id']; $thisChannel = model('Admin')->where('id',$this->authId)->find(); $this->groupId = 4; $this->assign('channelTitle','当前是代理商('.$thisChannel->nickname.')的数据'); $this->assignconfig('channelstr','?channel_id='.$this->authId); } }else{ //管理员查过来的 $this->authId = $_GET['channel_id']; $thisChannel = model('Admin')->where('id',$this->authId)->find(); $this->groupId = 4; $this->assign('channelTitle','当前是代理商('.$thisChannel->nickname.')的数据'); $this->assignconfig('channelstr','?channel_id='.$this->authId); } } } } } }else{ $this->authId = $this->auth->id; $this->groupId = $truegroupId; $this->assignconfig('channelstr','?channel_id=0'); } $this->view->assign("groupId",$this->groupId); $this->assignconfig('groupId',$this->groupId); $this->assignconfig('authId',$this->authId); } public function index() { //今天 $today = date('Ymd', time()); //昨天 $yesterday = date('Ymd', strtotime('-1 days')); //本月 $month = date('Ym', time()).'01'; $business_line = $this->request->param('business_line'); if (!$business_line) { $business_line = PayConstants::BUSINESS_WECHAT; } if($this->groupId < AdminConstants::ADMIN_GROUP_ID_CHANNEL){ //管理员 $todayData = $this->model->where(['type'=>'1','flag'=>'2','admin_id'=>0,'createdate'=>$today,'business_line'=> $business_line])->find(); //今天的数据 $yesterdayData = $this->model->where(['type'=>'1','flag'=>'2','admin_id'=>0,'createdate'=>$yesterday,'business_line'=> $business_line])->find(); //昨天的数据 // $monthData = $this->model->where(['type'=>'2','flag'=>'2','admin_id'=>0,'createdate'=>$month])->find(); //当月的数据 $monthData = $this->model->sumCollect(0, 1, 2, $month, $yesterday, $business_line); //当月的数据 // $allData = $this->model->where(['type'=>'3','flag'=>'2','admin_id'=>0,])->find(); //汇总的数据 $allData = $this->model->sumCollect(0, 1, 2, null, null, $business_line); //汇总的数据 $this->assign('guide_pvuv',null); $this->assign('today',$todayData); $this->assign('yesterday',$yesterdayData); $this->assign('month',$monthData); $this->assign('all',$allData); }elseif($this->groupId == AdminConstants::ADMIN_GROUP_ID_AGENT){ //代理商 $todayData = $this->model->where(['type'=>'1','flag'=>'1','admin_id'=>$this->authId,'createdate'=>$today,'business_line'=> $business_line])->find(); //今天的数据 $yesterdayData = $this->model->where(['type'=>'1','flag'=>'1','admin_id'=>$this->authId,'createdate'=>$yesterday,'business_line'=> $business_line])->find(); //昨天的数据 // $monthData = $this->model->where(['type'=>'2','flag'=>'1','admin_id'=>$this->authId,'createdate'=>$month])->find(); //当月的数据 $monthData = $this->model->sumCollect($this->authId, 1, 1, $month, $yesterday, $business_line); //当月的数据 // $allData = $this->model->where(['type'=>'3','flag'=>'1','admin_id'=>$this->authId,])->find(); //汇总的数据 $allData = $this->model->sumCollect($this->authId, 1, 1, null, null, $business_line); //汇总的数据 $pvuv['pv'] = Redis::instance()->get(PvuvCollectService::instance()->getPvKey($this->authId)); $pvuv['uv'] = Redis::instance()->pfCount(PvuvCollectService::instance()->getUvKey($this->authId)); $this->assign('guide_pvuv',$this->getGuidePvUv($this->authId,$this->groupId,$today)); $this->assign('pvuv',$pvuv); $this->assign('today',$todayData); $this->assign('yesterday',$yesterdayData); $this->assign('month',$monthData); $this->assign('all',$allData); }else{ //渠道商 $todayData = $this->model->where(['type'=>'1','flag'=>'1','admin_id'=>$this->authId,'createdate'=>$today,'business_line'=> $business_line])->find(); //今天自己的数据 $todayAgentData = $this->model->where(['type'=>'1','flag'=>'2','admin_id'=>$this->authId,'createdate'=>$today,'business_line'=> $business_line])->find(); //今天代理商的数据 $todayAllData = $this->model->where(['type'=>'1','flag'=>'3','admin_id'=>$this->authId,'createdate'=>$today,'business_line'=> $business_line])->find(); //今天所有的数据 $pvuv['pv'] = Redis::instance()->get(PvuvCollectService::instance()->getPvKey($this->authId)); $pvuv['uv'] = Redis::instance()->pfCount(PvuvCollectService::instance()->getUvKey($this->authId)); $this->assign('pvuv',$pvuv); if($todayAllData){ if($todayData){ $todayAllData['recharge_money'] = $todayData->recharge_money; $todayAllData['recharge_money_benefit'] = $todayData->recharge_money_benefit; }else{ $todayAllData['recharge_money'] = 0; $todayAllData['recharge_money_benefit'] = 0; } if($todayAgentData){ $todayAllData['agent_recharge'] = $todayAgentData->recharge_money; $todayAllData['agent_recharge_benefit'] = $todayAgentData->recharge_money_benefit; }else{ $todayAllData['agent_recharge'] = 0; $todayAllData['agent_recharge_benefit'] = 0; } } $yesterdayData = $this->model->where(['type'=>'1','flag'=>'1','admin_id'=>$this->authId,'createdate'=>$yesterday,'business_line'=> $business_line])->find(); //昨天自己的数据 $yesterdayAgentData = $this->model->where(['type'=>'1','flag'=>'2','admin_id'=>$this->authId,'createdate'=>$yesterday,'business_line'=> $business_line])->find(); //昨天代理商的数据 $yesterdayAllData = $this->model->where(['type'=>'1','flag'=>'3','admin_id'=>$this->authId,'createdate'=>$yesterday,'business_line'=> $business_line])->find(); //昨天所有的数据 if(!empty($yesterdayAllData)){ if($yesterdayData){ $yesterdayAllData['recharge_money'] = $yesterdayData->recharge_money; $yesterdayAllData['recharge_money_benefit'] = $yesterdayData->recharge_money_benefit; }else{ $yesterdayAllData['recharge_money'] = 0; $yesterdayAllData['recharge_money_benefit'] = 0; } if($yesterdayAgentData){ $yesterdayAllData['agent_recharge'] = $yesterdayAgentData->recharge_money; $yesterdayAllData['agent_recharge_benefit'] = $yesterdayAgentData->recharge_money_benefit; }else{ $yesterdayAllData['agent_recharge'] = 0; $yesterdayAllData['agent_recharge_benefit'] = 0; } } // $monthData = $this->model->where(['type'=>'2','flag'=>'1','admin_id'=>$this->authId,'createdate'=>$month])->find(); //当月自己的数据 $monthData = $this->model->sumCollect($this->authId,1,1,$month,$yesterday, $business_line); //当月自己的数据 // $monthAgentData = $this->model->where(['type'=>'2','flag'=>'2','admin_id'=>$this->authId,'createdate'=>$month])->find(); //当月代理商的数据 $monthAgentData = $this->model->sumCollect($this->authId,1,2,$month,$yesterday, $business_line); //当月代理商的数据 // $monthAllData = $this->model->where(['type'=>'2','flag'=>'3','admin_id'=>$this->authId,'createdate'=>$month])->find(); //当月所有的数据 $monthAllData = $this->model->sumCollect($this->authId,1,3,$month,$yesterday, $business_line); //当月所有的数据 if(!empty($monthAllData)){ if($monthData){ $monthAllData['recharge_money'] = $monthData->recharge_money; $monthAllData['recharge_money_benefit'] = $monthData->recharge_money_benefit; }else{ $monthAllData['recharge_money'] = 0; $monthAllData['recharge_money_benefit'] = 0; } if($monthAgentData){ $monthAllData['agent_recharge'] = $monthAgentData->recharge_money; $monthAllData['agent_recharge_benefit'] = $monthAgentData->recharge_money_benefit; }else{ $monthAllData['agent_recharge'] = 0; $monthAllData['agent_recharge_benefit'] = 0; } } // $allData = $this->model->where(['type'=>'3','flag'=>'1','admin_id'=>$this->authId,])->find(); //汇总自己的数据 $allData = $this->model->sumCollect($this->authId,1,1, null, null, $business_line); //汇总自己的数据 // $allAgentData = $this->model->where(['type'=>'3','flag'=>'2','admin_id'=>$this->authId,])->find(); //汇总代理商的数据 $allAgentData = $this->model->sumCollect($this->authId,1,2, null, null, $business_line); //汇总代理商的数据 // $allAllData = $this->model->where(['type'=>'3','flag'=>'3','admin_id'=>$this->authId,])->find(); //汇总所有的数据 $allAllData = $this->model->sumCollect($this->authId,1,3, null, null, $business_line); //汇总所有的数据 if($allAllData){ if($allData){ $allAllData['recharge_money'] = $allData->recharge_money; $allAllData['recharge_money_benefit'] = $allData->recharge_money_benefit; }else{ $allAllData['recharge_money'] = 0; $allAllData['recharge_money_benefit'] = 0; } if($allAgentData){ $allAllData['agent_recharge'] = $allAgentData->recharge_money; $allAllData['agent_recharge_benefit'] = $allAgentData->recharge_money_benefit; }else{ $allAllData['agent_recharge'] = 0; $allAllData['agent_recharge_benefit'] = 0; } } $this->assign('guide_pvuv',$this->getGuidePvUv($this->authId,$this->groupId,$today)); $this->assign('today',$todayAllData); $this->assign('yesterday',$yesterdayAllData); $this->assign('month',$monthAllData); $this->assign('all',$allAllData); } if ($this->request->isAjax()) { $beginDate = date('Ymd', strtotime('-31 days')); $endDate = date('Ymd', strtotime('-1 days')); list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $condition = []; $condition['type'] = 1; $condition['business_line'] = $business_line; if($this->groupId<3){ //管理员 $condition['admin_id'] = 0; $condition['flag'] = 2; $beginDate = date('Ymd', strtotime('-62 days')); }elseif($this->groupId == 3){ //渠道商 $condition['admin_id'] = $this->authId; $condition['flag'] = 3; }elseif($this->groupId == 4){ //代理商 $condition['admin_id'] = $this->authId; $condition['flag'] = 1; } if($this->groupId != 3){ $total = $this->model ->where($where) ->where('createdate','>=',$beginDate) ->where('createdate','<=',$endDate) ->where($condition) ->order($sort, $order) ->count(); $list = $this->model ->where($where) ->where('createdate','>=',$beginDate) ->where('createdate','<=',$endDate) ->where($condition) ->order($sort, $order) ->limit($offset, $limit) ->select(); $guide_pv_uv = $this->getGuidePvUv($this->authId,$this->groupId,[$beginDate,$endDate]); foreach ($list as $key=>$val) { $list[$key]['guide_pv'] = $guide_pv_uv[$val['createdate']]['pv'] ?? 0; $list[$key]['guide_uv'] = $guide_pv_uv[$val['createdate']]['uv'] ?? 0; } $result = array("total" => $total, "rows" => $list); }else{ //渠道商数据统计 $total = $this->model ->where($where) ->where('createdate','>=',$beginDate) ->where('createdate','<=',$endDate) ->where($condition) ->order($sort, $order) ->count(); $list = $this->model ->where($where) ->where('createdate','>=',$beginDate) ->where('createdate','<=',$endDate) ->where($condition) ->order($sort, $order) ->limit($offset, $limit) ->select(); //代理商数据 $condition_agent = [ 'business_line'=>$business_line ]; $condition_agent['type'] = 1; $condition_agent['admin_id'] = $this->authId; $condition_agent['flag'] = 2; $agentArr = []; $list_agent = $this->model ->where($where) ->where('createdate','>=',$beginDate) ->where('createdate','<=',$endDate) ->where($condition_agent) ->order($sort, $order) ->select(); if($list_agent){ foreach ($list_agent as $key=>$val) { $agentArr[$val['createdate']] = $val; } } //渠道商flag=1 渠道商自身数据 $condition_channel = [ 'business_line'=>$business_line ]; $condition_channel['type'] = 1; $condition_channel['admin_id'] = $this->authId; $condition_channel['flag'] = 1; $channelArr = []; $list_channel = $this->model ->where($where) ->where('createdate','>=',$beginDate) ->where('createdate','<=',$endDate) ->where($condition_channel) ->order($sort, $order) ->select(); if($list_channel){ foreach($list_channel as $key=>$val){ $channelArr[$val['createdate']] = $val; } } $guide_pv_uv = $this->getGuidePvUv($this->authId,$this->groupId,[$beginDate,$endDate]); foreach ($list as $key=>$val) { if(array_key_exists($val['createdate'],$channelArr)){ $list[$key]['self_recharge'] = $channelArr[$val['createdate']]['recharge_money']; $list[$key]['self_recharge_benefit'] = $channelArr[$val['createdate']]['recharge_money_benefit']; //total_benefit 渠道商自身的分成收益+代理商充值-代理商分成收益(之前晓红顶的算法) if(array_key_exists($val['createdate'],$agentArr)) { //当天有代理商数据 //$list[$key]['total_benefit'] = $channelArr[$val['createdate']]['recharge_money_benefit'] + $agentArr[$val['createdate']]['recharge_money'] - $agentArr[$val['createdate']]['recharge_money_benefit']; $list[$key]['total_benefit'] = $val['recharge_money_benefit'] - $agentArr[$val['createdate']]['recharge_money_benefit']; }else{ //代理商没有当天的数据; $list[$key]['total_benefit'] = $val['recharge_money_benefit']; } }else{ //$list[$key]['total_benefit'] = $val['recharge_money_benefit']; if(array_key_exists($val['createdate'],$agentArr)){ //$list[$key]['total_benefit'] = $agentArr[$val['createdate']]['recharge_money'] - $agentArr[$val['createdate']]['recharge_money_benefit']; $list[$key]['total_benefit'] = $val['recharge_money_benefit'] - $agentArr[$val['createdate']]['recharge_money_benefit']; }else{ $list[$key]['total_benefit'] = 0; } $list[$key]['self_recharge'] = 0; $list[$key]['self_recharge_benefit'] = 0; } if(array_key_exists($val['createdate'],$agentArr)){ $list[$key]['agent_benefit'] =$agentArr[$val['createdate']]['recharge_money_benefit']; $list[$key]['agent_recharge'] =$agentArr[$val['createdate']]['recharge_money']; }else{ $list[$key]['agent_benefit'] = 0; $list[$key]['agent_recharge'] = 0; } $list[$key]['guide_pv'] = $guide_pv_uv[$val['createdate']]['pv'] ?? 0; $list[$key]['guide_uv'] = $guide_pv_uv[$val['createdate']]['uv'] ?? 0; } unset($channelArr); unset($agentArr); $result = array("total" => $total, "rows" => $list); } return json($result); } return $this->view->fetch(); } //今日数据统计异步请求 public function ajaxToday(){ $today = date('Ymd', time()); $groupId = $this->request->post('groupId'); $authId = $this->request->post('authId'); $business_line = $this->request->param('business_line'); if (!$business_line) { $business_line = PayConstants::BUSINESS_WECHAT; } if ($this->request->isGet() || !$groupId || !$authId) { LogService::notice("invalid request for ajaxToday"); return json(['code' => 'request deny']); } if($groupId < 3){ //管理员 $todayData = Db::table('orders_collect')->where(['type'=>'1','flag'=>'2','admin_id'=>0,'createdate'=>$today, 'business_line'=>$business_line])->find(); //今天的数据 if($todayData){ $todayData['normal_percent'] = 0; if ($todayData['kandian_recharge_orders_count']) { $todayData['normal_percent'] = floor($todayData['kandian_recharge_orders']/$todayData['kandian_recharge_orders_count']*100); } else if ($todayData['normal_recharge_orders_count']) { $todayData['normal_percent'] = floor($todayData['normal_recharge_orders']/$todayData['normal_recharge_orders_count']*100); } $todayData['vip_percent'] = empty($todayData['vip_recharge_orders_count'])? 0 : floor($todayData['vip_recharge_orders']/$todayData['vip_recharge_orders_count']*100); }else{ $todayData['recharge_money'] = 0; $todayData['recharge_money_benefit'] = 0; $todayData['agent_recharge'] = 0; $todayData['agent_recharge_benefit'] = 0; $todayData['normal_percent'] = 0; $todayData['vip_percent'] = 0; $todayData['normal_recharge_orders'] = 0; $todayData['normal_recharge_orders_count'] = 0; $todayData['vip_recharge_orders'] = 0; $todayData['vip_recharge_orders_count'] = 0; $todayData['normal_recharge_money'] = 0; $todayData['vip_recharge_money'] = 0; } $todayData['guide_pv'] = 0; $todayData['guide_uv'] = 0; return json($todayData); }elseif($groupId==4){ //分销商 $todayData = Db::table('orders_collect')->where(['type'=>'1','flag'=>'1','admin_id'=>$this->authId,'createdate'=>$today, 'business_line'=>$business_line])->find(); //今天的数据 if($todayData){ $todayData['normal_percent'] = 0; if ($todayData['kandian_recharge_orders_count']) { $todayData['normal_percent'] = floor($todayData['kandian_recharge_orders']/$todayData['kandian_recharge_orders_count']*100); } else if ($todayData['normal_recharge_orders_count']) { $todayData['normal_percent'] = floor($todayData['normal_recharge_orders']/$todayData['normal_recharge_orders_count']*100); } $todayData['vip_percent'] = empty($todayData['vip_recharge_orders_count'])? 0 : floor($todayData['vip_recharge_orders']/$todayData['vip_recharge_orders_count']*100) ; }else{ $todayData['recharge_money'] = 0; $todayData['recharge_money_benefit'] = 0; $todayData['agent_recharge'] = 0; $todayData['agent_recharge_benefit'] = 0; $todayData['normal_percent'] = 0; $todayData['vip_percent'] = 0; $todayData['normal_recharge_orders'] = 0; $todayData['normal_recharge_orders_count'] = 0; $todayData['vip_recharge_orders'] = 0; $todayData['vip_recharge_orders_count'] = 0; $todayData['normal_recharge_money'] = 0; $todayData['vip_recharge_money'] = 0; } $twoHoursEarlier = time() - 7200; $pvuv = Db::table('admin_puv') ->where('admin_id', $authId) ->where('updatetime', '>', $twoHoursEarlier) ->find(); if(!empty($pvuv)){ $todayData['pv'] = $pvuv['pv']; $todayData['uv'] = $pvuv['uv']; }else{ $todayData['pv'] = 0; $todayData['uv'] = 0; } $guide_collect_data = $this->getGuidePvUv($authId,$groupId,$today); $todayData['guide_pv'] = $guide_collect_data['pv']; $todayData['guide_uv'] = $guide_collect_data['uv']; return json($todayData); }else{ //渠道商 $todayData = $this->model->where(['type'=>'1','flag'=>'1','admin_id'=>$this->authId,'createdate'=>$today, 'business_line'=>$business_line])->find(); //今天自己的数据 $todayAgentData = $this->model->where(['type'=>'1','flag'=>'2','admin_id'=>$this->authId,'createdate'=>$today, 'business_line'=>$business_line])->find(); //今天代理商的数据 $todayAllData = $this->model->where(['type'=>'1','flag'=>'3','admin_id'=>$this->authId,'createdate'=>$today, 'business_line'=>$business_line])->find(); //今天所有的数据 $twoHoursEarlier = time() - 7200; $pvuv = Db::table('admin_puv') ->where('admin_id', $authId) ->where('updatetime', '>', $twoHoursEarlier) ->find(); if($todayAllData){ if($todayData){ $todayAllData['recharge_money'] = $todayData->recharge_money; $todayAllData['recharge_money_benefit'] = $todayData->recharge_money_benefit; }else{ $todayAllData['recharge_money'] = 0; $todayAllData['recharge_money_benefit'] = 0; } if($todayAgentData){ $todayAllData['agent_recharge'] = $todayAgentData->recharge_money; $todayAllData['agent_recharge_benefit'] = $todayAgentData->recharge_money_benefit; }else{ $todayAllData['agent_recharge'] = 0.00; $todayAllData['agent_recharge_benefit'] = 0.00; } $todayAllData['normal_percent'] = 0; if ($todayAllData['kandian_recharge_orders_count']) { $todayAllData['normal_percent'] = floor($todayAllData['kandian_recharge_orders']/$todayAllData['kandian_recharge_orders_count']*100); } else if ($todayAllData['normal_recharge_orders_count']) { $todayAllData['normal_percent'] = floor($todayAllData['normal_recharge_orders']/$todayAllData['normal_recharge_orders_count']*100); } $todayAllData['vip_percent'] = empty($todayAllData['vip_recharge_orders_count'])? 0 : floor($todayAllData['vip_recharge_orders']/$todayAllData['vip_recharge_orders_count']*100); }else{ $todayAllData['recharge_money'] = 0; $todayAllData['recharge_money_benefit'] = 0; $todayAllData['agent_recharge'] = 0; $todayAllData['agent_recharge_benefit'] = 0; $todayAllData['normal_percent'] = 0; $todayAllData['vip_percent'] = 0; $todayAllData['normal_recharge_orders'] = 0; $todayAllData['normal_recharge_orders_count'] = 0; $todayAllData['vip_recharge_orders'] = 0; $todayAllData['vip_recharge_orders_count'] = 0; $todayAllData['normal_recharge_money'] = 0; $todayAllData['vip_recharge_money'] = 0; } if(!empty($pvuv)){ $todayAllData['pv'] = $pvuv['pv']; $todayAllData['uv'] = $pvuv['uv']; }else{ $todayAllData['pv'] = 0; $todayAllData['uv'] = 0; } $guide_collect_data = $this->getGuidePvUv($authId,$groupId,$today); $todayAllData['guide_pv'] = $guide_collect_data['pv']; $todayAllData['guide_uv'] = $guide_collect_data['uv']; return json($todayAllData); } } /** * 获取前置域名PV UV * @param $admin_id * @param $group_id * @param $date * @return array */ public function getGuidePvUv($admin_id,$group_id,$date){ if(!is_array($date)){ $result = ['pv'=>0,'uv'=>0]; //渠道商 if(intval($group_id) == AdminConstants::ADMIN_GROUP_ID_CHANNEL){ $agent_ids = model('AdminExtend')->where('create_by',$admin_id)->column('admin_id'); array_push($agent_ids,$admin_id); $map = ['admin_id'=>['in',implode(',',$agent_ids)],'createdate'=>$date,'type'=>'1']; $result_collect = model('GuideCollect')->where($map)->field('sum(pv) as pv,sum(uv) as uv')->find(); $result['pv'] = $result_collect['pv'] ?? 0; $result['uv'] = $result_collect['uv'] ?? 0; } //代理商 if(intval($group_id) == AdminConstants::ADMIN_GROUP_ID_AGENT){ $map = ['admin_id'=>$admin_id,'createdate'=>$date,'type'=>'1']; $result_collect = model('GuideCollect')->where($map)->find(); $result['pv'] = $result_collect['pv'] ?? 0; $result['uv'] = $result_collect['uv'] ?? 0; } return $result; }else{ list($begin,$end) = $date; $result_collect = null; //渠道商 if(intval($group_id) == AdminConstants::ADMIN_GROUP_ID_CHANNEL){ $agent_ids = model('AdminExtend')->where('create_by',$admin_id)->column('admin_id'); array_push($agent_ids,$admin_id); $map = ['admin_id'=>['in',implode(',',$agent_ids)],'type'=>'1']; $result_collect = model('GuideCollect') ->where($map) ->where('createdate','>=',$begin) ->where('createdate','<=',$end) ->field('createdate,sum(pv) as pv,sum(uv) as uv') ->group('createdate') ->select(); } //代理商 if(intval($group_id) == AdminConstants::ADMIN_GROUP_ID_AGENT){ $map = ['admin_id'=>$admin_id,'type'=>'1']; $result_collect = model('GuideCollect') ->where($map) ->where('createdate','>=',$begin) ->where('createdate','<=',$end) ->field('createdate,sum(pv) as pv ,sum(uv) as uv') ->group('createdate') ->select(); } if($result_collect){ $result_collect = collection($result_collect)->toArray(); $temp_key = array_column($result_collect,'createdate'); $result_collect = array_combine($temp_key,$result_collect); } return $result_collect; } } public function kl() { } }