/** * 得到选择改专业 * @access private * @param $usid int 学校ID * @param $type int 是硕士还是硕士预科,$type=1表示硕士,2表示预科 * @author liuxiaolin <*****@*****.**> * @return void; */ public function chooseCourse($usid, $type = 1) { $uid = session('uid'); $res = M('apply_info')->where(array('uid' => $uid))->find(); if (empty($res)) { $this->redirect('Home/Index/index', 5, L('CONTROLLER_MSG5')); } if ($type == 1) { $esid = $res['esid']; } else { $esid = $res['esid'] + 7; } //for($i = 0; $i < 7; $i++) { // $suArr[] = $esid + $i; //} $matchModel = new MatchModel(); $info = $matchModel->Match((int) $usid); if ($info['status'] == 1) { if (empty($info['data'])) { $this->error(L('CONTROLLER_MSG6'), U('Match/result')); } //得到成功率 if ($type == 1) { $radio = $info['data'][0]['r_radio']; } else { $radio = $info['data'][0]['y_radio']; } $lang = LANG_SET; //得到学校信息 $sModel = M('universitylang'); $school = $sModel->alias('a')->field('a.name,a.city, b.rank, b.logo')->where(array('a.lang' => $lang, 'a.fid' => $usid))->join('inner join __UNIVERSITY__ as b ON a.fid = b.id')->find(); if (empty($school['logo'])) { $school['logo'] = '/Application/Home/Static/images/school/listPic.png'; } if ($school['rank'] == 999) { $school['rank'] = '--'; } //得到专业信息 $model = M('university_majorlang'); $field = 'a.fid as id, a.us_id, a.name as major, c.name as school, d.name as subname,g.id plan,b.is_close'; $where = array('a.us_id' => $usid, 'a.su_id' => $esid, 'a.lang' => $lang, 'c.lang' => $lang, 'd.lang' => $lang); if ($_GET['month']) { $index = $_GET['month']; switch ($index) { case 0: break; case 1: $where['b.start_time'] = array('in', [9, 10]); break; case 2: $where['b.start_time'] = array('in', [1, 2]); break; case 3: $where['b.start_time'] = array('not in', [1, 2, 9, 10]); break; } } $join = array('left join __UNIVERSITY_MAJOR__ as b on a.fid=b.id', 'left join __UNIVERSITYLANG__ as c ON c.fid = a.us_id', 'left join __SUBJECT_SUB__ as d on d.sub_id = a.sub_id', 'LEFT JOIN __APPLY_COLLECTION__ g ON g.us_id=c.fid AND g.mj_id=a.fid'); $data = $model->alias('a')->field($field)->where($where)->join($join)->select(); //把数据按子学科分组 foreach ($data as $k => $v) { $dataArr[$v['subname']][] = $v; } $this->assign('index', $index); $this->assign('radio', $radio); $this->assign('type', $type); $this->assign('data', $dataArr); $this->assign('school', $school); if (is_wap()) { $this->theme('bootstrap'); } $this->display(); } }
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; }