DemandLabor.php 23 KB

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