DemandLabor.php 23 KB

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