Comjobs.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\BaseController;
  4. use app\common\model\Config;
  5. use app\common\model\RensheCode;
  6. use app\common\model\Worker as WorkerModel;
  7. use app\common\model\Comjobs as ComjobsModel;
  8. use app\common\model\ComjobsCate as ComjobsCateModel;
  9. use app\common\model\ComjobsLog as ComjobsLogModel;
  10. use app\common\model\ComjobsStar as ComjobsStarModel;
  11. use app\common\model\ComjobsReport as ComjobsReportModel;
  12. use app\common\model\Broker as BrokerModel;
  13. use app\common\model\ComjobsShare as ComjobsShareModel;
  14. use app\common\model\WorkerThird;
  15. use app\common\service\RensheService;
  16. use app\common\validate\Comjobs as ComjobsValidate;
  17. use think\exception\ValidateException;
  18. class Comjobs extends BaseController
  19. {
  20. // 报名记录
  21. public function logList()
  22. {
  23. $workerlist = WorkerModel::with('comjobs')->order(['id' => 'desc'])->select();
  24. return view('comjobs/loglist', [
  25. 'workerlist' => $workerlist,
  26. ]);
  27. }
  28. public function delLog()
  29. {
  30. $idarr = input('idarr/a');
  31. $log = ComjobsLogModel::whereIn('id', $idarr)->select();
  32. $result = $log->delete();
  33. if ($result) {
  34. exit(json_encode([
  35. 'code' => 0,
  36. 'msg' => "",
  37. ]));
  38. }
  39. exit(json_encode([
  40. 'code' => 1,
  41. 'msg' => "删除失败,请稍后重试",
  42. ]));
  43. }
  44. public function fieldLog()
  45. {
  46. $id = input('id/d', 0);
  47. $log = ComjobsLogModel::findOrEmpty($id);
  48. if ($log->isEmpty()) {
  49. exit(json_encode([
  50. 'code' => 1,
  51. 'msg' => "信息不存在",
  52. ]));
  53. } else {
  54. $log->save([
  55. input('field/s') => input('value'),
  56. ]);
  57. }
  58. exit(json_encode([
  59. 'code' => 0,
  60. ]));
  61. }
  62. public function listLog()
  63. {
  64. $limit = input('limit/d', 20);
  65. $page = input('page/d', 1);
  66. $map = [];
  67. $workercomjobsarr = explode(",", input('workercomjobs/s'));
  68. $workerid = isset($workercomjobsarr[0]) ? $workercomjobsarr[0] : 0;
  69. $comjobsid = isset($workercomjobsarr[1]) ? $workercomjobsarr[1] : 0;
  70. if (!empty($workerid)) {
  71. $map[] = ['workerid', '=', $workerid];
  72. }
  73. if (!empty($comjobsid)) {
  74. $map[] = ['comjobsid', '=', $comjobsid];
  75. }
  76. $status = input('status/d', 0);
  77. if (!empty($status)) {
  78. $map[] = ['status', '=', $status];
  79. }
  80. $list = ComjobsLogModel::with(['user', 'worker', 'comjobs'])->where($map)->order('id', 'DESC')->limit($limit)->page($page)->append(['status_text'])->select();
  81. $count = ComjobsLogModel::where($map)->count();
  82. if ($count == 0) {
  83. exit(json_encode([
  84. 'code' => 1,
  85. 'msg' => "未查询到数据",
  86. ]));
  87. }
  88. exit(json_encode([
  89. 'code' => 0,
  90. 'msg' => "",
  91. 'count' => $count,
  92. 'data' => $list,
  93. ]));
  94. }
  95. public function exportLog()
  96. {
  97. $map = [];
  98. $workercomjobsarr = explode(",", input('workercomjobs/s'));
  99. $workerid = isset($workercomjobsarr[0]) ? $workercomjobsarr[0] : 0;
  100. $comjobsid = isset($workercomjobsarr[1]) ? $workercomjobsarr[1] : 0;
  101. if (!empty($workerid)) {
  102. $map[] = ['workerid', '=', $workerid];
  103. }
  104. if (!empty($comjobsid)) {
  105. $map[] = ['comjobsid', '=', $comjobsid];
  106. }
  107. $status = input('status/d', 0);
  108. if (!empty($status)) {
  109. $map[] = ['status', '=', $status];
  110. }
  111. $xlsData = ComjobsLogModel::with(['user', 'worker', 'comjobs'])->where($map)->order('id', 'DESC')->append(['status_text'])->select()->toArray();
  112. $xlsCell = [
  113. ['id', '表ID'],
  114. ['user.nickname', '昵称'],
  115. ['user.realname', '姓名'],
  116. ['user.mobile', '手机号'],
  117. ['worker.title', '劳务公司'],
  118. ['comjobs.title', '招聘标题'],
  119. ['status_text', '公司反馈'],
  120. ['remark', '反馈备注'],
  121. ['createtime', '报名时间'],
  122. ];
  123. export_excel("招聘报名记录", $xlsCell, $xlsData);
  124. }
  125. // 企业招聘
  126. public function comjobsList()
  127. {
  128. $workerlist = WorkerModel::order(['id' => 'desc'])->select();
  129. $catelist = ComjobsCateModel::order(['priority' => 'desc', 'id' => 'desc'])->select();
  130. return view('comjobs/comjobslist', [
  131. 'workerlist' => $workerlist,
  132. 'catelist' => $catelist,
  133. ]);
  134. }
  135. public function comjobsForm()
  136. {
  137. $id = input('id/d, 0');
  138. $comjobs = ComjobsModel::findOrEmpty($id);
  139. $workerlist = WorkerModel::order(['id' => 'desc'])->select();
  140. $catelist = ComjobsCateModel::order(['priority' => 'desc', 'id' => 'desc'])->select();
  141. $agelist = RensheCode::getList('age');
  142. $educationlist = RensheCode::getList('education');
  143. $emptimelist = RensheCode::getList('emp_time');
  144. $welfarelist = RensheCode::getList('welfare');
  145. return view('comjobs/comjobsform', [
  146. 'catelist' => $catelist,
  147. 'workerlist' => $workerlist,
  148. 'agelist' => $agelist,
  149. 'educationlist' => $educationlist,
  150. 'emptimelist' => $emptimelist,
  151. 'welfarelist' => $welfarelist,
  152. 'comjobs' => $comjobs,
  153. ]);
  154. }
  155. public function editComjobs()
  156. {
  157. $id = input('id/d', 0);
  158. $wtype = input('wtype/d', 1);
  159. $zwagall = $wtype == 1 ? input('zwagall/s', "") : '';
  160. $data = [
  161. 'workerid' => input('workerid/d', 0),
  162. 'title' => input('title/s', ""),
  163. 'cateid' => input('cateid/d', 0),
  164. 'province' => input('province/s', ""),
  165. 'city' => input('city/s', ""),
  166. 'district' => input('district/s', ""),
  167. 'agegroup' => input('agegroup/s', ""),
  168. 'tags' => array_values(input('tags/a', [])),
  169. 'requirement' => input('requirement/s', ""),
  170. 'comdetails' => input('comdetails/s', ""),
  171. 'companydetails' => input('companydetails/s', ""),
  172. 'retmoney' => input('retmoney/d', ""),
  173. 'picall' => input('picall/a', []),
  174. 'recruit_num' => input('recruit_num/d', 1),
  175. 'wtype' => $wtype,
  176. 'zwagall' => $zwagall,
  177. 'telephone' => input('telephone/s', ""),
  178. 'remark' => input('remark/s', ""),
  179. 'status' => input('status/d', 1),
  180. 'num' => input('num/d', 1),
  181. 'priority' => input('priority/d', 0),
  182. 'updatetime' => input('updatetime/s', ""),
  183. 'createtime' => input('createtime/s', ""),
  184. 'volume' => input('volume/d', 0),
  185. 'recruitment_cate' => input('recruitment_cate/d', 1),
  186. 'latitude' => input('latitude/f', 0),
  187. 'longitude' => input('longitude/f', 0),
  188. 'address' => input('address/s', ''),
  189. 'is_worry' => input('is_worry/d', 0),
  190. 'education' => input('education/s', ''),
  191. 'emp_time' => array_values(input('emp_time/a', [])),
  192. ];
  193. try {
  194. validate(ComjobsValidate::class)->check($data);
  195. } catch (ValidateException $e) {
  196. exit(json_encode([
  197. 'code' => 1,
  198. 'msg' => $e->getError(),
  199. ]));
  200. }
  201. if (empty($id)) {
  202. $data['video'] = input('new_video/s', "");
  203. ComjobsModel::create($data);
  204. } else {
  205. $old_video = input('old_video/s', '');
  206. $new_video = input('new_video/s', '');
  207. if (!empty($new_video)) {
  208. $data['video'] = $new_video;
  209. } else {
  210. if (!empty($old_video)) {
  211. $data['video'] = $old_video;
  212. }
  213. }
  214. $comjobs = ComjobsModel::find($id);
  215. ComjobsLogModel::update(['workerid' => input('workerid/d', 0)], ['comjobsid' => $comjobs->id]);
  216. $comjobs->save($data);
  217. }
  218. exit(json_encode([
  219. 'code' => 0,
  220. ]));
  221. }
  222. public function fieldComjobs()
  223. {
  224. $id = input('id/d', 0);
  225. $comjobs = ComjobsModel::findOrEmpty($id);
  226. if ($comjobs->isEmpty()) {
  227. exit(json_encode([
  228. 'code' => 1,
  229. 'msg' => "信息不存在",
  230. ]));
  231. } else {
  232. $comjobs->save([
  233. input('field/s') => input('value'),
  234. ]);
  235. }
  236. exit(json_encode([
  237. 'code' => 0,
  238. ]));
  239. }
  240. public function delComjobs()
  241. {
  242. $idarr = input('idarr/a');
  243. ComjobsLogModel::whereIn('comjobsid', $idarr)->delete();
  244. ComjobsStarModel::whereIn('comjobsid', $idarr)->delete();
  245. ComjobsReportModel::whereIn('comjobsid', $idarr)->delete();
  246. $result = ComjobsModel::destroy($idarr, true);
  247. if ($result) {
  248. exit(json_encode([
  249. 'code' => 0,
  250. 'msg' => "",
  251. ]));
  252. }
  253. exit(json_encode([
  254. 'code' => 1,
  255. 'msg' => "删除失败,请稍后重试",
  256. ]));
  257. }
  258. public function listComjobs()
  259. {
  260. $limit = input('limit/d', 20);
  261. $page = input('page/d', 1);
  262. $map = [];
  263. $keywords = input('keywords/s', "");
  264. if (!empty($keywords)) {
  265. $map[] = ['title', 'like', '%' . $keywords . '%'];
  266. }
  267. $workerid = input('workerid/d', 0);
  268. if (!empty($workerid)) {
  269. $map[] = ['workerid', '=', $workerid];
  270. }
  271. $cateid = input('cateid/d', 0);
  272. if (!empty($cateid)) {
  273. $map[] = ['cateid', '=', $cateid];
  274. }
  275. $wtype = input('wtype/d');
  276. if (!empty($wtype)) {
  277. $map[] = ['wtype', '=', $wtype];
  278. }
  279. $status = input('status/d');
  280. if (!empty($status)) {
  281. $map[] = ['status', '=', $status];
  282. }
  283. $daterange = input('daterange/s', "");
  284. if (!empty($daterange)) {
  285. $daterangearr = explode("~", $daterange);
  286. $map[] = ['createtime', '>= time', trim($daterangearr[0])];
  287. $map[] = ['createtime', '<= time', trim($daterangearr[1])];
  288. }
  289. // $list = ComjobsModel::with(['worker', 'comjobsCate'])->withCount(['comjobsLog'])->where($map)->order(['priority' => 'desc', 'id' => 'desc'])->limit($limit)->page($page)->append(['wtype_text', 'status_text'])->select();
  290. $list = ComjobsModel::with(['worker', 'comjobsCate'])->withCount(['comjobsLog'])->where($map)->order(['updatetime' => 'desc'])->limit($limit)->page($page)->append(['wtype_text', 'status_text'])->select();
  291. $count = ComjobsModel::where($map)->count();
  292. $list = $list->toArray();
  293. foreach ($list as $k => $v) {
  294. if (!empty($v['company_name'])) {
  295. $list[$k]['worker']['title'] = $v['company_name'];
  296. }
  297. }
  298. if ($count == 0) {
  299. exit(json_encode([
  300. 'code' => 1,
  301. 'msg' => "未查询到数据",
  302. ]));
  303. }
  304. exit(json_encode([
  305. 'code' => 0,
  306. 'msg' => "",
  307. 'count' => $count,
  308. 'data' => $list,
  309. ]));
  310. }
  311. // 岗位类型
  312. public function cateList()
  313. {
  314. return view('comjobs/catelist');
  315. }
  316. public function cateForm()
  317. {
  318. $id = input('id/d', 0);
  319. $cate = ComjobsCateModel::findOrEmpty($id);
  320. $catelist = ComjobsCateModel::where('pid', 0)->select();
  321. return view('comjobs/cateform', [
  322. 'cate' => $cate,
  323. 'catelist' => $catelist,
  324. ]);
  325. }
  326. public function listCate()
  327. {
  328. $limit = input('limit');
  329. $page = input('page');
  330. $list = ComjobsCateModel::with('pcate')->order(['pid' => 'asc', 'priority' => 'desc'])->limit($limit)->page($page)->select();
  331. $count = ComjobsCateModel::count();
  332. if ($count == 0) {
  333. exit(json_encode([
  334. 'code' => 1,
  335. 'msg' => "未查询到数据",
  336. ]));
  337. }
  338. exit(json_encode([
  339. 'code' => 0,
  340. 'msg' => "",
  341. 'count' => $count,
  342. 'data' => $list,
  343. ]));
  344. }
  345. public function fieldCate()
  346. {
  347. $id = input('id/d', 0);
  348. $info = ComjobsCateModel::find($id);
  349. $info->save([
  350. input('field/s') => input('value/s', ""),
  351. ]);
  352. exit(json_encode([
  353. 'code' => 0,
  354. ]));
  355. }
  356. public function editCate()
  357. {
  358. $id = input('id/d');
  359. if (empty($id)) {
  360. $cate = ComjobsCateModel::create([
  361. 'title' => input('title/s', ""),
  362. 'pid' => input('pid/d', 0),
  363. 'priority' => input('priority/d', 0),
  364. ]);
  365. } else {
  366. $cate = ComjobsCateModel::find($id);
  367. $cate->save([
  368. 'title' => input('title/s', ""),
  369. 'pid' => input('pid/d', 0),
  370. 'priority' => input('priority/d', 0),
  371. ]);
  372. }
  373. exit(json_encode([
  374. 'code' => 0,
  375. ]));
  376. }
  377. public function delCate()
  378. {
  379. $id = input('id/d');
  380. $cate = ComjobsCateModel::where('id', $id)->select();
  381. $result = $cate->delete();
  382. if ($result) {
  383. exit(json_encode([
  384. 'code' => 0,
  385. 'msg' => "",
  386. ]));
  387. }
  388. exit(json_encode([
  389. 'code' => 1,
  390. 'msg' => "删除失败,请稍后重试",
  391. ]));
  392. }
  393. // 推广海报
  394. public function shareList()
  395. {
  396. return view('comjobs/sharelist', []);
  397. }
  398. public function shareForm()
  399. {
  400. $id = input('id/d', 0);
  401. $share = ComjobsShareModel::findOrEmpty($id);
  402. return view('comjobs/shareform', [
  403. 'share' => $share,
  404. ]);
  405. }
  406. public function editShare()
  407. {
  408. $id = input('id/d', 0);
  409. $data = [
  410. 'title' => input('title/s', ""),
  411. 'tilpic' => input('tilpic/s', ""),
  412. 'status' => input('status/d', 1),
  413. 'priority' => input('priority/d', 0),
  414. ];
  415. if (empty($id)) {
  416. $share = ComjobsShareModel::create($data);
  417. } else {
  418. $share = ComjobsShareModel::find($id);
  419. $share->save($data);
  420. }
  421. exit(json_encode([
  422. 'code' => 0,
  423. ]));
  424. }
  425. public function listShare()
  426. {
  427. $limit = input('limit');
  428. $page = input('page');
  429. $map = [];
  430. $status = input('status/d', 0);
  431. if (!empty($status)) {
  432. $map[] = ['status', '=', $status];
  433. }
  434. $list = ComjobsShareModel::where($map)->order(['priority' => 'desc', 'id' => 'desc'])->limit($limit)->page($page)->append(['status_text'])->select();
  435. $count = ComjobsShareModel::where($map)->count();
  436. if ($count == 0) {
  437. exit(json_encode([
  438. 'code' => 1,
  439. 'msg' => "未查询到数据",
  440. ]));
  441. }
  442. exit(json_encode([
  443. 'code' => 0,
  444. 'msg' => "",
  445. 'count' => $count,
  446. 'data' => $list,
  447. ]));
  448. }
  449. public function fieldShare()
  450. {
  451. $id = input('id/d', 0);
  452. $info = ComjobsShareModel::find($id);
  453. $info->save([
  454. input('field/s') => input('value/s', ""),
  455. ]);
  456. exit(json_encode([
  457. 'code' => 0,
  458. ]));
  459. }
  460. public function delShare()
  461. {
  462. $id = input('id/d', 0);
  463. $share = ComjobsShareModel::where('id', $id)->select();
  464. $result = $share->delete();
  465. if ($result) {
  466. exit(json_encode([
  467. 'code' => 0,
  468. 'msg' => "",
  469. ]));
  470. }
  471. exit(json_encode([
  472. 'code' => 1,
  473. 'msg' => "删除失败,请稍后重试",
  474. ]));
  475. }
  476. public function synRenshe()
  477. {
  478. //发送数据
  479. $id = input('id/d', 0);
  480. $service = new RensheService();
  481. $res = $service->jobInfoByComId($id);
  482. if ($res['code'] == 200) {
  483. return json(['code' => 0]);
  484. } else {
  485. return json([
  486. 'code' => 1,
  487. 'msg' => '网络异常,请重试',
  488. ]);
  489. }
  490. }
  491. public function import()
  492. {
  493. $data = ['cate', 'title', 'type', 'zwagall', 'community', 'province', 'city', 'district', 'education', 'agegroup', 'tags', 'comdetails', 'requirement',
  494. 'worker', 'telephone', 'name', 'address', 'time', 'emp_time', 'is_worry'];
  495. $list = importExecl('2.xlsx', $data, 1);
  496. $data = [];
  497. $wtype = ['按月' => 1, '按时' => 2, '按件' => 3, '按项目' => 4, '其他' => 5];
  498. $rensheCode = RensheCode::select();
  499. $renshe = [];
  500. foreach ($rensheCode as $v) {
  501. $renshe[$v['type']][$v['name']] = $v['code'];
  502. }
  503. $cateList = ComjobsCateModel::column('id', 'title');
  504. foreach ($list as $v) {
  505. if (empty($v['cate'])) {
  506. continue;
  507. }
  508. $item = [];
  509. $third = WorkerThird::create(['name' => $v['worker'], 'contact' => $v['name']]);
  510. $item['third_id'] = $third['id'];
  511. $item['cateid'] = empty($cateList[$v['cate']]) ? '' : $cateList[$v['cate']];
  512. $item['title'] = $v['title'];
  513. $item['wtype'] = $wtype[$v['type']];
  514. $item['zwagall'] = $item['bwagall'] = $v['zwagall'];
  515. if (!empty($renshe['community'][$v['community']])) {
  516. $item['community'] = $renshe['community'][$v['community']];
  517. }
  518. $item['province'] = $v['province'];
  519. $item['city'] = $v['city'];
  520. $item['district'] = $v['district'];
  521. if (!empty($renshe['education'][$v['education']])) {
  522. $item['education'] = $v['education'];
  523. }
  524. if (!empty($renshe['age'][$v['agegroup']])) {
  525. $item['agegroup'] = $v['agegroup'];
  526. }
  527. $tags = explode(',', $v['tags']);
  528. if (empty($tags[0])) {
  529. $tags = [];
  530. }
  531. $item['tags'] = $tags;
  532. $item['comdetails'] = (string)$v['comdetails'];
  533. $item['requirement'] = (string)$v['requirement'];
  534. $item['workerid'] = 8;
  535. $item['telephone'] = (string)$v['telephone'];
  536. $item['address'] = (string)$v['address'];
  537. $emp_time = explode(',', $v['emp_time']);
  538. if (empty($emp_time[0])) {
  539. $emp_time = [];
  540. }
  541. $item['emp_time'] = $emp_time;
  542. $item['is_worry'] = $v['is_worry'] ? $v['is_worry'] : 0;
  543. $item['picall'] = [];
  544. $item['companydetails'] = '';
  545. $item['video'] = '';
  546. $item['priority'] = 0;
  547. $item['status'] = 3;
  548. $item['enddate'] = 1664553599;
  549. $item['createtime'] = $item['updatetime'] = time();
  550. $data[] = $item;
  551. }
  552. foreach ($data as $v) {
  553. ComjobsModel::create($v);
  554. }
  555. }
  556. /**
  557. * 代报名
  558. */
  559. public function comjobsreport()
  560. {
  561. $id = input('id/d', 0);
  562. if (empty($id)) {
  563. return json([
  564. 'code' => 1,
  565. 'msg' => '网络异常,请重试',
  566. ]);
  567. }
  568. $comjobs = ComjobsModel::with('worker')->findOrEmpty($id);
  569. if (empty($comjobs)) {
  570. return json([
  571. 'code' => 1,
  572. 'msg' => '网络异常,请重试',
  573. ]);
  574. }
  575. return view('comjobs/comjobsreport', [
  576. 'comjobs' => $comjobs,
  577. ]);
  578. }
  579. /**
  580. * 代报名提交
  581. */
  582. public function submitreport()
  583. {
  584. $data = [
  585. 'comjobsid' => input('comjobsid/d',0),
  586. 'realname' => input('realname/s',''),
  587. 'mobile' => input('mobile/s',''),
  588. 'idcard' => input('idcard/s',''),
  589. 'arrivetime' => input('arrivetime/s',''),
  590. 'remark' => input('remark/s',''),
  591. ];
  592. //数据处理
  593. $data['createtime'] = time();
  594. $brokerid = Config::getConfigValue('default_broker');
  595. $broker = BrokerModel::findOrEmpty($brokerid);
  596. $data['workerid'] = $broker['workerid'];
  597. $data['agentid'] = $broker['agentid'];
  598. $data['brokerid'] = $broker['id'];
  599. //代报名
  600. ComjobsReportModel::create($data);
  601. return json(['code' => 0]);
  602. }
  603. }