|
@@ -1054,7 +1054,7 @@ class NewsService implements NewsServiceInterface
|
|
//20250226 产品列表
|
|
//20250226 产品列表
|
|
|
|
|
|
|
|
|
|
- // 20250306 招聘
|
|
|
|
|
|
+ // 20250306 -------招聘--------fr
|
|
/*
|
|
/*
|
|
* 招聘列表
|
|
* 招聘列表
|
|
* */
|
|
* */
|
|
@@ -1067,26 +1067,16 @@ class NewsService implements NewsServiceInterface
|
|
$user = User::where('id', $data['user_id'])->first();
|
|
$user = User::where('id', $data['user_id'])->first();
|
|
if(empty($user)){
|
|
if(empty($user)){
|
|
return Result::error("用户不存在", 0);
|
|
return Result::error("用户不存在", 0);
|
|
- }
|
|
|
|
|
|
+ }
|
|
// 3:企业会员
|
|
// 3:企业会员
|
|
if($user['type_id'] == 3){
|
|
if($user['type_id'] == 3){
|
|
array_push($where,['job_recruiting.user_id', $data['user_id']]);
|
|
array_push($where,['job_recruiting.user_id', $data['user_id']]);
|
|
array_push($where,['job_recruiting.website_id', $data['website_id']]);
|
|
array_push($where,['job_recruiting.website_id', $data['website_id']]);
|
|
}
|
|
}
|
|
// 如果 $where 为空,则不添加 where 条件
|
|
// 如果 $where 为空,则不添加 where 条件
|
|
- if (empty($where)) {
|
|
|
|
- $result['rows'] = JobRecruiting::leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
|
|
|
|
- ->leftJoin('user', 'job_recruiting.user_id', '=', 'user.id')
|
|
|
|
- ->select('job_recruiting.*', 'website.website_name as website_name', 'user.user_name as user_name')
|
|
|
|
- ->orderBy("updated_at", "desc")
|
|
|
|
- ->offset(($data['page'] - 1) * $data['page_size'])
|
|
|
|
- ->limit($data['page_size'])
|
|
|
|
- ->get()
|
|
|
|
- ->all();
|
|
|
|
-
|
|
|
|
- $result['count'] = JobRecruiting::count();
|
|
|
|
- } else {
|
|
|
|
- $result['rows'] = JobRecruiting::where($where)
|
|
|
|
|
|
+ $result['rows'] = JobRecruiting::when(!empty($where), function ($query) use ($where) {
|
|
|
|
+ return $query->where($where);
|
|
|
|
+ })
|
|
->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
|
|
->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
|
|
->leftJoin('user', 'job_recruiting.user_id', '=', 'user.id')
|
|
->leftJoin('user', 'job_recruiting.user_id', '=', 'user.id')
|
|
->select('job_recruiting.*', 'website.website_name as website_name', 'user.user_name as user_name')
|
|
->select('job_recruiting.*', 'website.website_name as website_name', 'user.user_name as user_name')
|
|
@@ -1095,220 +1085,59 @@ class NewsService implements NewsServiceInterface
|
|
->limit($data['page_size'])
|
|
->limit($data['page_size'])
|
|
->get()
|
|
->get()
|
|
->all();
|
|
->all();
|
|
- $result['count'] = JobRecruiting::where($where)->count();
|
|
|
|
- }
|
|
|
|
|
|
+ $result['count'] = JobRecruiting::when(!empty($where), function ($query) use ($where) {
|
|
|
|
+ return $query->where($where);
|
|
|
|
+ })
|
|
|
|
+ ->count();
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
return Result::error("暂无招聘信息", 0);
|
|
return Result::error("暂无招聘信息", 0);
|
|
}
|
|
}
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
/*
|
|
/*
|
|
- * 获取公司信息
|
|
|
|
- * */
|
|
|
|
- public function getJobCompany(array $data): array
|
|
|
|
- {
|
|
|
|
- $user = User::where('user.id', $data['user_id'])
|
|
|
|
- ->leftJoin('user_info', 'user_info.user_id', 'user.id')
|
|
|
|
- ->select('user.user_name','user.mobile','user.email','user.type_id', 'user_info.*')
|
|
|
|
- ->first();
|
|
|
|
- // return Result::success($user);
|
|
|
|
- if(empty($user)){
|
|
|
|
- return Result::error("用户不存在", 0);
|
|
|
|
- }
|
|
|
|
- if($user['type_id'] == 3){
|
|
|
|
- $result = [
|
|
|
|
- // 'id' => 0,
|
|
|
|
- 'user_id' => $data['user_id'],
|
|
|
|
- 'website_id' => $data['website_id'],
|
|
|
|
- 'business_name' => $user['business_name'], // 企业名称
|
|
|
|
- 'company_hy_id' => $user['company_hy_id'], // 企业所属行业
|
|
|
|
- 'company_nature' => $user['company_nature'], // 公司性质
|
|
|
|
- 'company_size' => $user['company_size'], // 公司规模
|
|
|
|
- 'introduction' => $user['introduction'], // 公司简介
|
|
|
|
- 'real_name' => $user['real_name'], // 企业联系人
|
|
|
|
- 'mobile' => $user['mobile'], // 企业联系电话
|
|
|
|
- 'company_url' => $user['company_url'], // 企业网址
|
|
|
|
- 'address_arr_id' => $user['address_arr_id'], // 企业网址
|
|
|
|
- 'address' => $user['address'], // 企业地址
|
|
|
|
- 'email' => $user['email'], // 企业邮箱
|
|
|
|
- ];
|
|
|
|
- }else if($user['type_id'] == 10000){
|
|
|
|
- if(!isset($data['job_id']) || empty($data['job_id'])){
|
|
|
|
- return Result::error("请传递职位id", 0);
|
|
|
|
- }
|
|
|
|
- $job = JobRecruiting::where('id',$data['job_id'])->first();
|
|
|
|
- if(empty($job)){
|
|
|
|
- return Result::error("招聘信息不存在", 0);
|
|
|
|
- }
|
|
|
|
- // return Result::success($job);
|
|
|
|
- if($job['user_type'] != 3){
|
|
|
|
- $result = JobCompany::where('job_id', $job['id'])->get()->toArray();
|
|
|
|
- }else{
|
|
|
|
- $user = User::where('user.id', $job['user_id'])
|
|
|
|
- ->leftJoin('user_info', 'user_info.user_id', 'user.id')
|
|
|
|
- ->select('user.user_name','user.mobile','user.email','user.type_id', 'user_info.*')
|
|
|
|
- ->first();
|
|
|
|
- $result = [
|
|
|
|
- // 'id' => 0,
|
|
|
|
- 'user_id' => $data['user_id'],
|
|
|
|
- 'website_id' => $data['website_id'],
|
|
|
|
- 'business_name' => $user['business_name'], // 企业名称
|
|
|
|
- 'company_hy_id' => $user['company_hy_id'], // 企业所属行业
|
|
|
|
- 'company_nature' => $user['company_nature'], // 公司性质
|
|
|
|
- 'company_size' => $user['company_size'], // 公司规模
|
|
|
|
- 'introduction' => $user['introduction'], // 公司简介
|
|
|
|
- 'real_name' => $user['real_name'], // 企业联系人
|
|
|
|
- 'mobile' => $user['mobile'], // 企业联系电话
|
|
|
|
- 'company_url' => $user['company_url'], // 企业网址
|
|
|
|
- 'address_arr_id' => $user['address_arr_id'], // 企业网址
|
|
|
|
- 'address' => $user['address'], // 企业地址
|
|
|
|
- 'email' => $user['email'], // 企业邮箱
|
|
|
|
- ];
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- return Result::error("用户类型错误", 0);
|
|
|
|
- }
|
|
|
|
- if(empty($result)){
|
|
|
|
- return Result::error("公司信息不存在", 0);
|
|
|
|
- }
|
|
|
|
- return Result::success($result);
|
|
|
|
- }
|
|
|
|
- /*
|
|
|
|
- * 修改公司信息
|
|
|
|
|
|
+ * 招聘信息添加
|
|
* */
|
|
* */
|
|
- public function upJobCompany(array $data): array
|
|
|
|
|
|
+ public function addJobRecruiting(array $data): array
|
|
{
|
|
{
|
|
|
|
+ // return Result::success($data);
|
|
$user = User::where('user.id', $data['user_id'])
|
|
$user = User::where('user.id', $data['user_id'])
|
|
|
|
+ ->where('user.status',1)
|
|
->leftJoin('user_info', 'user_info.user_id', 'user.id')
|
|
->leftJoin('user_info', 'user_info.user_id', 'user.id')
|
|
- ->select('user.user_name','user.type_id', 'user_info.*')
|
|
|
|
|
|
+ ->select(
|
|
|
|
+ 'user.type_id', 'user.mobile','user.email',
|
|
|
|
+ 'user_info.business_name',
|
|
|
|
+ 'user_info.hy_id',
|
|
|
|
+ 'user_info.company_nature',
|
|
|
|
+ 'user_info.company_size',
|
|
|
|
+ 'user_info.introduction',
|
|
|
|
+ 'user_info.real_name',
|
|
|
|
+ 'user_info.company_url',
|
|
|
|
+ 'user_info.address_arr_id',
|
|
|
|
+ 'user_info.address'
|
|
|
|
+ )
|
|
->first();
|
|
->first();
|
|
- if(empty($user)){
|
|
|
|
- return Result::error("用户不存在", 0);
|
|
|
|
- }
|
|
|
|
- $data['address_arr_id'] = isset($data['address_arr_id'])? json_encode(array_map('intval', $data['address_arr_id'])) : '';
|
|
|
|
- $company = [
|
|
|
|
- 'business_name' => $data['business_name'], // 企业名称
|
|
|
|
- 'company_hy_id' => $data['company_hy_id'], // 企业所属行业
|
|
|
|
- 'company_nature' => $data['company_nature'], // 公司性质
|
|
|
|
- 'company_size' => $data['company_size'], // 公司规模
|
|
|
|
- 'introduction' => $data['introduction'], // 公司简介
|
|
|
|
- 'real_name' => $data['real_name'], // 企业联系人
|
|
|
|
- 'company_url' => $data['company_url'], // 企业网址
|
|
|
|
- 'address_arr_id' => $data['address_arr_id'], // 企业地址
|
|
|
|
- 'address' => $data['address'], // 企业地址
|
|
|
|
- ];
|
|
|
|
- // return Result::success($data);
|
|
|
|
- // 管理员操作
|
|
|
|
- if($user['type_id'] == 10000){
|
|
|
|
- if(!isset($data['job_id']) || empty($data['job_id'])){
|
|
|
|
- return Result::error("请传递职位id", 0);
|
|
|
|
- }
|
|
|
|
- $job = JobRecruiting::where('id',$data['job_id'])->first();
|
|
|
|
- if(empty($job)){
|
|
|
|
- return Result::error("招聘信息不存在", 0);
|
|
|
|
- }
|
|
|
|
- // return Result::success($job);
|
|
|
|
- // 管理员操作管理员
|
|
|
|
- if($job['user_type']!= 3){
|
|
|
|
- unset($data['user_id']);
|
|
|
|
- unset($data['website_id']);
|
|
|
|
- // return Result::success($data);
|
|
|
|
- $result['company'] = JobCompany::where('job_id', $job['id'])->update($data);
|
|
|
|
- }else{
|
|
|
|
- // 管理员操作企业会员
|
|
|
|
- // 开启事务
|
|
|
|
- Db::beginTransaction();
|
|
|
|
- try {
|
|
|
|
- $result['userinfo'] = UserInfo::where('user_id', $job['user_id'])->update($company);
|
|
|
|
- $result['user'] = User::where('id', $job['user_id'])->update(['mobile' => $data['mobile'], 'email' => $data['email']]);
|
|
|
|
- // 提交事务
|
|
|
|
- Db::commit();
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
- // 回滚事务
|
|
|
|
- Db::rollBack();
|
|
|
|
- throw $e;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // 企业会员操作
|
|
|
|
- }else if($user['type_id'] == 3){
|
|
|
|
- // 开启事务
|
|
|
|
- Db::beginTransaction();
|
|
|
|
- try {
|
|
|
|
- $result['userinfo'] = UserInfo::where('user_id', $data['user_id'])->update($company);
|
|
|
|
- $result['user'] = User::where('id', $data['user_id'])->update(['mobile' => $data['mobile'], 'email' => $data['email']]);
|
|
|
|
- // 提交事务
|
|
|
|
- Db::commit();
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
- // 回滚事务
|
|
|
|
- Db::rollBack();
|
|
|
|
- throw $e;
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- return Result::error("用户类型错误", 0);
|
|
|
|
- }
|
|
|
|
- if(empty($result)){
|
|
|
|
- return Result::error("修改失败", 0);
|
|
|
|
- }
|
|
|
|
- return Result::success($result);
|
|
|
|
- }
|
|
|
|
- /*
|
|
|
|
- * 招聘信息详情
|
|
|
|
- * */
|
|
|
|
- public function getJobRecruitingInfo(array $data): array
|
|
|
|
- {
|
|
|
|
- $job = JobRecruiting::where('id', $data['id'])->first();
|
|
|
|
- if(empty($job)){
|
|
|
|
- return Result::error("招聘信息不存在", 0);
|
|
|
|
- }
|
|
|
|
- // return Result::success($job);
|
|
|
|
- $user = User::where('id', $data['user_id'])->first();
|
|
|
|
- if(empty($user)){
|
|
|
|
- return Result::error("用户不存在", 0);
|
|
|
|
- }
|
|
|
|
- $company_data = [
|
|
|
|
- 'user_id' => $data['user_id'],
|
|
|
|
- 'website_id' => $data['website_id'],
|
|
|
|
- ];
|
|
|
|
- if($user['type_id']!= 3){
|
|
|
|
- $company_data['job_id'] = $data['id'];
|
|
|
|
- }
|
|
|
|
- // return Result::success($company_data);
|
|
|
|
- $jobCompanyData = $this->getJobCompany($company_data);
|
|
|
|
- $company = $jobCompanyData['data'] ?? [];
|
|
|
|
- // return Result::success($jobCompanyData);
|
|
|
|
- if(empty($company)){
|
|
|
|
- return Result::error($jobCompanyData['message'], 0);
|
|
|
|
- }
|
|
|
|
- if (empty($job)) {
|
|
|
|
- return Result::error("暂无招聘信息", 0);
|
|
|
|
- }
|
|
|
|
- $result = array_merge($job->toArray(), $company);
|
|
|
|
- if (empty($result)) {
|
|
|
|
- return Result::error("暂无招聘信息", 0);
|
|
|
|
- }
|
|
|
|
- return Result::success($result);
|
|
|
|
- }
|
|
|
|
- /*
|
|
|
|
- * 招聘信息添加
|
|
|
|
- * */
|
|
|
|
- public function addJobRecruiting(array $data): array
|
|
|
|
- {
|
|
|
|
- $user = User::where('id', $data['user_id'])->first();
|
|
|
|
if(empty($user) || $user['type_id'] != $data['user_type']){
|
|
if(empty($user) || $user['type_id'] != $data['user_type']){
|
|
return Result::error("用户不存在", 0);
|
|
return Result::error("用户不存在", 0);
|
|
}
|
|
}
|
|
|
|
+ $web = Website::where('id', $data['website_id'])->first();
|
|
|
|
+ if(empty($web)){
|
|
|
|
+ return Result::error("网站不存在", 0);
|
|
|
|
+ }
|
|
|
|
+ // return Result::success($user);
|
|
|
|
+ $data['action_id'] = $data['user_id'];
|
|
$data['user_type'] = $user['type_id'];
|
|
$data['user_type'] = $user['type_id'];
|
|
$data['cat_arr_id'] = array_values(array_unique($data['cat_arr_id']));
|
|
$data['cat_arr_id'] = array_values(array_unique($data['cat_arr_id']));
|
|
$data['city_arr_id'] = array_values(array_unique($data['city_arr_id']));
|
|
$data['city_arr_id'] = array_values(array_unique($data['city_arr_id']));
|
|
$data['cat_arr_id'] = isset($data['cat_arr_id'])? json_encode(array_map('intval', $data['cat_arr_id'])) : '';
|
|
$data['cat_arr_id'] = isset($data['cat_arr_id'])? json_encode(array_map('intval', $data['cat_arr_id'])) : '';
|
|
$data['city_arr_id'] = isset($data['city_arr_id'])? json_encode(array_map('intval', $data['city_arr_id'])) : '';
|
|
$data['city_arr_id'] = isset($data['city_arr_id'])? json_encode(array_map('intval', $data['city_arr_id'])) : '';
|
|
- // 公司地址 管理员必填
|
|
|
|
- if(isset($data['address_arr_id']) && !empty($data['address_arr_id'])){
|
|
|
|
- $data['address_arr_id'] = array_values(array_unique($data['address_arr_id']));
|
|
|
|
- $data['address_arr_id'] = isset($data['address_arr_id'])? json_encode(array_map('intval', $data['address_arr_id'])) : '';
|
|
|
|
- }
|
|
|
|
- // 管理员-企业相关信息
|
|
|
|
|
|
+ // 公司地址 管理员必填
|
|
|
|
+ $data['address_arr_id'] = array_values(array_unique($data['address_arr_id']));
|
|
|
|
+ $data['address_arr_id'] = isset($data['address_arr_id'])? json_encode(array_map('intval', $data['address_arr_id'])) : '';
|
|
|
|
+ // 管理员-企业相关信息
|
|
$company = [
|
|
$company = [
|
|
|
|
+ // 'user_id' => $data['user_id']?? null,
|
|
'business_name' => $data['business_name']?? null,
|
|
'business_name' => $data['business_name']?? null,
|
|
'company_hy_id' => $data['company_hy_id']?? null,
|
|
'company_hy_id' => $data['company_hy_id']?? null,
|
|
'company_size' => $data['company_size']?? null,
|
|
'company_size' => $data['company_size']?? null,
|
|
@@ -1320,51 +1149,104 @@ class NewsService implements NewsServiceInterface
|
|
'address_arr_id' => $data['address_arr_id']?? null,
|
|
'address_arr_id' => $data['address_arr_id']?? null,
|
|
'address' => $data['address']?? null,
|
|
'address' => $data['address']?? null,
|
|
'email' => $data['email']?? null,
|
|
'email' => $data['email']?? null,
|
|
- ];
|
|
|
|
|
|
+ ];
|
|
//去掉相关企业信息
|
|
//去掉相关企业信息
|
|
- $data = array_diff_key($data, array_flip(array_keys($company)));
|
|
|
|
- // return Result::success($data);
|
|
|
|
- // 3:企业会员 10000:管理员
|
|
|
|
- if($user['type_id'] == 3 || $user['type_id'] == 10000){
|
|
|
|
- Db::beginTransaction();
|
|
|
|
- try {
|
|
|
|
- $jobId = JobRecruiting::insertGetId($data);
|
|
|
|
- if (empty($jobId)) {
|
|
|
|
- throw new \Exception("添加失败");
|
|
|
|
- }
|
|
|
|
- if($user['type_id'] == 10000){
|
|
|
|
- if($data['website_id'] == 0 || !isset($data['website_id'])){
|
|
|
|
- throw new \Exception("请选择所属网站");
|
|
|
|
- }
|
|
|
|
- $website = Website::where('id', $data['website_id'])->first();
|
|
|
|
- if(empty($website)){
|
|
|
|
- throw new \Exception("网站不存在");
|
|
|
|
- }
|
|
|
|
- $company['job_id'] = $jobId;
|
|
|
|
- $company['user_id'] = $user['id'];
|
|
|
|
- $company['website_id'] = $data['website_id'];
|
|
|
|
- $companyInsertResult = JobCompany::insert($company);
|
|
|
|
- if (empty($companyInsertResult)) {
|
|
|
|
- throw new \Exception("添加失败");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- $data['website_id'] = $user['website_id'];
|
|
|
|
- Db::commit();
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
|
+ $job = array_diff_key($data, array_flip(array_keys($company)));
|
|
|
|
+ Db::beginTransaction();
|
|
|
|
+ try {
|
|
|
|
+ // 先添加职位相关信息
|
|
|
|
+ $jobId = JobRecruiting::insertGetId($job);
|
|
|
|
+ if (empty($jobId)) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
- return Result::error($e->getMessage(), 0);
|
|
|
|
|
|
+ return Result::error("添加失败");
|
|
}
|
|
}
|
|
- return Result::success($jobId);
|
|
|
|
- }else{
|
|
|
|
- return Result::error("此用户暂无权限", 0);
|
|
|
|
|
|
+ // 添加公司信息
|
|
|
|
+ $company['user_id'] = $data['user_id']?? null;
|
|
|
|
+ $company['job_id'] = $jobId;
|
|
|
|
+ $company['user_type'] = $user['type_id']?? null;
|
|
|
|
+ $company['website_id'] = $data['website_id']?? null;
|
|
|
|
+ if($user['type_id'] == 10000){
|
|
|
|
+ // 管理员添加企业信息
|
|
|
|
+ // return Result::success($company);
|
|
|
|
+ $companyId = JobCompany::insertGetId($company);
|
|
|
|
+ if (empty($companyId)) {
|
|
|
|
+ Db::rollBack();
|
|
|
|
+ return Result::error("添加失败");
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ // 企业会员添加企业信息
|
|
|
|
+ $company = [
|
|
|
|
+ 'user_id' => $data['user_id']?? null,
|
|
|
|
+ 'business_name' => $user['business_name']?? null,
|
|
|
|
+ 'company_hy_id' => $user['hy_id']?? null,
|
|
|
|
+ 'company_size' => $user['company_size']?? null,
|
|
|
|
+ 'company_nature' => $user['company_nature']?? null,
|
|
|
|
+ 'introduction' => $user['introduction']?? null,
|
|
|
|
+ 'real_name' => $user['real_name']?? null,
|
|
|
|
+ 'mobile' => $user['mobile']?? null,
|
|
|
|
+ 'company_url' => $user['company_url']?? null,
|
|
|
|
+ 'address_arr_id' => $user['address_arr_id']?? null,
|
|
|
|
+ 'address' => $user['address']?? null,
|
|
|
|
+ 'email' => $user['email']?? null,
|
|
|
|
+ 'website_id' => $data['website_id']?? null,
|
|
|
|
+ 'user_type' => $user['type_id']?? null,
|
|
|
|
+ 'job_id' => $jobId,
|
|
|
|
+ ];
|
|
|
|
+ $companyId = JobCompany::insertGetId($company);
|
|
|
|
+ if (empty($companyId)) {
|
|
|
|
+ Db::rollBack();
|
|
|
|
+ return Result::error("添加失败");
|
|
|
|
+ }
|
|
|
|
+ // return Result::success($company);
|
|
|
|
+ }
|
|
|
|
+ Db::commit();
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ Db::rollBack();
|
|
|
|
+ return Result::error($e->getMessage(), 0);
|
|
|
|
+ }
|
|
|
|
+ $result = [
|
|
|
|
+ 'job_id' => $jobId,
|
|
|
|
+ 'company_id' => $companyId,
|
|
|
|
+ ];
|
|
|
|
+ if (empty($result)) {
|
|
|
|
+ return Result::error("添加失败", 0);
|
|
|
|
+ }
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ }
|
|
|
|
+ /*
|
|
|
|
+ * 获取招聘信息详情
|
|
|
|
+ * */
|
|
|
|
+ public function getJobRecruitingInfo(array $data): array
|
|
|
|
+ {
|
|
|
|
+ $result = JobRecruiting::where('job_recruiting.id', $data['id'])
|
|
|
|
+ ->leftJoin('website', 'job_recruiting.website_id', '=', 'website.id')
|
|
|
|
+ ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
|
|
|
|
+ ->select('job_recruiting.*', 'website.website_name as website_name',
|
|
|
|
+ 'job_company.business_name',
|
|
|
|
+ 'job_company.company_hy_id',
|
|
|
|
+ 'job_company.company_size',
|
|
|
|
+ 'job_company.company_nature',
|
|
|
|
+ 'job_company.introduction',
|
|
|
|
+ 'job_company.real_name',
|
|
|
|
+ 'job_company.mobile',
|
|
|
|
+ 'job_company.company_url',
|
|
|
|
+ 'job_company.address_arr_id',
|
|
|
|
+ 'job_company.address',
|
|
|
|
+ 'job_company.email'
|
|
|
|
+ )
|
|
|
|
+ ->first();
|
|
|
|
+ if(empty($result)){
|
|
|
|
+ return Result::error("招聘信息不存在", 0);
|
|
}
|
|
}
|
|
|
|
+ // return Result::success($job);
|
|
|
|
+ return Result::success($result);
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
- * 招聘信息更新
|
|
|
|
|
|
+ * 修改招聘信息
|
|
* */
|
|
* */
|
|
public function upJobRecruiting(array $data): array
|
|
public function upJobRecruiting(array $data): array
|
|
{
|
|
{
|
|
- $job = JobRecruiting::where('id', $data['id'])->first();
|
|
|
|
|
|
+ $job = JobRecruiting::where('job_recruiting.id', $data['id'])->first();
|
|
// return Result::success($job);
|
|
// return Result::success($job);
|
|
if(empty($job)){
|
|
if(empty($job)){
|
|
return Result::error("招聘信息不存在", 0);
|
|
return Result::error("招聘信息不存在", 0);
|
|
@@ -1377,15 +1259,18 @@ class NewsService implements NewsServiceInterface
|
|
if($user['type_id']==3 && $job['user_id']!= $user['id']){
|
|
if($user['type_id']==3 && $job['user_id']!= $user['id']){
|
|
return Result::error("用户暂无权限修改此招聘信息!", 0);
|
|
return Result::error("用户暂无权限修改此招聘信息!", 0);
|
|
}
|
|
}
|
|
- // $data['user_type'] = $user['type_id'];
|
|
|
|
$data['cat_arr_id'] = array_values(array_unique($data['cat_arr_id']));
|
|
$data['cat_arr_id'] = array_values(array_unique($data['cat_arr_id']));
|
|
$data['city_arr_id'] = array_values(array_unique($data['city_arr_id']));
|
|
$data['city_arr_id'] = array_values(array_unique($data['city_arr_id']));
|
|
$data['cat_arr_id'] = isset($data['cat_arr_id'])? json_encode(array_map('intval', $data['cat_arr_id'])) : '';
|
|
$data['cat_arr_id'] = isset($data['cat_arr_id'])? json_encode(array_map('intval', $data['cat_arr_id'])) : '';
|
|
$data['city_arr_id'] = isset($data['city_arr_id'])? json_encode(array_map('intval', $data['city_arr_id'])) : '';
|
|
$data['city_arr_id'] = isset($data['city_arr_id'])? json_encode(array_map('intval', $data['city_arr_id'])) : '';
|
|
|
|
+
|
|
|
|
+ // 公司地址 管理员必填
|
|
|
|
+ $data['address_arr_id'] = array_values(array_unique($data['address_arr_id']));
|
|
|
|
+ $data['address_arr_id'] = isset($data['address_arr_id'])? json_encode(array_map('intval', $data['address_arr_id'])) : '';
|
|
// 管理员-企业相关信息
|
|
// 管理员-企业相关信息
|
|
$company = [
|
|
$company = [
|
|
'business_name' => $data['business_name']?? null,
|
|
'business_name' => $data['business_name']?? null,
|
|
- 'company_hy_id' => $data['company_hy_id']?? null,
|
|
|
|
|
|
+ 'company_hy_id' => $data['hy_id']?? null,
|
|
'company_size' => $data['company_size']?? null,
|
|
'company_size' => $data['company_size']?? null,
|
|
'company_nature' => $data['company_nature']?? null,
|
|
'company_nature' => $data['company_nature']?? null,
|
|
'introduction' => $data['introduction']?? null,
|
|
'introduction' => $data['introduction']?? null,
|
|
@@ -1396,53 +1281,43 @@ class NewsService implements NewsServiceInterface
|
|
'address' => $data['address']?? null,
|
|
'address' => $data['address']?? null,
|
|
'email' => $data['email']?? null,
|
|
'email' => $data['email']?? null,
|
|
];
|
|
];
|
|
- $company['user_id'] = $job['user_id'];
|
|
|
|
- $company['job_id'] = $data['id'];
|
|
|
|
//去掉相关企业信息
|
|
//去掉相关企业信息
|
|
- unset($data['user_type']);
|
|
|
|
$data = array_diff_key($data, array_flip(array_keys($company)));
|
|
$data = array_diff_key($data, array_flip(array_keys($company)));
|
|
|
|
+ $jobId = $data['id'];
|
|
|
|
+ $web = $data['website_id'];
|
|
|
|
+ $data['action_id'] = $data['user_id'];
|
|
|
|
+ unset($data['user_id']);
|
|
|
|
+ unset($data['user_type']);
|
|
|
|
+ unset($data['id']);
|
|
|
|
+ unset($data['website_id']);
|
|
// return Result::success($data);
|
|
// return Result::success($data);
|
|
- // 3:企业会员 10000:管理员
|
|
|
|
- if($user['type_id'] == 3 || $user['type_id'] == 10000){
|
|
|
|
- Db::beginTransaction();
|
|
|
|
- try {
|
|
|
|
- $jobId = JobRecruiting::where('id',$data['id'])->update($data);
|
|
|
|
- // $jobId = JobRecruiting::where('id',$data['id'])->first();
|
|
|
|
- if (empty($jobId)) {
|
|
|
|
- Db::rollback();
|
|
|
|
- return Result::error("修改职位信息失败");
|
|
|
|
- }
|
|
|
|
- // $company = $this->upJobCompany($company);
|
|
|
|
- // return $company;
|
|
|
|
- if($user['type_id'] == 10000){
|
|
|
|
- if($data['website_id'] == 0 || !isset($data['website_id']) || empty($data['website_id'])){
|
|
|
|
- Db::rollback();
|
|
|
|
- return Result::error("请选择所属网站");
|
|
|
|
- }
|
|
|
|
- $website = Website::where('id', $data['website_id'])->first();
|
|
|
|
- if(empty($website)){
|
|
|
|
- Db::rollback();
|
|
|
|
- return Result::error("网站不存在");
|
|
|
|
- }
|
|
|
|
- $company['job_id'] = $data['id'];
|
|
|
|
- $company['website_id'] = $data['website_id'];
|
|
|
|
-
|
|
|
|
- $companyData = $this->upJobCompany($company);
|
|
|
|
- if (empty($companyData)) {
|
|
|
|
- Db::rollback();
|
|
|
|
- return Result::error("修改失败");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- $data['website_id'] = $user['website_id'];
|
|
|
|
- Db::commit();
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
|
|
+ Db::beginTransaction();
|
|
|
|
+ try {
|
|
|
|
+ // 管理员修改招聘信息
|
|
|
|
+ if($user['type_id'] == 10000){
|
|
|
|
+ $data['website_id'] = $web;
|
|
|
|
+ $company['website_id'] = $data['website_id'];
|
|
|
|
+ }
|
|
|
|
+ // Db::rollBack();
|
|
|
|
+ // return Result::success($company);
|
|
|
|
+ $result['job'] = JobRecruiting::where('id', $jobId)->update($data);
|
|
|
|
+ if (empty($result['job'])) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
- return Result::error($e->getMessage(), 0);
|
|
|
|
|
|
+ return Result::error("修改招聘信息失败");
|
|
}
|
|
}
|
|
- return Result::success($jobId);
|
|
|
|
- }else{
|
|
|
|
- return Result::error("此用户暂无权限", 0);
|
|
|
|
|
|
+ // 管理员修改企业相关信息
|
|
|
|
+ $result['company'] = JobCompany::where('job_id', $jobId)->update($company);
|
|
|
|
+ if (empty($result['company'])) {
|
|
|
|
+ Db::rollBack();
|
|
|
|
+ return Result::error("修改企业相关信息失败");
|
|
|
|
+ }
|
|
|
|
+ Db::commit();
|
|
|
|
+ // return Result::success($result);
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ Db::rollBack();
|
|
|
|
+ return Result::error($e->getMessage(), 0);
|
|
}
|
|
}
|
|
|
|
+ return Result::success($result);
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
* 招聘信息删除
|
|
* 招聘信息删除
|
|
@@ -1467,19 +1342,106 @@ class NewsService implements NewsServiceInterface
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
return Result::error("删除招聘信息失败");
|
|
return Result::error("删除招聘信息失败");
|
|
}
|
|
}
|
|
- if ($job['user_type'] == 10000) {
|
|
|
|
- $result['company'] = JobCompany::where('job_id', $data['id'])->delete(); // 修正为JobCompany
|
|
|
|
- if (empty($result['company'])) {
|
|
|
|
- Db::rollBack();
|
|
|
|
- return Result::error("删除企业相关信息失败");
|
|
|
|
- }
|
|
|
|
|
|
+ $result['company'] = JobCompany::where('job_id', $data['id'])->delete();
|
|
|
|
+ if (empty($result['company'])) {
|
|
|
|
+ Db::rollBack();
|
|
|
|
+ return Result::error("删除企业相关信息失败");
|
|
}
|
|
}
|
|
Db::commit();
|
|
Db::commit();
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
return Result::error($e->getMessage(), 0);
|
|
return Result::error($e->getMessage(), 0);
|
|
}
|
|
}
|
|
- return Result::success($data);
|
|
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ }
|
|
|
|
+ /*
|
|
|
|
+ * 获取公司信息
|
|
|
|
+ * */
|
|
|
|
+ public function getJobCompany(array $data): array
|
|
|
|
+ {
|
|
|
|
+ $user = User::where('user.id', $data['user_id'])
|
|
|
|
+ ->leftJoin('user_info', 'user_info.user_id', 'user.id')
|
|
|
|
+ ->select('user.user_name','user.mobile','user.email','user.type_id', 'user_info.*')
|
|
|
|
+ ->first();
|
|
|
|
+ // return Result::success($user);
|
|
|
|
+ if(empty($user)){
|
|
|
|
+ return Result::error("用户不存在", 0);
|
|
|
|
+ }
|
|
|
|
+ if($user['type_id'] == 3){
|
|
|
|
+ $result = [
|
|
|
|
+ // 'id' => 0,
|
|
|
|
+ 'user_id' => $data['user_id'],
|
|
|
|
+ 'website_id' => $data['website_id'],
|
|
|
|
+ 'business_name' => $user['business_name'], // 企业名称
|
|
|
|
+ 'company_hy_id' => $user['company_hy_id'], // 企业所属行业
|
|
|
|
+ 'company_nature' => $user['company_nature'], // 公司性质
|
|
|
|
+ 'company_size' => $user['company_size'], // 公司规模
|
|
|
|
+ 'introduction' => $user['introduction'], // 公司简介
|
|
|
|
+ 'real_name' => $user['real_name'], // 企业联系人
|
|
|
|
+ 'mobile' => $user['mobile'], // 企业联系电话
|
|
|
|
+ 'company_url' => $user['company_url'], // 企业网址
|
|
|
|
+ 'address_arr_id' => $user['address_arr_id'], // 企业网址
|
|
|
|
+ 'address' => $user['address'], // 企业地址
|
|
|
|
+ 'email' => $user['email'], // 企业邮箱
|
|
|
|
+ ];
|
|
|
|
+ }else{
|
|
|
|
+ return Result::error("用户类型错误", 0);
|
|
|
|
+ }
|
|
|
|
+ if(empty($result)){
|
|
|
|
+ return Result::error("公司信息不存在", 0);
|
|
|
|
+ }
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ }
|
|
|
|
+ /*
|
|
|
|
+ * 修改公司信息
|
|
|
|
+ * */
|
|
|
|
+ public function upJobCompany(array $data): array
|
|
|
|
+ {
|
|
|
|
+ // return Result::success($data);
|
|
|
|
+ $user = User::where('user.id', $data['user_id'])
|
|
|
|
+ ->where('user.status',1)
|
|
|
|
+ ->leftJoin('user_info', 'user_info.user_id', 'user.id')
|
|
|
|
+ ->select('user.user_name','user.type_id', 'user_info.*')
|
|
|
|
+ ->first();
|
|
|
|
+ if(empty($user)){
|
|
|
|
+ return Result::error("用户不存在", 0);
|
|
|
|
+ }
|
|
|
|
+ $data['address_arr_id'] = isset($data['address_arr_id'])? json_encode(array_map('intval', $data['address_arr_id'])) : '';
|
|
|
|
+ $company = [
|
|
|
|
+ 'business_name' => $data['business_name'], // 企业名称
|
|
|
|
+ 'company_hy_id' => $data['company_hy_id'], // 企业所属行业
|
|
|
|
+ 'company_nature' => $data['company_nature'], // 公司性质
|
|
|
|
+ 'company_size' => $data['company_size'], // 公司规模
|
|
|
|
+ 'introduction' => $data['introduction'], // 公司简介
|
|
|
|
+ 'real_name' => $data['real_name'], // 企业联系人
|
|
|
|
+ 'company_url' => $data['company_url'], // 企业网址
|
|
|
|
+ 'address_arr_id' => $data['address_arr_id'], // 企业地址
|
|
|
|
+ 'address' => $data['address'], // 企业详细地址
|
|
|
|
+ ];
|
|
|
|
+ if($user['type_id'] == 3){
|
|
|
|
+ $result['user'] = User::where('user.id', $data['user_id'])->update([
|
|
|
|
+ 'mobile' => $data['mobile'], // 企业联系电话
|
|
|
|
+ 'email' => $data['email'], // 企业邮箱
|
|
|
|
+ ]);
|
|
|
|
+ $result['userinfo'] = UserInfo::where('user_id', $data['user_id'])->update([
|
|
|
|
+ 'business_name' => $data['business_name'], // 企业名称
|
|
|
|
+ 'company_hy_id' => $data['company_hy_id'], // 企业所属行业
|
|
|
|
+ 'company_nature' => $data['company_nature'], // 公司性质
|
|
|
|
+ 'company_size' => $data['company_size'], // 公司规模
|
|
|
|
+ 'introduction' => $data['introduction'], // 公司简介
|
|
|
|
+ 'real_name' => $data['real_name'], // 企业联系人
|
|
|
|
+ 'company_url' => $data['company_url'], // 企业网址
|
|
|
|
+ 'address_arr_id' => $data['address_arr_id'], // 企业地址
|
|
|
|
+ 'address' => $data['address'], // 企业详细地址
|
|
|
|
+ ]);
|
|
|
|
+ $result = JobCompany::where('user_id', $data['user_id'])->update($company);
|
|
|
|
+ }else{
|
|
|
|
+ return Result::error("用户类型错误", 0);
|
|
|
|
+ }
|
|
|
|
+ if(empty($result)){
|
|
|
|
+ return Result::error("修改失败", 0);
|
|
|
|
+ }
|
|
|
|
+ return Result::success($result);
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
* 获取省-市
|
|
* 获取省-市
|