123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503 |
- <?php
- namespace app\api\controller;
- use app\common\model\PlatformLike;
- use app\common\model\RecruitCate;
- use app\common\model\User;
- use app\common\model\UserCollect;
- use app\common\model\UserSearch;
- use app\common\model\UserTrack;
- use library\tools\Data;
- use think\Db;
- /**
- * @title 招聘
- * @controller Recruit
- * @group base
- */
- class Recruit extends Base
- {
- // 需要登录的
- protected $need_login = [
- 'activityTags',
- 'recruitCollect',
- 'recruitTransmit',
- 'getOwnRecruitList',
- 'getBrowseList',
- 'getRecruitCollect',
- ];
- public function initialize()
- {
- parent::initialize();
- parent::setUid();
- }
- /**
- * @title 招聘接口说明
- * @desc 招聘接口说明
- * @author qc
- * @url /api/Recruit/classIntro
- * @method GET
- * @return name:1 type:string default:-- desc:--
- */
- public function classIntro(){}
- /**
- * @title 获取招聘分类
- * @desc 两级分类
- * @author qc
- * @url /api/Recruit/getRecruitCate
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @return name:id type:int default:-- desc:分类id
- * @return name:title type:string default:0 desc:分类名称
- * @return name:children type:array default:0 desc:下级分类
- */
- public function getRecruitCate()
- {
- $list = RecruitCate::where(['is_deleted'=>0])->field('id,title,pid')->order('sort desc')->select()->toArray();
- $list = make_tree($list);
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 联系我们【两个二维码】(招聘详情内部)
- * @desc 联系HR
- * @author qc
- * @method GET
- * @url /api/Recruit/getRecruitContact
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:招聘记录id
- * @return name:phone type:string default:-- desc:招聘电话
- * @return name:email type:string default:-- desc:招聘email
- * @return name:hr_code type:int default:-- desc:招聘二维码
- * @return name:principal type:string default:-- desc:招聘联系人
- * @return name:qrcode type:string default:-- desc:平台二维码
- * @return name:contact_phone type:string default:-- desc:平台电话
- * @return name:contact_email type:string default:-- desc:平台邮箱
- */
- public function getRecruitContact()
- {
- $sel_where[] = ['id','=',input('get.id')];
- $detail = \app\common\model\Recruit::field('id,phone,email,hr_code,principal')->where($sel_where)->find()->toArray();
- $contact = Db::name('contact')->where('tag','recruit')->field('qrcode,phone contact_phone,email contact_email')->find();
- $contact['phone'] = $detail['phone'];
- $contact['email'] = $detail['email'];
- $contact['hr_code'] = $detail['hr_code'];
- $contact['principal'] = $detail['principal'];
- $this->success('ok',$contact);
- }
- /**
- * @title 招聘推荐
- * @desc 招聘推荐
- * @author qc
- * @method GET
- * @url /api/Recruit/getRecommendList
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:id type:int default:-- desc:记录ID
- * @return name:title type:string default:-- desc:标题
- * @return name:company type:string default:-- desc:公司名
- * @return name:principal type:string default:-- desc:联系人
- * @return name:hr_headimg type:string default:-- desc:hr头像
- * @return name:cover type:string default:-- desc:公司logo
- * @return name:label_name type:array default:-- desc:标签
- * @return name:welfare_arr type:array default:-- desc:岗位福利
- * @return name:education type:string default:-- desc:学历
- * @return name:experience_min type:int default:0 desc:最低工作年限
- * @return name:experience_max type:int default:0 desc:最高工作年限
- * @return name:price_min type:int default:-- desc:最低薪资[弃用]
- * @return name:price_max type:int default:-- desc:最高薪资[弃用]
- * @return name:salary type:int default:-- desc:薪资【文本】
- * @return name:province type:string default:-- desc:省名
- * @return name:city type:string default:-- desc:市名
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- */
- public function getRecommendList()
- {
- $app_name = sysconf('app_name');
- $app_logo = sysconf('app_logo');
- $search_log = UserSearch::getSearchTitle($this->user_id,8);
- $search_arr = [];
- $where_str = 'b.id > 0';
- foreach ($search_log as $t){
- $search_arr[] = " b.title like '".'%'.$t."%'" .' ';
- $search_arr[] = " b.label like '".'%'.$t."%'" .' ';
- }
- if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
- $field = 'a.id,title,a.user_id,label,salary,principal,hr_headimg,address,price_min,price_max,company,education,experience_min,experience_max,welfare,province,city,county,IFNULL(is_recommend,0) is_recommend ';
- $table = 'dd_recruit';
- $order_by_two = 'id';
- $sql = "SELECT $field FROM " .$table . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM $table b WHERE ( $where_str )) AS c ON c.id = a.id WHERE a.status = 1 AND a.is_deleted = 0 ORDER BY is_recommend DESC , $order_by_two desc LIMIT {$this->off_set},{$this->page_num}";
- $list = Db::query($sql);
- array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
- if(!$v['user_id']){
- $v['app_name'] = $app_name;
- $v['app_logo'] = $app_logo;
- }else{
- $user_info = User::where('id',$v['user_id'])->field('name,headimg')->find();
- $v['app_name'] = $user_info ? $user_info->name : '';
- $v['app_logo'] = $user_info ? $user_info->headimg : '';
- }
- $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
- $v['welfare_arr'] = explode(',',trim($v['welfare'],','));
- });
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取招聘列表
- * @desc 获取招聘列表
- * @author qc
- * @method GET
- * @url /api/Recruit/getRecruitList
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
- * @param name:first_classify type:int default:0 desc:一级分类id
- * @param name:second_classify type:int default:0 desc:二级分类id
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:company type:string default:-- desc:公司名
- * @return name:cover type:string default:-- desc:公司logo
- * @return name:phone type:string default:-- desc:电话
- * @return name:email type:string default:-- desc:email
- * @return name:label_name type:array default:-- desc:标签
- * @return name:welfare_arr type:array default:-- desc:岗位福利
- * @return name:education type:string default:-- desc:学历
- * @return name:experience_min type:int default:0 desc:最低工作年限
- * @return name:experience_max type:int default:0 desc:最高工作年限
- * @return name:price_min type:int default:-- desc:最低薪资[弃用]
- * @return name:price_max type:int default:-- desc:最高薪资[弃用]
- * @return name:salary type:int default:-- desc:薪资【文本】
- * @return name:content type:string default:-- desc:招聘详情
- * @return name:create_at type:string default:-- desc:发布时间
- * @return name:first_classify type:int default:-- desc:一级分类id
- * @return name:second_classify type:int default:-- desc:二级分类id
- * @return name:province type:string default:-- desc:省名
- * @return name:city type:string default:-- desc:市名
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:longitude type:string default:-- desc:经度
- * @return name:latitude type:string default:-- desc:纬度
- * @return name:num type:int default:-- desc:招聘人数
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- */
- public function getRecruitList(){
- $title = input('get.title');
- $sort_type = input('get.sort_type',1);
- $first_classify = input('get.first_classify');
- $second_classify = input('get.second_classify');
- $app_name = sysconf('app_name');
- $app_logo = sysconf('app_logo');
- switch ($sort_type) {
- case 1:
- $order = ['sort'=>'desc','id'=>'desc'];
- break;
- case 2:
- $order = ['id'=>'asc','sort'=>'desc'];
- break;
- case 3:
- $order = ['id'=>'desc','sort'=>'desc'];
- break;
- }
- $sel_where = [];
- $sel_where[] = ['is_deleted','=',0];
- $sel_where[] = ['status','=',1];
- if($first_classify) $sel_where[] = ['first_classify','=',$first_classify];
- if($second_classify) $sel_where[] = ['second_classify','=',$second_classify];
- if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,8);
- $list = \app\common\model\Recruit::where($sel_where)
- ->when($title,function ($query)use($title){
- if($title) $query->where('title|label','like','%'.$title.'%');
- })->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
- foreach ($list as &$v) {
- $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
- $v['welfare_arr'] = explode(',',trim($v['welfare'],','));
- if(!$v['user_id']){
- $v['app_name'] = $app_name;
- $v['app_logo'] = $app_logo;
- }else{
- $user_info = User::where('id',$v['user_id'])->field('name,headimg')->find();
- $v['app_name'] = $user_info ? $user_info->name : '';
- $v['app_logo'] = $user_info ? $user_info->headimg : '';
- }
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取招聘详情
- * @desc 获取招聘详情
- * @author qc
- * @method GET
- * @url /api/Recruit/getRecruitDetail
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:招聘记录id
- * @return name:title type:string default:-- desc:标题
- * @return name:company type:string default:-- desc:公司名
- * @return name:cover type:string default:-- desc:公司logo
- * @return name:company_label type:array default:-- desc:公司标签
- * @return name:principal type:string default:-- desc:联系人
- * @return name:hr_headimg type:string default:-- desc:联系人头像
- * @return name:phone type:string default:-- desc:电话
- * @return name:email type:string default:-- desc:email
- * @return name:label_name type:array default:-- desc:标签
- * @return name:welfare_arr type:array default:-- desc:岗位福利
- * @return name:education type:string default:-- desc:学历
- * @return name:experience_min type:int default:0 desc:最低工作年限
- * @return name:experience_max type:int default:0 desc:最高工作年限
- * @return name:price_min type:int default:-- desc:最低薪资[弃用]
- * @return name:price_max type:int default:-- desc:最高薪资[弃用]
- * @return name:salary type:int default:-- desc:薪资【文本】
- * @return name:content type:string default:-- desc:招聘详情
- * @return name:create_at type:string default:-- desc:发布时间
- * @return name:first_classify type:int default:-- desc:一级分类id
- * @return name:second_classify type:int default:-- desc:二级分类id
- * @return name:praise_num type:int default:-- desc:点赞量
- * @return name:is_praise type:int default:-- desc:是否点赞【0否1是】
- * @return name:is_collect type:int default:-- desc:是否收藏【0否1是】
- * @return name:collect_num type:int default:-- desc:收藏量
- * @return name:transmit_num type:int default:-- desc:转发量
- * @return name:province type:string default:-- desc:省名
- * @return name:city type:string default:-- desc:市名
- * @return name:county type:string default:-- desc:县区
- * @return name:address type:string default:-- desc:地址
- * @return name:longitude type:string default:-- desc:经度
- * @return name:latitude type:string default:-- desc:纬度
- * @return name:num type:int default:-- desc:招聘人数
- * @return name:hr_code type:int default:-- desc:二维码
- */
- public function getRecruitDetail()
- {
- $sel_where[] = ['id','=',input('get.id')];
- $detail = \app\common\model\Recruit::where($sel_where)->find()->toArray();
- $detail['label_name'] = explode(',',trim($detail['label'],','));
- $detail['welfare_arr'] = explode(',',trim($detail['welfare'],','));
- $detail['company_label'] = explode(',',trim($detail['company_label'],','));
- $detail['is_praise'] = PlatformLike::checkTags($this->user_id,$detail['id'],5);
- $detail['praise_num'] = PlatformLike::getPraiseNum($detail['id'],5);
- $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,8,$detail['id']);
- $detail['collect_num'] = UserCollect::getCollectNum(8,$detail['id']);
- UserTrack::crateTrack($this->user_id,8,input('get.id'),0);
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @title 以下接口调用验证登录【需要header传Authorization】
- * @desc 以下接口调用验证登录
- * @author qc
- * @method
- * @url /api/Recruit/needLogin()
- */
- public function needLogin(){}
- /**
- * @title 点赞||取消点赞
- * @desc 点赞||取消点赞
- * @author qc
- * @method POST
- * @url /api/Recruit/recruitTags
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:1 desc:招聘记录id
- * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
- */
- public function recruitTags()
- {
- $ret_val = PlatformLike::userTags($this->user_id,input('post.id'),5);
- $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
- }
- /**
- * @title 收藏||取消收藏
- * @desc 用户收藏
- * @author qc
- * @method POST
- * @url /api/Recruit/recruitCollect
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int require:1 default:-- desc:招聘记录id
- * @param name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
- */
- public function recruitCollect(){
- $coll_status = UserCollect::plateCollect($this->user_id,8,input('post.id',0));
- $coll_status ? $this->success('收藏成功',['status'=>1]) : $this->success('取消收藏成功',['status'=>0]);
- }
- /**
- * @title 转发(转发数量统计)
- * @desc 转发成功后调用
- * @author qc
- * @method POST
- * @url /api/Recruit/recruitTransmit
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:招聘记录id
- */
- public function recruitTransmit()
- {
- $id = input('post.id',0);
- \app\common\model\Recruit::where('id',$id)->setInc('transmit_num');
- $this->success('ok');
- }
- /**
- * @title 我的发布【招聘】
- * @desc 我的发布【招聘】
- * @author qc
- * @method GET
- * @url /api/Recruit/getOwnRecruitList
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:title type:string default:-- desc:标题
- * @return name:company type:string default:-- desc:公司名
- * @return name:cover type:string default:-- desc:公司logo
- * @return name:label_name type:array default:-- desc:标签
- * @return name:welfare_arr type:array default:-- desc:岗位福利
- * @return name:education type:string default:-- desc:学历
- * @return name:experience_min type:int default:0 desc:最低工作年限
- * @return name:experience_max type:int default:0 desc:最高工作年限
- * @return name:price_min type:int default:-- desc:最低薪资[弃用]
- * @return name:price_max type:int default:-- desc:最高薪资[弃用]
- * @return name:salary type:int default:-- desc:薪资【文本】
- * @return name:create_at type:string default:-- desc:发布时间
- * @return name:num type:int default:-- desc:招聘人数
- * @return name:principal type:string default:-- desc:联系人
- * @return name:hr_headimg type:string default:-- desc:联系人头像
- */
- public function getOwnRecruitList()
- {
- $title = input('get.title');
- $sel_where = [];
- $sel_where[] = ['is_deleted','=',0];
- $sel_where[] = ['status','=',1];
- $sel_where[] = ['user_id','=',$this->user_id];
- $list = \app\common\model\Recruit::where($sel_where)
- ->field('id,title,company,label,welfare,education,experience_min,salary,experience_max,price_min,price_max,create_at,num,principal,hr_headimg,province,city,county')
- ->when($title,function ($query)use($title){
- if($title) $query->where('title|label','like','%'.$title.'%');
- })->order(['id'=>'desc'])
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
- $v['welfare_arr'] = explode(',',trim($v['welfare'],','));
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 浏览记录【招聘】
- * @desc 浏览记录【招聘】
- * @author qc
- * @method GET
- * @url /api/Recruit/getBrowseList
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:id type:int default:-- desc:浏览记录id
- * @return name:title type:string default:-- desc:标题
- * @return name:recruit_id type:int default:-- desc:招聘记录id
- * @return name:company type:string default:-- desc:公司名
- * @return name:cover type:string default:-- desc:公司logo
- * @return name:label_name type:array default:-- desc:标签
- * @return name:welfare_arr type:array default:-- desc:岗位福利
- * @return name:education type:string default:-- desc:学历
- * @return name:experience_min type:int default:0 desc:最低工作年限
- * @return name:experience_max type:int default:0 desc:最高工作年限
- * @return name:price_min type:int default:-- desc:最低薪资[弃用]
- * @return name:price_max type:int default:-- desc:最高薪资[弃用]
- * @return name:salary type:int default:-- desc:薪资【文本】
- * @return name:num type:int default:-- desc:招聘人数
- * @return name:time type:string default:-- desc:浏览时间
- * @return name:principal type:string default:-- desc:联系人
- * @return name:hr_headimg type:string default:-- desc:联系人头像
- */
- public function getBrowseList()
- {
- $sel_where = [];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.type','=',8];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $list = UserTrack::where($sel_where)
- ->alias('t')
- ->field('t.id,t.update_int,t.first_id recruit_id,i.salary,i.title,i.price_max,i.company,i.label,province,city,county,i.welfare,i.education,i.experience_min,i.experience_max,price_min,price_max,i.num,principal,hr_headimg')
- ->leftJoin('Recruit i','t.first_id = i.id')
- ->order('update_int desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['time'] = date("Y-m-d H:i:s",$v['update_int']);
- $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
- $v['welfare_arr'] = explode(',',trim($v['welfare'],','));
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 收藏记录【招聘】
- * @desc 收藏记录【招聘】
- * @author qc
- * @method GET
- * @url /api/Recruit/getRecruitCollect
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 desc:每页数
- * @return name:id type:int default:-- desc:收藏记录id
- * @return name:title type:string default:-- desc:标题
- * @return name:recruit_id type:int default:-- desc:招聘记录id
- * @return name:company type:string default:-- desc:公司名
- * @return name:cover type:string default:-- desc:公司logo
- * @return name:label_name type:array default:-- desc:标签
- * @return name:welfare_arr type:array default:-- desc:岗位福利
- * @return name:education type:string default:-- desc:学历
- * @return name:experience_min type:int default:0 desc:最低工作年限
- * @return name:experience_max type:int default:0 desc:最高工作年限
- * @return name:price_min type:int default:-- desc:最低薪资[弃用]
- * @return name:price_max type:int default:-- desc:最高薪资[弃用]
- * @return name:, type:int default:-- desc:薪资【文本】
- * @return name:num type:int default:-- desc:招聘人数
- * @return name:time type:string default:-- desc:浏览时间
- * @return name:principal type:string default:-- desc:联系人
- * @return name:hr_headimg type:string default:-- desc:联系人头像
- */
- public function getRecruitCollect()
- {
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.coll_type','=',8];
- $list = UserCollect::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.coll_id recruit_id,i.title,i.company,i.label,i.salary,i.welfare,i.education,i.experience_min,i.experience_max,price_min,price_max,i.num,principal,hr_headimg,province,city,county')
- ->leftJoin('Recruit i','t.coll_id = i.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
- $v['welfare_arr'] = explode(',',trim($v['welfare'],','));
- }
- $this->success('ok',['list'=>$list]);
- }
- }
|