companyRepository = $companyRepository;
$this->jobsRepository = $jobsRepository;
$this->oauthRepository = $oauthRepository;
$this->taskService = $taskService;
$this->personalJobsApplyRepository = $personalJobsApplyRepository;
$this->personFocusComRepository = $personFocusComRepository;
$this->companyRepository = $companyRepository;
$this->companyImgRepository = $companyImgRepository;
$this->categoryRepository = $categoryRepository;
$this->memberSetmealRepository = $memberSetmealRepository;
$this->categoryDistrictRepository = $categoryDistrictRepository;
$this->companyStatisticsRepository = $companyStatisticsRepository;
$this->taskLogRepository = $taskLogRepository;
$this->memberPointRepository = $memberPointRepository;
$this->companyInterviewRepository = $companyInterviewRepository;
$this->memberLogRepository = $memberLogRepository;
$this->pmsRepository = $pmsRepository;
$this->memberMsgtipRepository = $memberMsgtipRepository;
$this->msgRepository = $msgRepository;
$this->subsiteRepository = $subsiteRepository;
$this->thirdloginRepository = $thirdloginRepository;
$this->companyContactRepository = $companyContactRepository;
}
/**
* 企业会员中心页
* @return array
*/
public function index($user)
{
$myPoints = $this->memberPointRepository->getPointsOne($user->id, $user->utype); //我的积分
$mySetmeal = $this->memberSetmealRepository->getSetmealByUid($user->id, 1);
//套餐临近到期提醒
$setmealMsg = '';
session(["setmeal_message" => ""]);
if ($mySetmeal->endtime != 0) {
$days = (strtotime($mySetmeal->endtime) - time()) / 86400;
$meal_min_remind = config('aix.companyset.setmeal_com.setmeal_com_set.meal_min_remind');
if ($meal_min_remind > 0 && $days <= $meal_min_remind) {
$setmealMsg = "提醒:您的套餐快到期,为避免造成不必要的麻烦,请升级套餐";
}
if (strtotime($mySetmeal->endtime) < time() && $mySetmeal->endtime != 0) {
$setmealMsg = "提醒:您的套餐已到期,请及时到我的套餐处升级套餐";
}
session(["setmeal_message" => $setmealMsg]);
}
//招聘中的职位数
$condition = [
'company_id' => $user->id,
'valid' => 1,
'display' => 1,
];
if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
$condition[] = ['audit', '=', 1];
} else {
$condition[] = ['audit', '<>', 3];
}
$jobsing = $this->jobsRepository->getJobCount($condition);
//待处理简历
$condition1 = [
'is_reply' => 0,
'company_id' => $user->id,
];
$resumes = $this->personalJobsApplyRepository->resumesCount($condition1);
//面试邀请
$condition2 = [
'company_id' => $user->id,
'result' => 0,
];
$interview = $this->companyInterviewRepository->interviewCount($condition2);
//谁关注我
$condition3 = [
'company_id' => $user->id,
];
$concern = $this->personFocusComRepository->getFansCount($condition3);
//我的消息
/* $condition4 = [
'msgtouid' => $user->id,
'utype' => $user->utype,
'new' => 1,
];
$pms = $this->pmsRepository->getPmsCount($condition4);*/
//是否已签到
$isSign = $this->taskLogRepository->getTaskLogCount($user->id, 18, $user->utype);
$res = [
'week' => array('日', '一', '二', '三', '四', '五', '六'),
'mypoints' => $myPoints,
'user' => $user,
'jobsing' => $jobsing,
'resumesCount' => $resumes,
'interview' => $interview,
'isSign' => $isSign,
'concern' => $concern,
/* 'pms'=>$pms,*/
'mySetmeal' => $mySetmeal,
'setmealMsg' => $setmealMsg,
];
return $res;
}
public function ajaxSms($user)
{
//获取当天
//当天开始时间
$start_time = strtotime(date("Y-m-d", time()));
//当天结束之间
$end_time = $start_time + 60 * 60 * 24;
$condit[] = ['new', 1];
$condit[] = ['msgtouid', $user->id];
$condit[] = ['utype', $user->utype];
$condit[] = ['msgtype', 2];
$condit[] = ['msgfromuid', 0];
$condit[] = ['msgfrom', 'admin'];
/*$condit[] = ['started_at', '<=', time()];
$condit[] = ['ended_at', '>=', time()];*/
$condit[] = ['started_at', '<=', $start_time];
$condit[] = ['ended_at', '>=', $start_time];
$message = $this->pmsRepository->findFirstPms($condit);;
$info = '';
$id = '';
if ($message) {
$order = array("\r\n", "\n", "\r");
$replace = '
';
$info = $message->message;
$id = $message->id;
}
return ['message' => $info, 'id' => $id];
}
public function setMatchJob($data, $company)
{
$job_id = array_get($data, 'job_id');
$type = array_get($data, 'type');
$jids = session('match_jobs_' . $company->id, array());
if ($jids) {
$jids[] = $job_id;
} else {
$jids = array($job_id);
}
if ($job_id) {
session(['match_jobs_' . $company->id => $jids]);
}
//判断当前企业是否有其它职位,如果没有则清空过滤的session
$job = $this->getMatchJob($company);
if (!$job) {
session(['match_jobs_' . $company->id => null]);
}
}
//获取推荐简历需要匹配的职位
public function getMatchJob($company)
{
$job_where = array(
array('company_id', '=', $company->id),
array('valid', '=', 1),
array('deadline', '>=', time())
);
if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
$job_where[] = array('audit', '=', 1);
} else {
$job_where[] = array('audit', '<>', 3);
}
//排除已推荐过的职位
$has_jids = session('match_jobs_' . $company->id, array());
$where_notIn = array();
if ($has_jids) {
$where_notIn = ['id' => $has_jids];
}
$orderby = array('stime' => 'DESC', 'refresh_time' => 'DESC', 'click' => 'DESC');
$jobinfo = $this->jobsRepository->getMatchJob($job_where, $where_notIn, $orderby);
if ($jobinfo) {
return $jobinfo;
} else {
return array();
}
}
//获取推荐简历排序
public function getRecommendOrder($user = array())
{
$order = array();
$order = array('click' => 'desc', 'stime' => 'desc', 'updated_at' => 'desc');
return $order;
}
public function getRecommendWhere($user)
{
$where = array();
if ($user && $user->utype == 1) {
//获取发布中的职位
$job_where = array(
array('company_id', '=', $user->id),
array('valid', '=', 1),
array('deadline', '>=', time())
);
if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
$job_where[] = array('audit', '=', 1);
} else {
$job_where[] = array('audit', '<>', 3);
}
$orderby = array('stime' => 'DESC', 'refresh_time' => 'DESC', 'click' => 'DESC');
$jobs = $this->jobsRepository->fliterJobs($job_where, array(), $orderby);
if ($jobs->isNotEmpty()) {
$or_where = array();
foreach ($jobs as $k => $v) {
$or_where[] = $this->getRecommendResumeWhere($v);
}
$and_where[] = array('display', '=', 1);
if (config('aix.personal_set.per_set.show_set.resume_display') == 1) {
$and_where[] = array('audit', '=', 2);
} else {
$and_where[] = array('audit', '<>', 0);
}
$where['or'] = $or_where;
}
return $where;
} else {
$where[] = array('display', '=', 1);
if (config('aix.personal_set.per_set.show_set.resume_display') == 1) {
$where[] = array('audit', '=', 2);
} else {
$where[] = array('audit', '<>', 0);
}
return $where;
}
}
//获取推荐简历
public function getRecommendResumeWhere($job)
{
$where = array();
//简历公开、简历审核状态、默认简历通过审核
$where[] = array('display', '=', 1);
//$where[] = array('def','=',1);
if (config('aix.personal_set.per_set.show_set.resume_display') == 1) {
$where[] = array('audit', '=', 2);
} else {
$where[] = array('audit', '<>', 0);
}
if (auth('web-company')->check()) {
//获取企业信息
$company = auth('web-company')->user();
if ($job) {
//匹配年龄、工作性质、期望行业、期望职位、工作地区、期望薪资
//匹配学历
$education = $job->education;
if ($education) {
$where[] = array('education', '>=', $education);
}
//匹配工作经验
$experience = $job->experience;
if ($experience) {
$where[] = array('experience', '>=', $experience);
}
//匹配性别
$sex = $job->sex;
if ($sex) {
$where[] = array('sex', '=', $sex);
}
//匹配年龄
$age = $job->age;
if (array_get($age, 0) || array_get($age, 1)) {
if (is_numeric(array_get($age, 0))) {
$birthday_min = date("Y") - $age[0];
$where[] = array('member_infos.birthday', '<=', $birthday_min);
}
if (is_numeric(array_get($age, 1))) {
$birthday_max = date("Y") - $age[1];
$where[] = array('member_infos.birthday', '>=', $birthday_max);
}
}
//匹配工作性质
$nature = $job->nature;
$where[] = array('nature', '=', $nature);
//匹配期望行业
/*$trade = $company->trade;
$where[] = array('trade','=',$trade);*/
//匹配工作地区 - 判断三级地区是否存在,如果不存在则判断二级地区
$district = $job->district;
if ($district) {
if (!strpos($district, ".")) {
$where[] = array('district', '=', $district);
} else {
$district_arr = explode('.', $district);
if (array_has($district_arr, 2) && array_get($district_arr, 2) > 0) {
$where[] = array('district', '=', $district_arr[2]);
} else {
$where[] = array('district', '=', $district_arr[1]);
}
}
}
//匹配期望薪资
if ($job->wage >= -1) {
$where[] = array('wage_min', '>=', $job->wage_min);
$where[] = array('wage_max', '<=', $job->wage_max);
}
//期望职位 - intention_jobs_id
$category = $job->category;
if ($category) {
$where[] = array('intention_jobs_id', '=', $category);
}
}
}
$where[] = array('subsite_ids', '=', get_subsite_id());
return $where;
}
public function ajaxGetStatistics($request, $user)
{
$where['company_id'] = $user->id;
$type = $request['type'] ? $request['type'] : 'visitor';
switch ($type) {
case 'visitor':
$where['apply'] = 0;
break;
case 'apply':
$where['apply'] = 1;
break;
case 'viewjobs':
$where['apply'] = 0;
$where[] = ['job_id', '>', 0];
break;
}
$settr = $request['settr'] ? $request['settr'] : 7;
$today = date('Y-m-d');
$where[] = ['created_at', '<', $today];
if ($settr > 0) {
$settr_tmp = strtotime($today) - $settr * 3600 * 24;
$where[] = ['created_at', '>=', date('Y-m-d H:i:s', $settr_tmp)];
$where[] = ['created_at', '<', $today];
}
$category = [];
$set_total = $set_login = [];
for ($i = $settr_tmp; $i < strtotime($today); $i = $i + 3600 * 24) {
$category[] = date('Y-m-d', $i);
$set_total[$i] = 0;
$set_login[$i] = 0;
}
$uidArr = [];
$statistics_list = $this->companyStatisticsRepository->findWhere($where);
foreach ($statistics_list as $key => $value) {
if ($value['uid'] > 0) {
$set_login[strtotime(date('Y-m-d', strtotime($value['created_at'])))]++;
}
$set_total[strtotime(date('Y-m-d', strtotime($value['created_at'])))]++;
}
$line_xml = '';
$line_xml .= '';
foreach ($category as $key => $value) {
$line_xml .= '';
}
$line_xml .= '';
if ($where['apply'] == 1) {
$line_xml .= '';
foreach ($set_login as $key => $value) {
$line_xml .= '';
}
$line_xml .= '';
} else {
$line_xml .= '';
foreach ($set_total as $key => $value) {
$line_xml .= '';
}
$line_xml .= '';
$line_xml .= '';
foreach ($set_login as $key => $value) {
$line_xml .= '';
}
$line_xml .= '';
}
$line_xml .= '';
$res = [
'line_xml' => $line_xml,
];
return response()->json(['data' => view('app.company.ajax.ajax_statistics', $res)->render()]);
}
public function mobileCompanySave($data, $user)
{
$id = $data['id'];
$updateData['short_name'] = $data['short_name'];
$updateData['nature'] = $data['nature'];
$updateData['scale'] = $data['scale'];
$updateData['trade'] = $data['trade'];
$updateData['district'] = $data['district'];
$updateData['district_cn'] = get_district_cn($data['district']);
$updateData['contents'] = $data['contents'];
$updateData['address'] = $data['address'];
$updateData['contact'] = $data['contact'];
$updateData['mobile'] = $data['mobile'];
$updateData['email'] = $data['email'];
$updateData['map_x'] = $data['map_x'] ? $data['map_x'] : 0;
$updateData['map_y'] = $data['map_y'] ? $data['map_y'] : 0;
$updateData['map_zoom'] = $data['map_zoom'] ? $data['map_zoom'] : 0;
$updateData['tag'] = explode(',', $data['tag']);
$updateData['landline_tel'] = $data['landline_tel_first'] . '-' . $data['landline_tel_next'] . '-' . $data['landline_tel_last'];
!empty($data['landline_tel_first']) ? $updateData['landline_tel'] = $data['landline_tel_first'] : $updateData['landline_tel'] = "";
!empty($data['landline_tel_next']) ? $updateData['landline_tel'] = $updateData['landline_tel'] . "-" . $data['landline_tel_next'] : "";
!empty($data['landline_tel_last']) ? $updateData['landline_tel'] = $updateData['landline_tel'] . "-" . $data['landline_tel_last'] : "";
$updateData['organization_code'] = $data['organization_code'];
$updateData['unit_character'] = $data['unit_character'];
$updateData['unit_character_cn'] = get_category($data['unit_character']);
$updateData['industry'] = $data['industry'];
$updateData['industry_cn'] = get_category($data['industry']);
$updateData['economy'] = $data['economy'];
$updateData['economy_cn'] = get_category($data['economy']);
$company_audit = $this->companyRepository->find($id, ['audit']);
if ($company_audit->audit != 0) {
if (config('aix.companyset.audit.audit_type.audit_edit_com') != 1) {
$updateData['audit'] = 2;
}
}
DB::beginTransaction();
try {
if (!$this->companyRepository->companySave($updateData, $user->id)) {
throw new \Exception('企业信息修改失败');
}
event_search_update(Company::class, (string)$id, 'update');
DB::commit();
$taskid = 27;
$dotask = $this->taskService->doTask($taskid, $id, 1);
if ($updateData['map_x'] && $updateData['map_y']) {
$this->taskService->doTask(29, $id, 1);
}
if ($dotask['code']) {
$html = view('app.company.ajax.ajax_com_info_saved', ['points' => $dotask['data']['points']])->render();
return ['status' => 1, 'msg' => '企业信息修改成功', 'html' => $html, 'data' => $dotask['data']['points']];
} else {
$html = view('app.company.ajax.ajax_com_info_saved')->render();
return ['status' => 1, 'msg' => '企业信息修改成功', 'html' => $html, 'data' => ''];
}
} catch (\Exception $e) {
DB::rollback();
return ['status' => 0, 'msg' => $e->getMessage()];
}
}
/**
* @param $data
* @return array
* @throws \Throwable
*/
public function companySave($data, $user)
{
if ($data['legal_idcard'] && !isCreditNo($data['legal_idcard'])) {
return ['status' => 0, 'msg' => '法人代表身份证格式不正确'];
}
if (empty($data['address'])) {
return ['status' => 0, 'msg' => '联系地址不能为空'];
}
$apiAddress = apiAddress($data['address']);
if (!$apiAddress) {
return ['status' => 0, 'msg' => '联系地址定位不准确'];
}
$id = $user->id;
$updateData['nature'] = $data['nature'];
$updateData['scale'] = $data['scale'];
$updateData['trade'] = $data['trade'];
$updateData['registered'] = $data['registered'];
$city = getCityInfo($data['district']);
$updateData['district'] = $city['district'];
$updateData['district_cn'] = $city['district_cn_all'];
$updateData['website'] = $data['website'];
$updateData['currency'] = $data['currency'];
$updateData['contents'] = $data['contents'];
$updateData['address'] = $data['address'];
$updateData['contact'] = $data['contact'];
$updateData['mobile'] = $data['mobile'];
$updateData['email'] = $data['email'];
$updateData['legal'] = $data['legal'];
$updateData['legal_idcard'] = $data['legal_idcard'];
$updateData['qq'] = $data['qq'] ? $data['qq'] : '';
$updateData['map_x'] = $apiAddress['lng'];
$updateData['map_y'] = $apiAddress['lat'];
$updateData['map_zoom'] = $data['map_zoom'] ? $data['map_zoom'] : 0;
$updateData['contact_show'] = $data['contact_show'];
$updateData['telephone_show'] = $data['telephone_show'];
$updateData['email_show'] = $data['email_show'];
$updateData['landline_tel_show'] = $data['landline_tel_show'];
$updateData['tag'] = explode(',', $data['tag']);
!empty($data['landline_tel_first']) ? $updateData['landline_tel'] = $data['landline_tel_first'] : $updateData['landline_tel'] = "";
!empty($data['landline_tel_next']) ? $updateData['landline_tel'] = $updateData['landline_tel'] . "-" . $data['landline_tel_next'] : "";
!empty($data['landline_tel_last']) ? $updateData['landline_tel'] = $updateData['landline_tel'] . "-" . $data['landline_tel_last'] : "";
$updateData['logo'] = $data['logo'];
$updateData['short_name'] = $data['short_name'];
$updateData['organization_code'] = $data['organization_code'];
$company_audit = $this->companyRepository->find($id, ['audit']);
if ($company_audit->audit != 0) {
if (config('aix.companyset.audit.audit_type.audit_edit_com') != 1) {
$updateData['audit'] = 2;
}
}
$jobsData['map_x'] = $data['map_x'];
$jobsData['map_y'] = $data['map_y'];
$jobsData['map_zoom'] = $data['map_zoom'] ? $data['map_zoom'] : '';
DB::beginTransaction();
try {
if ($data['sync'] == 1) {
$jobs_id = Jobs::where(['company_id' => $user->id])->pluck('id')->toArray();
$contact = [];
if ($jobs_id) {
$contact['telephone'] = $data['mobile'];
$contact['email'] = $data['email'];
$contact['contact'] = $data['contact'];
$contact['qq'] = $data['qq'];
$contact['landline_tel'] = $updateData['landline_tel'];
$contact['address'] = $data['address'];
$contact['contact_show'] = $data['contact_show'];
$contact['telephone_show'] = $data['telephone_show'];
$contact['email_show'] = $data['email_show'];
$contact['landline_tel_show'] = $data['landline_tel_show'];
JobsContact::whereIn('job_id', $jobs_id)->update($contact);
}
}
if (!$this->companyRepository->companySave($updateData, $id)) {
throw new \Exception('企业信息修改失败');
}
if (!$this->jobsRepository->getJobsByUid($id)->isEmpty()) {
if (!$this->jobsRepository->updateMap($id, $jobsData)) {
throw new \Exception('修改联系方式同步到职位失败!');
}
}
event_search_update(Company::class, (string)$id, 'update');
DB::commit();
if ($jobsData['map_x'] && $jobsData['map_y']) {
$this->taskService->doTask(29, $id, 1);
}
$taskid = 27;
$dotask = $this->taskService->doTask($taskid, $id, 1);
$user = auth('web-company')->user();
$this->memberLogRepository->createLog($user, 1004, "");
if ($dotask['code']) {
$html = view('app.company.ajax.ajax_com_info_saved', ['points' => $dotask['data']['points']])->render();
return ['status' => 1, 'msg' => '企业信息修改成功', 'html' => $html, 'data' => $dotask['data']['points']];
} else {
$html = view('app.company.ajax.ajax_com_info_saved')->render();
return ['status' => 1, 'msg' => '企业信息修改成功', 'html' => $html, 'data' => ''];
}
} catch (\Exception $e) {
DB::rollback();
return ['status' => 0, 'msg' => $e->getMessage()];
}
}
/**保存logo
* @param $request
* @return \Illuminate\Http\JsonResponse
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function saveLogo($request, $user)
{
$logo = $request['logo'];
$companyInfo = $this->companyRepository->getCompanyInfoByID($user->id);
//就是重新认证
if (config('aix.companyset.audit.audit_type.audit_edit_com') == 2) {
if (!empty($companyInfo->certificate_img)) {//只要企业的营业执照不为空,那企业就是未认证
$data['audit'] = 2;
} else {
$data['audit'] = 0;
}
}
$data['logo'] = $logo;
if (!$this->companyRepository->companySave($data, $user->id)) {
return response()->json(['status' => 0, 'msg' => "LOGO保存失败!"]);
}
$dotask = $this->taskService->doTask(19, $user->id, 1);
if ($dotask['code']) {
return response()->json(['status' => 1, 'msg' => "LOGO保存成功!", 'data' => ['path' => upload_asset($logo), 'points' => $dotask['data']['points']]]);
} else {
return response()->json(['status' => 1, 'msg' => "LOGO保存成功!", 'data' => ['path' => upload_asset($logo)]]);
}
}
/**删除logo
* @return \Illuminate\Http\JsonResponse
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function logoDel($user)
{
$data['logo'] = '';
if (!$this->companyRepository->companySave($data, $user->id)) {
return response()->json(['status' => 0, 'msg' => "LOGO删除失败!"]);
}
return response()->json(['status' => 1, 'msg' => "LOGO删除成功!"]);
}
/**
* 企业资料页面
* @return array
* @throws ResponseException
*/
public function companyInfo($user)
{
$companyInfo = $this->companyRepository->getCompanyInfoByID($user->id);
if ($companyInfo->subsite_id) {
$subsiteInfo = $this->subsiteRepository->find($companyInfo->subsite_id);
} else {
$subsiteInfo = '';
}
$companyInfo->subsite_name = $subsiteInfo ? $subsiteInfo->sitename : '总站';
//企业性质
$companyType = Category::categoryType('AIX_company_type');
//企业规模
$scale = Category::categoryType('AIX_scale');
//企业行业
$trade = Category::categoryType('AIX_trade');
//单位性质
$unit_character = Category::categoryType('AIX_dwxz');
$industry = Category::categoryType('AIX_cylb');
$economy = Category::categoryType('AIX_jjlx');
if ($jump_certificate = config('aix.companyset.audit.checkset.login_com_audit_certificate') == 1 && $companyInfo->audit == 0) {
$jump_certificate = 1;
} else {
$jump_certificate = 0;
}
$res = [
'companyInfo' => $companyInfo,
'companyType' => $companyType,
'scale' => $scale,
'trade' => $trade,
'unit_character' => $unit_character,
'industry' => $industry,
'economy' => $economy,
'jump_certificate' => $jump_certificate,
];
return $res;
}
/**
* 获取企业基本信息
* @return mixed
* @throws ResponseException
*/
public function getInfoById($user)
{
return $this->companyRepository->getCompanyInfoByID($user->id);
}
/**
* 获取企业基本信息
* @return mixed
* @throws ResponseException
*/
public function getCompInfo($id)
{
$where = ['id' => $id];
return $this->companyRepository->getCompanyInfo($where);
}
/**
* 账号安全
* @return array
* @throws ResponseException
*/
public function companySecurity($user)
{
$companyInfo = $this->companyRepository->getCompanyInfoByID($user->id);
$thirdBindQq = $this->thirdloginRepository->checkBind($user, ['1']); //qq
$thirdBindWechat = $this->thirdloginRepository->checkBind($user, ['2', '3', '4']); //微信
$isBind_qq = 0;
$isBind_weixin = 0;
if ($thirdBindQq) {
$isBind_qq = 1;
}
if ($thirdBindWechat) {
$isBind_weixin = 1;
}
$res = [
'companyInfo' => $companyInfo,
'qq' => $isBind_qq,
'weixin' => $isBind_weixin,
];
return $res;
}
public function unBindThird($alias, $user)
{
$type = [];
switch ($alias) {
case 'qq':
$type = ['1'];
break;
case 'weixin':
$type = ['2', '3', '4'];
break;
}
if (!$type) {
return response()->json(['status' => 0, 'msg' => "参数错误"]);
}
if (!$this->thirdloginRepository->checkBind($user, $type)) {
return response()->json(['status' => 0, 'msg' => "参数错误"]);
}
if ($this->thirdloginRepository->unBind($type, $user)) {
return response()->json(['status' => 1, 'msg' => "解绑成功!"]);
}
return response()->json(['status' => 0, 'msg' => "解绑失败!"]);
}
/**
* 修改用户名
* @param $request
* @return bool
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function saveUsername($username, $user)
{
if (!$this->companyRepository->save(['username' => $username], $user->id)) {
return false;
}
return true;
}
public function modifyUserName($user)
{
return $this->companyRepository->getCompanyColumn($user->id, ['username']);
}
/**
* 修改密码
* @param $oldpassword
* @param $pwd
* @param $pwd1
* @return bool
* @throws ResponseException
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function savePwd($user, $oldpassword, $pwd, $pwd1)
{
$com_info = $this->companyRepository->getCompanyColumn($user->id, ['password']);
if (!Hash::check($oldpassword, $com_info['password'])) {
throw new ResponseException('原密码不正确!');
}
if ($oldpassword == $pwd) {
throw new ResponseException('新密码与原密码一致!');
}
if ($pwd != $pwd1) {
throw new ResponseException('新密码与确认密码不一致');
}
if (!$this->companyRepository->save(['password' => bcrypt($pwd)], $user->id)) {
return false;
}
return true;
}
/**
* 验证手机
* @return mixed
*/
public function authMobile($user)
{
return $this->companyRepository->getCompanyColumn($user->id, ['mobile', 'mobile_audit']);
}
public function checkMobileAudit($id, $mobile)
{
return $this->companyRepository->findByField(['id' => $id, 'mobile' => $mobile, 'mobile_audit' => 1]);
}
/**
* 认证手机
* @param $request
* @return \Illuminate\Http\JsonResponse
*/
public function verifyCode($mobile, $user)
{
$data['mobile'] = $mobile;
$data['mobile_audit'] = 1;
if (!$this->companyRepository->verifyCode($data, $user->id)) {
return ['status' => 0, 'msg' => '手机认证失败'];
}
$taskRes = $this->taskService->doTask(22, $user->id, 1);
if (!$taskRes['code']) {
return ['status' => 1, 'msg' => '你的手机已经通过验证!'];
}
return ['status' => 1, 'msg' => '你的手机已经通过验证', 'data' => $taskRes['data']];
}
/**
* 验证email
* @return mixed
*/
public function authEmail($user)
{
return $this->companyRepository->getCompanyColumn($user->id, ['email', 'email_audit']);
}
public function checkEmailAudit($id, $email)
{
return $this->companyRepository->findByField(['id' => $id, 'email' => $email, 'email_audit' => 1]);
}
/**
* 企业登录日志
* @return mixed
*/
public function companyLoginLog($user)
{
return $this->memberLogRepository->getMemberLog($user->id, 1, 1001);
}
/**
* @param $request
* @return mixed
* @throws \Prettus\Validator\Exceptions\ValidatorException
*/
public function certificate($certificate_img_up, $user)
{
$data['audit'] = 2;
$data['certificate_img'] = $certificate_img_up;
if (!$this->companyRepository->save($data, $user->id)) {
return response()->json(['status' => 0, 'msg' => '营业执照保存失败']);
}
//写入日志
$this->memberLogRepository->createLog($user, 1005, "");
return response()->json(['status' => 1, 'msg' => '营业执照保存成功']);
}
//获取企业详细信息页面内容
public function getCompanyInfo($where)
{
$where[] = array('user_status', '=', 1);
//获取企业信息
$company = $this->companyRepository->getCompanyInfo($where);
if (!$company) {
throw new ResponseException('企业不存在', [], 404);
}
//处理企业地址和介绍、logo
$company->company_url = route(url_rewrite('AIX_companyshow'), array('id' => $company->id));
$company->company_profile = htmlspecialchars_decode($company->contents, ENT_QUOTES);
if ($company->logo) {
$company->logo = upload_asset($company->logo);
} else {
$company->logo = public_data_path('data/upload/no_logo.png');
}
//简历处理率、统计近两周企业简历处理率、如果收到的简历是0份,则简历处理率为0%
$app_where[] = array('company_id', '=', $company->id);
$app_where[] = array('created_at', '>', date('Y-m-d H:i:s', strtotime("-14day")));
$apply = $this->personalJobsApplyRepository->getJobsApply($app_where);
$reply = 0;
$reply_time = 0;
foreach ($apply as $key => $val) {
if ($val->is_reply) {
$reply++;
$val['reply_time'] && $reply_time += $val->reply_time - strtotime($val->created_at);
}
}
if ($apply->toArray()) {
$company->reply_ratio = intval($reply / count($apply) * 100);
if ($reply_time) {
$company->reply_time = sub_day(intval($reply_time / count($apply)), 0);
} else {
$company->reply_time = '0天';
}
} else {
$company->reply_ratio = 0;
$company->reply_time = '0天';
}
//登录时间
if (!$company->last_login_time) {
$company->last_login_time = '未登录';
} else {
$company->last_login_time = date('Y-m-d H:i', $company->last_login_time);
}
//获取在招职位信息(职位显示规则)
$jobs_display = config('aix.companyset.comset.show_set.jobs_display');
$job_count_map = array(array('company_id', '=', $company->id), array('valid', '=', 1), array('display', '=', 1));
if ($jobs_display == 1) {
$job_count_map[] = array('audit', '=', '1');
} else {
$job_count_map[] = array('audit', '<>', '3');
}
$jobs_count = $this->jobsRepository->getJobsCount($job_count_map);
$company->jobs_count = $jobs_count;
//企业网址
if ($company->website) {
$company->website_ = $company->website;
if ((strstr($company->website, "http://") === false) && (strstr($company->website, "https://") === false)) {
$company->website = "http://" . $company->website;
} else {
if (strstr($company->website, "http://") === false) {
$company->website_ = str_replace("https://", "", $company->website_);
} else {
$company->website_ = str_replace("http://", "", $company->website_);
}
}
}
//获取粉丝数量
$fan_where = array('company_id' => $company->id);
$fans = $this->personFocusComRepository->getFansCount($fan_where);
$company->fans = $fans;
$company->preview = 0;
if (auth('web-company')->check()) {
if (auth('web-company')->user()->id == $company->id) {
$company->preview = 1;
}
}
$company->focus = 0;
//个人用户登录时判断是否关注过当前企业
if (auth('web-member')->check()) {
$focus_where = array(
'uid' => auth('web-member')->user()->id,
'company_id' => $company->id
);
$focus_rst = $this->personFocusComRepository->getFocus($focus_where);
if ($focus_rst) {
$company->focus = 1;
}
}
//企业风采
$img_where = array(
array('company_id', '=', $company->id)
);
$companyimg_display = config('aix.companyset.comset.show_set.companyimg_display');
if ($companyimg_display == 1) {
$img_where[] = array('audit', '=', 1);
} else {
$img_where[] = array('audit', '<>', 3);
}
$company_images = $this->companyImgRepository->getImages($img_where);
if ($company_images->toArray()) {
foreach ($company_images as $key => $value) {
$company_images[$key]->img = upload_asset($value->image);
}
} else {
$company_images = null;
}
$company->img = $company_images;
//亮点tag
$tag_arr = array();
$other_categories = $this->categoryRepository->getCategories();
if (implode(',', $company->tag)) {
$tag_ids = $company->tag;
if ($other_categories) {
$tag_category = array_get($other_categories, 'AIX_jobtag');
if ($tag_category) {
foreach ($tag_ids as $k => $v) {
if (array_get($tag_category, $v)) {
$tag_arr[] = array_get($tag_category, $v);
}
}
}
}
}
$company->tag_arr = $tag_arr;
//企业性质/行业/规模/地区/注册资金
$company->nature_cn = '';
$company->trade_cn = '';
$company->scale_cn = '';
$company->district_cn = '';
if ($other_categories) {
$company_types = array_get($other_categories, 'AIX_company_type');
$company_trades = array_get($other_categories, 'AIX_trade');
$company_scales = array_get($other_categories, 'AIX_scale');
if ($company_types) {
$type_cn = array_get($company_types, $company->nature);
if ($type_cn) {
$company->nature_cn = $type_cn['demand'];
}
}
$company_trades = array_get($other_categories, 'AIX_trade');
if ($company_trades) {
$trade_cn = array_get($company_trades, $company->trade);
if ($trade_cn) {
$company->trade_cn = $trade_cn['demand'];
}
}
$company_scales = array_get($other_categories, 'AIX_scale');
if ($company_scales) {
$scale_cn = array_get($company_scales, $company->scale);
if ($scale_cn) {
$company->scale_cn = $scale_cn['demand'];
}
}
}
$city_cates = Cache::get('city_cate_list');
if (null === $city_cates) {
$city_cates = $this->categoryDistrictRepository->cityCateCache();
Cache::put('city_cate_list', $city_cates, '86400');
}
if (!strpos($company->district, ".")) { //直接读取地区信息
$district_cn = array_get($city_cates['id'], $company->district);
if ($district_cn) {
$company->district_cn = $district_cn['name'];
}
} else {//处理地区信息
$c_district = explode('.', $company->district);
$district_cn = array();
foreach ($c_district as $k => $v) {
if ($v) {
$district_info = array_get($city_cates['id'], $v);
if ($district_info) {
$district_cn[] = $district_info['name'];
}
}
}
$district_cn = implode('/', $district_cn);
$company->district_cn = $district_cn;
}
///会员套餐
$setmeal = $this->memberSetmealRepository->getSetmealByUid($company->id, $company->utype);
$company->setmeal = $setmeal;
$company->setmeal_id = $setmeal->id;
$company->setmeal_name = $setmeal->setmeal_name;
$company->setmeal_img = $setmeal->setmeal_img;
///联系方式
/*判断查看联系方式设置
如果设置成游客
判断企业中心的联系方式设置 公开 完全显示,
不公开 显示‘企业设置不公开’
设置成登陆会员
游客:
企业中心的联系方式设置 公开 *******
不公开 显示‘企业设置不公开’
已登录用户:
企业中心的联系方式设置 公开 完全显示
不公开 显示‘企业设置不公开’
如果设置成下载后可见
判断企业中心的联系方式设置 公开 *******,
不公开 显示‘企业设置不公开’
*
*/
/// 处理固定电话
if (strstr($company->landline_tel, '-')) {
$landline_tel_arr = explode('-', $company->landline_tel);
foreach ($landline_tel_arr as $k => $v) {
if (!(int)$v) {
unset($landline_tel_arr[$k]);
}
}
} elseif (strstr($company->landline_tel, ' ')) {
$landline_tel_arr = explode(' ', $company->landline_tel);
foreach ($landline_tel_arr as $k => $v) {
if (!(int)$v) {
unset($landline_tel_arr[$k]);
}
}
} else {
$landline_tel_arr = (array)$company->landline_tel;
}
if ($landline_tel_arr) {
$landline_tel = implode('-', $landline_tel_arr);
} else {
$landline_tel = '';
}
$company->landline_tel = $landline_tel;
$hide = true;
if (config('aix.companyset.comset.contact_set.showjobcontact') == 0) { //游客
$hide = false;
} elseif (config('aix.companyset.comset.contact_set.showjobcontact') == 1) { //已登录会员
if (auth('web-member')->check() || auth('web-company')->check()) {
$hide = false;
}
}
if ($hide) {
if ($company->mobile) {
$company->mobile = contact_hide($company->mobile, 2);
}
if ($company->landline_tel) {
$company->landline_tel = contact_hide($landline_tel, 1);
}
if ($company->email) {
$company->email = contact_hide($company->email, 3);
}
}
if (!$company->contact_show) {
$company->contact = '企业设置不公开';
}
//联系方式展现方式
$pwdhash = config('aix.system.site_other.site_other.pwb_hash');
if (config('aix.companyset.comset.contact_type_set.contact_img_com') == 2) {
if (!$company->telephone_show) {
$company->mobile = '企业设置不公开';
} else {
if ($company->mobile) {
$company->mobile = "
encrypt($company->mobile, $pwdhash), 'type' => 'phone')) . "' />";
}
}
if (!$company->landline_tel_show) {
$company->landline_tel = '企业设置不公开';
} else {
if ($company->landline_tel) {
$company->landline_tel = "
encrypt($company->landline_tel, $pwdhash), 'type' => 'phone')) . "' />";
}
}
if (!$company->email_show) {
$company->email = '企业设置不公开';
} else {
if ($company->email) {
$company->email = "
encrypt($company->email, $pwdhash), 'type' => 'email')) . "' />";
}
}
} else {
//判断企业中心设置
if (!$company->telephone_show) {
$company->mobile = '企业设置不公开';
}
if (!$company->landline_tel_show) {
$company->landline_tel = '企业设置不公开';
}
if (!$company->email_show) {
$company->email = '企业设置不公开';
}
}
$company->hide = $hide;
$company->setmeal_id = $setmeal->setmeal_id;
$company->setmeal_name = $setmeal->setmeal_name;
//来源分站名称
$subsites = Cache::get('subsites_list');
if (array_has($subsites, $company->subsite_id)) {
$company->subsite_cn = $subsites[$company->subsite_id]['sitename'];
} else {
$company->subsite_cn = '';
}
return $company;
}
//关注/取消关注
public function focusCompany($company_id, $person_id)
{
$focus_where = array(
'uid' => $person_id,
'company_id' => $company_id
);
$has = $this->personFocusComRepository->getFocus($focus_where);
if ($has) {
//取消关注
$rst = $this->personFocusComRepository->deleteFocus($focus_where);
if ($rst) {
return array('status' => 1, 'msg' => '已取消关注!', 'data' => array('html' => '关注', 'op' => 2));
} else {
return array('status' => 0, 'msg' => '取消关注失败!');
}
} else {
//关注
$stime = date('Y-m-d H:i:s', time());
$focus_data = array(
'uid' => $person_id,
'company_id' => $company_id,
'created_at' => $stime,
'updated_at' => $stime
);
$rst = $this->personFocusComRepository->addFocus($focus_data);
if ($rst) {
return array('status' => 1, 'msg' => '已关注!', 'data' => array('html' => '取消关注', 'op' => 1));
} else {
return array('status' => 0, 'msg' => '关注失败!');
}
}
}
//添加企业访客统计
public function addStatistics($company_id, $job_id = 0, $user = array(), $apply = 0, $source = 1)
{
$uid = 0;
$utype = 0;
$source = $source;
if ($user) {
$utype = $user->utype;
$uid = $user->id;
}
if ($job_id) {
$apply = 1;
}
$time = date('Y-m-d H:i:s', time());
$add_data = array(
'company_id' => (int)$company_id,
'uid' => $uid,
'utype' => $utype,
'job_id' => $job_id,
'source' => $source,
'apply' => $apply,
'created_at' => $time,
'updated_at' => $time
);
return $this->companyStatisticsRepository->addRecord($add_data);
}
//获取其它公司
public function getSetmailCompanies($where, $limit = 20)
{
$except_id = array_get($where, 'except_id');
if (array_has($where, 'except_id')) {
unset($where['except_id']);
}
if ($limit > 20) {
$limit = 20;
}
$order = 'real_refreshtime desc,id desc';
$field = '*,if(refresh_time>UNIX_TIMESTAMP(NOW()),(refresh_time-100000000),refresh_time) as real_refreshtime';
//处理trade
$map = array();
$trade = array_get($where, 'trade');
$trade_in = array();
if ($trade) {
if (strpos($trade, ',')) {
$arr = explode(',', $trade);
$sqlin = implode(',', array_slice($arr, 0, $limit));
if (preg_match('/^(\d{1,10},)*(\d{1,10})$/', $sqlin) === 1) {
$trade_in = explode(',', $sqlin);
}
} else {
$map[] = array('trade', '=', intval($trade));
}
}
if ($except_id) {
$map[] = array('id', '<>', intval($except_id));
}
$map[] = array('subsite_id', '=', get_subsite_id());
$result = $this->companyRepository->getTradeCompanies($map, $trade_in, $field, $order, $limit);
$job_where = array(
array('valid', '=', 1),
array('display', '=', 1),
);
if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
$job_where[] = array('audit', '=', 1);
} else {
$job_where[] = array('audit', '<>', 3);
}
$order_by = array('refresh_time' => 'desc');
$com_arr = ['com_id'=>[]];
if ($result->toArray()) {
foreach ($result as $key => $value) {
$row = $value;
$row->companyname_ = $row->companyname;
$row->refreshtime_cn = $row->refresh_time > time() ? daterange(time(), $row->real_refreshtime) : daterange(time(), $row->refresh_time);
$row->url = route(url_rewrite('AIX_companyshow'), array('id' => $row->id));
$row->comjobs_url = route('jobs.company.jobs', array('id' => $row->id));
$row->briefly = strip_tags($row->contents);
if ($row->logo) {
$row->logo = upload_asset($row->logo);
} else {
$row->logo = public_data_path('data/upload/no_logo.png');
}
$com_arr['com_id'][] = $row->id;
$com_arr[$row->id]['logo'] = $row->logo;
$com_arr[$row->id]['companyname_'] = $row->companyname_;
$com_arr[$row->id]['comjobs_url'] = $row->comjobs_url;
$com_arr[$row->id]['url'] = $row->url;
//$list[] = $row;
}
}
$job_where_in = array('company_id' => $com_arr['com_id']);
$jobs_list = $this->jobsRepository->getCompanyJobs($job_where, $job_where_in, $order_by, 16);
if ($jobs_list->isNotEmpty()) {
foreach ($jobs_list as $k => $val) {
$subsite_id = get_jobs_subsite_id($val);
$val->logo = isset($com_arr[$val->company_id]['logo']) ? $com_arr[$val->company_id]['logo'] : '';
$val->companyname_ = isset($com_arr[$val->company_id]['companyname_']) ? $com_arr[$val->company_id]['companyname_'] : '';
$val->comjobs_url = isset($com_arr[$val->company_id]['comjobs_url']) ? $com_arr[$val->company_id]['comjobs_url'] : '';
$val->url = isset($com_arr[$val->company_id]['url']) ? $com_arr[$val->company_id]['url'] : '';
$val->jobs_url = route(url_rewrite('AIX_jobsshow', null, $subsite_id), array('id'=>$val['id']));
//薪资待遇
if ($val->wage > 0) {
$wage_category = $this->categoryRepository->getOriginCategory(array('alias'=>'AIX_wage','id'=>$val->wage));
if ($wage_category && preg_match_all('(\d+)', $wage_category->demand, $reg)) {
$reg = $reg[0];
if (config('aix.system.site_other.site_other.site_salary') == 1) {
$val->minwage = $reg[0]%1000==0?(($reg[0]/1000).'K'):(round($reg[0]/1000, 1).'K');
$val->maxwage = array_has($reg, 1)?($reg[1]%1000==0?(($reg[1]/1000).'K'):(round($reg[1]/1000, 1).'K')):0;
} elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
if ($reg[0] >= 10000) {
if ($reg[0]%10000 == 0) {
$val->minwage = ($reg[0]/10000).'万';
} else {
$minwage = round($reg[0]/10000, 1);
$val->minwage = strpos($minwage, '.') ? str_replace('.', '万', $minwage) : $minwage.'万';
}
} else {
if ($reg[0]%1000 == 0) {
$val->minwage = ($reg[0]/1000).'千';
} else {
$minwage = round($reg[0]/1000, 1);
$val->minwage = strpos($minwage, '.') ? str_replace('.', '千', $minwage) : $minwage.'千';
}
}
if (array_has($reg, 1)) {
if ($reg[1] >= 10000) {
if ($reg[1]%10000 == 0) {
$val->maxwage = ($reg[1]/10000).'万';
} else {
$maxwage = round($reg[1]/10000, 1);
$val->maxwage = strpos($maxwage, '.') ? str_replace('.', '万', $maxwage) : $maxwage.'万';
}
} elseif ($reg[1]) {
if ($reg[1]%1000 == 0) {
$val->maxwage = ($reg[1]/1000).'千';
} else {
$maxwage = round($reg[1]/1000, 1);
$val->maxwage = strpos($maxwage, '.') ? str_replace('.', '千', $maxwage) : $maxwage.'千';
}
} else {
$val->maxwage = 0;
}
} else {
$val->maxwage = 0;
}
}
} else {
$val->maxwage = 0;
}
if ($val->minwage == $val->maxwage) {
$val->wage_cn = $val->minwage.'/月';
} else {
if ($val->minwage>0 && $val->maxwage==0) {
$val->wage_cn = $val->minwage.'以上/月';
} else {
$val->wage_cn = $val->minwage.'~'.$val->maxwage.'/月';
}
}
} elseif ($val->wage == -1) {
$val->wage_cn = '面议';
} else {
//自定义薪资
$maxwage = $val->wage_max;
$minwage = $val->wage_min;
if ($val->ygxs == '363') {
$val->wage_cn = $val->wage_min . '元/小时';
} else {
if (config('aix.system.site_other.site_other.site_salary') == 1) {
$val->minwage = $minwage % 1000 == 0 ? (($minwage / 1000) . 'K') : (round($minwage / 1000, 1) . 'K');
if ($minwage == 0) {
$val->maxwage = '以上';
} else {
$val->maxwage = $maxwage % 1000 == 0 ? (($maxwage / 1000) . 'K') : (round($maxwage / 1000, 1) . 'K');
}
} elseif (config('aix.system.site_other.site_other.site_salary') == 2) {
if ($minwage >= 10000) {
if ($minwage % 10000 == 0) {
$val->minwage = ($minwage / 10000) . '万';
} else {
$minwage = round($minwage / 10000, 1);
$val->minwage = strpos($minwage, '.') ? str_replace('.', '万', $minwage) : $minwage . '万';
}
} else {
if ($minwage % 1000 == 0) {
$val->minwage = ($minwage / 1000) . '千';
} else {
$minwage = round($minwage / 1000, 1);
$val->minwage = strpos($minwage, '.') ? str_replace('.', '千', $minwage) : $minwage . '千';
}
}
if ($maxwage > 0) {
if ($maxwage >= 10000) {
if ($maxwage % 10000 == 0) {
$val->maxwage = ($maxwage / 10000) . '万';
} else {
$maxwage = round($maxwage / 10000, 1);
$val->maxwage = strpos($maxwage, '.') ? str_replace('.', '万', $maxwage) : $maxwage . '万';
}
} elseif ($maxwage) {
if ($maxwage % 1000 == 0) {
$val->maxwage = ($maxwage / 1000) . '千';
} else {
$maxwage = round($maxwage / 1000, 1);
$val->maxwage = strpos($maxwage, '.') ? str_replace('.', '千', $maxwage) : $maxwage . '千';
}
} else {
$val->maxwage = '0';
}
} else {
$val->maxwage = '0';
}
}
if ($val->minwage == $val->maxwage) {
$val->wage_cn = $val->minwage . '/月';
} else {
if ($val->minwage > 0 && $val->maxwage == 0) {
$val->wage_cn = $val->minwage . '以上/月';
} else {
$val->wage_cn = $val->minwage . '~' . $val->maxwage . '/月';
}
}
}
}
//工作经验
$other_categories = $this->categoryRepository->getCategories();
$job_experience = array_get($other_categories, 'AIX_experience');
if ($job_experience) {
$experience_cn = array_get($job_experience, $val->experience);
}
if ($experience_cn) {
$val->experience_cn = $experience_cn['demand'];
} else {
$val->experience_cn = '不限';
}
//学历要求
$job_education = array_get($other_categories, 'AIX_education');
if ($job_education) {
$education_cn = array_get($job_education, $val->education);
}
if ($education_cn) {
$val->education_cn = $education_cn['demand'];
} else {
$val->education_cn = '不限';
}
//工作地点
$city_cates = Cache::get('city_cate_list');
if (null === $city_cates) {
$city_cates = $this->categoryDistrictRepository->cityCateCache();
Cache::put('city_cate_list', $city_cates, '86400');
}
if (!strpos($val->district, ".")) {
if (array_get($city_cates['id'], $val->district)) {
$val->district_cn = $city_cates['id'][$val->district]['name'];
if ($city_cates['id'][$val->district]['parent_id'] > 0) {
$parent_district = array_get($city_cates['id'], $city_cates['id'][$val->district]['parent_id']);
if ($parent_district) {
$val->district_cn = $parent_district['name'].$val->district_cn;
if ($parent_district['parent_id'] > 0) {
$pp_district = array_get($city_cates['id'], $parent_district['parent_id']);
if ($pp_district) {
$val->district_cn = $pp_district['name'].$val->district_cn;
}
}
}
}
}
} else {
$city_district = explode('.', $val->district);
$city_district_cn = array();
foreach ($city_district as $k => $v) {
if ($v) {
$district_info = array_get($city_cates['id'], $v);
if ($district_info) {
$city_district_cn[] = $district_info['name'];
}
}
}
$val->district_cn = implode('/', $city_district_cn);
}
}
}
return $jobs_list;
}
//获取其它公司
public function getOtherCompanies($where, $limit = 10)
{
$except_id = array_get($where, 'except_id');
if (array_has($where, 'except_id')) {
unset($where['except_id']);
}
if ($limit > 20) {
$limit = 20;
}
$order = 'real_refreshtime desc,id desc';
$field = '*,if(refresh_time>UNIX_TIMESTAMP(NOW()),(refresh_time-100000000),refresh_time) as real_refreshtime';
//处理trade
$map = array();
$trade = array_get($where, 'trade');
$trade_in = array();
if ($trade) {
if (strpos($trade, ',')) {
$arr = explode(',', $trade);
$sqlin = implode(',', array_slice($arr, 0, $limit));
if (preg_match('/^(\d{1,10},)*(\d{1,10})$/', $sqlin) === 1) {
$trade_in = explode(',', $sqlin);
}
} else {
$map[] = array('trade', '=', intval($trade));
}
}
if ($except_id) {
$map[] = array('id', '<>', intval($except_id));
}
$map[] = array('subsite_id', '=', get_subsite_id());
$result = $this->companyRepository->getTradeCompanies($map, $trade_in, $field, $order, $limit);
$list = array();
if ($result->toArray()) {
foreach ($result as $key => $value) {
$row = $value;
$row->companyname_ = $row->companyname;
$row->refreshtime_cn = $row->refresh_time > time() ? daterange(time(), $row->real_refreshtime) : daterange(time(), $row->refresh_time);
$row->url = route(url_rewrite('AIX_companyshow'), array('id' => $row->id));
//$row['comjobs_url'] = url_rewrite('QS_companyjobs',array('id'=>$row['id']));
$row->comjobs_url = route('jobs.company.jobs', array('id' => $row->id));
$row->contents = str_replace(' ', '', $row->contents);
$row->briefly = strip_tags($row->contents);
if ($row->logo) {
$row->logo = upload_asset($row->logo);
} else {
$row->logo = public_data_path('data/upload/no_logo.png');
}
$row->jobs_count = $this->getCompanyValidJobs($row->id);
$list[] = $row;
}
}
return $list;
}
/**
* 根据查询条件获取企业
* @param $where
* @param int $limit
*/
public function getCompaniesByConditions($where,$limit = 10){
if ($limit > 20) {
$limit = 20;
}
$order = 'real_refreshtime desc,id desc';
$field = '*,if(refresh_time>UNIX_TIMESTAMP(NOW()),(refresh_time-100000000),refresh_time) as real_refreshtime';
//处理trade
$map = array();
$map[] = array('subsite_id', '=', $where['subsite_id']);
$result = $this->companyRepository->getTradeCompanies($map, [], $field, $order, $limit);
$job_where = array(
array('valid', '=', 1),
array('display', '=', 1),
);
if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
$job_where[] = array('audit', '=', 1);
} else {
$job_where[] = array('audit', '<>', 3);
}
$order_by = array('refresh_time' => 'desc');
if ($result->toArray()) {
$result = $result->toArray();
foreach ($result as $key => $value) {
$result[$key]['companyname'] = $value['companyname'];
$result[$key]['refreshtime_cn'] = $value['refresh_time'] > time() ? daterange(time(), $value['real_refreshtime']) : daterange(time(), $value['refresh_time']);
$result[$key]['url'] = route(url_rewrite('AIX_companyshow'), array('id' => $value['id']));
$result[$key]['comjobs_url'] = route('jobs.company.jobs', array('id' => $value['id']));
$result[$key]['briefly'] = strip_tags($value['contents']);
if ($value['logo']) {
$result[$key]['logo'] = upload_asset($value['logo']);
} else {
$result[$key]['logo'] = public_data_path('data/upload/no_logo.png');
}
$job_where_in = array('company_id'=>array($value['id']));
$jobs_list = $this->jobsRepository->getCompanyJobs($job_where, $job_where_in, $order_by,16);
$result[$key]['jobs'] = $jobs_list->toArray();
//$list[] = $row;
}
}
return $result;
}
//获取企业在招职位
public function getCompanyValidJobs($company_id)
{
$jobs_display = config('aix.companyset.comset.show_set.jobs_display');
$job_count_map = array(
array('company_id', '=', $company_id),
array('valid', '=', 1)
);
if ($jobs_display == 1) {
$job_count_map[] = array('audit', '=', '1');
} else {
$job_count_map[] = array('audit', '<>', '3');
}
return $this->jobsRepository->getJobsCount($job_count_map);
}
//获取企业会员积分
public function getPoint($uid, $utype)
{
return $this->memberPointRepository->getPointsById($uid, $utype);
}
/**签到
* @return array
*/
public function signIn($user)
{
$signCount = $this->taskLogRepository->getTaskLogCount($user->id, 18, $user->utype);
if ($signCount) {
return ['code' => 0, 'msg' => '您今天已经签到过了!', 'info' => ''];
} else {
$res = $this->taskService->doTask(18, $user->id, 1);
if ($res['code'] == 1) {
$this->memberLogRepository->createLog($user, 8003, "");
return ['code' => 1, 'msg' => '签到成功', 'info' => $res['data']['points']];
} else {
return ['code' => 1, 'msg' => $res['info'], 'info' => ''];
}
}
}
/**企业中心======我的消息(系统消息)
* @param $request
* @return array
*/
public function comPms($data, $user)
{
$where = [];
$new = isset($data['new']) ? $data['new'] : '';
$settr = isset($data['settr']) ? $data['settr'] : '';
if ($new) {
$where['new'] = $new;
}
if ($settr) {
$where[] = ['created_at', '<=', date('Y-m-d H:i:s', strtotime("{$settr} day"))];
}
$param_array = array('new', 'settr');
$params = array();
if ($data) {
foreach ($data as $k => $v) {
if (in_array($k, $param_array)) {
$params[$k] = $v;
}
}
}
$where['msgtouid'] = $user->id;
$where['utype'] = $user->utype;
$pms = $this->pmsRepository->comPms($where);
$res = [
'companyInfo' => $user,
'pms' => $pms,
'params' => $params,
];
return $res;
}
public function pmsRead($id)
{
if (!$id) {
return response()->json(['status' => 0, 'msg' => '参数错误']);
}
return $this->pmsRepository->update(['new' => 2], $id);
}
public function msgSend($user, $input)
{
$data = [];
if (empty($input['parent_id'])) {
throw new ResponseException('数据异常!');
}
if (empty($input['to_uid'])) {
throw new ResponseException('个人信息不存在!');
}
if (empty($input['message'])) {
throw new ResponseException('回复信息不能为空!');
}
if (mb_strlen($input['message'], 'utf-8') > 200) {
throw new ResponseException('回复信息不能超过200个字。');
}
$data['parent_id'] = $input['parent_id'];
$data['utype'] = $user->utype;
$data['from_uid'] = $user->id;
$data['to_uid'] = $input['to_uid'];
$data['message'] = $input['message'];
$res = $this->msgRepository->msgSend($data);
$this->memberLogRepository->createLog($user, 1026, [$input['parent_id'], $input['to_uid'], $input['message']]);
if ($res) {
$member = MemberInfo::where(['uid' => $data['to_uid']])->select('realname')->first();
if ($member) {
$res->personName = $member->realname;
} else {
$res->personName = '';
}
}
return $res;
}
public function msgDelete($input)
{
if (empty($input['parent_id'])) {
throw new ResponseException('请选择要删除的咨询消息!');
}
return $this->msgRepository->msgDelete($input['parent_id']);
}
/**消息设为查看
* @param $request
* @return bool|\Illuminate\Http\JsonResponse
* @throws \Throwable
*/
public function companyPmsCheck($request)
{
$user = auth('web-company')->user();
if ($request->method() == 'POST') {
return true;
}
$id = $request->id;
if (!$id) {
return response()->json(['status' => 0, 'msg' => '请选择查看的消息!']);
}
$ids = is_array($id) ? $id : explode(',', $id);
//设置消息为已读
$res = $this->msgCheck($ids, $user);
if ($res['state']) {
$html = view('app.company.ajax.ajax_show_msg', ['msg' => $res['data']])->render();
return response()->json(['status' => 1, 'msg' => '获取消息成功!', 'data' => $html]);
}
return response()->json(['status' => 0, 'msg' => $res['error']]);
}
public function companyPmsConsult($user)
{
$res = $this->msgRepository->msg($user->utype, $user->id);
if ($res->total()) {
foreach ($res as $key => $val) {
$utype = explode(',', $val->result);
foreach ($utype as $key1 => $val1) {
$utype1 = explode(':', $val1);
if ($utype1[0] == 1) {
$company = Company::where(['id' => $utype1[1]])->select('companyname')->first();
// $member = MemberInfo::where(['uid'=>$utype1[2]])->select('images')->first();
$member = MemberInfo::with(['resumes' => function ($query) {
$query->where('def', 1);
}])->where(['uid' => $utype1[2]])->select('images', 'uid')->first();
$res[$key]->result = str_replace($utype1[2], isset($member->resumes[0]->id) ? $member->resumes[0]->id : 0, $res[$key]->result);
if ($company) {
$res[$key]->companyName = $company->companyname;
} else {
$res[$key]->companyName = '';
}
if ($member) {
$res[$key]->images = $member->images;
$res[$key]->personName = isset($member->resumes[0]->fullname) ? $member->resumes[0]->fullname : 0;
} else {
$res[$key]->images = '';
}
break;
} else {
$company = Company::where(['id' => $utype1[2]])->select('companyname')->first();
// $member = MemberInfo::where(['uid'=>$utype1[1]])->select('images')->first();
$member = MemberInfo::with(['resumes' => function ($query) {
$query->where('def', 1);
}])->where(['uid' => $utype1[1]])->select('images', 'uid')->first();
$res[$key]->result = str_replace($utype1[1], isset($member->resumes[0]->id) ? $member->resumes[0]->id : 0, $res[$key]->result);
if ($company) {
$res[$key]->companyName = $company->companyname;
} else {
$res[$key]->companyName = '';
}
if ($member) {
$res[$key]->images = $member->images;
$res[$key]->personName = isset($member->resumes[0]->fullname) ? $member->resumes[0]->fullname : 0;
} else {
$res[$key]->images = '';
}
break;
}
}
}
}
return $res;
}
public function companyPmsDel($request, $user)
{
if (!$id = $request->id) {
return response()->json(['status' => 0, 'msg' => "请选择删除的消息!"]);
}
$ids = is_array($id) ? $id : explode(',', $id);
if (!$this->pmsRepository->deleteAll($ids, $user->id)) {
return response()->json(['status' => 0, 'msg' => "删除消息失败!"]);
}
if (!$this->memberLogRepository->createLog($user, 1025, $ids)) {
throw new \Exception("日志记录失败!");
}
return response()->json(['status' => 1, 'msg' => "删除消息成功!"]);
}
public function getContactInfo($id, $user)
{
if (!$id) {
return ['status' => 0, 'msg' => "请选择查看的联系信息!"];
}
$companyContact = CompanyContact::find($id);
if (!$companyContact) {
return ['status' => 0, 'msg' => "联系信息不存在"];
}
if ($companyContact->company_id != $user->id) {
return ['status' => 0, 'msg' => "联系信息不存在"];
}
$contact_info = $this->companyContactRepository->getContact(['id' => $id]);
if ($contact_info) {
$landline_tel_cn = explode('-', $contact_info->landline_tel);
$contact_info->landline_tel_one = array_get($landline_tel_cn, 0);
$contact_info->landline_tel_two = array_get($landline_tel_cn, 1);
$contact_info->landline_tel_three = array_get($landline_tel_cn, 2);
return ['status' => 1, 'contact' => $contact_info];
} else {
return ['status' => 0, 'msg' => "联系信息不存在"];
}
}
public function companyContactDel($ids, $user)
{
if (!$ids) {
return response()->json(['status' => 0, 'msg' => "请选择删除的联系信息!"]);
}
$companyContact = CompanyContact::whereIn('id', $ids)->get();
if (!$companyContact->toArray()) {
return ['status' => 0, 'msg' => "联系信息不存在"];
}
$id_M = array_column($companyContact->toArray(), 'company_id');
foreach ($id_M as $key => $val) {
if ($val != $user->id) {
return ['status' => 0, 'msg' => "联系信息不存在"];
}
}
if (!$this->companyContactRepository->deleteContact([], ['id' => $ids])) {
return response()->json(['status' => 0, 'msg' => "删除失败!"]);
}
return response()->json(['status' => 1, 'msg' => "删除成功!"]);
}
public function updateContact($data, $user)
{
$id = $data['id'];
$landline_tel = '';
$tel_first = array_get($data, 'tel_first', '-');
$tel_next = array_get($data, 'tel_next', '-');
$tel_last = array_get($data, 'tel_last', '-');
$landline_tel = implode('-', [$tel_first ? $tel_first : '', $tel_next ? $tel_next : '', $tel_last ? $tel_last : '']);
$update_data = array(
'contact' => array_has($data, 'contact') ? $data['contact'] : '',
'telephone' => array_has($data, 'telephone') ? $data['telephone'] : '',
'landline_tel' => $landline_tel,
'email' => array_has($data, 'email') ? $data['email'] : '',
'qq' => array_has($data, 'qq') ? $data['qq'] : '',
'address' => array_has($data, 'contact') ? $data['address'] : ''
);
return $this->companyContactRepository->ContactUpdate(['company_id' => $user->id, 'id' => $id], $update_data);
}
protected function msgCheck($ids, $user)
{
$msg = $this->pmsRepository->findMsg($ids);
$where['msgtouid'] = $user->id;
$where['utype'] = $user->utype;
$where['new'] = 1;
$data['new'] = 2;
if (false === $count = $this->pmsRepository->updateNew($ids, $where, $data)) {
return ['state' => 0, 'error' => '消息已删除或不存在'];
}
//写日志
return array('state' => 1, 'data' => $msg);
}
/**
* 检查字段惟一性
* @param $key
* @param $value
* @param $id
* @return mixed
*/
public function checkUnique($key, $value, $id)
{
return $this->checkUnique($key, $value, $id);
}
/**
* 认证邮件发送成功回调
* @param $newEmail
* @param $company
*/
public function sendAuthEmailHook($newEmail, $company)
{
Cache::put($newEmail, $company, 24 * 60);
}
/**
* 邮箱验证
* @param $newEmail
* @return bool
*/
public function verifyEmail($newEmail)
{
$company = Cache::pull($newEmail, null);
if ($company) {
$this->companyRepository->changeEmail($company->id, $newEmail);
return true;
}
return false;
}
//更新短信数量
public function incSms($uid, $type, $num)
{
return $this->companyRepository->updataSmsNum($uid, $type, $num);
}
//最新招聘
public function getNewestCompanies($params)
{
$lists = Cache::get('newest_jobs_company_list_s' . get_subsite_id());
if ($lists === null) {
$lists = $this->getSeatmealCompanies($params);
Cache::put('newest_jobs_company_list_' . get_subsite_id(), $lists, '1800');
}
return $lists;
}
//知名企业(非免费会员、有发布中的职位的企业信息 处理企业logo、企业名称长度、企业数量限制 页面显示的职位数量限制、处理职位名称和路由)
public function getSeatmealCompanies($params)
{
$list = array();
//获取有正在发布职位的企业
$where = array();
$where = array(
array('valid', '=', 1),
array('display', '=', 1),
);
if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
$where[] = array('audit', '=', 1);
} else {
$where[] = array('audit', '<>', 3);
}
if (array_has($params, 'seatmeal')) {
$where[] = array('setmeal_id', '>', $params['seatmeal']);
}
$where[] = array('deadline', '>', time());
$order_by = array('refresh_time' => 'desc');
$limit = '';
if (array_has($params, 'size')) {
$limit = $params['size'];
}
$rst = $this->jobsRepository->getJobCompanies($where, $order_by, $limit);
if ($rst) {
$com_rst = $rst->pluck('jobs_num', 'company_id');
$cid = $rst->pluck('company_id')->toArray();
//获取企业信息
$com_whereIn['id'] = $cid;
$companyInfo = $this->companyRepository->getCompanyies(array(), $com_whereIn, $order_by);
$cids = array();
$company = array();
if ($companyInfo->isNotEmpty()) {
foreach ($companyInfo as $key => $val) {
$company[$val->id] = $companyInfo[$key];
if ($val->logo) {
$company[$val->id]->logo = upload_asset($val->logo);
} else {
$company[$val->id]->logo = public_data_path('data/upload/no_logo.png');
}
$company[$val->id]->jobs_num = $com_rst[$val->id];
$company[$val->id]->company_url = route(url_rewrite('AIX_companyshow'), array('id' => $val->id));
$company[$val->id]->company_jobs_url = route(url_rewrite('AIX_companyjobs'), array('id' => $val->id));
$company[$val->id]->refreshtime_cn = daterange(time(), $val->refresh_time, 'm-d', "#FF3300");
$company[$val->id]->jobs_list = array();
if (array_has($params, 'companynamelen')) {
$dot = '...';
if (array_has($params, 'dot')) {
$dot = $params['dot'];
}
$company[$val->id]->companyname = cut_str($val->companyname, $params['companynamelen'], 0, $dot);
}
$cids[] = $val['id'];
}
if ($cids) {
//获取当前所选企业的所有职位信息
$job_where = array(
array('valid', '=', 1),
array('display', '=', 1),
array('deadline', '>', time())
);
if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
$job_where[] = array('audit', '=', 1);
} else {
$job_where[] = array('audit', '<>', 3);
}
$job_where_in = array('company_id' => $cids);
$jobs = $this->jobsRepository->getCompanyJobs($job_where, $job_where_in, $order_by);
if ($jobs) {
foreach ($jobs as $k => $v) {
if (array_has($params, 'jobs_num')) {
if (count($company[$v->company_id]->jobs_list) >= $params['jobs_num']) {
continue;
}
}
//添加职位信息
$jobs_list = $company[$v->company_id]->jobs_list;
$jobs_list[] = $v;
$company[$v->company_id]->jobs_list = $jobs_list;
}
}
}
}
$list = $company;
}
return $list;
}
public function dealCompanyFields($list)
{
if ($list) {
$other_categories = $this->categoryRepository->getCategories();
$company_types = array();
$company_trades = array();
$company_scale = array();
if ($other_categories) {
$company_types = array_has($other_categories, 'AIX_company_type') ? $other_categories['AIX_company_type'] : array();
$company_trades = array_has($other_categories, 'AIX_trade') ? $other_categories['AIX_trade'] : array();
$company_scale = array_has($other_categories, 'AIX_scale') ? $other_categories['AIX_scale'] : array();
}
$jobs_display = config('aix.companyset.comset.show_set.jobs_display');
foreach ($list as $key => $val) {
$list[$key]->company_url = route(url_rewrite('AIX_companyshow'), array('id' => $val->id));
$list[$key]->contents = htmlspecialchars_decode($val->contents, ENT_QUOTES);
if ($val->logo) {
$list[$key]->logo = upload_asset($val->logo);
} else {
$list[$key]->logo = public_data_path('data/upload/no_logo.png');
}
$content = str_replace(' ', '', $val->contents);
$content = cut_str(strip_tags($content), 130, 0, '...');
$list[$key]->contents = $content;
$list[$key]->comjobs_url = route('jobs.company.jobs', array('id' => $val->id));
$list[$key]->nature_cn = '';
$list[$key]->trade_cn = '';
$list[$key]->scale_cn = '';
if ($company_types && array_has($company_types, $val->nature)) {
$list[$key]->nature_cn = $company_types[$val->nature]['demand'];
}
if ($company_trades && array_has($company_trades, $val->trade)) {
$list[$key]->trade_cn = $company_trades[$val->trade]['demand'];
}
if ($company_scale && array_has($company_scale, $val->scale)) {
$list[$key]->scale_cn = $company_scale[$val->scale]['demand'];
}
//在招职位数量
$job_count_map = array(array('company_id', '=', $val->id), array('valid', '=', 1));
if ($jobs_display == 1) {
$job_count_map[] = array('audit', '=', '1');
} else {
$job_count_map[] = array('audit', '<>', '3');
}
$jobs_count = $this->jobsRepository->getJobsCount($job_count_map);
$list[$key]->jobs_count = $jobs_count;
}
}
return $list;
}
//处理名企信息
public function dealSetmealCompany($companyInfo, $params)
{
$list = array();
$order_by = array('refresh_time' => 'desc');
$company = array();
$cids = [];
if (array_has($params, 'size')) {
$limit = $params['size'];
}
foreach ($companyInfo as $key => $val) {
if ($limit && count($company) >= $limit) {
break;
}
$company[$val->id] = $companyInfo[$key];
if ($val->logo) {
$company[$val->id]->logo = upload_asset($val->logo);
} else {
$company[$val->id]->logo = public_data_path('data/upload/no_logo.png');
}
if ($val->job->count() == 0) {
unset($company[$val->id]);
continue;
}
$company[$val->id]->jobs_num = $val->job->count();
$company[$val->id]->company_url = route(url_rewrite('AIX_companyshow'), array('id' => $val->id));
$company[$val->id]->company_jobs_url = route(url_rewrite('AIX_companyjobs'), array('id' => $val->id));
$company[$val->id]->refreshtime_cn = daterange(time(), $val->refresh_time, 'm-d', "#FF3300");
$company[$val->id]->jobs_list = array();
if (array_has($params, 'companynamelen')) {
$dot = '...';
if (array_has($params, 'dot')) {
$dot = $params['dot'];
}
$company[$val->id]->companyname = cut_str($val->companyname, $params['companynamelen'], 0, $dot);
}
$cids[] = $val['id'];
//$jobs = $val->job;
$job_count_map = array(array('valid', '=', 1), array('display', '=', 1));
if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
$job_count_map[] = array('audit', '=', '1');
} else {
$job_count_map[] = array('audit', '<>', '3');
}
$jobs = $val->job()->where($job_count_map)->orderBy('refresh_time', 'desc')->get();
if ($jobs) {
$jobs_arr = $jobs->toArray();
$company[$val->id]->newst_job_refresh = $jobs_arr[0]['refresh_time'];
foreach ($jobs as $k => $v) {
if (array_has($params, 'jobs_num')) {
if (count($company[$v->company_id]->jobs_list) >= $params['jobs_num']) {
continue;
}
}
//添加职位信息
$jobs_list = $company[$v->company_id]->jobs_list;
$jobs_list[] = $v;
$company[$v->company_id]->jobs_list = $jobs_list;
}
}
}
if ($company) {
$list = $company;
}
return $list;
}
//获取企业基本信息
public function getCompany($where)
{
return $this->companyRepository->getCompanyInfo($where);
}
//获取企业联系人信息
public function companyContact($company, $page_num = '')
{
$where = array('company_id' => $company->id);
$rsts = $this->companyContactRepository->getList($where, $page_num);
return $rsts;
}
public function addContact($data)
{
return $this->companyContactRepository->create($data);
}
//发送短信回调事件
public function sendSMSCallBack($user_id)
{
//减少短信条数
$this->companyRepository->SetSmsReduce($user_id);
}
}