JobfairPersonalJopApplyService.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wuzhenke
  5. * Date: 2019/1/27
  6. * Time: 10:42
  7. */
  8. namespace App\Services\Jobfair;
  9. use App\Exceptions\ResponseException;
  10. use App\Models\Jobfair\JobfairPersonalJobsApply;
  11. use App\Repositories\Jobfair\JobfairPersonalJobsApplyRepository;
  12. use App\Repositories\ResumeRepository;
  13. use App\Services\Company\CompanyDownResumeService;
  14. class JobfairPersonalJopApplyService
  15. {
  16. protected $jobfairPersonalJobsApplyRepository;
  17. protected $resumeRepository;
  18. protected $companyDownResumeService;
  19. /**
  20. * JobfairPersonalJopApplyService constructor.
  21. * @param $resumeRepository
  22. * @param $companyDownResumeService
  23. */
  24. public function __construct(JobfairPersonalJobsApplyRepository $jobfairPersonalJobsApplyRepository, ResumeRepository $resumeRepository,CompanyDownResumeService $companyDownResumeService)
  25. {
  26. $this->jobfairPersonalJobsApplyRepository = $jobfairPersonalJobsApplyRepository;
  27. $this->resumeRepository = $resumeRepository;
  28. $this->companyDownResumeService = $companyDownResumeService;
  29. }
  30. public function downResumeDel($request,$user)
  31. {
  32. $id = $request->y_id;
  33. if (!$id) {
  34. return response()->json(['status'=>0, 'msg'=>'请选择操作的项目!']);
  35. }
  36. if (!is_array($id)) {
  37. $ids = explode(',', $id);
  38. } else {
  39. $ids = $id;
  40. }
  41. $this->isComOwn($ids,$user);
  42. if ($this->jobfairPersonalJobsApplyRepository->downResumeDel($ids)) {
  43. return response()->json(['status'=>1,'msg'=>'简历删除成功!']);
  44. }
  45. return response()->json(['status'=>0,'msg'=>'简历删除失败!']);
  46. }
  47. public function personJobfair()
  48. {
  49. $data[] = ['personal_uid','=',auth('web-member')->user()->id];
  50. if (request()->resume_id) {
  51. $data[] = ['resume_id','=',request()->resume_id];
  52. }
  53. $interview = $this->jobfairPersonalJobsApplyRepository->personJobfair($data);
  54. return ['interview'=>$interview];
  55. }
  56. public function personDelect($id,$user)
  57. {
  58. if (empty($id)) {
  59. throw new ResponseException('请选择预约职位!');
  60. }
  61. $res = JobfairPersonalJobsApply::where(['personal_uid'=>$user->id])->get()->toArray();
  62. $array_id = array_column($res,'id');
  63. $arr_id = string_to_array(',', $id);
  64. foreach ($arr_id as $key=>$val){
  65. if(!in_array($val,$array_id)){
  66. throw new ResponseException('预约职位不存在!');
  67. }
  68. }
  69. return $this->jobfairPersonalJobsApplyRepository->downResumeDel(string_to_array(',', $id));
  70. }
  71. public function ifJobApply($user)
  72. {
  73. //判断是否有可以投递的简历
  74. $resume_audit = config('aix.personal_set.per_set.show_set.resume_display');
  75. $resume_where = array(array('uid', '=', $user->id));
  76. if (config('aix.personal_set.per_set.show_set.resume_display') == '1') {
  77. $resume_where[] = array('audit', '=', '2');
  78. } else {
  79. $resume_where[] = array('audit', '<>', '0');
  80. }
  81. $resumes = $this->resumeRepository->getResumes($resume_where);
  82. if (count($resumes) == 0) {
  83. //判断是否有简历
  84. $user_resumes = $this->resumeRepository->getResumes(array('uid' => $user->id));
  85. if ($user_resumes->toArray()) {
  86. throw new ResponseException("您没有审核通过的简历!");
  87. } else {
  88. throw new ResponseException("请您先填写一份简历!");
  89. }
  90. } else if (count($resumes) == 1) {
  91. //直接进入投递环节
  92. return ['status'=>3, 'resumes'=>$resumes];
  93. } else {
  94. //获取默认简历信息
  95. $def_resume = array();
  96. foreach ($resumes as $k => $v) {
  97. if ($v->def == '1') {
  98. $def_resume = $v;
  99. }
  100. }
  101. if (!$def_resume) {
  102. $def_resume = $resumes[0];
  103. }
  104. //提示用户选择需要投递的简历
  105. return array('status' => 2, 'resumes' => $resumes, 'def_resume' => $def_resume);
  106. }
  107. }
  108. public function applyJob($data)
  109. {
  110. return $this->jobfairPersonalJobsApplyRepository->create($data);
  111. }
  112. //发送面试邀请
  113. public function interview($request,$user){
  114. $type = $request->input('type');
  115. if($type == 2){
  116. //直接修改状态
  117. if(empty($request->input('apply_id'))){
  118. return response()->json(array('status'=>0,'msg'=>'邀请失败'));
  119. }
  120. $ret = $this->jobfairPersonalJobsApplyRepository->interviewEdit($request->input('apply_id'));
  121. $msg2 = '邀请成功';
  122. $msg3 = '邀请失败,请稍后重试';
  123. }else{
  124. if($type == 3 || $type == 5){
  125. $data['jobs_id'] = $request->input('job_id');
  126. $data['personal_uid'] = $request->input('personal_uid');
  127. $data['company_id'] = $user->id;
  128. $data['position_id'] = session('floorplan_stands.id');
  129. $data['jobfair_id'] = session('floorplan_stands.jobfair_id');
  130. }
  131. $res = $this->jobfairPersonalJobsApplyRepository->applyFind($data);
  132. if ($type == 3){
  133. $data['is_apply'] = 2;
  134. $msg = '您已对该简历进行过面试邀请,不能重复邀请';
  135. $msg2 = '邀请成功';
  136. $msg3 = '邀请失败,请稍后重试';
  137. }elseif ($type == 5){
  138. $data['is_apply'] = 1;
  139. $msg = '恭喜您已被面试邀请';
  140. $msg1 = '您已投递该职位,不能重复投递';
  141. $msg2 = '投递成功';
  142. $msg3 = '投递失败,请稍后重试';
  143. }
  144. if(!$res){
  145. $data['resume_id'] = $request->input('resume_id');
  146. $ret = $this->jobfairPersonalJobsApplyRepository->interviewAdd($data);
  147. //判断企业套餐是否允许查看
  148. $this->companyDownResumeService->addDownResumes($user->id,$data['resume_id']);
  149. }else{
  150. if($res->is_apply == 2 || ($res->is_apply == 1 && $res->is_interview == 1)){
  151. return response()->json(array('status'=>0,'msg'=>$msg));
  152. }elseif($res->is_apply == 1 && $res->is_interview == 2){
  153. if($type == 5){
  154. return response()->json(array('status'=>0,'msg'=>$msg1));
  155. }else{
  156. $ret = $this->jobfairPersonalJobsApplyRepository->interviewEdit($res->id);
  157. }
  158. }
  159. }
  160. }
  161. if ($ret) {
  162. return response()->json(array('status'=>1,'msg'=>$msg2));
  163. } else {
  164. return response()->json(array('status'=>0,'msg'=>$msg3));
  165. }
  166. }
  167. public function getApplyJobs($where, $field = 'jobs_id')
  168. {
  169. $rst = $this->jobfairPersonalJobsApplyRepository->getJobsApply($where);
  170. $list = array();
  171. if ($rst->toArray()) {
  172. foreach ($rst as $key => $val) {
  173. $list[$val->$field] = $val;
  174. }
  175. }
  176. return $list;
  177. }
  178. //判断是否有过面试
  179. public function isApply($where)
  180. {
  181. return $this->jobfairPersonalJobsApplyRepository->applyFind($where);
  182. }
  183. //个人判断
  184. public function isOwn($id,$user)
  185. {
  186. $apply = $this->jobfairPersonalJobsApplyRepository->applyFind(['id'=>$id]);
  187. if(!$apply)
  188. {
  189. throw new ResponseException('参数错误!');
  190. }
  191. if($apply->personal_uid != $user->id)
  192. {
  193. throw new ResponseException('抱歉,您只能操作自己的招聘会!');
  194. }
  195. }
  196. //企业判断
  197. public function isComOwn($idsArr,$user)
  198. {
  199. $idsArr = is_array($idsArr)?$idsArr:explode(',',$idsArr);
  200. $allIdsArr = $this->jobfairPersonalJobsApplyRepository->getPluck(['company_id'=>$user->id],'id')->toArray();
  201. if(array_diff($idsArr,$allIdsArr))
  202. {
  203. throw new ResponseException('抱歉,您只能操作自己的招聘会数据!');
  204. }
  205. }
  206. }