Recruit.php 51 KB

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