DemandLabor.php 23 KB

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