Recruit.php 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975
  1. <?php
  2. namespace app\api\controller;
  3. use AlibabaCloud\SDK\Vod\V20170321\Models\GetMediaDNAResultResponseBody\DNAResult\videoDNA\detail\input;
  4. use app\common\model\PlatformLike;
  5. use app\common\model\PlatformSwitch;
  6. use app\common\model\RecruitCate;
  7. use app\common\model\RecruitResume;
  8. use app\common\model\TopSearch;
  9. use app\common\model\User;
  10. use app\common\model\UserCollect;
  11. use app\common\model\UserMessage;
  12. use app\common\model\UserSearch;
  13. use app\common\model\UserTrack;
  14. use app\common\service\CheckPower;
  15. use app\common\service\UserSynth;
  16. use library\tools\Data;
  17. use think\Db;
  18. /**
  19. * @title 招聘
  20. * @controller Recruit
  21. * @group base
  22. */
  23. class Recruit extends Base
  24. {
  25. // 需要登录的
  26. protected $need_login = [
  27. 'sendResume',
  28. 'recruitTags',
  29. 'recruitCollect',
  30. 'recruitTransmit',
  31. 'getTagsRecruit',
  32. 'resumeToRecruits',
  33. 'getRecruitResumeList',
  34. 'getOwnRecruitList',
  35. 'getBrowseList',
  36. 'getRecruitCollect',
  37. 'getFollowUpList',
  38. 'getFollowUpMessage',
  39. 'batchesDel',
  40. 'unreadChange',
  41. ];
  42. public function initialize()
  43. {
  44. parent::initialize();
  45. parent::setUid();
  46. }
  47. /**
  48. * @title 招聘接口说明
  49. * @desc 招聘接口说明
  50. * @author qc
  51. * @url /api/Recruit/classIntro
  52. * @method GET
  53. * @return name:1 type:string default:-- desc:--
  54. */
  55. public function classIntro(){}
  56. /**
  57. * @title 获取招聘分类
  58. * @desc 三级分类
  59. * @author qc
  60. * @url /api/Recruit/getRecruitCate
  61. * @method GET
  62. * @header name:Authorization require:1 desc:Token
  63. * @return name:id type:int default:-- desc:分类id
  64. * @return name:title type:string default:0 desc:分类名称
  65. * @return name:children type:array default:0 desc:下级分类
  66. */
  67. public function getRecruitCate()
  68. {
  69. $list = RecruitCate::where(['is_deleted'=>0])->field('id,title,pid')->order('sort desc,id asc')->select()->toArray();
  70. $list = make_tree($list);
  71. $this->success('ok',['list'=>$list]);
  72. }
  73. /**
  74. * @title 获取第三级分类
  75. * @desc 获取第三级分类
  76. * @author qc
  77. * @url /api/Recruit/getThirdCate
  78. * @method GET
  79. * @header name:Authorization require:1 desc:Token
  80. * @param name:fid type:int default:-- desc:一级分类id
  81. * @param name:pid type:int default:-- desc:二级分类id【不传查一级分类下全部的三级分类】
  82. * @return name:id type:int default:-- desc:分类id
  83. * @return name:title type:string default:0 desc:分类名称
  84. * @return name:lev type:int default:0 desc:分类等级
  85. * @return name:children type:array default:0 desc:下级分类
  86. *
  87. */
  88. public function getThirdCate()
  89. {
  90. $where = [];
  91. $where[]=['is_deleted','=',0];
  92. $where[]=['pid','=',input('fid')];
  93. if(input('pid')) $where[] = ['id','=',input('pid')];
  94. $list = RecruitCate::where($where)->field('id,title,pid,lev')->order('sort desc,id asc')->select()->toArray();
  95. foreach ($list as &$v) {
  96. $v['children'] = RecruitCate::where([['is_deleted','=',0],['pid','=',$v['id']]])->field('id,title,pid,lev')->order('sort desc,id asc')->select()->toArray();
  97. }
  98. $this->success('ok',['list'=>$list]);
  99. }
  100. /**
  101. * @title 投递简历
  102. * @desc 投递简历
  103. * @author qc
  104. * @url /api/Recruit/sendResume
  105. * @method POST
  106. * @header name:Authorization require:1 desc:Token
  107. * @param name:recruit_id type:int default:-- desc:招聘记录id
  108. * @param name:type type:int default:0 desc:类型0图片1pdf
  109. * @param name:images type:string default:0 desc:pdf||图片(多张|隔开)
  110. */
  111. public function sendResume()
  112. {
  113. $images = input('post.images');
  114. $type = input('post.type',0);
  115. if(empty($images)) $this->error('请上传文件');
  116. RecruitResume::create([
  117. 'user_id'=>$this->user_id,
  118. 'recruit_id'=>input('post.recruit_id'),
  119. 'images'=>$images,
  120. 'type'=>$type,
  121. ]);
  122. $this->success('投递成功');
  123. }
  124. /**
  125. * @title 获取简历详情
  126. * @desc 获取简历详情
  127. * @author qc
  128. * @url /api/Recruit/getResumeInfo
  129. * @method GET
  130. * @header name:Authorization require:1 desc:Token
  131. * @param name:resume_id type:int default:-- desc:简历记录id
  132. * @return name:images type:string default:-- desc:图片||pdf
  133. * @return name:images_arr type:array default:-- desc:数组
  134. * @return name:type type:int default:0 desc:类型0图片1pdf
  135. */
  136. public function getResumeInfo()
  137. {
  138. $info = RecruitResume::field('id,user_id,images,create_at,type')->where('id',input('get.resume_id'))->where(['is_deleted'=>0])->find();
  139. if(!$info) $this->error('简历详情不存在');
  140. $info = $info->toArray();
  141. $info['images_arr'] = explode('|',$info['images']);
  142. $this->success('ok',$info);
  143. }
  144. /**
  145. * @title 联系我们【两个二维码】(招聘详情内部)
  146. * @desc 联系HR
  147. * @author qc
  148. * @method GET
  149. * @url /api/Recruit/getRecruitContact
  150. * @header name:Authorization require:1 desc:Token
  151. * @param name:id type:int default:-- desc:招聘记录id
  152. * @return name:phone type:string default:-- desc:招聘电话
  153. * @return name:email type:string default:-- desc:招聘email
  154. * @return name:hr_code type:int default:-- desc:招聘二维码
  155. * @return name:principal type:string default:-- desc:招聘联系人
  156. * @return name:qrcode type:string default:-- desc:平台二维码
  157. * @return name:contact_phone type:string default:-- desc:平台电话
  158. * @return name:contact_email type:string default:-- desc:平台邮箱
  159. */
  160. public function getRecruitContact()
  161. {
  162. $sel_where[] = ['id','=',input('get.id')];
  163. $detail = \app\common\model\Recruit::field('id,phone,email,hr_code,principal')->where($sel_where)->find()->toArray();
  164. $contact = Db::name('contact')->where('tag','recruit')->field('qrcode,phone contact_phone,email contact_email')->find();
  165. $contact['phone'] = $detail['phone'];
  166. $contact['email'] = $detail['email'];
  167. $contact['hr_code'] = $detail['hr_code'];
  168. $contact['principal'] = $detail['principal'];
  169. $this->success('ok',$contact);
  170. }
  171. /**
  172. * @title 招聘推荐
  173. * @desc 招聘推荐
  174. * @author qc
  175. * @method GET
  176. * @url /api/Recruit/getRecommendList
  177. * @header name:Authorization require:1 desc:Token
  178. * @param name:page type:int default:0 desc:页数
  179. * @param name:page_num type:int default:20 desc:每页数
  180. * @param name:is_over type:int default:20 desc:每页数
  181. * @param name:rand_user type:string default:-- desc:随机id(非登录状态必传,page=1时生成(a123),其他页数(a123),一直查询到没有数据)
  182. * @param name:city type:string default:1 desc:城市名称
  183. * @return name:id type:int default:-- desc:记录ID
  184. * @return name:title type:string default:-- desc:标题
  185. * @return name:company type:string default:-- desc:公司名
  186. * @return name:principal type:string default:-- desc:联系人
  187. * @return name:hr_headimg type:string default:-- desc:hr头像
  188. * @return name:cover type:string default:-- desc:公司logo
  189. * @return name:label_name type:array default:-- desc:标签
  190. * @return name:welfare_arr type:array default:-- desc:岗位福利
  191. * @return name:education type:string default:-- desc:学历
  192. * @return name:experience_min type:int default:0 desc:最低工作年限
  193. * @return name:experience_max type:int default:0 desc:最高工作年限
  194. * @return name:price_min type:int default:-- desc:最低薪资[弃用]
  195. * @return name:price_max type:int default:-- desc:最高薪资[弃用]
  196. * @return name:salary type:int default:-- desc:薪资【文本】
  197. * @return name:province type:string default:-- desc:省名
  198. * @return name:city type:string default:-- desc:市名
  199. * @return name:county type:string default:-- desc:县区
  200. * @return name:address type:string default:-- desc:地址
  201. * @return name:app_name type:string default:-- desc:发布方名称
  202. * @return name:app_logo type:string default:-- desc:发布方头像
  203. * @return name:release_time type:string default:-- desc:上架时间
  204. * @return name:company_intro type:string default:-- desc:公司简介
  205. * @return name:is_ss type:string default:-- desc:是否上市,1上市0未上市
  206. * @return name:scale type:string default:-- desc:公司规模(人数)
  207. */
  208. public function getRecommendList()
  209. {
  210. $user_id = $this->user_id ? $this->user_id : input('rand_user');
  211. if(!$user_id) $this->error('参数错误');
  212. $list = UserSynth::getRecommendList($user_id,'recruit',$this->page,$this->page_num,['city'=>input('city')]);
  213. if($list['code'] != 200) $this->error($list['msg']);
  214. $this->success('ok',$list);
  215. $search_log = UserSearch::getSearchTitle($this->user_id,8);
  216. $search_arr = [];
  217. $where_str = 'b.id > 0';
  218. foreach ($search_log as $t){
  219. $search_arr[] = " b.title like '".'%'.$t."%'" .' ';
  220. $search_arr[] = " b.label like '".'%'.$t."%'" .' ';
  221. }
  222. if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
  223. $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 ';
  224. $table = 'dd_recruit';
  225. $order_by_two = 'a.id';
  226. $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}";
  227. $list = Db::query($sql);
  228. $list = dispose_recommend($list);
  229. array_walk($list,function (&$v,$k){
  230. $auth_info = \app\common\model\Recruit::getAuth($v['user_id'],APPNAME,APPLOGO);
  231. $v['app_name'] = $auth_info['app_name'];
  232. $v['app_logo'] = $auth_info['app_logo'];
  233. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  234. $v['welfare_arr'] = explode(',',trim($v['welfare'],','));
  235. });
  236. $sql2 = "SELECT count(a.id) num 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}";
  237. $total = Db::query($sql2);
  238. $this->success('ok',['list'=>$list,'total_count'=>$total[0]['num'],'page_num'=>$this->page_num]);
  239. }
  240. /**
  241. * @title 合集列表
  242. * @desc 合集列表
  243. * @author qc
  244. * @method GET
  245. * @url /api/Recruit/getRecruitList
  246. * @header name:Authorization require:1 desc:Token
  247. * @param name:page type:int default:0 desc:页数
  248. * @param name:page_num type:int default:20 desc:每页数
  249. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  250. * @param name:city type:string default:1 desc:城市名称
  251. * @param name:first_classify type:int default:0 desc:一级分类id
  252. * @param name:second_classify type:int default:0 desc:二级分类id
  253. * @param name:third_classify type:int default:0 desc:三级分类id
  254. *
  255. * @return name:title type:string default:-- desc:标题
  256. * @return name:company type:string default:-- desc:公司名
  257. * @return name:cover type:string default:-- desc:公司logo
  258. * @return name:salary type:int default:-- desc:薪资【文本】
  259. * @return name:phone type:string default:-- desc:电话
  260. * @return name:email type:string default:-- desc:email
  261. * @return name:label_name type:array default:-- desc:标签
  262. * @return name:welfare_arr type:array default:-- desc:岗位福利
  263. * @return name:principal type:string default:-- desc:HR
  264. * @return name:hr_headimg type:string default:-- desc:HR头像
  265. * @return name:province type:string default:-- desc:省名
  266. * @return name:city type:string default:-- desc:市名
  267. * @return name:county type:string default:-- desc:县区
  268. * @return name:address type:string default:-- desc:地址
  269. * @return name:num type:int default:-- desc:招聘人数
  270. * @return name:app_name type:string default:-- desc:发布方名称
  271. * @return name:app_logo type:string default:-- desc:发布方头像
  272. * @return name:release_time type:string default:-- desc:上架时间
  273. * @return name:follow_switch type:int default:-- desc:订阅开关状态【0关闭1开启】
  274. * @return name:third_title type:string default:-- desc:第三级分类名称
  275. * @return name:company_intro type:string default:-- desc:公司简介
  276. * @return name:is_ss type:string default:-- desc:是否上市,1上市0未上市
  277. * @return name:scale type:string default:-- desc:公司规模(人数)
  278. */
  279. public function getRecruitList(){
  280. $sort_type = input('get.sort_type',1);
  281. $first_classify = input('get.first_classify');
  282. $second_classify = input('get.second_classify');
  283. $third_classify = input('get.third_classify');
  284. $city = input('get.city');
  285. switch ($sort_type) {
  286. case 1:
  287. $order = ['sort'=>'desc','read_num'=>'desc'];
  288. break;
  289. case 2:
  290. $order = ['id'=>'asc','sort'=>'desc'];
  291. break;
  292. case 3:
  293. $order = ['id'=>'desc','sort'=>'desc'];
  294. break;
  295. }
  296. $sel_where = [];
  297. $sel_where[] = ['is_deleted','=',0];
  298. $sel_where[] = ['status','=',1];
  299. if($first_classify) $sel_where[] = ['first_classify','=',$first_classify];
  300. if($second_classify) $sel_where[] = ['second_classify','=',$second_classify];
  301. if($third_classify) $sel_where[] = ['third_classify','=',$third_classify];
  302. if($city) $sel_where[] = ['city','like','%'.$city.'%'];
  303. $field = "id,title,num,province,city,county,address,user_id,principal,hr_headimg,label,welfare,salary,release_time,company,company_intro,is_ss,scale";
  304. $list = \app\common\model\Recruit::field($field)->where($sel_where)->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
  305. $third_title = RecruitCate::where('id',$third_classify)->value('title');
  306. foreach ($list as &$v) {
  307. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  308. $v['welfare_arr'] = explode(',',trim($v['welfare'],','));
  309. $auth_info = \app\common\model\Recruit::getAuth($v['user_id'],APPNAME,APPLOGO);
  310. $v['app_name'] = $auth_info['app_name'];
  311. $v['app_logo'] = $auth_info['app_logo'];
  312. }
  313. $total_num = \app\common\model\Recruit::where($sel_where)->count();
  314. $follow_switch = PlatformSwitch::checkSwitch($this->user_id,$third_classify,6);
  315. $this->success('ok',['list'=>$list,'third_title'=>$third_title,'follow_switch'=>$follow_switch,'total_num'=>$total_num,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  316. }
  317. /**
  318. * @title 获取招聘详情
  319. * @desc 获取招聘详情
  320. * @author qc
  321. * @method GET
  322. * @url /api/Recruit/getRecruitDetail
  323. * @header name:Authorization require:1 desc:Token
  324. * @param name:id type:int default:-- desc:招聘记录id
  325. * @return name:title type:string default:-- desc:标题
  326. * @return name:company type:string default:-- desc:公司名
  327. * @return name:cover type:string default:-- desc:公司logo
  328. * @return name:company_label type:array default:-- desc:公司标签
  329. * @return name:principal type:string default:-- desc:RH
  330. * @return name:hr_headimg type:string default:-- desc:RH头像
  331. * @return name:phone type:string default:-- desc:电话
  332. * @return name:email type:string default:-- desc:email
  333. * @return name:label_name type:array default:-- desc:标签
  334. * @return name:welfare_arr type:array default:-- desc:岗位福利
  335. * @return name:education type:string default:-- desc:学历
  336. * @return name:experience_min type:int default:0 desc:最低工作年限
  337. * @return name:experience_max type:int default:0 desc:最高工作年限
  338. * @return name:salary type:string:-- desc:薪资【文本】
  339. * @return name:content type:string default:-- desc:招聘详情
  340. * @return name:create_at type:string default:-- desc:发布时间
  341. * @return name:praise_num type:int default:-- desc:点赞量
  342. * @return name:is_praise type:int default:-- desc:是否点赞【0否1是】
  343. * @return name:is_collect type:int default:-- desc:是否收藏【0否1是】
  344. * @return name:collect_num type:int default:-- desc:收藏量
  345. * @return name:transmit_num type:int default:-- desc:转发量
  346. * @return name:read_num type:int default:-- desc:阅读量
  347. * @return name:province type:string default:-- desc:省名
  348. * @return name:city type:string default:-- desc:市名
  349. * @return name:county type:string default:-- desc:县区
  350. * @return name:address type:string default:-- desc:地址
  351. * @return name:longitude type:string default:-- desc:经度
  352. * @return name:latitude type:string default:-- desc:纬度
  353. * @return name:num type:int default:-- desc:招聘人数
  354. * @return name:hr_code type:int default:-- desc:二维码
  355. * @return name:release_time type:string default:-- desc:上架时间
  356. * @return name:follow_switch type:int default:-- desc:订阅开关状态【0关闭1开启】
  357. * @return name:company_intro type:string default:-- desc:公司简介
  358. * @return name:is_ss type:string default:-- desc:是否上市,1上市0未上市
  359. * @return name:scale type:string default:-- desc:公司规模(人数)
  360. *
  361. */
  362. public function getRecruitDetail()
  363. {
  364. $sel_where[] = ['id','=',input('get.id')];
  365. $detail = \app\common\model\Recruit::where($sel_where)->find()->toArray();
  366. if($detail['is_deleted'] == 1 || $detail['status'] == 0) $this->error('该招聘信息已取消');
  367. $detail['label_name'] = explode(',',trim($detail['label'],','));
  368. $detail['welfare_arr'] = explode(',',trim($detail['welfare'],','));
  369. $detail['company_label'] = explode(',',trim($detail['company_label'],','));
  370. $detail['is_praise'] = PlatformLike::checkTags($this->user_id,$detail['id'],5);
  371. $detail['praise_num'] = PlatformLike::getPraiseNum($detail['id'],5);
  372. $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,8,$detail['id']);
  373. $detail['collect_num'] = UserCollect::getCollectNum(8,$detail['id']);
  374. $detail['transmit_num'] = numTransform($detail['transmit_num']);
  375. \app\common\model\Recruit::where('id',$detail['id'])->setInc('read_num');
  376. TopSearch::seIncHotNum($detail['id'],$this->request->controller());
  377. UserTrack::crateTrack($this->user_id,8,input('get.id'),0);
  378. $this->success('ok',['detail'=>$detail]);
  379. }
  380. /**
  381. * @title 点赞||取消点赞
  382. * @desc 点赞||取消点赞
  383. * @author qc
  384. * @method POST
  385. * @url /api/Recruit/recruitTags
  386. * @header name:Authorization require:1 desc:Token
  387. * @param name:id type:int default:1 desc:招聘记录id
  388. * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
  389. */
  390. public function recruitTags()
  391. {
  392. $ret_val = PlatformLike::userTags($this->user_id,input('post.id'),5);
  393. $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
  394. }
  395. /**
  396. * @title 收藏||取消收藏
  397. * @desc 用户收藏
  398. * @author qc
  399. * @method POST
  400. * @url /api/Recruit/recruitCollect
  401. * @header name:Authorization require:1 desc:Token
  402. * @param name:id type:int require:1 default:-- desc:招聘记录id
  403. * @param name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
  404. */
  405. public function recruitCollect(){
  406. $coll_status = UserCollect::plateCollect($this->user_id,8,input('post.id',0));
  407. $coll_status ? $this->success('收藏成功',['status'=>1]) : $this->success('取消收藏成功',['status'=>0]);
  408. }
  409. /**
  410. * @title 转发(转发数量统计)
  411. * @desc 转发成功后调用
  412. * @author qc
  413. * @method POST
  414. * @url /api/Recruit/recruitTransmit
  415. * @header name:Authorization require:1 desc:Token
  416. * @param name:id type:int default:-- desc:招聘记录id
  417. */
  418. public function recruitTransmit()
  419. {
  420. $id = input('post.id',0);
  421. \app\common\model\Recruit::where('id',$id)->setInc('transmit_num');
  422. $this->success('ok');
  423. }
  424. /**
  425. * @title 点赞我的
  426. * @desc 点赞我的
  427. * @author qc
  428. * @method GET
  429. * @url /api/Recruit/praiseRecruitList
  430. * @header name:Authorization require:1 desc:Token
  431. * @param name:page type:int default:-- desc:页数
  432. * @param name:page_num type:int default:-- desc:每页数
  433. * @return name:id type:int default:-- desc:记录id
  434. * @return name:label_name type:array default:-- desc:标签
  435. * @return name:recruit_id type:array default:-- desc:招聘id
  436. * @return name:create_at type:string default:-- desc:时间
  437. * @return name:user_name type:string default:-- desc:会员名称
  438. * @return name:headimg type:string default:-- desc:会员头像
  439. * @return name:salary type:int default:-- desc:薪资【文本】
  440. * @return name:company type:string default:-- desc:公司名
  441. * @return name:education type:string default:-- desc:学历
  442. * @return name:experience_min type:int default:0 desc:最低工作年限
  443. * @return name:experience_max type:int default:0 desc:最高工作年限
  444. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  445. * @return name:company_intro type:string default:-- desc:公司简介
  446. * @return name:is_ss type:string default:-- desc:是否上市,1上市0未上市
  447. * @return name:scale type:string default:-- desc:公司规模(人数)
  448. */
  449. public function praiseRecruitList()
  450. {
  451. $sel_where = [];
  452. $sel_where[] = ['p.type', '=', 5];
  453. $sel_where[] = ['f.user_id', '=', $this->user_id];
  454. $sel_where[] = ['p.user_id', '<>', $this->user_id];
  455. $sel_where[] = ['p.to_deleted', '=', 0];
  456. $list = PlatformLike::where($sel_where)
  457. ->field('p.id,p.like_id,f.title,u.name user_name,u.headimg,f.title,f.id recruit_id,f.label,salary,f.company,f.company_intro,f.is_ss,f.scale,education,experience_min,experience_max,p.create_at')
  458. ->alias('p')
  459. ->leftJoin('Recruit f', 'f.id = p.like_id')
  460. ->leftJoin('StoreMember u', 'u.id = p.user_id')
  461. ->limit($this->off_set,$this->page_num)
  462. ->select()->toArray();
  463. array_walk($list,function (&$v){
  464. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  465. $v['is_normal'] = CheckPower::checkModulesPower($v['like_id'], 0, $this->request->controller());
  466. });
  467. $total_num = PlatformLike::where($sel_where)->alias('p')->leftJoin('Recruit f', 'f.id = p.like_id')->leftJoin('StoreMember u', 'u.id = p.user_id')->count();
  468. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  469. }
  470. /**
  471. * @title 我的点赞
  472. * @desc 我的点赞
  473. * @author qc
  474. * @method GET
  475. * @url /api/Recruit/getTagsRecruit
  476. * @header name:Authorization require:1 desc:Token
  477. * @param name:page type:int default:-- desc:页数
  478. * @param name:page_num type:int default:-- desc:每页数
  479. * @return name:id type:int default:-- desc:记录id
  480. * @return name:label_name type:array default:-- desc:标签
  481. * @return name:recruit_id type:array default:-- desc:招聘id
  482. * @return name:create_at type:string default:-- desc:时间
  483. * @return name:user_name type:string default:-- desc:会员名称
  484. * @return name:headimg type:string default:-- desc:会员头像
  485. * @return name:salary type:int default:-- desc:薪资【文本】
  486. * @return name:company type:string default:-- desc:公司名
  487. * @return name:education type:string default:-- desc:学历
  488. * @return name:experience_min type:int default:0 desc:最低工作年限
  489. * @return name:experience_max type:int default:0 desc:最高工作年限
  490. * @return name:principal type:string default:-- desc:联系人
  491. * @return name:hr_headimg type:string default:-- desc:联系人头像
  492. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  493. * @return name:company_intro type:string default:-- desc:公司简介
  494. * @return name:is_ss type:string default:-- desc:是否上市,1上市0未上市
  495. * @return name:scale type:string default:-- desc:公司规模(人数)
  496. */
  497. public function getTagsRecruit()
  498. {
  499. $sel_where = [];
  500. $sel_where[] = ['p.type', '=', 5];
  501. $sel_where[] = ['p.user_id', '=', $this->user_id];
  502. $sel_where[] = ['f.user_id', '<>', $this->user_id];
  503. $sel_where[] = ['p.to_deleted', '=', 0];
  504. $list = PlatformLike::where($sel_where)
  505. ->field('p.id,p.like_id,f.title,u.name user_name,u.headimg,f.title,f.id recruit_id,f.label,salary,f.company,f.company_intro,f.is_ss,f.scale,education,experience_min,experience_max,principal,hr_headimg')
  506. ->alias('p')
  507. ->leftJoin('Recruit f', 'f.id = p.like_id')
  508. ->leftJoin('StoreMember u', 'u.id = p.user_id')
  509. ->limit($this->off_set,$this->page_num)
  510. ->select()->toArray();
  511. array_walk($list,function (&$v){
  512. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  513. $v['is_normal'] = CheckPower::checkModulesPower($v['like_id'], 0, $this->request->controller());
  514. });
  515. $total_num = PlatformLike::where($sel_where)->alias('p')->leftJoin('Recruit f', 'f.id = p.like_id')->leftJoin('StoreMember u', 'u.id = p.user_id')->count();
  516. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  517. }
  518. /**
  519. * @title 给我投的
  520. * @desc 给我投的
  521. * @author qc
  522. * @method GET
  523. * @url /api/Recruit/resumeToRecruits
  524. * @header name:Authorization require:1 desc:Token
  525. * @param name:page type:int default:-- desc:页数
  526. * @param name:page_num type:int default:-- desc:每页数
  527. * @return name:id type:int default:-- desc:招聘记录id
  528. * @return name:salary type:string default:-- desc:薪资
  529. * @return name:unread_num type:string default:-- desc:未读量
  530. * @return name:time_str type:string default:-- desc:时间
  531. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  532. */
  533. public function resumeToRecruits()
  534. {
  535. $recruits = \app\common\model\Recruit::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  536. $recruit_ids = RecruitResume::where('recruit_id','in',$recruits)->where('is_deleted',0)->where('to_deleted',0)->group('recruit_id')->column('recruit_id');
  537. $ids_str = implode(',',$recruit_ids);
  538. $list = \app\common\model\Recruit::where(['r.user_id'=>$this->user_id,'r.is_deleted'=>0,]) ->alias('r')
  539. ->where('r.id','in',$ids_str)
  540. //->field('r.id,IFNULL( (SELECT count( s.id) FROM dd_recruit_resume as s WHERE r.id=s.recruit_id ),0) as re_num,IFNULL( (SELECT max(y.id) FROM dd_recruit_resume as y WHERE r.id=y.recruit_id ),0) as max_id')
  541. ->field('r.id,r.title,r.salary,IFNULL( (SELECT count( s.id) FROM dd_recruit_resume as s WHERE r.id=s.recruit_id ),0) as re_num')
  542. ->order('r.id desc')
  543. ->limit($this->off_set,$this->page_num)
  544. ->select()->toArray();
  545. array_walk($list,function (&$v){
  546. $v['unread_num'] = RecruitResume::getUnreadNum($v['id']);
  547. $new_info = RecruitResume::where(['recruit_id'=>$v['id'],'is_deleted'=>0,'is_read'=>0])->order('id desc')->find();
  548. $v['time_str'] = $new_info ? timeTransform($new_info->create_at) :null;
  549. $v['is_normal'] = CheckPower::checkModulesPower($v['id'],0,$this->request->controller());
  550. });
  551. $total_num = \app\common\model\Recruit::where(['r.user_id'=>$this->user_id,'r.is_deleted'=>0,]) ->alias('r') ->where('r.id','in',$ids_str)
  552. ->field('r.id,IFNULL( (SELECT count( s.id) FROM dd_recruit_resume as s WHERE r.id=s.recruit_id ),0) as re_num')
  553. ->order('r.id desc')->count();
  554. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  555. }
  556. /**
  557. * @title 给我投的--简历列表
  558. * @desc 给我投的--简历列表
  559. * @author qc
  560. * @method GET
  561. * @url /api/Recruit/getRecruitResumeList
  562. * @header name:Authorization require:1 desc:Token
  563. * @param name:page type:int default:-- desc:页数
  564. * @param name:page_num type:int default:-- desc:每页数
  565. * @param name:recruit_id type:int default:-- desc:招聘记录id
  566. * @return name:images type:string default:-- desc:图片
  567. * @return name:images_arr type:array default:-- desc:数组
  568. * @return name:name type:string default:-- desc:名称
  569. * @return name:headimg type:string default:-- desc:头像
  570. * @return name:create_at type:string default:-- desc:时间
  571. * @return name:type type:int default:0 desc:类型0图片1pdf
  572. * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
  573. */
  574. public function getRecruitResumeList()
  575. {
  576. $list = RecruitResume::where(['r.recruit_id'=>input('get.recruit_id'),'r.is_deleted'=>0,'r.to_deleted'=>0])->alias('r')
  577. ->field('r.id,r.recruit_id,u.name,u.headimg,images,r.create_at,r.is_read,r.type')
  578. ->leftJoin('StoreMember u','u.id = r.user_id')
  579. ->limit($this->off_set,$this->page_num)
  580. ->order('r.id desc')
  581. ->select()->toArray();
  582. array_walk($list,function (&$v){
  583. $v['images_arr'] = explode('|',$v['images']);
  584. $v['create_at'] = substr($v['create_at'],0,10);
  585. });
  586. $total_num = RecruitResume::where(['r.recruit_id'=>input('get.recruit_id'),'r.is_deleted'=>0,'r.to_deleted'=>0])->alias('r')
  587. ->leftJoin('StoreMember u','u.id = r.user_id')->count();
  588. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  589. }
  590. /**
  591. * @title 我的发布【招聘】
  592. * @desc 我的发布【招聘】
  593. * @author qc
  594. * @method GET
  595. * @url /api/Recruit/getOwnRecruitList
  596. * @header name:Authorization require:1 desc:Token
  597. * @param name:title type:string default:-- desc:标题
  598. * @param name:page type:int default:0 desc:页数
  599. * @param name:page_num type:int default:20 desc:每页数
  600. * @return name:title type:string default:-- desc:标题
  601. * @return name:company type:string default:-- desc:公司名
  602. * @return name:cover type:string default:-- desc:公司logo
  603. * @return name:label_name type:array default:-- desc:标签
  604. * @return name:welfare_arr type:array default:-- desc:岗位福利
  605. * @return name:education type:string default:-- desc:学历
  606. * @return name:experience_min type:int default:0 desc:最低工作年限
  607. * @return name:experience_max type:int default:0 desc:最高工作年限
  608. * @return name:price_min type:int default:-- desc:最低薪资[弃用]
  609. * @return name:price_max type:int default:-- desc:最高薪资[弃用]
  610. * @return name:salary type:int default:-- desc:薪资【文本】
  611. * @return name:create_at type:string default:-- desc:发布时间
  612. * @return name:num type:int default:-- desc:招聘人数
  613. * @return name:principal type:string default:-- desc:联系人
  614. * @return name:hr_headimg type:string default:-- desc:联系人头像
  615. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  616. * @return name:company_intro type:string default:-- desc:公司简介
  617. * @return name:is_ss type:string default:-- desc:是否上市,1上市0未上市
  618. * @return name:scale type:string default:-- desc:公司规模(人数)
  619. */
  620. public function getOwnRecruitList()
  621. {
  622. $title = input('get.title');
  623. $sel_where = [];
  624. $sel_where[] = ['is_deleted','=',0];
  625. $sel_where[] = ['status','=',1];
  626. $sel_where[] = ['user_id','=',$this->user_id];
  627. $list = \app\common\model\Recruit::where($sel_where)
  628. ->field('id,title,company,company_intro,is_ss,scale,label,welfare,education,experience_min,salary,experience_max,price_min,price_max,create_at,num,principal,hr_headimg,province,city,county')
  629. ->when($title,function ($query)use($title){
  630. if($title) $query->where('title|label','like','%'.$title.'%');
  631. })->order(['id'=>'asc'])
  632. ->limit($this->off_set,$this->page_num)
  633. ->select()->toArray();
  634. $user_info = $this->userInfo('name,headimg');
  635. foreach ($list as &$v) {
  636. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  637. $v['welfare_arr'] = explode(',',trim($v['welfare'],','));
  638. $v['is_normal'] = CheckPower::checkModulesPower($v['id'],0,$this->request->controller());
  639. $v['app_name'] = $user_info['name'];
  640. $v['app_logo'] = $user_info['headimg'];
  641. }
  642. $total_num = \app\common\model\Recruit::where($sel_where)
  643. ->when($title,function ($query)use($title){
  644. if($title) $query->where('title|label','like','%'.$title.'%');
  645. })->count();
  646. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  647. }
  648. /**
  649. * @title 浏览记录【招聘】
  650. * @desc 浏览记录【招聘】
  651. * @author qc
  652. * @method GET
  653. * @url /api/Recruit/getBrowseList
  654. * @header name:Authorization require:1 desc:Token
  655. * @param name:title type:string default:-- desc:标题
  656. * @param name:page type:int default:0 desc:页数
  657. * @param name:page_num type:int default:20 desc:每页数
  658. * @return name:id type:int default:-- desc:浏览记录id
  659. * @return name:title type:string default:-- desc:标题
  660. * @return name:recruit_id type:int default:-- desc:招聘记录id
  661. * @return name:company type:string default:-- desc:公司名
  662. * @return name:label_name type:array default:-- desc:标签
  663. * @return name:welfare_arr type:array default:-- desc:岗位福利
  664. * @return name:education type:string default:-- desc:学历
  665. * @return name:experience_min type:int default:0 desc:最低工作年限
  666. * @return name:experience_max type:int default:0 desc:最高工作年限
  667. * @return name:salary type:int default:-- desc:薪资【文本】
  668. * @return name:num type:int default:-- desc:招聘人数
  669. * @return name:time type:string default:-- desc:浏览时间
  670. * @return name:principal type:string default:-- desc:HR
  671. * @return name:hr_headimg type:string default:-- desc:HR头像
  672. * @return name:app_name type:string default:-- desc:发布人名称
  673. * @return name:app_logo type:string default:-- desc:发布人头像
  674. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  675. * @return name:company_intro type:string default:-- desc:公司简介
  676. * @return name:is_ss type:string default:-- desc:是否上市,1上市0未上市
  677. * @return name:scale type:string default:-- desc:公司规模(人数)
  678. */
  679. public function getBrowseList()
  680. {
  681. $sel_where = [];
  682. $sel_where[] = ['t.user_id','=',$this->user_id];
  683. $sel_where[] = ['t.type','=',8];
  684. $title = input('get.title');
  685. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  686. $list = UserTrack::where($sel_where)
  687. ->alias('t')
  688. ->field('t.id,t.update_int,t.first_id recruit_id,i.salary,i.title,i.price_max,i.company,i.company_intro,i.is_ss,i.scale,i.label,province,city,county,i.welfare,i.education,i.experience_min,i.experience_max,price_min,price_max,i.num,principal,hr_headimg,i.user_id')
  689. ->leftJoin('Recruit i','t.first_id = i.id')
  690. ->order('update_int desc')
  691. ->limit($this->off_set,$this->page_num)
  692. ->select()->toArray();
  693. foreach ($list as &$v) {
  694. $v['time'] = date("Y-m-d H:i:s",$v['update_int']);
  695. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  696. $v['welfare_arr'] = explode(',',trim($v['welfare'],','));
  697. $v['is_normal'] = CheckPower::checkModulesPower($v['recruit_id'],0,$this->request->controller());
  698. $auth_info = \app\common\model\Recruit::getAuth($v['user_id'],APPNAME,APPLOGO);
  699. $v['app_name'] = $auth_info['app_name'];
  700. $v['app_logo'] = $auth_info['app_logo'];
  701. }
  702. $total_num = UserTrack::where($sel_where)->alias('t')->leftJoin('Recruit i','t.first_id = i.id')->count();
  703. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  704. }
  705. /**
  706. * @title 收藏记录【招聘】
  707. * @desc 收藏记录【招聘】
  708. * @author qc
  709. * @method GET
  710. * @url /api/Recruit/getRecruitCollect
  711. * @header name:Authorization require:1 desc:Token
  712. * @param name:title type:string default:-- desc:标题
  713. * @param name:page type:int default:0 desc:页数
  714. * @param name:page_num type:int default:20 desc:每页数
  715. * @return name:id type:int default:-- desc:收藏记录id
  716. * @return name:title type:string default:-- desc:标题
  717. * @return name:recruit_id type:int default:-- desc:招聘记录id
  718. * @return name:company type:string default:-- desc:公司名
  719. * @return name:cover type:string default:-- desc:公司logo
  720. * @return name:label_name type:array default:-- desc:标签
  721. * @return name:welfare_arr type:array default:-- desc:岗位福利
  722. * @return name:education type:string default:-- desc:学历
  723. * @return name:experience_min type:int default:0 desc:最低工作年限
  724. * @return name:experience_max type:int default:0 desc:最高工作年限
  725. * @return name:price_min type:int default:-- desc:最低薪资[弃用]
  726. * @return name:price_max type:int default:-- desc:最高薪资[弃用]
  727. * @return name:salary type:string default:-- desc:薪资【文本】
  728. * @return name:num type:int default:-- desc:招聘人数
  729. * @return name:time type:string default:-- desc:浏览时间
  730. * @return name:principal type:string default:-- desc:联系人
  731. * @return name:hr_headimg type:string default:-- desc:联系人头像
  732. * @return name:app_name type:string default:-- desc:发布人名称
  733. * @return name:app_logo type:string default:-- desc:发布人头像
  734. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  735. * @return name:company_intro type:string default:-- desc:公司简介
  736. * @return name:is_ss type:string default:-- desc:是否上市,1上市0未上市
  737. * @return name:scale type:string default:-- desc:公司规模(人数)
  738. */
  739. public function getRecruitCollect()
  740. {
  741. $sel_where = [];
  742. $title = input('get.title');
  743. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  744. $sel_where[] = ['t.user_id','=',$this->user_id];
  745. $sel_where[] = ['t.coll_type','=',8];
  746. $list = UserCollect::where($sel_where)
  747. ->alias('t')
  748. ->field('t.id,t.create_at,t.coll_id recruit_id,i.title,i.company,i.company_intro,i.is_ss,i.scale,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,i.user_id')
  749. ->leftJoin('Recruit i','t.coll_id = i.id')
  750. ->order('id desc')
  751. ->limit($this->off_set,$this->page_num)
  752. ->select()->toArray();
  753. foreach ($list as &$v) {
  754. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  755. $v['welfare_arr'] = explode(',',trim($v['welfare'],','));
  756. $v['is_normal'] = CheckPower::checkModulesPower($v['recruit_id'],0,$this->request->controller());
  757. $auth_info = \app\common\model\Recruit::getAuth($v['user_id'],APPNAME,APPLOGO);
  758. $v['app_name'] = $auth_info['app_name'];
  759. $v['app_logo'] = $auth_info['app_logo'];
  760. }
  761. $total_num = UserCollect::where($sel_where)->alias('t')->leftJoin('Recruit i','t.coll_id = i.id')->count();
  762. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  763. }
  764. /**
  765. * @title 我的订阅
  766. * @desc 我的订阅
  767. * @author qc
  768. * @method GET
  769. * @url /api/Recruit/getFollowUpList
  770. * @header name:Authorization require:1 desc:Token
  771. * @param name:title type:string default:-- desc:标题
  772. * @param name:page type:int default:0 desc:页数
  773. * @param name:page_num type:int default:20 desc:每页数
  774. * @return name:create_at type:string default:-- desc:追更设置时间
  775. * @return name:cate_id type:int default:-- desc:招聘分类id
  776. * @return name:title type:string default:-- desc:标题
  777. * @return name:logo type:string default:-- desc:分类图片
  778. */
  779. public function getFollowUpList()
  780. {
  781. $sel_where = [];
  782. $sel_where[] = ['p.user_id','=',$this->user_id];
  783. $sel_where[] = ['p.type','=',6];
  784. $sel_where[] = ['p.switch_value','=',1];
  785. $field = 'p.id,p.switch_id as cate_id,p.create_at,a.title,a.logo';
  786. $list = PlatformSwitch::field($field)
  787. ->alias('p')
  788. ->leftJoin('RecruitCate a','p.switch_id = a.id')
  789. ->where($sel_where)
  790. ->limit($this->off_set,$this->page_num)
  791. ->order('p.id desc')
  792. ->select()->toArray();
  793. $total_num = PlatformSwitch::alias('p')->leftJoin('RecruitCate a','p.switch_id = a.id') ->where($sel_where)->count();
  794. $this->success('ok', ['list' => $list, 'total_count' => $total_num, 'page_num' => $this->page_num]);
  795. }
  796. /**
  797. * @title 订阅消息
  798. * @desc 订阅消息
  799. * @author qc
  800. * @method GET
  801. * @url /api/Recruit/getFollowUpMessage
  802. * @header name:Authorization require:1 desc:Token
  803. * @param name:page type:int default:-- desc:页数
  804. * @param name:page_num type:int default:-- desc:每页数
  805. * @return name:id type:int default:-- desc:记录id
  806. * @return name:title type:string default:-- desc:标题
  807. * @return name:content type:string default:-- desc:内容
  808. * @return name:create_at type:string default:-- desc:时间
  809. * @return name:is_read type:int default:-- desc:是否已读【0否1是】
  810. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  811. */
  812. public function getFollowUpMessage()
  813. {
  814. $list = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'recruit','m.type_id'=>5])->alias('m')
  815. ->field('m.id,m.create_at,m.is_read,m.children_id recruit_id,m.content')
  816. ->limit($this->off_set,$this->page_num)
  817. ->order(['m.id'=>'desc'])
  818. ->select()->toArray();
  819. array_walk($list,function (&$v){
  820. $v['is_normal'] = CheckPower::checkModulesPower($v['recruit_id'], 0, $this->request->controller());
  821. });
  822. $total_num = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'recruit','m.type_id'=>5])->alias('m')->count();
  823. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  824. }
  825. /**
  826. * @title 获取角标数量
  827. * @desc 获取角标数量
  828. * @author qc
  829. * @method GET
  830. * @url /api/Recruit/getMarkNum
  831. * @header name:Authorization require:1 desc:Token
  832. * @return name:praise_num type:int default:-- desc:点赞我的
  833. * @return name:follow_num type:int default:-- desc:我的订阅
  834. * @return name:total_num type:int default:-- desc:总数
  835. */
  836. public function getMarkNum()
  837. {
  838. $praise_num = PlatformLike::where([['p.type', '=', 5],['f.user_id', '=', $this->user_id],['p.to_deleted', '=', 0],['p.is_read','=',0]])->alias('p') ->leftJoin('Recruit f', 'f.id = p.like_id')->count();
  839. $follow_num = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'recruit','m.type_id'=>5,'is_read'=>0])->alias('m')->count();
  840. $total_num = $praise_num + $follow_num;
  841. $this->success('ok',compact(['praise_num','follow_num','total_num']));
  842. }
  843. /**
  844. * @title 批量删除||批量取消
  845. * @desc 删除||取消
  846. * @author qc
  847. * @method POST
  848. * @url /api/Recruit/batchesDel
  849. * @header name:Authorization require:1 desc:Token
  850. * @param name:id type:string default:1 desc:记录id【多个用逗号隔开=>'1,2'】
  851. * @param name:type type:string default:1 desc:消息类型【1点赞我的,2我的点赞,3我的收藏,4给我投的--简历列表,5订阅消息,6我的订阅】
  852. */
  853. public function batchesDel()
  854. {
  855. $type = input('post.type',1);
  856. $id = input('post.id');
  857. if(!$id) $this->error('请选择要删除的记录');
  858. $del_where = [];
  859. $del_where[] = ['id','in',$id];
  860. if(in_array($type,[2,3,5,6])) $del_where[] = ['user_id','=',$this->user_id];
  861. if(in_array($type,[1])) PlatformLike::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
  862. if(in_array($type,[2])) PlatformLike::where($del_where)->where('user_id',$this->user_id)->delete();
  863. if(in_array($type,[3])) UserCollect::where($del_where)->where('user_id',$this->user_id)->where('coll_type',8)->delete();
  864. if(in_array($type,[4])) RecruitResume::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
  865. if(in_array($type,[5])) UserMessage::where($del_where)->update(['is_deleted'=>1]);
  866. if(in_array($type,[6])) PlatformSwitch::where($del_where)->delete();
  867. $this->success('操作成功');
  868. }
  869. /**
  870. * @title 消息已读未读变更
  871. * @desc 消息已读
  872. * @author qc
  873. * @method POST
  874. * @url /api/Recruit/unreadChange
  875. * @header name:Authorization require:1 desc:Token
  876. * @param name:id type:string default:-- desc:记录id(多个逗号隔开,不传修改全部])
  877. * @param name:type type:string default:1 desc:消息类型【1给我投的--简历列表,2订阅消息,3点赞我的】
  878. * @param name:is_read type:int default:1 desc:变更类型【0消息变更为未读,1变更为已读】
  879. */
  880. public function unreadChange()
  881. {
  882. $type = input('post.type',1);
  883. $id = input('post.id');
  884. $is_read = input('post.is_read');
  885. switch ($type) {
  886. case 1:
  887. $recruit_ids = \app\common\model\Recruit::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  888. RecruitResume::where(['r.is_deleted'=>0,'r.to_deleted'=>0])
  889. ->where('r.recruit_id','in',$recruit_ids)
  890. ->alias('r')
  891. ->when($id ,function ($query)use ($id){
  892. if($id) return $query->where('r.id','in',$id);
  893. })->update(['is_read'=>$is_read]);
  894. break;
  895. case 2:
  896. $where[] = ['user_id','=',$this->user_id];
  897. $where[] = ['module','=','recruit'];
  898. if($id) $where[] = ['id','in',$id];
  899. UserMessage::where($where)->update(['is_read'=>$is_read]);
  900. break;
  901. case 3:
  902. PlatformLike::where([['p.type', '=', 5],['f.user_id', '=', $this->user_id]])
  903. ->alias('p') ->leftJoin('Recruit f', 'f.id = p.like_id')->update(['p.is_read'=>$is_read]);
  904. break;
  905. }
  906. $this->success('操作成功');
  907. }
  908. }