getTodayServiceData($kfuidarray); if (!$todayall) { return false; } $kfuidarray_index = kftoKey($kfuidarray, 1); $uids = $kfuidarray; $hyl = $this->hyl($kfuidarray, $todayall); $jdl = $this->jdl($kfuidarray, $todayall); $pjhysc = $this->pjhusc($kfuidarray, $todayall); $cpl = $this->cpl($kfuidarray, $todayall); foreach ($kfuidarray_index as $uid => $val) { $kfuidarray_index[$uid]['uid'] = $uids[$uid]; $kfuidarray_index[$uid]['hhl'] = $hyl[$uid]; $kfuidarray_index[$uid]['jdl'] = $jdl[$uid]; $kfuidarray_index[$uid]['pjhysc'] = $pjhysc[$uid]; $kfuidarray_index[$uid]['cpl'] = $cpl[$uid]; } $last = []; foreach ($kfuidarray_index as $val) { $last[] = $val; } return $last; } //按条件获取用户数组 组ID, 在线状态 0为全部 public function getValiKF($groupid, $onlinestatus) { $groupusers = (new Users)->getByGroup($groupid); $groupuserArray = []; if ($groupusers) { foreach ($groupusers as $val) { $groupuserArray[$val['id']] = $val['id']; } } $statusArr = (new Kfonline())->getOnlineAll($onlinestatus); $return = array_intersect($groupuserArray, $statusArr); return $return; } //会话量 统计 public function hyl($uidArray, $alllogs) { $rets = kftoKey($uidArray); foreach ($rets as $uid => $aaaa) { foreach ($alllogs as $log) { if ($uid == $log['kf_id'] && $log['status'] == 2) { $rets[$uid]++; } } } return $rets; } //接待量 统计 public function jdl($uidArray, $alllogs) { $rets = kftoKey($uidArray); foreach ($rets as $uid => $aaa) { foreach ($alllogs as $log) { if ($uid == $log['kf_id']) { $rets[$uid]++; } } } return $rets; } //平均会话时长 统计 public function pjhusc($uidArray, $alllogs) { $rets = kftoKey($uidArray, 1); foreach ($rets as $uid => $aaa) { foreach ($alllogs as $log) { //if ($uid == $log['kf_id'] && $log['status'] == 2) { if ($uid == $log['kf_id']) { (!isset($rets[$uid]['count'])) ? ($rets[$uid]['count'] = 1) : $rets[$uid]['count']++; (!isset($rets[$uid]['times'])) ? ($rets[$uid]['times'] = 0) : ($log['end_time'] - $log['start_time']); } } } $return = []; foreach ($rets as $uid => $val) { if (isset($rets[$uid]['count'])) { $return[$uid] = $rets[$uid]['times'] / $rets[$uid]['count']; } else { $return[$uid] = 0; } } return $return; } //参评率 public function cpl($uidArray, $alllogs) { $rets = kftoKey($uidArray, 1); foreach ($rets as $uid => $aaa) { foreach ($alllogs as $log) { if ($uid == $log['kf_id']) { !(isset($rets[$uid]['count'])) ? 1 : $rets[$uid]['count']++; isset($rets[$uid]['pl']) ? ($rets[$uid]['pl'] = ($log['evaluate_id'] > 0 ? 1 : 0)) : 0; } } } $return = []; foreach ($rets as $uid => $val) { if (isset($rets[$uid]['count'])) { $return[$uid] = $return[$uid]['pl'] / $return[$uid]['cocountunt']; } else { $return[$uid] = 0; } } return $return; } public function mydl($kfuid) { } public function pjxysc($kfuid) { } public function jrxxsc($kfuid) { } public function getTodayServiceData($kfuidArray = []) { $today_begin = strtotime(date("Y-m-d")); $today_end = $today_begin + 86400; $filds = "group_id,kf_id,user_id,status,start_time,intime,end_time,evaluate_id"; if ($kfuidArray) { $ret = Db::name('service_log')->field($filds)->where(['start_time' => ['>=', $today_begin], 'kf_id' => ['IN', $kfuidArray]])->where(['start_time' => ['<', $today_end]])->select(); } else { $ret = Db::name('service_log')->field($filds)->where(['start_time' => ['>=', $today_begin]])->where(['start_time' => ['<', $today_end]])->select(); } return $ret; } }