memberRepository = $memberRepository; $this->memberInfoRepository = $memberInfoRepository; $this->resumeRepository = $resumeRepository; $this->resumeEducationRepository = $resumeEducationRepository; $this->resumeWorkRepository = $resumeWorkRepository; $this->resumeTrainRepository = $resumeTrainRepository; $this->auditReasonsRepository = $auditReasonsRepository; $this->smsService = $smsService; } public function getDuration($list) { if ($list) { foreach ($list as $key => $value) { $start = $value['startyear'].'-'.$value['startmonth']; $end = $value['endyear'].'-'.$value['endmonth']; if ($value['todate']==1) { $end = date('Y-m'); } $list[$key]['duration'] = ddate($start, $end); } } return $list; } public function totalWorkDuration($list) { $total_year = 0; $total_month = 0; $return = ''; if ($list) { foreach ($list as $key => $value) { $current_duration = strpos($value['duration'], '年'); if ($current_duration === false) { $total_month += intval($value['duration']); } else { $arr = explode("年", $value['duration']); $total_year += intval($arr[0]); $total_month += intval($arr[1]); } } } $add_year = intval($total_month/12); $total_year += $add_year; $total_month = intval($total_month%12); if ($total_year > 0) { $return .= $total_year.'年'; } if ($total_month>0) { $return .= $total_month.'个月'; } return $return; } public function getResume($resume_id) { //获取简历信息 $where = ['id'=>$resume_id]; $resume = $this->resumeRepository->getResumeInfo($where); if (!$resume) { return ['status'=>0,'msg'=>'简历不存在或已经被删除!']; } $memberInfo = $this->memberInfoRepository->getMemberInfo($resume->uid); $resume->education_cn = $memberInfo->education_cn; //学历 $resume->experience_cn = $memberInfo->experience_cn; //工作经验 $resume->sex_cn = $memberInfo->sex_cn; //教育经历 $education = $this->resumeEducationRepository->getResumeEducationByResumeId($resume_id); $education = $this->getDuration($education); $resume->resume_education = $education; //获取工作信息 $work = $this->resumeWorkRepository->getResumeWorkByResumeId($resume_id); $work = $this->getDuration($work); $resume->resume_work = $work; $resume->work_count = count($work); $work_duration = $this->totalWorkDuration($work); //工龄 $resume->work_duration = $work_duration; //获取培训信息 $train = $this->resumeTrainRepository->getResumeTrainByResumeId($resume_id); $train = $this->getDuration($train); $resume->resume_training = $train; $resume->addtime = strtotime($resume->created_at); $resume->refreshtime = strtotime($resume->updated_at); $resume->fullname_ = $resume->fullname; $resume->fullname = $memberInfo->realname; $resume->age = date("Y") - $memberInfo->birthday; //年龄 $resume->height = $memberInfo->height; $resume->marriage_cn = $memberInfo->marriage_cn; $resume->telephone = $memberInfo->phone; $resume->email = $memberInfo->email; $resume->householdaddress = $memberInfo->householdaddress_cn; if ($resume->display==1) { $resume->display_cn = '公开'; } else { $resume->display_cn = '不公开'; } if ($resume->talent==1) { $resume->talent_cn = '高级'; } else { $resume->talent_cn = '普通'; } if($resume->audit=='2'){ $resume->audit_cn = '已通过审核'; }elseif($resume->audit=='1'){ $resume->audit_cn = '正在审核中'; }elseif($resume->audit=='0'){ $resume->audit_cn = '审核未通过'; } if ($memberInfo->images) { if ($memberInfo->display_images == 1) { $resume->photo_display_cn = '公开'; } else { $resume->photo_display_cn = '不公开'; } } else { $resume->photo_display_cn = '未上传照片'; } if (!$resume->specialty) { $resume->specialty = '无'; } return ['status'=>1,'msg'=>$resume]; } //审核简历 public function auditResume($id, $data) { $audit = array_has($data, 'audit')?$data['audit']:''; $remark = array_has($data, 'reason')?$data['reason']:''; $pms_notice = array_has($data, 'pms_notice')?$data['pms_notice']:0; $audit_username = array_has($data, 'audit_username')?$data['audit_username']:'CRM业务员'; $arr = array_filter($id); if (empty($arr)) { return ['status'=>0, 'msg'=>'数据异常']; } $reus = $this->resumeRepository->getCrmResumes([], ['id'=>$arr]); $mobile = []; foreach ($reus as $res) { if (isset($res->members->mobile)) { if (validator_check($res->members->mobile, new MobileRule())) { $mobile[] = $res->members->mobile; } } } $mobile = array_unique($mobile); $sms_id = $audit ? 'sms_resumeallow' : 'sms_resumenotallow'; $result = Resume::whereIn('id', $arr)->update(['audit'=>$audit]); $data=[]; foreach ($arr as $k => $v) { $data[$k]['type'] = 1; $data[$k]['type_id'] = $v; $data[$k]['status'] = $audit; $data[$k]['reason'] = $remark; $data[$k]['audit_man'] = $audit_username; $data[$k]['created_at'] = date('Y-m-d H:i:s', time()); $data[$k]['updated_at'] = date('Y-m-d H:i:s', time()); } AuditReason::insert($data); if ($pms_notice) { if ($audit==0) { $stat='审核未通过'; } elseif ($audit==2) { $stat = '审核通过'; } else { $stat='等待审核'; } $da = []; foreach ($reus as $k => $v) { $da[$k]['uid'] = $v['members']['id']; $da[$k]['username'] = $v['members']['username']; $da[$k]['resume_title'] = $v->title; } foreach ($da as $k => $v) { $ds[$k]['msgtype'] = 1; $ds[$k]['msgfromuid'] = 0; $ds[$k]['msgfrom'] = $audit_username; $ds[$k]['msgtoname'] = $v['username'] ? $v['username'] : 'admin'; $ds[$k]['msgtouid'] = $v['uid'] ? $v['uid'] : 0; if ($v['resume_title']) { $resume_title = '('.$v['resume_title'].')'; } else { $resume_title = ''; } $ds[$k]['message'] = $remark ? '简历'.$resume_title.$stat.'<备注:'.$remark.'>' : '简历'.$resume_title.$stat; $ds[$k]['created_at'] = date('Y-m-d H:i:s', time()); $ds[$k]['updated_at'] = date('Y-m-d H:i:s', time()); } Pms::insert($ds); } if ($result) { event_search_update(Resume::class, (string)implode(',', $arr), 'update'); $this->resumeSms($sms_id, $mobile); return ['status'=>1, 'msg'=>'审核成功']; } else { return ['status'=>0, 'msg'=>'审核失败']; } } public function resumeSms($sms_id, $mobile) { $SmsRule = SmsRule::where('alias', $sms_id)->first(); if (isset($SmsRule->status) && !empty($SmsRule->status)) { if ($mobile) { foreach ($mobile as $mobiles) { $this->smsService->sendSms($mobiles, $sms_id, ['sitename'=>config('aix.system.site.site.site_name'),'sitedomain'=>config('aix.system.site.site.site_domain')]); } } } } }