|
@@ -8,6 +8,7 @@ use App\Model\WebsiteCategory;
|
|
|
use App\Model\ArticleSurvey;
|
|
|
use App\Model\District;
|
|
|
use App\Model\Good;
|
|
|
+use App\Model\JobCompany;
|
|
|
use App\Model\Website;
|
|
|
use App\Model\JobRecruiting;
|
|
|
use App\Model\JobIndustry;
|
|
@@ -1088,28 +1089,51 @@ class NewsService implements NewsServiceInterface
|
|
|
* */
|
|
|
public function getJobRecruitingInfo(array $data): array
|
|
|
{
|
|
|
- $result = JobRecruiting::where('job_recruiting.id', $data['id'])
|
|
|
- ->leftJoin('user_info', 'job_recruiting.user_id', 'user_info.id')
|
|
|
- ->leftJoin('user', 'job_recruiting.user_id', 'user.id')
|
|
|
- ->select(
|
|
|
- 'job_recruiting.*',
|
|
|
- 'user_info.business_name', // 企业名称
|
|
|
- 'user_info.hy_id', // 企业所属行业
|
|
|
- 'user_info.company_size', // 公司规模
|
|
|
- 'user_info.company_nature', // 公司性质
|
|
|
- 'user_info.introduction', // 公司简介
|
|
|
- 'user_info.real_name', // 企业联系人
|
|
|
- 'user.mobile', // 企业联系电话
|
|
|
- 'user_info.company_url', // 企业网址
|
|
|
- 'user_info.address_arr_id', // 企业地址
|
|
|
- 'user_info.address', // 企业地址
|
|
|
- 'user.email', // 企业邮箱
|
|
|
- )
|
|
|
- ->orderBy("updated_at", "desc")
|
|
|
- ->first();
|
|
|
+ $job = JobRecruiting::where('id', $data['id'])->first();
|
|
|
+ if(empty($job)){
|
|
|
+ return Result::error("招聘信息不存在", 0);
|
|
|
+ }
|
|
|
+ $user = User::where('id', $data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error("用户不存在", 0);
|
|
|
+ }
|
|
|
+ if($user['user_type'] == 3){
|
|
|
+ $result = JobRecruiting::where('job_recruiting.id', $data['id'])
|
|
|
+ ->leftJoin('user_info', 'job_recruiting.user_id', 'user_info.id')
|
|
|
+ ->leftJoin('user', 'job_recruiting.user_id', 'user.id')
|
|
|
+ ->select(
|
|
|
+ 'job_recruiting.*',
|
|
|
+ 'user_info.business_name', // 企业名称
|
|
|
+ 'user_info.hy_id', // 企业所属行业
|
|
|
+ 'user_info.company_size', // 公司规模
|
|
|
+ 'user_info.company_nature', // 公司性质
|
|
|
+ 'user_info.introduction', // 公司简介
|
|
|
+ 'user_info.real_name', // 企业联系人
|
|
|
+ 'user.mobile', // 企业联系电话
|
|
|
+ 'user_info.company_url', // 企业网址
|
|
|
+ 'user_info.address_arr_id', // 企业地址
|
|
|
+ 'user_info.address as address_info', // 企业地址
|
|
|
+ 'user.email', // 企业邮箱
|
|
|
+ )
|
|
|
+ ->first();
|
|
|
+ }else{
|
|
|
+ $result = JobRecruiting::where('job_recruiting.id', $data['id'])
|
|
|
+ ->leftJoin('job_company', 'job_recruiting.id', 'job_company.job_id')
|
|
|
+ ->select(
|
|
|
+ 'job_recruiting.*','job_company.id as company_id','job_company.website_id as webid', // 企业名称
|
|
|
+ 'job_company.*', // 企业名称
|
|
|
+ )
|
|
|
+ ->first();
|
|
|
+ }
|
|
|
if (empty($result)) {
|
|
|
return Result::error("暂无招聘信息", 0);
|
|
|
}
|
|
|
+ if(!empty($result['address_arr_id'])){
|
|
|
+ // 假设此处是要将字符串解析为数组,如果是JSON格式可以使用json_decode
|
|
|
+ $address_arr = json_decode($result['address_arr_id'], true);
|
|
|
+ $address = District::whereIn('id', $address_arr)->pluck('name');
|
|
|
+ $result['address'] = $address->toArray();
|
|
|
+ }
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
/*
|
|
@@ -1118,30 +1142,69 @@ class NewsService implements NewsServiceInterface
|
|
|
public function addJobRecruiting(array $data): array
|
|
|
{
|
|
|
$user = User::where('id', $data['user_id'])->first();
|
|
|
- if(empty($user)){
|
|
|
+ if(empty($user) || $user['type_id'] != $data['user_type']){
|
|
|
return Result::error("用户不存在", 0);
|
|
|
}
|
|
|
- // 3:企业会员
|
|
|
- if($user['type_id'] != 3){
|
|
|
- if($data['website_id'] == 0){
|
|
|
- return Result::error("请选择所属网站", 0);
|
|
|
- }
|
|
|
- $website = Website::where('id', $data['website_id'])->first();
|
|
|
- if(empty($website)){
|
|
|
- return Result::error("网站不存在", 0);
|
|
|
- }
|
|
|
- $data['website_id'] = $website['id'];
|
|
|
- }
|
|
|
+ $data['user_type'] = $user['type_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['cat_arr_id'] = isset($data['cat_arr_id'])? json_encode($data['cat_arr_id']) : '';
|
|
|
$data['city_arr_id'] = isset($data['city_arr_id'])? json_encode($data['city_arr_id']) : '';
|
|
|
- $result = JobRecruiting::insertGetId($data);
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("添加失败", 0);
|
|
|
+ // 公司地址 管理员必填
|
|
|
+ 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($data['address_arr_id']) : '';
|
|
|
+ }
|
|
|
+ // 管理员-企业相关信息
|
|
|
+ $company = [
|
|
|
+ 'business_name' => $data['business_name']?? null,
|
|
|
+ 'company_hy_id' => $data['company_hy_id']?? null,
|
|
|
+ 'company_size' => $data['company_size']?? null,
|
|
|
+ 'company_nature' => $data['company_nature']?? null,
|
|
|
+ 'introduction' => $data['introduction']?? null,
|
|
|
+ 'real_name' => $data['real_name']?? null,
|
|
|
+ 'mobile' => $data['mobile']?? null,
|
|
|
+ 'company_url' => $data['company_url']?? null,
|
|
|
+ 'address_arr_id' => $data['address_arr_id']?? null,
|
|
|
+ 'address' => $data['address']?? null,
|
|
|
+ 'email' => $data['email']?? null,
|
|
|
+ ];
|
|
|
+ //去掉相关企业信息
|
|
|
+ $data = array_diff_key($data, array_flip(array_keys($company)));
|
|
|
+ $company['user_id'] = $user['id'];
|
|
|
+ // 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['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) {
|
|
|
+ Db::rollBack();
|
|
|
+ return Result::error($e->getMessage(), 0);
|
|
|
+ }
|
|
|
+ return Result::success($jobId);
|
|
|
+ }else{
|
|
|
+ return Result::error("此用户暂无权限", 0);
|
|
|
}
|
|
|
- return Result::success($result);
|
|
|
-
|
|
|
}
|
|
|
/*
|
|
|
* 招聘信息更新
|
|
@@ -1153,42 +1216,99 @@ class NewsService implements NewsServiceInterface
|
|
|
return Result::error("招聘信息不存在", 0);
|
|
|
}
|
|
|
$user = User::where('id', $data['user_id'])->first();
|
|
|
- if(empty($user)){
|
|
|
+ if(empty($user) || $user['type_id'] != $data['user_type']){
|
|
|
return Result::error("用户不存在", 0);
|
|
|
}
|
|
|
- // 3:企业会员
|
|
|
- if($user['type_id'] != 3){
|
|
|
- if($data['website_id'] == 0){
|
|
|
- return Result::error("请选择所属网站", 0);
|
|
|
- }
|
|
|
- $website = Website::where('id', $data['website_id'])->first();
|
|
|
- if(empty($website)){
|
|
|
- return Result::error("网站不存在", 0);
|
|
|
- }
|
|
|
- $data['website_id'] = $website['id'];
|
|
|
- }
|
|
|
+ $data['user_type'] = $user['type_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['cat_arr_id'] = isset($data['cat_arr_id'])? json_encode($data['cat_arr_id']) : '';
|
|
|
$data['city_arr_id'] = isset($data['city_arr_id'])? json_encode($data['city_arr_id']) : '';
|
|
|
- $result = JobRecruiting::where('id', $data['id'])->update($data);
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("更新失败", 0);
|
|
|
+ // 公司地址 管理员必填
|
|
|
+ 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($data['address_arr_id']) : '';
|
|
|
+ }
|
|
|
+ // 管理员-企业相关信息
|
|
|
+ $company = [
|
|
|
+ 'business_name' => $data['business_name']?? null,
|
|
|
+ 'company_hy_id' => $data['company_hy_id']?? null,
|
|
|
+ 'company_size' => $data['company_size']?? null,
|
|
|
+ 'company_nature' => $data['company_nature']?? null,
|
|
|
+ 'introduction' => $data['introduction']?? null,
|
|
|
+ 'real_name' => $data['real_name']?? null,
|
|
|
+ 'mobile' => $data['mobile']?? null,
|
|
|
+ 'company_url' => $data['company_url']?? null,
|
|
|
+ 'address_arr_id' => $data['address_arr_id']?? null,
|
|
|
+ 'address' => $data['address']?? null,
|
|
|
+ 'email' => $data['email']?? null,
|
|
|
+ ];
|
|
|
+ //去掉相关企业信息
|
|
|
+ $data = array_diff_key($data, array_flip(array_keys($company)));
|
|
|
+ $company['user_id'] = $user['id'];
|
|
|
+ // 3:企业会员 10000:管理员
|
|
|
+ if($user['type_id'] == 3 || $user['type_id'] == 10000){
|
|
|
+ Db::beginTransaction();
|
|
|
+ try {
|
|
|
+ $jobId = JobRecruiting::where('id',$data['id'])->update($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['website_id'] = $data['website_id'];
|
|
|
+ $companyInsertResult = JobCompany::where('job_id',$data['id'])->update($company);
|
|
|
+ if (empty($companyInsertResult)) {
|
|
|
+ throw new \Exception("添加失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $data['website_id'] = $user['website_id'];
|
|
|
+ Db::commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollBack();
|
|
|
+ return Result::error($e->getMessage(), 0);
|
|
|
+ }
|
|
|
+ return Result::success($jobId);
|
|
|
+ }else{
|
|
|
+ return Result::error("此用户暂无权限", 0);
|
|
|
}
|
|
|
- return Result::success($data);
|
|
|
}
|
|
|
/*
|
|
|
* 招聘信息删除
|
|
|
* */
|
|
|
public function delJobRecruiting(array $data): array
|
|
|
{
|
|
|
+ $user = User::where('id', $data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error("用户不存在", 0);
|
|
|
+ }
|
|
|
$job = JobRecruiting::where('id', $data['id'])->first();
|
|
|
if(empty($job)){
|
|
|
return Result::error("招聘信息不存在", 0);
|
|
|
}
|
|
|
- $result = JobRecruiting::where('id',$data['id'])->delete();
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("删除失败", 0);
|
|
|
+ Db::beginTransaction();
|
|
|
+ try {
|
|
|
+ $result['job'] = JobRecruiting::where('id', $data['id'])->delete();
|
|
|
+ if (empty($result['job'])) {
|
|
|
+ throw new \Exception("删除招聘信息失败");
|
|
|
+ }
|
|
|
+ if ($job['type_id'] == 10000) {
|
|
|
+ $result['company'] = JobCompany::where('job_id', $data['id'])->delete(); // 修正为JobCompany
|
|
|
+ if (empty($result['company'])) {
|
|
|
+ throw new \Exception("删除企业相关信息失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollBack();
|
|
|
+ return Result::error($e->getMessage(), 0);
|
|
|
}
|
|
|
return Result::success($data);
|
|
|
}
|