Human.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\AdminBaseController;
  4. use app\common\model\HumanEnterpriseApplyModel;
  5. use app\common\model\HumanEnterpriseModel;
  6. use app\common\model\HumanInstitutionApplyModel;
  7. use app\common\model\HumanInstitutionModel;
  8. use app\common\service\QrcodeService;
  9. use app\common\validate\HumanEnterpriseValidate;
  10. use app\common\validate\HumanInstitutionValidate;
  11. use think\exception\ValidateException;
  12. class Human extends AdminBaseController
  13. {
  14. /**
  15. * 机构报名
  16. */
  17. public function institutionApply()
  18. {
  19. $file_url = QrcodeService::getQrcode('human_arrive', url('/mobile/human/arrive'), 600);
  20. return view('', [
  21. 'status_list' => HumanInstitutionApplyModel::STATUS,
  22. 'is_arrive_list' => HumanInstitutionApplyModel::IS_ARRIVE,
  23. 'file_url' => $file_url,
  24. ]);
  25. }
  26. public function listInstitutionApply()
  27. {
  28. $map = $this->dealEqualInput(['status', 'is_arrive'], $this->dealLikeInput(['name']));
  29. $list = HumanInstitutionApplyModel::where($map)
  30. ->order(['status' => 'asc'])
  31. ->limit(input('limit'))
  32. ->page(input('page'))
  33. ->append(['status_text', 'is_arrive_text'])
  34. ->select();
  35. $count = HumanInstitutionApplyModel::where($map)->count();
  36. if ($count == 0) {
  37. ajax_return(1, '未查询到数据');
  38. }
  39. list_return($list, $count);
  40. }
  41. public function statusInstitutionApply()
  42. {
  43. $id_arr = input('id_arr/a');
  44. $status = input('status', 1);
  45. $comment = input('comment', '');
  46. HumanInstitutionApplyModel::update(['status' => $status, 'comment' => $comment], ['id' => $id_arr]);
  47. ajax_return();
  48. }
  49. public function delInstitutionApply()
  50. {
  51. $id_arr = input('id_arr/a');
  52. HumanInstitutionApplyModel::destroy($id_arr);
  53. ajax_return();
  54. }
  55. public function institutionDetail()
  56. {
  57. $id = input('id/d');
  58. $info = HumanInstitutionApplyModel::find($id);
  59. return view('', [
  60. 'info' => $info,
  61. ]);
  62. }
  63. public function exportInstitutionApply()
  64. {
  65. $map = $this->dealInInput(['id'], $this->dealEqualInput(['status', 'is_arrive'], $this->dealLikeInput(['name'])));
  66. $list = HumanInstitutionApplyModel::where($map)
  67. ->order(['status' => 'asc'])
  68. ->append(['status_text', 'is_arrive_text'])
  69. ->select();
  70. foreach ($list as $v) {
  71. $v['cooperate_text'] = implode(',', $v['cooperate']);
  72. }
  73. $xlsCell = [
  74. ['id', '表ID'],
  75. ['name', '机构名称'],
  76. ['join', '参会人'],
  77. ['join_mobile', '参会手机号'],
  78. ['wechat', '微信号'],
  79. ['suggestion', '对本次活动想说的话'],
  80. ['status_text', '状态'],
  81. ['create_time', '报名时间'],
  82. ['describe', '机构介绍'],
  83. ['cooperate_text', '希望合作的业务'],
  84. ['url', '公司网址'],
  85. ['is_arrive_text', '签到'],
  86. ];
  87. export_exl("机构报名表", $xlsCell, $list, ['join_mobile', 'wechat']);
  88. }
  89. public function institutionToEnterprise()
  90. {
  91. $id = input('id/d', 0);
  92. empty($id) && ajax_return(1, '请选择机构');
  93. $info = HumanInstitutionApplyModel::find($id);
  94. empty($info) && ajax_return(1, '请机构不存在');
  95. HumanEnterpriseApplyModel::create([
  96. 'open_id' => $info['open_id'],
  97. 'name' => $info['name'],
  98. 'join' => $info['join'],
  99. 'join_mobile' => $info['join_mobile'],
  100. 'wechat' => $info['wechat'],
  101. 'cooperate' => $info['cooperate'],
  102. 'suggestion' => $info['suggestion'],
  103. 'status' => $info['status'],
  104. 'describe' => $info['describe'],
  105. 'url' => $info['url'],
  106. 'images' => $info['images'],
  107. 'is_arrive' => $info['is_arrive'],
  108. 'comment' => $info['comment'],
  109. ]);
  110. $info->delete();
  111. ajax_return();
  112. }
  113. /**
  114. * 企业报名
  115. */
  116. public function enterpriseApply()
  117. {
  118. $file_url = QrcodeService::getQrcode('human_arrive', url('/mobile/human/arrive'), 600);
  119. return view('', [
  120. 'status_list' => HumanEnterpriseApplyModel::STATUS,
  121. 'is_arrive_list' => HumanEnterpriseApplyModel::IS_ARRIVE,
  122. 'file_url' => $file_url,
  123. ]);
  124. }
  125. public function listEnterpriseApply()
  126. {
  127. $map = $this->dealEqualInput(['status', 'is_arrive'], $this->dealLikeInput(['name']));
  128. $list = HumanEnterpriseApplyModel::where($map)
  129. ->order(['status' => 'asc'])
  130. ->limit(input('limit'))
  131. ->page(input('page'))
  132. ->append(['status_text', 'is_arrive_text'])
  133. ->select();
  134. $count = HumanEnterpriseApplyModel::where($map)->count();
  135. if ($count == 0) {
  136. ajax_return(1, '未查询到数据');
  137. }
  138. list_return($list, $count);
  139. }
  140. public function statusEnterpriseApply()
  141. {
  142. $id_arr = input('id_arr/a');
  143. $status = input('status', 1);
  144. $comment = input('comment', '');
  145. HumanEnterpriseApplyModel::update(['status' => $status, 'comment' => $comment], ['id' => $id_arr]);
  146. ajax_return();
  147. }
  148. public function delEnterpriseApply()
  149. {
  150. $id_arr = input('id_arr/a');
  151. HumanEnterpriseApplyModel::destroy($id_arr);
  152. ajax_return();
  153. }
  154. public function enterpriseDetail()
  155. {
  156. $id = input('id/d');
  157. $info = HumanEnterpriseApplyModel::find($id);
  158. return view('', [
  159. 'info' => $info,
  160. ]);
  161. }
  162. public function exportEnterpriseApply()
  163. {
  164. $map = $this->dealInInput(['id'], $this->dealEqualInput(['status', 'is_arrive'], $this->dealLikeInput(['name'])));
  165. $list = HumanEnterpriseApplyModel::where($map)
  166. ->order(['status' => 'asc'])
  167. ->append(['status_text', 'is_arrive_text'])
  168. ->select();
  169. foreach ($list as $v) {
  170. $v['cooperate_text'] = implode(',', $v['cooperate']);
  171. }
  172. $xlsCell = [
  173. ['id', '表ID'],
  174. ['name', '企业名称'],
  175. ['join', '参会人'],
  176. ['join_mobile', '参会手机号'],
  177. ['wechat', '微信号'],
  178. ['cooperate_text', '希望合作的业务'],
  179. ['suggestion', '对本次活动想说的话'],
  180. ['status_text', '状态'],
  181. ['create_time', '报名时间'],
  182. ['describe', '机构介绍'],
  183. ['url', '公司网址'],
  184. ['is_arrive_text', '签到'],
  185. ];
  186. export_exl("企业报名表", $xlsCell, $list, ['join_mobile', 'wechat']);
  187. }
  188. /**
  189. * 机构列表
  190. */
  191. public function institutionList()
  192. {
  193. return view('', [
  194. 'status_list' => HumanInstitutionModel::STATUS,
  195. ]);
  196. }
  197. public function listInstitution()
  198. {
  199. $map = $this->dealEqualInput(['status'], $this->dealLikeInput(['name']));
  200. $booth_status = input('booth_status');
  201. if (!empty($booth_status)) {
  202. if ($booth_status == 1) {
  203. $map[] = ['booth', '<>', ''];
  204. } else {
  205. $map[] = ['booth', '=', ''];
  206. }
  207. }
  208. $list = HumanInstitutionModel::where($map)
  209. ->order(['priority' => 'desc', 'update_time' => 'desc'])
  210. ->limit(input('limit'))
  211. ->page(input('page'))
  212. ->append(['status_text'])
  213. ->select();
  214. $count = HumanInstitutionModel::where($map)->count();
  215. if ($count == 0) {
  216. ajax_return(1, '未查询到数据');
  217. }
  218. list_return($list, $count);
  219. }
  220. public function delInstitution()
  221. {
  222. $id_arr = input('id_arr/a');
  223. HumanInstitutionModel::destroy($id_arr);
  224. ajax_return();
  225. }
  226. /**
  227. * 编辑
  228. */
  229. public function institutionForm()
  230. {
  231. $id = input('id/d, 0');
  232. $info = HumanInstitutionModel::find($id);
  233. return view('', [
  234. 'info' => $info,
  235. 'status_list' => HumanInstitutionModel::STATUS,
  236. 'cooperate_list' => HumanInstitutionModel::COOPERATE,
  237. ]);
  238. }
  239. public function editInstitution()
  240. {
  241. $data = input('post.');
  242. try {
  243. validate(HumanInstitutionValidate::class)->check($data);
  244. } catch (ValidateException $e) {
  245. ajax_return(1, $e->getError());
  246. }
  247. if (empty($data['cooperate'])) {
  248. $data['cooperate'] = [];
  249. } else {
  250. $data['cooperate'] = array_values($data['cooperate']);
  251. }
  252. if (empty($data['id'])) {
  253. HumanInstitutionModel::create($data);
  254. } else {
  255. HumanInstitutionModel::update($data, ['id' => $data['id']]);
  256. }
  257. ajax_return();
  258. }
  259. public function importInstitution()
  260. {
  261. return view('public/import', [
  262. 'url' => url('human/importInstitutionPost'),
  263. 'last_table' => 'lay-human-institutionList-table',
  264. 'template_file' => '/static/common/exl/human_institution.xls',
  265. ]);
  266. }
  267. public function importInstitutionPost()
  268. {
  269. $file_url = input('file_url/s', "");
  270. if (!file_exists($file_url)) {
  271. ajax_return(1, '文件不存在');
  272. }
  273. //初始化数据
  274. $data = ['name', 'tel', 'address', 'introduction', 'cooperate', 'join', 'join_mobile'];
  275. $list = import_exl($file_url, $data, 1);
  276. if (empty($list)) {
  277. ajax_return(1, '请上传有数据的文件');
  278. }
  279. $empty_check = [
  280. 'name' => '企业名称',
  281. 'tel' => '联系电话',
  282. 'address' => '企业地址',
  283. ];
  284. //错误判断
  285. $time = time();
  286. foreach ($list as $k => $v) {
  287. foreach ($empty_check as $key => $value) {
  288. if (empty($v[$key])) {
  289. ajax_return(1, '第' . ($k + 2) . '行的' . $value . '不能为空');
  290. }
  291. }
  292. $cooperate = explode(',', $v['cooperate']);
  293. if (!empty($cooperate)) {
  294. foreach ($cooperate as $c) {
  295. if (!in_array($c, HumanInstitutionModel::COOPERATE)) {
  296. ajax_return(1, '第' . ($k + 2) . '行的业务范围(' . $c . ')不在业务范围列表中');
  297. }
  298. }
  299. }
  300. $list[$k]['cooperate'] = $cooperate;
  301. $list[$k]['priority'] = 255;
  302. $list[$k]['create_time'] = $list[$k]['update_time'] = $time;
  303. }
  304. HumanInstitutionModel::insertAll($list);
  305. ajax_return(0);
  306. }
  307. public function enterpriseToInstitution()
  308. {
  309. $id = input('id/d', 0);
  310. empty($id) && ajax_return(1, '请选择企业');
  311. $info = HumanEnterpriseApplyModel::find($id);
  312. empty($info) && ajax_return(1, '请企业不存在');
  313. HumanInstitutionApplyModel::create([
  314. 'open_id' => $info['open_id'],
  315. 'name' => $info['name'],
  316. 'join' => $info['join'],
  317. 'join_mobile' => $info['join_mobile'],
  318. 'wechat' => $info['wechat'],
  319. 'cooperate' => $info['cooperate'],
  320. 'suggestion' => $info['suggestion'],
  321. 'status' => $info['status'],
  322. 'describe' => $info['describe'],
  323. 'url' => $info['url'],
  324. 'images' => $info['images'],
  325. 'is_arrive' => $info['is_arrive'],
  326. 'comment' => $info['comment'],
  327. ]);
  328. $info->delete();
  329. ajax_return();
  330. }
  331. /**
  332. * 企业列表
  333. */
  334. public function enterpriseList()
  335. {
  336. return view('', [
  337. 'status_list' => HumanEnterpriseModel::STATUS,
  338. ]);
  339. }
  340. public function listEnterprise()
  341. {
  342. $map = $this->dealEqualInput(['status'], $this->dealLikeInput(['name']));
  343. $booth_status = input('booth_status');
  344. if (!empty($booth_status)) {
  345. if ($booth_status == 1) {
  346. $map[] = ['booth', '<>', ''];
  347. } else {
  348. $map[] = ['booth', '=', ''];
  349. }
  350. }
  351. $list = HumanEnterpriseModel::where($map)
  352. ->order(['priority' => 'desc', 'update_time' => 'desc'])
  353. ->limit(input('limit'))
  354. ->page(input('page'))
  355. ->append(['status_text'])
  356. ->select();
  357. $count = HumanEnterpriseModel::where($map)->count();
  358. if ($count == 0) {
  359. ajax_return(1, '未查询到数据');
  360. }
  361. list_return($list, $count);
  362. }
  363. public function delEnterprise()
  364. {
  365. $id_arr = input('id_arr/a');
  366. HumanEnterpriseModel::destroy($id_arr);
  367. ajax_return();
  368. }
  369. /**
  370. * 编辑
  371. */
  372. public function enterpriseForm()
  373. {
  374. $id = input('id/d, 0');
  375. $info = HumanEnterpriseModel::find($id);
  376. return view('', [
  377. 'info' => $info,
  378. 'status_list' => HumanEnterpriseModel::STATUS,
  379. 'cooperate_list' => HumanInstitutionModel::COOPERATE,
  380. 'industry_list' => HumanEnterpriseModel::INDUSTRY,
  381. ]);
  382. }
  383. public function editEnterprise()
  384. {
  385. $data = input('post.');
  386. try {
  387. validate(HumanEnterpriseValidate::class)->check($data);
  388. } catch (ValidateException $e) {
  389. ajax_return(1, $e->getError());
  390. }
  391. if (empty($data['id'])) {
  392. HumanEnterpriseModel::create($data);
  393. } else {
  394. HumanEnterpriseModel::update($data, ['id' => $data['id']]);
  395. }
  396. ajax_return();
  397. }
  398. public function importEnterprise()
  399. {
  400. return view('public/import', [
  401. 'url' => url('human/importEnterprisePost'),
  402. 'last_table' => 'lay-human-enterpriseList-table',
  403. 'template_file' => '/static/common/exl/human_enterprise.xls',
  404. ]);
  405. }
  406. public function importEnterprisePost()
  407. {
  408. $file_url = input('file_url/s', "");
  409. if (!file_exists($file_url)) {
  410. ajax_return(1, '文件不存在');
  411. }
  412. //初始化数据
  413. $data = ['name', 'capital', 'tel', 'address', 'introduction', 'join', 'join_mobile'];
  414. $list = import_exl($file_url, $data, 1);
  415. if (empty($list)) {
  416. ajax_return(1, '请上传有数据的文件');
  417. }
  418. $empty_check = [
  419. 'name' => '企业名称',
  420. 'capital' => '注册资本',
  421. 'tel' => '联系电话',
  422. 'address' => '企业地址',
  423. ];
  424. //错误判断
  425. $time = time();
  426. foreach ($list as $k => $v) {
  427. foreach ($empty_check as $key => $value) {
  428. if (empty($v[$key])) {
  429. return ajax_return(1, '第' . ($k + 2) . '行的' . $value . '不能为空');
  430. }
  431. }
  432. $list[$k]['priority'] = 255;
  433. $list[$k]['create_time'] = $list[$k]['update_time'] = $time;
  434. }
  435. HumanEnterpriseModel::insertAll($list);
  436. ajax_return(0);
  437. }
  438. }