|
@@ -0,0 +1,322 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\admin\controller;
|
|
|
+
|
|
|
+use app\admin\AdminBaseController;
|
|
|
+use app\common\model\HumanEnterpriseApplyModel;
|
|
|
+use app\common\model\HumanEnterpriseModel;
|
|
|
+use app\common\model\HumanInstitutionApplyModel;
|
|
|
+use app\common\model\HumanInstitutionModel;
|
|
|
+use app\common\validate\HumanEnterpriseValidate;
|
|
|
+use app\common\validate\HumanInstitutionValidate;
|
|
|
+use think\exception\ValidateException;
|
|
|
+
|
|
|
+class Human extends AdminBaseController
|
|
|
+{
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 机构报名
|
|
|
+ */
|
|
|
+ public function institutionApply()
|
|
|
+ {
|
|
|
+ return view('', [
|
|
|
+ 'status_list' => HumanInstitutionApplyModel::STATUS,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function listInstitutionApply()
|
|
|
+ {
|
|
|
+ $map = $this->dealEqualInput(['status'], $this->dealLikeInput(['name']));
|
|
|
+ $list = HumanInstitutionApplyModel::where($map)
|
|
|
+ ->order(['status' => 'asc'])
|
|
|
+ ->limit(input('limit'))
|
|
|
+ ->page(input('page'))
|
|
|
+ ->append(['status_text'])
|
|
|
+ ->select();
|
|
|
+ $count = HumanInstitutionApplyModel::where($map)->count();
|
|
|
+ if ($count == 0) {
|
|
|
+ ajax_return(1, '未查询到数据');
|
|
|
+ }
|
|
|
+ list_return($list, $count);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function statusInstitutionApply()
|
|
|
+ {
|
|
|
+ $id_arr = input('id_arr/a');
|
|
|
+ $status = input('status', 1);
|
|
|
+ HumanInstitutionApplyModel::update(['status' => $status], ['id' => $id_arr]);
|
|
|
+ ajax_return();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业报名
|
|
|
+ */
|
|
|
+ public function enterpriseApply()
|
|
|
+ {
|
|
|
+ return view('', [
|
|
|
+ 'status_list' => HumanEnterpriseApplyModel::STATUS,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function listEnterpriseApply()
|
|
|
+ {
|
|
|
+ $map = $this->dealEqualInput(['status'], $this->dealLikeInput(['name']));
|
|
|
+ $list = HumanEnterpriseApplyModel::where($map)
|
|
|
+ ->order(['status' => 'asc'])
|
|
|
+ ->limit(input('limit'))
|
|
|
+ ->page(input('page'))
|
|
|
+ ->append(['status_text'])
|
|
|
+ ->select();
|
|
|
+ $count = HumanEnterpriseApplyModel::where($map)->count();
|
|
|
+ if ($count == 0) {
|
|
|
+ ajax_return(1, '未查询到数据');
|
|
|
+ }
|
|
|
+ list_return($list, $count);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function statusEnterpriseApply()
|
|
|
+ {
|
|
|
+ $id_arr = input('id_arr/a');
|
|
|
+ $status = input('status', 1);
|
|
|
+ HumanEnterpriseApplyModel::update(['status' => $status], ['id' => $id_arr]);
|
|
|
+ ajax_return();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 机构列表
|
|
|
+ */
|
|
|
+ public function institutionList()
|
|
|
+ {
|
|
|
+ return view('', [
|
|
|
+ 'status_list' => HumanInstitutionModel::STATUS,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function listInstitution()
|
|
|
+ {
|
|
|
+ $map = $this->dealEqualInput(['status'], $this->dealLikeInput(['name']));
|
|
|
+ $list = HumanInstitutionModel::where($map)
|
|
|
+ ->order(['priority' => 'desc', 'update_time' => 'desc'])
|
|
|
+ ->limit(input('limit'))
|
|
|
+ ->page(input('page'))
|
|
|
+ ->append(['status_text'])
|
|
|
+ ->select();
|
|
|
+ $count = HumanInstitutionModel::where($map)->count();
|
|
|
+ if ($count == 0) {
|
|
|
+ ajax_return(1, '未查询到数据');
|
|
|
+ }
|
|
|
+ list_return($list, $count);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function delInstitution()
|
|
|
+ {
|
|
|
+ $id_arr = input('id_arr/a');
|
|
|
+ HumanInstitutionModel::destroy($id_arr);
|
|
|
+ ajax_return();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ */
|
|
|
+ public function institutionForm()
|
|
|
+ {
|
|
|
+ $id = input('id/d, 0');
|
|
|
+ $info = HumanInstitutionModel::find($id);
|
|
|
+
|
|
|
+ return view('', [
|
|
|
+ 'info' => $info,
|
|
|
+ 'status_list' => HumanInstitutionModel::STATUS,
|
|
|
+ 'cooperate_list' => HumanInstitutionModel::COOPERATE,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function editInstitution()
|
|
|
+ {
|
|
|
+ $data = input('post.');
|
|
|
+ try {
|
|
|
+ validate(HumanInstitutionValidate::class)->check($data);
|
|
|
+ } catch (ValidateException $e) {
|
|
|
+ ajax_return(1, $e->getError());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (empty($data['cooperate'])) {
|
|
|
+ $data['cooperate'] = [];
|
|
|
+ } else {
|
|
|
+ $data['cooperate'] = array_values($data['cooperate']);
|
|
|
+ }
|
|
|
+ if (empty($data['id'])) {
|
|
|
+ HumanInstitutionModel::create($data);
|
|
|
+ } else {
|
|
|
+ HumanInstitutionModel::update($data, ['id' => $data['id']]);
|
|
|
+ }
|
|
|
+
|
|
|
+ ajax_return();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function importInstitution()
|
|
|
+ {
|
|
|
+ return view('public/import', [
|
|
|
+ 'url' => url('human/importInstitutionPost'),
|
|
|
+ 'last_table' => 'lay-human-institutionList-table',
|
|
|
+ 'template_file' => '/static/common/exl/human_institution.xls',
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function importInstitutionPost()
|
|
|
+ {
|
|
|
+ $file_url = input('file_url/s', "");
|
|
|
+ if (!file_exists($file_url)) {
|
|
|
+ ajax_return(1, '文件不存在');
|
|
|
+ }
|
|
|
+
|
|
|
+ //初始化数据
|
|
|
+ $data = ['name', 'tel', 'address', 'introduction', 'cooperate', 'join', 'join_mobile'];
|
|
|
+ $list = import_exl($file_url, $data, 1);
|
|
|
+ if (empty($list)) {
|
|
|
+ ajax_return(1, '请上传有数据的文件');
|
|
|
+ }
|
|
|
+ $empty_check = [
|
|
|
+ 'name' => '企业名称',
|
|
|
+ 'tel' => '联系电话',
|
|
|
+ 'address' => '企业地址',
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ //错误判断
|
|
|
+ $time = time();
|
|
|
+ foreach ($list as $k => $v) {
|
|
|
+ foreach ($empty_check as $key => $value) {
|
|
|
+ if (empty($v[$key])) {
|
|
|
+ ajax_return(1, '第' . ($k + 2) . '行的' . $value . '不能为空');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $cooperate = explode(',', $v['cooperate']);
|
|
|
+ if (!empty($cooperate)) {
|
|
|
+ foreach ($cooperate as $c) {
|
|
|
+ if (!in_array($c, HumanInstitutionModel::COOPERATE)) {
|
|
|
+ ajax_return(1, '第' . ($k + 2) . '行的业务范围(' . $c . ')不在业务范围列表中');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $list[$k]['cooperate'] = $cooperate;
|
|
|
+ $list[$k]['priority'] = 255;
|
|
|
+ $list[$k]['create_time'] = $list[$k]['update_time'] = $time;
|
|
|
+ }
|
|
|
+
|
|
|
+ HumanInstitutionModel::insertAll($list);
|
|
|
+
|
|
|
+ ajax_return(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业列表
|
|
|
+ */
|
|
|
+ public function enterpriseList()
|
|
|
+ {
|
|
|
+ return view('', [
|
|
|
+ 'status_list' => HumanEnterpriseModel::STATUS,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function listEnterprise()
|
|
|
+ {
|
|
|
+ $map = $this->dealEqualInput(['status'], $this->dealLikeInput(['name']));
|
|
|
+ $list = HumanEnterpriseModel::where($map)
|
|
|
+ ->order(['priority' => 'desc', 'update_time' => 'desc'])
|
|
|
+ ->limit(input('limit'))
|
|
|
+ ->page(input('page'))
|
|
|
+ ->append(['status_text'])
|
|
|
+ ->select();
|
|
|
+ $count = HumanEnterpriseModel::where($map)->count();
|
|
|
+ if ($count == 0) {
|
|
|
+ ajax_return(1, '未查询到数据');
|
|
|
+ }
|
|
|
+ list_return($list, $count);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function delEnterprise()
|
|
|
+ {
|
|
|
+ $id_arr = input('id_arr/a');
|
|
|
+ HumanEnterpriseModel::destroy($id_arr);
|
|
|
+ ajax_return();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ */
|
|
|
+ public function enterpriseForm()
|
|
|
+ {
|
|
|
+ $id = input('id/d, 0');
|
|
|
+ $info = HumanEnterpriseModel::find($id);
|
|
|
+
|
|
|
+ return view('', [
|
|
|
+ 'info' => $info,
|
|
|
+ 'status_list' => HumanEnterpriseModel::STATUS,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function editEnterprise()
|
|
|
+ {
|
|
|
+ $data = input('post.');
|
|
|
+ try {
|
|
|
+ validate(HumanEnterpriseValidate::class)->check($data);
|
|
|
+ } catch (ValidateException $e) {
|
|
|
+ ajax_return(1, $e->getError());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (empty($data['id'])) {
|
|
|
+ HumanEnterpriseModel::create($data);
|
|
|
+ } else {
|
|
|
+ HumanEnterpriseModel::update($data, ['id' => $data['id']]);
|
|
|
+ }
|
|
|
+
|
|
|
+ ajax_return();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function importEnterprise()
|
|
|
+ {
|
|
|
+ return view('public/import', [
|
|
|
+ 'url' => url('human/importEnterprisePost'),
|
|
|
+ 'last_table' => 'lay-human-enterpriseList-table',
|
|
|
+ 'template_file' => '/static/common/exl/human_enterprise.xls',
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function importEnterprisePost()
|
|
|
+ {
|
|
|
+ $file_url = input('file_url/s', "");
|
|
|
+ if (!file_exists($file_url)) {
|
|
|
+ ajax_return(1, '文件不存在');
|
|
|
+ }
|
|
|
+
|
|
|
+ //初始化数据
|
|
|
+ $data = ['name', 'capital', 'tel', 'address', 'introduction', 'join', 'join_mobile'];
|
|
|
+ $list = import_exl($file_url, $data, 1);
|
|
|
+ if (empty($list)) {
|
|
|
+ ajax_return(1, '请上传有数据的文件');
|
|
|
+ }
|
|
|
+ $empty_check = [
|
|
|
+ 'name' => '企业名称',
|
|
|
+ 'capital' => '注册资本',
|
|
|
+ 'tel' => '联系电话',
|
|
|
+ 'address' => '企业地址',
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ //错误判断
|
|
|
+ $time = time();
|
|
|
+ foreach ($list as $k => $v) {
|
|
|
+ foreach ($empty_check as $key => $value) {
|
|
|
+ if (empty($v[$key])) {
|
|
|
+ return ajax_return(1, '第' . ($k + 2) . '行的' . $value . '不能为空');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $list[$k]['priority'] = 255;
|
|
|
+ $list[$k]['create_time'] = $list[$k]['update_time'] = $time;
|
|
|
+ }
|
|
|
+
|
|
|
+ HumanEnterpriseModel::insertAll($list);
|
|
|
+ ajax_return(0);
|
|
|
+ }
|
|
|
+}
|