Human.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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. $list = HumanInstitutionModel::where($map)
  201. ->order(['priority' => 'desc', 'update_time' => 'desc'])
  202. ->limit(input('limit'))
  203. ->page(input('page'))
  204. ->append(['status_text'])
  205. ->select();
  206. $count = HumanInstitutionModel::where($map)->count();
  207. if ($count == 0) {
  208. ajax_return(1, '未查询到数据');
  209. }
  210. list_return($list, $count);
  211. }
  212. public function delInstitution()
  213. {
  214. $id_arr = input('id_arr/a');
  215. HumanInstitutionModel::destroy($id_arr);
  216. ajax_return();
  217. }
  218. /**
  219. * 编辑
  220. */
  221. public function institutionForm()
  222. {
  223. $id = input('id/d, 0');
  224. $info = HumanInstitutionModel::find($id);
  225. return view('', [
  226. 'info' => $info,
  227. 'status_list' => HumanInstitutionModel::STATUS,
  228. 'cooperate_list' => HumanInstitutionModel::COOPERATE,
  229. ]);
  230. }
  231. public function editInstitution()
  232. {
  233. $data = input('post.');
  234. try {
  235. validate(HumanInstitutionValidate::class)->check($data);
  236. } catch (ValidateException $e) {
  237. ajax_return(1, $e->getError());
  238. }
  239. if (empty($data['cooperate'])) {
  240. $data['cooperate'] = [];
  241. } else {
  242. $data['cooperate'] = array_values($data['cooperate']);
  243. }
  244. if (empty($data['id'])) {
  245. HumanInstitutionModel::create($data);
  246. } else {
  247. HumanInstitutionModel::update($data, ['id' => $data['id']]);
  248. }
  249. ajax_return();
  250. }
  251. public function importInstitution()
  252. {
  253. return view('public/import', [
  254. 'url' => url('human/importInstitutionPost'),
  255. 'last_table' => 'lay-human-institutionList-table',
  256. 'template_file' => '/static/common/exl/human_institution.xls',
  257. ]);
  258. }
  259. public function importInstitutionPost()
  260. {
  261. $file_url = input('file_url/s', "");
  262. if (!file_exists($file_url)) {
  263. ajax_return(1, '文件不存在');
  264. }
  265. //初始化数据
  266. $data = ['name', 'tel', 'address', 'introduction', 'cooperate', 'join', 'join_mobile'];
  267. $list = import_exl($file_url, $data, 1);
  268. if (empty($list)) {
  269. ajax_return(1, '请上传有数据的文件');
  270. }
  271. $empty_check = [
  272. 'name' => '企业名称',
  273. 'tel' => '联系电话',
  274. 'address' => '企业地址',
  275. ];
  276. //错误判断
  277. $time = time();
  278. foreach ($list as $k => $v) {
  279. foreach ($empty_check as $key => $value) {
  280. if (empty($v[$key])) {
  281. ajax_return(1, '第' . ($k + 2) . '行的' . $value . '不能为空');
  282. }
  283. }
  284. $cooperate = explode(',', $v['cooperate']);
  285. if (!empty($cooperate)) {
  286. foreach ($cooperate as $c) {
  287. if (!in_array($c, HumanInstitutionModel::COOPERATE)) {
  288. ajax_return(1, '第' . ($k + 2) . '行的业务范围(' . $c . ')不在业务范围列表中');
  289. }
  290. }
  291. }
  292. $list[$k]['cooperate'] = $cooperate;
  293. $list[$k]['priority'] = 255;
  294. $list[$k]['create_time'] = $list[$k]['update_time'] = $time;
  295. }
  296. HumanInstitutionModel::insertAll($list);
  297. ajax_return(0);
  298. }
  299. public function enterpriseToInstitution()
  300. {
  301. $id = input('id/d', 0);
  302. empty($id) && ajax_return(1, '请选择企业');
  303. $info = HumanEnterpriseApplyModel::find($id);
  304. empty($info) && ajax_return(1, '请企业不存在');
  305. HumanInstitutionApplyModel::create([
  306. 'open_id' => $info['open_id'],
  307. 'name' => $info['name'],
  308. 'join' => $info['join'],
  309. 'join_mobile' => $info['join_mobile'],
  310. 'wechat' => $info['wechat'],
  311. 'cooperate' => $info['cooperate'],
  312. 'suggestion' => $info['suggestion'],
  313. 'status' => $info['status'],
  314. 'describe' => $info['describe'],
  315. 'url' => $info['url'],
  316. 'images' => $info['images'],
  317. 'is_arrive' => $info['is_arrive'],
  318. 'comment' => $info['comment'],
  319. ]);
  320. $info->delete();
  321. ajax_return();
  322. }
  323. /**
  324. * 企业列表
  325. */
  326. public function enterpriseList()
  327. {
  328. return view('', [
  329. 'status_list' => HumanEnterpriseModel::STATUS,
  330. ]);
  331. }
  332. public function listEnterprise()
  333. {
  334. $map = $this->dealEqualInput(['status'], $this->dealLikeInput(['name']));
  335. $list = HumanEnterpriseModel::where($map)
  336. ->order(['priority' => 'desc', 'update_time' => 'desc'])
  337. ->limit(input('limit'))
  338. ->page(input('page'))
  339. ->append(['status_text'])
  340. ->select();
  341. $count = HumanEnterpriseModel::where($map)->count();
  342. if ($count == 0) {
  343. ajax_return(1, '未查询到数据');
  344. }
  345. list_return($list, $count);
  346. }
  347. public function delEnterprise()
  348. {
  349. $id_arr = input('id_arr/a');
  350. HumanEnterpriseModel::destroy($id_arr);
  351. ajax_return();
  352. }
  353. /**
  354. * 编辑
  355. */
  356. public function enterpriseForm()
  357. {
  358. $id = input('id/d, 0');
  359. $info = HumanEnterpriseModel::find($id);
  360. return view('', [
  361. 'info' => $info,
  362. 'status_list' => HumanEnterpriseModel::STATUS,
  363. ]);
  364. }
  365. public function editEnterprise()
  366. {
  367. $data = input('post.');
  368. try {
  369. validate(HumanEnterpriseValidate::class)->check($data);
  370. } catch (ValidateException $e) {
  371. ajax_return(1, $e->getError());
  372. }
  373. if (empty($data['id'])) {
  374. HumanEnterpriseModel::create($data);
  375. } else {
  376. HumanEnterpriseModel::update($data, ['id' => $data['id']]);
  377. }
  378. ajax_return();
  379. }
  380. public function importEnterprise()
  381. {
  382. return view('public/import', [
  383. 'url' => url('human/importEnterprisePost'),
  384. 'last_table' => 'lay-human-enterpriseList-table',
  385. 'template_file' => '/static/common/exl/human_enterprise.xls',
  386. ]);
  387. }
  388. public function importEnterprisePost()
  389. {
  390. $file_url = input('file_url/s', "");
  391. if (!file_exists($file_url)) {
  392. ajax_return(1, '文件不存在');
  393. }
  394. //初始化数据
  395. $data = ['name', 'capital', 'tel', 'address', 'introduction', 'join', 'join_mobile'];
  396. $list = import_exl($file_url, $data, 1);
  397. if (empty($list)) {
  398. ajax_return(1, '请上传有数据的文件');
  399. }
  400. $empty_check = [
  401. 'name' => '企业名称',
  402. 'capital' => '注册资本',
  403. 'tel' => '联系电话',
  404. 'address' => '企业地址',
  405. ];
  406. //错误判断
  407. $time = time();
  408. foreach ($list as $k => $v) {
  409. foreach ($empty_check as $key => $value) {
  410. if (empty($v[$key])) {
  411. return ajax_return(1, '第' . ($k + 2) . '行的' . $value . '不能为空');
  412. }
  413. }
  414. $list[$k]['priority'] = 255;
  415. $list[$k]['create_time'] = $list[$k]['update_time'] = $time;
  416. }
  417. HumanEnterpriseModel::insertAll($list);
  418. ajax_return(0);
  419. }
  420. }