url(true)); $response = redirect('https://www.jucai.gov.cn/api/auth/wechat_auth?url=' . urlencode(url('/mobile/login/humanLogin'))); throw new \think\exception\HttpResponseException($response); } } /** * 表单 */ public function index() { $this->_formValidate(); return view(); } public function institutionForm() { $this->_formValidate(); return view('', [ 'cooperate_list' => json_encode(HumanInstitutionModel::COOPERATE), ]); } public function institutionFormPost() { $data = input('post.'); try { validate(HumanInstitutionApplyValidate::class)->check($data); } catch (ValidateException $e) { ajax_return(1, $e->getError()); } $data['open_id'] = session('mobile.human.open_id'); HumanInstitutionApplyModel::create($data); ajax_return(); } public function enterpriseForm() { $this->_formValidate(); $industry_list = []; foreach (HumanEnterpriseModel::INDUSTRY as $industry) { $industry_list[] = ['text' => $industry, 'value' => $industry]; } return view('', [ 'cooperate_list' => json_encode(HumanInstitutionModel::COOPERATE), 'industry_list' => json_encode($industry_list), ]); } public function enterpriseFormPost() { $data = input('post.'); try { validate(HumanEnterpriseApplyValidate::class)->check($data); } catch (ValidateException $e) { ajax_return(1, $e->getError()); } $data['open_id'] = session('mobile.human.open_id'); HumanEnterpriseApplyModel::create($data); ajax_return(); } public function tips() { $open_id = session('mobile.human.open_id'); $msg = ''; $type = ''; $institution = HumanInstitutionApplyModel::where('open_id', $open_id)->find(); $enterprise = HumanEnterpriseApplyModel::where('open_id', $open_id)->find(); if (empty($institution) && empty($enterprise)) { return redirect(url('human/index')); } if (!empty($institution)) { $type = 'institution'; if ($institution['status'] != HumanInstitutionApplyModel::STATUS_PASS) { $msg = HumanInstitutionApplyModel::STATUS[$institution['status']]; if (!empty($institution['comment'])) { $msg .= ':' . $institution['comment']; } } else { return redirect(url('human/enterpriseList')); } } if (!empty($enterprise)) { $type = 'enterprise'; if ($enterprise['status'] != HumanEnterpriseApplyModel::STATUS_PASS) { $msg = HumanEnterpriseApplyModel::STATUS[$enterprise['status']]; if (!empty($enterprise['comment'])) { $msg .= ':' . $enterprise['comment']; } } else { return redirect(url('human/institutionList')); } } return view('', ['msg' => $msg, 'type' => $type]); } public function resetApply() { $open_id = session('mobile.human.open_id'); $institution = HumanInstitutionApplyModel::where('open_id', $open_id)->find(); if (!empty($institution)) { $institution->delete(); } $enterprise = HumanEnterpriseApplyModel::where('open_id', $open_id)->find(); if (!empty($enterprise)) { $enterprise->delete(); } return redirect(url('human/index')); } /** * 列表 */ public function institutionList() { $this->_listValidate(); $cooperate_list = [['text' => '全部', 'value' => '']]; foreach (HumanInstitutionModel::COOPERATE as $cooperate) { $cooperate_list[] = ['text' => $cooperate, 'value' => $cooperate]; } return view('', [ 'cooperate_list' => json_encode($cooperate_list), ]); } public function listInstitution() { $where = $this->dealLikeInput(['name', 'cooperate']); $where[] = ['status', '=', HumanInstitutionModel::STATUS_SHOW]; $list = HumanInstitutionModel::where($where) ->order(['priority' => 'desc']) ->limit(input('limit', 10)) ->page(input('page', 1)) ->select(); ajax_success($list); } public function institutionDetail() { $human = $this->_listValidate(); $id = input('id'); empty($id) && jump('该机构不存在或已删除'); $info = HumanInstitutionModel::find($id); empty($info) && jump('该机构不存在或已删除'); $apply = HumanInstitutionApplyModel::where('join_mobile', '=', $info['join_mobile'])->find(); if (!empty($apply)) { $check = HumanSeeModel::where([ ['join_mobile', '=', $human['data']['join_mobile']], ['human_id', '=', $apply['id']], ['type', '=', '机构'], ])->find(); if (empty($check)) { HumanSeeModel::create([ 'type' => '机构', 'human_id' => $apply['id'], 'name' => $human['data']['name'], 'join' => $human['data']['join'], 'join_mobile' => $human['data']['join_mobile'], ]); } } return view('', ['info' => $info]); } public function enterpriseList() { $this->_listValidate(); $cooperate_list = [['text' => '全部业务', 'value' => '']]; foreach (HumanInstitutionModel::COOPERATE as $cooperate) { $cooperate_list[] = ['text' => $cooperate, 'value' => $cooperate]; } $industry_list = [['text' => '全部行业', 'value' => '']]; foreach (HumanEnterpriseModel::INDUSTRY as $industry) { $industry_list[] = ['text' => $industry, 'value' => $industry]; } return view('', [ 'cooperate_list' => json_encode($cooperate_list), 'industry_list' => json_encode($industry_list), ]); } public function listEnterprise() { $where = $this->dealLikeInput(['name', 'cooperate', 'industry']); $where[] = ['status', '=', HumanEnterpriseModel::STATUS_SHOW]; $list = HumanEnterpriseModel::where($where) ->order(['priority' => 'desc']) ->limit(input('limit', 10)) ->page(input('page', 1)) ->select(); ajax_success($list); } public function enterpriseDetail() { $human = $this->_listValidate(); $id = input('id'); empty($id) && jump('该企业不存在或已删除'); $info = HumanEnterpriseModel::find($id); empty($info) && jump('该企业不存在或已删除'); $apply = HumanEnterpriseApplyModel::where('join_mobile', '=', $info['join_mobile'])->find(); if (!empty($apply)) { $check = HumanSeeModel::where([ ['join_mobile', '=', $human['data']['join_mobile']], ['human_id', '=', $apply['id']], ['type', '=', '企业'], ])->find(); if (empty($check)) { HumanSeeModel::create([ 'type' => '企业', 'human_id' => $apply['id'], 'name' => $human['data']['name'], 'join' => $human['data']['join'], 'join_mobile' => $human['data']['join_mobile'], ]); } } return view('', ['info' => $info]); } public function center() { $this->_listValidate(); return view(); } public function describe() { return view(); } public function guide() { return view(); } public function jinjiang() { return view(); } public function renzi() { return view(); } public function arrive() { $open_id = session('mobile.human.open_id'); $institution = HumanInstitutionApplyModel::where('open_id', $open_id)->find(); $enterprise = HumanEnterpriseApplyModel::where('open_id', $open_id)->find(); $msg = ''; if (empty($institution) && empty($enterprise)) { $msg = '请先报名'; } if (!empty($institution)) { $institution->is_arrive = HumanInstitutionApplyModel::IS_ARRIVE_YES; $institution->save(); $msg = '签到成功'; } if (!empty($enterprise)) { $enterprise->is_arrive = HumanEnterpriseApplyModel::IS_ARRIVE_YES; $enterprise->save(); $msg = '签到成功'; } return view('', ['msg' => $msg]); } public function bindMobile() { $mobile = input('mobile', ''); empty($mobile) && ajax_return(1, '请输入手机号'); $institution = HumanInstitutionApplyModel::where('join_mobile', $mobile)->find(); if (empty($institution)) { $enterprise = HumanEnterpriseApplyModel::where('join_mobile', $mobile)->find(); if (empty($enterprise)) { ajax_return(1, '该手机号未报名,请确认手机号'); } else { HumanEnterpriseApplyModel::create([ 'open_id' => session('mobile.human.open_id'), 'name' => $enterprise->name, 'join' => $enterprise->join, 'join_mobile' => $enterprise->join_mobile, 'cooperate' => $enterprise->cooperate, 'status' => HumanEnterpriseApplyModel::STATUS_PASS, ]); } } else { HumanInstitutionApplyModel::create([ 'open_id' => session('mobile.human.open_id'), 'name' => $institution->name, 'join' => $institution->join, 'join_mobile' => $institution->join_mobile, 'cooperate' => $institution->cooperate, 'status' => HumanInstitutionApplyModel::STATUS_PASS, ]); } ajax_return(); } public function seeme() { $this->_listValidate(); return view(); } public function tuwen() { return view(); } public function listSeeme() { $human = $this->_listValidate(); $where = [ ['type', '=', $human['type']], ['human_id', '=', $human['data']['id']], ]; $list = HumanSeeModel::where($where) ->order(['update_time' => 'desc']) ->limit(input('limit', 10)) ->page(input('page', 1)) ->select(); ajax_success($list); } private function _formValidate() { $open_id = session('mobile.human.open_id'); $institution = HumanInstitutionApplyModel::where('open_id', $open_id)->find(); $enterprise = HumanEnterpriseApplyModel::where('open_id', $open_id)->find(); if (!empty($institution)) { if ($institution['status'] != HumanInstitutionApplyModel::STATUS_PASS) { throw new \think\exception\HttpResponseException(redirect(url('human/tips'))); } else { throw new \think\exception\HttpResponseException(redirect(url('human/enterpriseList'))); } } if (!empty($enterprise)) { if ($enterprise['status'] != HumanEnterpriseApplyModel::STATUS_PASS) { throw new \think\exception\HttpResponseException(redirect(url('human/tips'))); } else { throw new \think\exception\HttpResponseException(redirect(url('human/institutionList'))); } } } private function _listValidate() { $action = $this->request->action(); if ($action != 'center') { if (time() < 1730779200) { jump('11月5日12点开启,敬请期待','mobile/human/center'); } } $open_id = session('mobile.human.open_id'); $institution = HumanInstitutionApplyModel::where('open_id', $open_id)->find(); $enterprise = HumanEnterpriseApplyModel::where('open_id', $open_id)->find(); if (empty($institution) && empty($enterprise)) { throw new \think\exception\HttpResponseException(redirect(url('human/index'))); } if (!empty($institution)) { if ($institution['status'] != HumanInstitutionApplyModel::STATUS_PASS) { throw new \think\exception\HttpResponseException(redirect(url('human/tips'))); } return ['type' => '机构', 'data' => $institution]; } if (!empty($enterprise)) { if ($enterprise['status'] != HumanEnterpriseApplyModel::STATUS_PASS) { throw new \think\exception\HttpResponseException(redirect(url('human/tips'))); } return ['type' => '企业', 'data' => $enterprise]; } } }