123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- <?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\service\QrcodeService;
- use app\common\validate\HumanEnterpriseValidate;
- use app\common\validate\HumanInstitutionValidate;
- use think\exception\ValidateException;
- class Human extends AdminBaseController
- {
- /**
- * 机构报名
- */
- public function institutionApply()
- {
- $file_url = QrcodeService::getQrcode('human_arrive', url('/mobile/human/arrive'), 600);
- return view('', [
- 'status_list' => HumanInstitutionApplyModel::STATUS,
- 'is_arrive_list' => HumanInstitutionApplyModel::IS_ARRIVE,
- 'file_url' => $file_url,
- ]);
- }
- public function listInstitutionApply()
- {
- $map = $this->dealEqualInput(['status', 'is_arrive'], $this->dealLikeInput(['name']));
- $list = HumanInstitutionApplyModel::where($map)
- ->order(['status' => 'asc'])
- ->limit(input('limit'))
- ->page(input('page'))
- ->append(['status_text', 'is_arrive_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 delInstitutionApply()
- {
- $id_arr = input('id_arr/a');
- HumanInstitutionApplyModel::destroy($id_arr);
- ajax_return();
- }
- public function institutionDetail()
- {
- $id = input('id/d');
- $info = HumanInstitutionApplyModel::find($id);
- return view('', [
- 'info' => $info,
- ]);
- }
- public function exportInstitutionApply()
- {
- $map = $this->dealInInput(['id'],$this->dealEqualInput(['status', 'is_arrive'], $this->dealLikeInput(['name'])));
- $list = HumanInstitutionApplyModel::where($map)
- ->order(['status' => 'asc'])
- ->append(['status_text', 'is_arrive_text'])
- ->select();
- $xlsCell = [
- ['id', '表ID'],
- ['name', '机构名称'],
- ['join', '参会人'],
- ['join_mobile', '参会手机号'],
- ['wechat', '微信号'],
- ['suggestion', '对本次活动想说的话'],
- ['status_text', '状态'],
- ['create_time', '报名时间'],
- ['describe', '机构介绍'],
- ['url', '公司网址'],
- ['is_arrive_text', '签到'],
- ];
- export_exl("机构报名表", $xlsCell, $list, ['join_mobile','wechat']);
- }
- /**
- * 企业报名
- */
- public function enterpriseApply()
- {
- $file_url = QrcodeService::getQrcode('human_arrive', url('/mobile/human/arrive'), 600);
- return view('', [
- 'status_list' => HumanEnterpriseApplyModel::STATUS,
- 'is_arrive_list' => HumanEnterpriseApplyModel::IS_ARRIVE,
- 'file_url' => $file_url,
- ]);
- }
- public function listEnterpriseApply()
- {
- $map = $this->dealEqualInput(['status', 'is_arrive'], $this->dealLikeInput(['name']));
- $list = HumanEnterpriseApplyModel::where($map)
- ->order(['status' => 'asc'])
- ->limit(input('limit'))
- ->page(input('page'))
- ->append(['status_text', 'is_arrive_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 delEnterpriseApply()
- {
- $id_arr = input('id_arr/a');
- HumanEnterpriseApplyModel::destroy($id_arr);
- ajax_return();
- }
- public function enterpriseDetail()
- {
- $id = input('id/d');
- $info = HumanEnterpriseApplyModel::find($id);
- return view('', [
- 'info' => $info,
- ]);
- }
- public function exportEnterpriseApply()
- {
- $map = $this->dealInInput(['id'],$this->dealEqualInput(['status', 'is_arrive'], $this->dealLikeInput(['name'])));
- $list = HumanEnterpriseApplyModel::where($map)
- ->order(['status' => 'asc'])
- ->append(['status_text', 'is_arrive_text'])
- ->select();
- foreach ($list as $v) {
- $v['cooperate_text'] = implode(',', $v['cooperate']);
- }
- $xlsCell = [
- ['id', '表ID'],
- ['name', '企业名称'],
- ['join', '参会人'],
- ['join_mobile', '参会手机号'],
- ['wechat', '微信号'],
- ['cooperate_text', '希望合作的业务'],
- ['suggestion', '对本次活动想说的话'],
- ['status_text', '状态'],
- ['create_time', '报名时间'],
- ['describe', '机构介绍'],
- ['url', '公司网址'],
- ['is_arrive_text', '签到'],
- ];
- export_exl("企业报名表", $xlsCell, $list, ['join_mobile','wechat']);
- }
- /**
- * 机构列表
- */
- 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);
- }
- }
|