/** * 得到计算成功率并分组 * @access private * @param maxied $us_id 学校 * @return json * @author liuxiaolin <*****@*****.**> */ private function getMatchData($us_id) { $matchModel = new MatchModel(); $info = $matchModel->match($us_id); $res['status'] = 1; if ($info['status'] == 1) { if (!empty($info['data'])) { foreach ($info['data'] as $k => $v) { $school[$v['us_id']] = $v; $schoolID[$v['us_id']] = $v['us_id']; } $schoolData = $this->getSchoolData($schoolID); foreach ($schoolData as $k => $v) { $data[$k] = array_merge($school[$k], $v); } //找到收藏的大学 //$collect = $this->getClollect($uid); foreach ($data as $k => $v) { if (empty($v['logo'])) { $v['logo'] = '/Application/Home/Static/images/school/listPic.png'; } // if($v['rank'] == 999){ // $v['rank'] = '--'; // } //if(in_array($v['us_id'], $collect)){ // $v['coll'] = 1; //} else { // $v['coll'] = 0; //} if ($v['r_radio'] < 0.4) { $res['out'][] = $v; } elseif ($v['r_radio'] < 0.55) { $res['chan'][] = $v; } elseif ($v['r_radio'] < 0.7) { $res['core'][] = $v; } else { $res['fall'][] = $v; } $res['all'][] = $v; } /* $sort = I('post.order')?:'desc'; if($sort == 'asc') { $order = SORT_ASC; } elseif($sort == 'desc') { $order = SORT_DESC; } multi_array_sort($res['all'], 'r_radio', $order, 'rank', $order); multi_array_sort($res['chan'], 'r_radio', $order, 'rank', $order); multi_array_sort($res['core'], 'r_radio', $order, 'rank', $order); multi_array_sort($res['fall'], 'r_radio', $order, 'rank', $order); multi_array_sort($res['out'], 'r_radio', $order, 'rank', $order);*/ } else { $res['all'] = array(); $res['out'] = array(); $res['chan'] = array(); $res['core'] = array(); $res['fall'] = array(); } } elseif ($info['status'] == -1) { $res['status'] = -1; } elseif ($info['status'] == -2) { $res['status'] = -2; } return $res; }
private function userCollectionList($uid, $year, $lang) { $collectionModel = M('apply_collection'); $field = 'a.id,a.us_id,a.mj_id,b.`name`,c.`name` mjname,d.logo,e.is_close'; $join = 'LEFT JOIN __UNIVERSITYLANG__ b ON a.us_id=b.fid LEFT JOIN __UNIVERSITY_MAJORLANG__ c ON a.mj_id=c.fid LEFT JOIN __UNIVERSITY_MAJOR__ e ON a.mj_id=e.id LEFT JOIN __UNIVERSITY__ d ON a.us_id=d.id'; $condition = "b.lang='{$lang}' and c.lang='{$lang}'"; if ($uid) { $condition .= " and a.uid={$uid}"; } if ($year) { $condition .= " and a.year='{$year}'"; } $data = $collectionModel->alias('a')->field($field)->join($join)->where($condition)->select(); $statusModel = M('apply_status'); $applyData = $statusModel->field('us_id,mj_id')->where("uid={$uid} and year='{$year}' and fuid=0")->select(); if ($applyData && $data) { foreach ($data as $key => $value) { foreach ($applyData as $k => $v) { if ($value['us_id'] == $v['us_id'] && $value['mj_id'] == $v['mj_id']) { unset($data[$key]); } else { continue; } } } } $schoolList = array(); if ($data) { foreach ($data as $row) { if ($schoolList[$row['us_id']]) { continue; } $schoolList[$row['us_id']] = $row['us_id']; } $model = new MatchModel(); $successLists = $model->match($schoolList); $successMerge = array(); if ($successLists['status'] == 1) { $successLists = empty($successLists['data']) ? [] : $successLists['data']; foreach ($successLists as $value) { $successMerge[$value['us_id']] = $value; } } foreach ($data as $key => $value) { if ($successMerge[$value['us_id']]) { $data[$key]['r_radio'] = $successMerge[$value['us_id']]['r_radio']; $data[$key]['y_radio'] = $successMerge[$value['us_id']]['y_radio']; } } } return $data; }