123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <?php
- namespace app\mobile\controller;
- use app\common\model\HumanEnterpriseApplyModel;
- use app\common\model\HumanEnterpriseModel;
- use app\common\model\HumanInstitutionApplyModel;
- use app\common\model\HumanInstitutionModel;
- use app\common\validate\HumanEnterpriseApplyValidate;
- use app\common\validate\HumanInstitutionApplyValidate;
- use app\mobile\MobileBaseController;
- use think\exception\ValidateException;
- class Human extends MobileBaseController
- {
- protected function initialize()
- {
- // session('mobile.human.open_id', 'sdfjosijdfoi1');
- $open_id = session('mobile.human.open_id');
- if (empty($open_id)) {
- session('mobile.human.back_url', request()->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();
- return view('', [
- 'cooperate_list' => json_encode(HumanInstitutionModel::COOPERATE),
- ]);
- }
- 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()
- {
- $this->_listValidate();
- $id = input('id');
- empty($id) && jump('该机构不存在或已删除');
- $info = HumanInstitutionModel::find($id);
- empty($info) && jump('该机构不存在或已删除');
- return view('', ['info' => $info]);
- }
- public function enterpriseList()
- {
- $this->_listValidate();
- return view();
- }
- public function listEnterprise()
- {
- $where = $this->dealLikeInput(['name']);
- $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()
- {
- $this->_listValidate();
- $id = input('id');
- empty($id) && jump('该企业不存在或已删除');
- $info = HumanEnterpriseModel::find($id);
- empty($info) && jump('该企业不存在或已删除');
- return view('', ['info' => $info]);
- }
- public function center()
- {
- $this->_listValidate();
- return view();
- }
- public function describe()
- {
- return view();
- }
- public function guide()
- {
- // $this->_listValidate();
- 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]);
- }
- 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()
- {
- $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')));
- }
- }
- if (!empty($enterprise)) {
- if ($enterprise['status'] != HumanEnterpriseApplyModel::STATUS_PASS) {
- throw new \think\exception\HttpResponseException(redirect(url('human/tips')));
- }
- }
- }
- }
|