123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- <?php
- namespace app\data\controller\api\auth;
- use app\data\controller\api\Auth;
- use app\data\controller\api\Data;
- use app\data\model\DataCollectionLog;
- use app\data\model\DataMerchants;
- use app\data\model\DataRecruitment;
- use app\data\model\DataShipyard;
- use app\data\model\DataTeachingKnowledge;
- use app\data\model\DataUser;
- use app\data\model\DataUserApplyJobInfo;
- use app\data\model\DataUserApplyJobInfoChild;
- use app\data\model\SystemUser;
- use app\data\service\MessageService;
- use think\admin\Storage;
- use think\db\Query;
- use think\exception\HttpResponseException;
- use think\admin\Controller;
- use hg\apidoc\annotation\Title;
- use hg\apidoc\annotation\Method;
- use hg\apidoc\annotation\Param;
- use hg\apidoc\annotation\Header;
- use hg\apidoc\annotation\Returned;
- use think\facade\Validate;
- /**
- * @Title("劳务需求")
- */
- class DemandLabor extends Auth
- {
- protected $noNeedLogin=['demandlist'];
- /**
- * @Title("招聘信息,应聘信息列表")
- * @Method("post")
- * @Header("api-name",type="string",require=1,default="",desc="访问类型")
- * @Header("api-token",type="string",require=1,default="",desc="token")
- * @Param("type",type="string",require=1,default="1",desc="1:招聘信息2:应聘信息")
- * @Param("keyword",type="string",require=0,default="",desc="关键词搜索")
- * @Param("salary",type="string",require=0,default="",desc="薪资待遇1:不限 2:4K以下 3:4K-6K 4:6K-8K 5:8K-12K 6:12K以上")
- * @Param("type",type="string",require=1,default="",desc="1:招聘信息2:应聘信息")
- * @Param("schooling",type="string",require=1,default="",desc="学历")
- *
- * @Returned("json",desc="")
- */
- public function demandlist()
- {
- $data = $this->_vali([
- 'type.require|in:1,2'=>'type有误',
- 'keyword.default'=>'',
- 'salary.default'=>'',
- 'schooling.default'=>''
- ]);
- $keyword = $data['keyword'];
- switch ($data['type']){
- case 1:
- $salary = $data['salary'];
- if($data['schooling'] == '不限'){
- $data['schooling'] = '';
- }
- $schooling = $data['schooling'];
- $list = DataRecruitment::mk()
- ->where('is_del',1)
- ->where('state',1)
- // ->hasWhere('shipyard',function ($query) use ($keyword){
- // $query->whereLike('data_recruitment.title|name','%'.$keyword.'%');
- // },'data_recruitment.id,shipyard_id,title,data_recruitment.province,data_recruitment.city,schooling,salary_start,salary_end,contact_person,contact_headimg,contact_position,experience')
- ->when($salary,function ($query) use ($salary){
- switch ($salary){
- case 1:
- break;
- case 2:
- $query->where('salary_start','<','4');
- break;
- case 3:
- $query->whereRaw('(salary_start>=4 and salary_start<6) or (salary_end>=4 and salary_end<6)');
- break;
- case 4:
- $query->whereRaw('(salary_start>=6 and salary_start<8) or (salary_end>=6 and salary_end<8)');
- break;
- case 5:
- $query->whereRaw('(salary_start>=8 and salary_start<12) or (salary_end>=8 and salary_end<12)');
- break;
- case 6:
- $query->whereRaw('(salary_start>=12) or (salary_end>=12)');
- break;
- }
- })
- ->when($keyword,function ($query) use ($keyword){
- $query->whereLike('title','%'.$keyword.'%');
- })
- ->when($schooling,function ($query) use ($schooling){
- $query->where('schooling',$schooling);
- })
- ->with(['shipyard'=>function($query){
- $query->field('id,name');
- }])
- ->order('create_at','desc')
- ->paginate();
- foreach ($list as $v){
- if($v['province'] == $v['city']){
- $v['city'] = $v['area'];
- }
- }
- break;
- case 2:
- $list = DataUserApplyJobInfo::mk()->alias('a')
- ->where('a.audit',2)
- ->where('a.hidden',1)
- ->when($keyword,function ($query) use ($keyword){
- $query->whereLike('a.real_name|job_application|scope_work_area|province|area','%'.$keyword.'%');
- })
- ->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')
- ->rightJoin('data_user b','a.uuid=b.id')
- ->order('b.is_vip desc,a.id desc')
- ->paginate();
- break;
- }
- $this->success('成功',$list);
- }
- /**
- * @Title("招聘信息详情、应聘信息详情")
- * @Method("post")
- * @Header("api-name",type="string",require=1,default="",desc="访问类型")
- * @Header("api-token",type="string",require=1,default="",desc="token")
- * @Param("type",type="string",require=1,default="",desc="1:招聘信息2:应聘信息")
- * @Param("id",type="string",require=1,default="",desc="主键ID")
- * @Returned("is_collection",desc="1:已收藏0:未收藏")
- * @Returned("is_like",desc="1:已感兴趣0:未感兴趣")
- */
- public function demanddetail(){
- $data = $this->_vali([
- 'type.require|in:1,2'=>'type有误',
- 'id.require'=>'id必须'
- ]);
- switch ($data['type']){
- case 1:
- $info = DataRecruitment::mk()
- ->where('id',$data['id'])
- ->where('is_del',1)
- ->where('state',1)
- ->findOrEmpty();
- $info['is_collection'] = DataCollectionLog::Show(3,$this->uuid,$data['id'])->count() ? 1 : 0;
- $info['is_like'] = DataCollectionLog::Show(3,$this->uuid,$data['id'],2)->count() ? 1 : 0;
- $info['huanxinID'] = DataUser::mk()->where('id',DataShipyard::mk()->where('id',$info['shipyard_id'])->value('uuid'))->value('huanxinID');
- break;
- case 2:
- $info = DataUserApplyJobInfo::mk()
- ->where('id',$data['id'])
- ->where('audit',2)
- ->where('hidden',1)
- ->with(['workexperience','professionalskills','certificate'])
- ->findOrEmpty();
- $info['is_collection'] = DataCollectionLog::Show(4,$this->uuid,$data['id'])->count() ? 1 : 0;
- $info['is_like'] = DataCollectionLog::Show(4,$this->uuid,$data['id'],2)->count() ? 1 : 0;
- $info['huanxinID'] = DataUser::mk()->where('id',$info['uuid'])->value('huanxinID');
- break;
- }
- $this->success('成功',$info);
- }
- /**
- * @Title("招聘信息、应聘信息收藏/取消收藏")
- * @Method("post")
- * @Header("api-name",type="string",require=1,default="",desc="访问类型")
- * @Header("api-token",type="string",require=1,default="",desc="token")
- * @Param("type",type="string",require=1,default="",desc="1:招聘信息2:应聘信息")
- * @Param("id",type="string",require=1,default="",desc="主键ID")
- * @Param("category",type="string",require=1,default="",desc="1:收藏2:取消收藏")
- */
- public function cocanclecollection(){
- $data = $this->_vali([
- 'type.require|in:1,2'=>'type有误',
- 'id.require'=>'id必须',
- 'category.require|in:1,2'=>'category有误'
- ]);
- switch ($data['category']){
- case 1:
- switch ($data['type']){
- case 1:
- DataCollectionLog::Show(3,$this->uuid,$data['id'])->count() ? $this->error('已收藏过') : '';
- $type = 3;
- break;
- case 2:
- $type = 4;
- DataCollectionLog::Show(4,$this->uuid,$data['id'])->count() ? $this->error('已收藏过') : '';
- break;
- }
- if (DataCollectionLog::mk()->insert(['uuid'=>$this->uuid,'type'=>$type,'link_id'=>$data['id']])){
- $this->success('收藏成功');
- }
- $this->error('收藏失败');
- break;
- case 2:
- switch ($data['type']){
- case 1:
- DataCollectionLog::Show(3,$this->uuid,$data['id'])->count() ? : $this->error('未收藏');
- $type = 3;
- break;
- case 2:
- $type = 4;
- DataCollectionLog::Show(4,$this->uuid,$data['id'])->count() ? : $this->error('未收藏');
- break;
- }
- $d = DataCollectionLog::mk()->where('uuid',$this->uuid)->where('type',$type)->where('link_id',$data['id'])->where('cate',1)->select();
- // return json($d);
- if (DataCollectionLog::mk()->where('uuid',$this->uuid)->where('type',$type)->where('link_id',$data['id'])->where('cate',1)->delete()){
- $this->success('收藏成功');
- }
- $this->error('收藏失败');
- break;
- }
- }
- /**
- * @Title("招聘信息、应聘信息感兴趣/取消感兴趣")
- * @Method("post")
- * @Header("api-name",type="string",require=1,default="",desc="访问类型")
- * @Header("api-token",type="string",require=1,default="",desc="token")
- * @Param("type",type="string",require=1,default="",desc="1:招聘信息2:应聘信息")
- * @Param("id",type="string",require=1,default="",desc="主键ID")
- * @Param("category",type="string",require=1,default="",desc="1:感兴趣2:取消感兴趣")
- */
- public function cocanclelike(){
- $data = $this->_vali([
- 'type.require|in:1,2'=>'type有误',
- 'id.require'=>'id必须',
- 'category.require|in:1,2'=>'category有误'
- ]);
- switch ($data['category']){
- case 1:
- switch ($data['type']){
- case 1:
- DataCollectionLog::Show(3,$this->uuid,$data['id'],2)->count() ? $this->error('已感兴趣') : '';
- $type = 3;
- break;
- case 2:
- $type = 4;
- DataCollectionLog::Show(4,$this->uuid,$data['id'],2)->count() ? $this->error('已感兴趣') : '';
- break;
- }
- if (DataCollectionLog::mk()->insert(['uuid'=>$this->uuid,'cate'=>2,'type'=>$type,'link_id'=>$data['id']])){
- $this->success('感兴趣成功');
- }
- $this->error('感兴趣失败');
- break;
- case 2:
- switch ($data['type']){
- case 1:
- DataCollectionLog::Show(3,$this->uuid,$data['id'],2)->count() ? : $this->error('未感兴趣');
- $type = 3;
- break;
- case 2:
- $type = 4;
- DataCollectionLog::Show(4,$this->uuid,$data['id'],2)->count() ? : $this->error('未已感兴趣');
- break;
- }
- if (DataCollectionLog::Show($type,$this->uuid,$data['id'],2)->delete()){
- $this->success('取消成功');
- }
- $this->error('取消失败');
- break;
- }
- }
- /**
- * @Title("发布应聘、修改")
- * @Method("post")
- * @Header("api-name",type="string",require=1,default="",desc="访问类型")
- * @Header("api-token",type="string",require=1,default="",desc="token")
- * @Param("type",type="string",require=1,default="",desc="1:基本信息2:求职意向3:工作经历4:专业技能5:资质证书6:其他(福利待遇、备注,定位省市区)")
- * @Param("head_img",type="string",require=0,default="",desc="头像")
- * @Param("real_name",type="string",require=0,default="",desc="真实姓名")
- * @Param("sex",type="string",require=0,default="",desc="性别")
- * @Param("date_birth",type="string",require=0,default="",desc="出生年月")
- * @Param("schooling",type="string",require=0,default="",desc="学历")
- * @Param("start_working_time",type="string",require=0,default="",desc="参加工作时间")
- * @Param("phone",type="string",require=0,default="",desc="手机号")
- * @Param("email",type="string",require=0,default="",desc="邮箱")
- * @Param("job_application",type="string",require=0,default="",desc="应聘岗位")
- * @Param("scope_work_area",type="string",require=0,default="",desc="工作地区")
- * @Param("monthly_salary",type="string",require=0,default="",desc="期望月薪")
- * @Param("working_time",type="string",require=0,default="",desc="可工作时间")
- * @Param("work_nature",type="string",require=0,default="",desc="工作性质")
- * @Param("work_experience",type="json",require=0,default="",desc="工作经历json,(company_name:公司名称,position_name:职位名称,on_job_start:在职时间开始,on_job_end:在职时间结束,job_description:工作内容)")
- * @Param("professional_skills",type="json",require=0,default="",desc="专业技能json,(skill_name:技能名称,degree:掌握程度)")
- * @Param("certificate",type="json",require=0,default="",desc="资质证书json,(certificate_name:证书名称,gain_time:获得时间,img:图片)")
- * @Param("child_id",type="string",require=0,default="",desc="id,type为3,4,5时,修改时传入此值")
- * @Param("welfare_benefits",type="string",require=0,default="",desc="福利待遇")
- * @Param("remark",type="string",require=0,default="",desc="备注")
- * @Param("province",type="string",require=0,default="",desc="定位-省")
- * @Param("city",type="string",require=0,default="",desc="定位-市")
- * @Param("area",type="string",require=0,default="",desc="定位-区")
- */
- public function applyjob(){
- $data = $this->_vali([
- 'type.require|in:1,2,3,4,5,6'=>'type有误',
- ]);
- $type = $data['type'];
- switch ($type){
- case 1:
- $data = $this->_vali([
- 'uuid.default'=>$this->uuid,
- 'head_img.requireIf:type,1'=>'头像必须',
- 'real_name.requireIf:type,1'=>'真实姓名必须',
- 'sex.requireIf:type,1'=>'性别必须',
- 'date_birth.requireIf:type,1'=>'出生年月必须',
- 'schooling.requireIf:type,1'=>'学历必须',
- 'start_working_time.requireIf:type,1'=>'参加工作时间必须',
- 'phone.requireIf:type,1'=>'手机号必须',
- 'email.requireIf:type,1'=>'邮箱必须',
- ]);
- $data['age'] = getAge($data['date_birth']);
- $data['work_year'] = getAge($data['start_working_time']);
- break;
- case 2:
- $data = $this->_vali([
- 'uuid.default'=>$this->uuid,
- 'job_application.requireIf:type,2'=>'应聘岗位必须',
- 'scope_work_area.requireIf:type,2'=>'工作地区必须',
- 'monthly_salary.requireIf:type,2'=>'期望月薪必须',
- 'working_time.requireIf:type,2'=>'可工作时间必须',
- 'work_nature.requireIf:type,2'=>'工作性质必须',
- ]);
- break;
- case 3:
- $data = $this->_vali([
- 'uuid.default'=>$this->uuid,
- 'work_experience.requireIf:type,3'=>'工作经历必须',
- 'child_id.default'=>'',
- ]);
- break;
- case 4:
- $data = $this->_vali([
- 'uuid.default'=>$this->uuid,
- 'professional_skills.requireIf:type,4'=>'专业技能必须',
- 'child_id.default'=>'',
- ]);
- break;
- case 5:
- $data = $this->_vali([
- 'uuid.default'=>$this->uuid,
- 'certificate.requireIf:type,5'=>'资质证书必须',
- 'child_id.default'=>'',
- ]);
- break;
- case 6:
- $data = $this->_vali([
- 'welfare_benefits.requireIf:type,6'=>'福利待遇必须',
- 'remark.requireIf:type,6'=>'备注必须',
- 'province.requireIf:type,6'=>'定位省必须',
- 'city.requireIf:type,6'=>'定位市必须',
- 'area.requireIf:type,6'=>'定位区必须',
- ]);
- break;
- }
- if (in_array($type,[3,4,5])){
- $info_id = DataUserApplyJobInfo::mk()->where('uuid',$this->uuid)->value('id') ? : DataUserApplyJobInfo::mk()->insertGetId(['uuid'=>$this->uuid]);
- $child_id = $data['child_id'];
- switch ($type){
- case 3:
- $child_type = 1;
- $content = $data['work_experience'];
- break;
- case 4:
- $child_type = 2;
- $content = $data['professional_skills'];
- break;
- case 5:
- $child_type = 3;
- $content = $data['certificate'];
- break;
- }
- $child_array = [
- 'info_id'=>$info_id,
- 'type'=>$child_type,
- 'content'=>$content
- ];
- !empty($child_id) ? $child_array['update_at'] = date('Y-m-d H:i:s') : '';
- if (!empty($child_id) ? DataUserApplyJobInfoChild::mk()->where('id',$child_id)->update($child_array) : DataUserApplyJobInfoChild::mk()->insert($child_array)){
- $this->success('成功');
- }
- $this->error('失败');
- }
- $id = DataUserApplyJobInfo::mk()->where('uuid',$this->uuid)->value('id');
- $audit = DataUserApplyJobInfo::mk()->where('uuid',$this->uuid)->value('audit');
- !empty($id) ? $data['update_at'] = date('Y-m-d H:i:s') : '';
- !empty($id) && $audit==3 ? $data['audit'] = 1 : '';
- if (!empty($id) ? DataUserApplyJobInfo::mk()->where('id',$id)->update($data) : DataUserApplyJobInfo::mk()->insert($data)){
- $this->success('成功');
- }
- $this->error('失败');
- }
- /**
- * @Title("应聘信息,工作经历、专业技能、资质证书删除")
- * @Method("post")
- * @Header("api-name",type="string",require=1,default="",desc="访问类型")
- * @Header("api-token",type="string",require=1,default="",desc="token")
- * @Param("id",type="string",require=1,default="",desc="ID")
- */
- public function delapplyjobchild(){
- $data = $this->_vali([
- 'id.require'=>'id必须',
- ]);
- if (DataUserApplyJobInfoChild::mk()->where('id',$data['id'])->delete()){
- $this->success('成功');
- }
- $this->error('失败');
- }
- /**
- * @Title("确认发布")
- * @Method("post")
- * @Header("api-name",type="string",require=1,default="",desc="访问类型")
- * @Header("api-token",type="string",require=1,default="",desc="token")
- * @Param("id_card",type="string",require=1,default="",desc="身份证号")
- * @Param("phone2",type="string",require=1,default="",desc="手机号")
- * @Param("code",type="string",require=1,default="",desc="验证码")
- */
- public function subapplyjob(){
- $data = $this->_vali([
- 'id_card.require'=>'身份证必须',
- 'phone2.require'=>'手机号必须',
- 'code.require'=>'验证码必须',
- 'sub_at.default'=>date('Y-m-d H:i:s'),
- 'audit.default'=>1,
- ]);
- if (!isCreditNo($data['id_card'])) $this->error('身份证号格式错误');
- $info = DataUserApplyJobInfo::mk()
- ->withoutField('id_card,phone2,audit,audit_at,why,sub_at,update_at,work_year')
- ->where('uuid',$this->uuid)
- ->find()->toArray();
- if (!MessageService::instance()->checkCode($data['code'], $data['phone2'],4)) {
- $this->error('手机短信验证失败!');
- }
- // $count = count($info);
- // $array1 = array_filter($info);
- // if ($count!=count($array1)) $this->error('有未填写项,无法提交1');
- DataUserApplyJobInfoChild::mk()->where('info_id',$info['id'])->count() ? : $this->error('有未填写项,无法提交');
- unset($data['code']);
- if (DataUserApplyJobInfo::mk()->where('id',$info['id'])->update($data)){
- $this->success('成功');
- }
- $this->error('失败');
- }
- /**
- * @Title("我的收藏")
- * @Method("post")
- * @Header("api-name",type="string",require=1,default="",desc="访问类型")
- * @Header("api-token",type="string",require=1,default="",desc="token")
- * @Param("type",type="string",require=1,default="",desc="1:招聘信息2:应聘信息")
- */
- public function mycollection(){
- $data = $this->_vali([
- 'type.require|in:1,2'=>'type有误',
- ]);
- switch ($data['type']){
- case 1:
- $list = DataCollectionLog::Show(3,$this->uuid)
- ->with(['recruitment'=>function($query){
- $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){
- $query->field('id,name');
- }]);
- }])
- ->paginate();
- break;
- case 2:
- $list = DataCollectionLog::Show(4,$this->uuid)
- ->with(['joblist'=>function($query){
- $query->where('audit',2)
- ->where('hidden',1)
- ->field('id,head_img,real_name,sex,age,work_year,schooling,job_application');
- }])
- ->paginate();
- break;
- }
- $this->success('成功',$list);
- }
- }
|