DemandLabor.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <?php
  2. namespace app\data\controller\api\auth;
  3. use app\data\controller\api\Auth;
  4. use app\data\controller\api\Data;
  5. use app\data\model\DataCollectionLog;
  6. use app\data\model\DataRecruitment;
  7. use app\data\model\DataTeachingKnowledge;
  8. use app\data\model\DataUserApplyJobInfo;
  9. use app\data\model\DataUserApplyJobInfoChild;
  10. use app\data\service\MessageService;
  11. use think\admin\Storage;
  12. use think\db\Query;
  13. use think\exception\HttpResponseException;
  14. use think\admin\Controller;
  15. use hg\apidoc\annotation\Title;
  16. use hg\apidoc\annotation\Method;
  17. use hg\apidoc\annotation\Param;
  18. use hg\apidoc\annotation\Header;
  19. use hg\apidoc\annotation\Returned;
  20. use think\facade\Validate;
  21. /**
  22. * @Title("劳务需求")
  23. */
  24. class DemandLabor extends Auth
  25. {
  26. protected $noNeedLogin=[];
  27. /**
  28. * @Title("招聘信息,应聘信息列表")
  29. * @Method("post")
  30. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  31. * @Header("api-token",type="string",require=1,default="",desc="token")
  32. * @Param("type",type="string",require=1,default="1",desc="1:招聘信息2:应聘信息")
  33. * @Param("keyword",type="string",require=0,default="",desc="关键词搜索")
  34. * @Param("salary",type="string",require=0,default="",desc="薪资待遇1:不限 2:4K以下 3:4K-6K 4:6K-8K 5:8K-12K 6:12K以上")
  35. * @Param("type",type="string",require=1,default="",desc="1:招聘信息2:应聘信息")
  36. * @Returned("json",desc="")
  37. */
  38. public function demandlist()
  39. {
  40. $data = $this->_vali([
  41. 'type.require|in:1,2'=>'type有误',
  42. 'keyword.default'=>'',
  43. 'salary.default'=>'',
  44. 'schooling.default'=>''
  45. ]);
  46. switch ($data['type']){
  47. case 1:
  48. $keyword = $data['keyword'];
  49. $salary = $data['salary'];
  50. $schooling = $data['schooling'];
  51. $list = DataRecruitment::mk()
  52. ->where('is_del',1)
  53. ->where('state',1)
  54. // ->hasWhere('shipyard',function ($query) use ($keyword){
  55. // $query->whereLike('data_recruitment.title|name','%'.$keyword.'%');
  56. // },'data_recruitment.id,shipyard_id,title,data_recruitment.province,data_recruitment.city,schooling,salary_start,salary_end,contact_person,contact_headimg,contact_position,experience')
  57. ->when($salary,function ($query) use ($salary){
  58. switch ($salary){
  59. case 1:
  60. break;
  61. case 2:
  62. $query->where('salary_start','<','4000');
  63. break;
  64. case 3:
  65. $query->whereRaw('(salary_start>=4000 and salary_start<6000) or (salary_end>=4000 and salary_end<6000)');
  66. break;
  67. case 4:
  68. $query->whereRaw('(salary_start>=6000 and salary_start<8000) or (salary_end>=6000 and salary_end<8000)');
  69. break;
  70. case 5:
  71. $query->whereRaw('(salary_start>=8000 and salary_start<12000) or (salary_end>=8000 and salary_end<12000)');
  72. break;
  73. case 6:
  74. $query->whereRaw('(salary_start>=12000) or (salary_end>=12000)');
  75. break;
  76. }
  77. })
  78. ->when($schooling,function ($query) use ($schooling){
  79. $query->where('schooling',$schooling);
  80. })
  81. ->with(['shipyard'=>function($query){
  82. $query->field('id,name');
  83. }])
  84. ->paginate();
  85. break;
  86. case 2:
  87. $list = DataUserApplyJobInfo::mk()->alias('a')
  88. ->where('a.audit',2)
  89. ->where('a.hidden',1)
  90. ->field('a.id,uuid,a.head_img,a.real_name,a.sex,age,work_year,schooling,job_application,scope_work_area,province,city,area,b.is_vip')
  91. ->leftJoin('data_user b','a.uuid=b.id')
  92. ->order('b.is_vip desc,a.id desc')
  93. ->paginate();
  94. break;
  95. }
  96. $this->success('成功',$list);
  97. }
  98. /**
  99. * @Title("招聘信息详情、应聘信息详情")
  100. * @Method("post")
  101. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  102. * @Header("api-token",type="string",require=1,default="",desc="token")
  103. * @Param("type",type="string",require=1,default="",desc="1:招聘信息2:应聘信息")
  104. * @Param("id",type="string",require=1,default="",desc="主键ID")
  105. * @Returned("is_collection",desc="1:已收藏0:未收藏")
  106. * @Returned("is_like",desc="1:已感兴趣0:未感兴趣")
  107. */
  108. public function demanddetail(){
  109. $data = $this->_vali([
  110. 'type.require|in:1,2'=>'type有误',
  111. 'id.require'=>'id必须'
  112. ]);
  113. switch ($data['type']){
  114. case 1:
  115. $info = DataRecruitment::mk()
  116. ->where('id',$data['id'])
  117. ->where('is_del',1)
  118. ->where('state',1)
  119. ->findOrEmpty();
  120. $info['is_collection'] = DataCollectionLog::Show(3,$this->uuid,$data['id'])->count() ? 1 : 0;
  121. $info['is_like'] = DataCollectionLog::Show(3,$this->uuid,$data['id'],2)->count() ? 1 : 0;
  122. break;
  123. case 2:
  124. $info = DataUserApplyJobInfo::mk()
  125. ->where('id',$data['id'])
  126. ->where('audit',2)
  127. ->where('hidden',1)
  128. ->with(['workexperience','professionalskills','certificate'])
  129. ->findOrEmpty();
  130. $info['is_collection'] = DataCollectionLog::Show(4,$this->uuid,$data['id'])->count() ? 1 : 0;
  131. $info['is_like'] = DataCollectionLog::Show(4,$this->uuid,$data['id'],2)->count() ? 1 : 0;
  132. break;
  133. }
  134. $this->success('成功',$info);
  135. }
  136. /**
  137. * @Title("招聘信息、应聘信息收藏/取消收藏")
  138. * @Method("post")
  139. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  140. * @Header("api-token",type="string",require=1,default="",desc="token")
  141. * @Param("type",type="string",require=1,default="",desc="1:招聘信息2:应聘信息")
  142. * @Param("id",type="string",require=1,default="",desc="主键ID")
  143. * @Param("category",type="string",require=1,default="",desc="1:收藏2:取消收藏")
  144. */
  145. public function cocanclecollection(){
  146. $data = $this->_vali([
  147. 'type.require|in:1,2'=>'type有误',
  148. 'id.require'=>'id必须',
  149. 'category.require|in:1,2'=>'category有误'
  150. ]);
  151. switch ($data['category']){
  152. case 1:
  153. switch ($data['type']){
  154. case 1:
  155. DataCollectionLog::Show(3,$this->uuid,$data['id'])->count() ? $this->error('已收藏过') : '';
  156. $type = 3;
  157. break;
  158. case 2:
  159. $type = 4;
  160. DataCollectionLog::Show(4,$this->uuid,$data['id'])->count() ? $this->error('已收藏过') : '';
  161. break;
  162. }
  163. if (DataCollectionLog::mk()->insert(['uuid'=>$this->uuid,'type'=>$type,'link_id'=>$data['id']])){
  164. $this->success('收藏成功');
  165. }
  166. $this->error('收藏失败');
  167. break;
  168. case 2:
  169. switch ($data['type']){
  170. case 1:
  171. DataCollectionLog::Show(3,$this->uuid,$data['id'])->count() ? : $this->error('未收藏');
  172. $type = 3;
  173. break;
  174. case 2:
  175. $type = 4;
  176. DataCollectionLog::Show(4,$this->uuid,$data['id'])->count() ? : $this->error('未收藏');
  177. break;
  178. }
  179. if (DataCollectionLog::mk()->where('uuid',$this->uuid)->where('type',$type)->where('link_id',$data['id'])->delete()){
  180. $this->success('收藏成功');
  181. }
  182. $this->error('收藏失败');
  183. break;
  184. }
  185. }
  186. /**
  187. * @Title("招聘信息、应聘信息感兴趣/取消感兴趣")
  188. * @Method("post")
  189. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  190. * @Header("api-token",type="string",require=1,default="",desc="token")
  191. * @Param("type",type="string",require=1,default="",desc="1:招聘信息2:应聘信息")
  192. * @Param("id",type="string",require=1,default="",desc="主键ID")
  193. * @Param("category",type="string",require=1,default="",desc="1:感兴趣2:取消感兴趣")
  194. */
  195. public function cocanclelike(){
  196. $data = $this->_vali([
  197. 'type.require|in:1,2'=>'type有误',
  198. 'id.require'=>'id必须',
  199. 'category.require|in:1,2'=>'category有误'
  200. ]);
  201. switch ($data['category']){
  202. case 1:
  203. switch ($data['type']){
  204. case 1:
  205. DataCollectionLog::Show(3,$this->uuid,$data['id'],2)->count() ? $this->error('已感兴趣') : '';
  206. $type = 3;
  207. break;
  208. case 2:
  209. $type = 4;
  210. DataCollectionLog::Show(4,$this->uuid,$data['id'],2)->count() ? $this->error('已感兴趣') : '';
  211. break;
  212. }
  213. if (DataCollectionLog::mk()->insert(['uuid'=>$this->uuid,'cate'=>2,'type'=>$type,'link_id'=>$data['id']])){
  214. $this->success('感兴趣成功');
  215. }
  216. $this->error('感兴趣失败');
  217. break;
  218. case 2:
  219. switch ($data['type']){
  220. case 1:
  221. DataCollectionLog::Show(3,$this->uuid,$data['id'],2)->count() ? : $this->error('未感兴趣');
  222. $type = 3;
  223. break;
  224. case 2:
  225. $type = 4;
  226. DataCollectionLog::Show(4,$this->uuid,$data['id'],2)->count() ? : $this->error('未已感兴趣');
  227. break;
  228. }
  229. if (DataCollectionLog::Show($type,$this->uuid,$data['id'],2)->delete()){
  230. $this->success('取消成功');
  231. }
  232. $this->error('取消失败');
  233. break;
  234. }
  235. }
  236. /**
  237. * @Title("发布应聘、修改")
  238. * @Method("post")
  239. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  240. * @Header("api-token",type="string",require=1,default="",desc="token")
  241. * @Param("type",type="string",require=1,default="",desc="1:基本信息2:求职意向3:工作经历4:专业技能5:资质证书6:其他(福利待遇、备注,定位省市区)")
  242. * @Param("head_img",type="string",require=0,default="",desc="头像")
  243. * @Param("real_name",type="string",require=0,default="",desc="真实姓名")
  244. * @Param("sex",type="string",require=0,default="",desc="性别")
  245. * @Param("date_birth",type="string",require=0,default="",desc="出生年月")
  246. * @Param("schooling",type="string",require=0,default="",desc="学历")
  247. * @Param("start_working_time",type="string",require=0,default="",desc="参加工作时间")
  248. * @Param("phone",type="string",require=0,default="",desc="手机号")
  249. * @Param("email",type="string",require=0,default="",desc="邮箱")
  250. * @Param("job_application",type="string",require=0,default="",desc="应聘岗位")
  251. * @Param("scope_work_area",type="string",require=0,default="",desc="工作地区")
  252. * @Param("monthly_salary",type="string",require=0,default="",desc="期望月薪")
  253. * @Param("working_time",type="string",require=0,default="",desc="可工作时间")
  254. * @Param("work_nature",type="string",require=0,default="",desc="工作性质")
  255. * @Param("work_experience",type="json",require=0,default="",desc="工作经历json,(company_name:公司名称,position_name:职位名称,on_job_start:在职时间开始,on_job_end:在职时间结束,job_description:工作内容)")
  256. * @Param("professional_skills",type="json",require=0,default="",desc="专业技能json,(skill_name:技能名称,degree:掌握程度)")
  257. * @Param("certificate",type="json",require=0,default="",desc="资质证书json,(certificate_name:证书名称,gain_time:获得时间,img:图片)")
  258. * @Param("child_id",type="string",require=0,default="",desc="id,type为3,4,5时,修改时传入此值")
  259. * @Param("welfare_benefits",type="string",require=0,default="",desc="福利待遇")
  260. * @Param("remark",type="string",require=0,default="",desc="备注")
  261. * @Param("province",type="string",require=0,default="",desc="定位-省")
  262. * @Param("city",type="string",require=0,default="",desc="定位-市")
  263. * @Param("area",type="string",require=0,default="",desc="定位-区")
  264. */
  265. public function applyjob(){
  266. $data = $this->_vali([
  267. 'type.require|in:1,2,3,4,5,6'=>'type有误',
  268. ]);
  269. $type = $data['type'];
  270. switch ($type){
  271. case 1:
  272. $data = $this->_vali([
  273. 'uuid.default'=>$this->uuid,
  274. 'head_img.requireIf:type,1'=>'头像必须',
  275. 'real_name.requireIf:type,1'=>'真实姓名必须',
  276. 'sex.requireIf:type,1'=>'性别必须',
  277. 'date_birth.requireIf:type,1'=>'出生年月必须',
  278. 'schooling.requireIf:type,1'=>'学历必须',
  279. 'start_working_time.requireIf:type,1'=>'参加工作时间必须',
  280. 'phone.requireIf:type,1'=>'手机号必须',
  281. 'email.requireIf:type,1'=>'邮箱必须',
  282. ]);
  283. $data['age'] = getAge($data['date_birth']);
  284. $data['work_year'] = getAge($data['start_working_time']);
  285. break;
  286. case 2:
  287. $data = $this->_vali([
  288. 'uuid.default'=>$this->uuid,
  289. 'job_application.requireIf:type,2'=>'应聘岗位必须',
  290. 'scope_work_area.requireIf:type,2'=>'工作地区必须',
  291. 'monthly_salary.requireIf:type,2'=>'期望月薪必须',
  292. 'working_time.requireIf:type,2'=>'可工作时间必须',
  293. 'work_nature.requireIf:type,2'=>'工作性质必须',
  294. ]);
  295. break;
  296. case 3:
  297. $data = $this->_vali([
  298. 'uuid.default'=>$this->uuid,
  299. 'work_experience.requireIf:type,3'=>'工作经历必须',
  300. 'child_id.default'=>'',
  301. ]);
  302. break;
  303. case 4:
  304. $data = $this->_vali([
  305. 'uuid.default'=>$this->uuid,
  306. 'professional_skills.requireIf:type,4'=>'专业技能必须',
  307. 'child_id.default'=>'',
  308. ]);
  309. break;
  310. case 5:
  311. $data = $this->_vali([
  312. 'uuid.default'=>$this->uuid,
  313. 'certificate.requireIf:type,5'=>'资质证书必须',
  314. 'child_id.default'=>'',
  315. ]);
  316. break;
  317. case 6:
  318. $data = $this->_vali([
  319. 'welfare_benefits.requireIf:type,6'=>'福利待遇必须',
  320. 'remark.requireIf:type,6'=>'备注必须',
  321. 'province.requireIf:type,6'=>'定位省必须',
  322. 'city.requireIf:type,6'=>'定位市必须',
  323. 'area.requireIf:type,6'=>'定位区必须',
  324. ]);
  325. break;
  326. }
  327. if (in_array($type,[3,4,5])){
  328. $info_id = DataUserApplyJobInfo::mk()->where('uuid',$this->uuid)->value('id') ? : DataUserApplyJobInfo::mk()->insertGetId(['uuid'=>$this->uuid]);
  329. $child_id = $data['child_id'];
  330. switch ($type){
  331. case 3:
  332. $child_type = 1;
  333. $content = $data['work_experience'];
  334. break;
  335. case 4:
  336. $child_type = 2;
  337. $content = $data['professional_skills'];
  338. break;
  339. case 5:
  340. $child_type = 3;
  341. $content = $data['certificate'];
  342. break;
  343. }
  344. $child_array = [
  345. 'info_id'=>$info_id,
  346. 'type'=>$child_type,
  347. 'content'=>$content
  348. ];
  349. !empty($child_id) ? $child_array['update_at'] = date('Y-m-d H:i:s') : '';
  350. if (!empty($child_id) ? DataUserApplyJobInfoChild::mk()->where('id',$child_id)->update($child_array) : DataUserApplyJobInfoChild::mk()->insert($child_array)){
  351. $this->success('成功');
  352. }
  353. $this->error('失败');
  354. }
  355. $id = DataUserApplyJobInfo::mk()->where('uuid',$this->uuid)->value('id');
  356. $audit = DataUserApplyJobInfo::mk()->where('uuid',$this->uuid)->value('audit');
  357. !empty($id) ? $data['update_at'] = date('Y-m-d H:i:s') : '';
  358. !empty($id) && $audit==3 ? $data['audit'] = 1 : '';
  359. if (!empty($id) ? DataUserApplyJobInfo::mk()->where('id',$id)->update($data) : DataUserApplyJobInfo::mk()->insert($data)){
  360. $this->success('成功');
  361. }
  362. $this->error('失败');
  363. }
  364. /**
  365. * @Title("应聘信息,工作经历、专业技能、资质证书删除")
  366. * @Method("post")
  367. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  368. * @Header("api-token",type="string",require=1,default="",desc="token")
  369. * @Param("id",type="string",require=1,default="",desc="ID")
  370. */
  371. public function delapplyjobchild(){
  372. $data = $this->_vali([
  373. 'id.require'=>'id必须',
  374. ]);
  375. if (DataUserApplyJobInfoChild::mk()->where('id',$data['id'])->delete()){
  376. $this->success('成功');
  377. }
  378. $this->error('失败');
  379. }
  380. /**
  381. * @Title("确认发布")
  382. * @Method("post")
  383. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  384. * @Header("api-token",type="string",require=1,default="",desc="token")
  385. * @Param("id_card",type="string",require=1,default="",desc="身份证号")
  386. * @Param("phone2",type="string",require=1,default="",desc="手机号")
  387. * @Param("code",type="string",require=1,default="",desc="验证码")
  388. */
  389. public function subapplyjob(){
  390. $data = $this->_vali([
  391. 'id_card.require'=>'身份证必须',
  392. 'phone2.require'=>'手机号必须',
  393. 'code.require'=>'验证码必须',
  394. 'sub_at.default'=>date('Y-m-d H:i:s'),
  395. 'audit.default'=>1,
  396. ]);
  397. if (!isCreditNo($data['id_card'])) $this->error('身份证号格式错误');
  398. $info = DataUserApplyJobInfo::mk()
  399. ->withoutField('id_card,phone2,audit,audit_at,why,sub_at,update_at,work_year')
  400. ->where('uuid',$this->uuid)
  401. ->find()->toArray();
  402. // if (!MessageService::instance()->checkCode($data['code'], $data['phone2'],4)) {
  403. // $this->error('手机短信验证失败!');
  404. // }
  405. // $count = count($info);
  406. // $array1 = array_filter($info);
  407. // if ($count!=count($array1)) $this->error('有未填写项,无法提交1');
  408. DataUserApplyJobInfoChild::mk()->where('info_id',$info['id'])->count() ? : $this->error('有未填写项,无法提交2');
  409. unset($data['code']);
  410. if (DataUserApplyJobInfo::mk()->where('id',$info['id'])->update($data)){
  411. $this->success('成功');
  412. }
  413. $this->error('失败');
  414. }
  415. /**
  416. * @Title("我的收藏")
  417. * @Method("post")
  418. * @Header("api-name",type="string",require=1,default="",desc="访问类型")
  419. * @Header("api-token",type="string",require=1,default="",desc="token")
  420. * @Param("type",type="string",require=1,default="",desc="1:招聘信息2:应聘信息")
  421. */
  422. public function mycollection(){
  423. $data = $this->_vali([
  424. 'type.require|in:1,2'=>'type有误',
  425. ]);
  426. switch ($data['type']){
  427. case 1:
  428. $list = DataCollectionLog::Show(3,$this->uuid)
  429. ->with(['recruitment'=>function($query){
  430. $query->field('data_recruitment.id,shipyard_id,title,data_recruitment.province,data_recruitment.city,schooling,salary_start,salary_end,contact_person,contact_headimg,contact_position,experience')->with(['shipyard'=>function($query){
  431. $query->field('id,name');
  432. }]);
  433. }])
  434. ->paginate();
  435. break;
  436. case 2:
  437. $list = DataCollectionLog::Show(4,$this->uuid)
  438. ->with(['joblist'=>function($query){
  439. $query->where('audit',2)
  440. ->where('hidden',1)
  441. ->field('id,head_img,real_name,sex,age,work_year,schooling,job_application');
  442. }])
  443. ->paginate();
  444. break;
  445. }
  446. $this->success('成功',$list);
  447. }
  448. }