|
@@ -49,6 +49,7 @@ use Hyperf\Codec\Json;
|
|
|
|
|
|
use App\Tools\buildMenuTree;
|
|
|
use App\Model\JobApply;
|
|
|
+use App\Model\JobRemuse;
|
|
|
#[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class NewsService implements NewsServiceInterface
|
|
|
{
|
|
@@ -1484,87 +1485,49 @@ class NewsService implements NewsServiceInterface
|
|
|
*/
|
|
|
public function getWebsiteAllArticle(array $data): array
|
|
|
{
|
|
|
- // 修正传入的字符串,将单引号替换为双引号
|
|
|
- $input['id'] = $data['id'];
|
|
|
- $input['website_id'] = $data['website_id'];
|
|
|
- // 将 JSON 字符串转换为 PHP 数组
|
|
|
- $data = json_decode($input['id'], true);
|
|
|
- // 使用 array_map 处理每个元素
|
|
|
- $result = array_map(function ($item) use ($input) {
|
|
|
- // 检查parent元素是否存在且不是undefined
|
|
|
- if (isset($item['parent']) && $item['parent'] != 'undefined' && $item['parent'] != "") {
|
|
|
- list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
|
|
|
- $website = [
|
|
|
- 'website_id' => $input['website_id'],
|
|
|
- ];
|
|
|
- // 查询栏目名称
|
|
|
- $category = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id', 'aLIas_pinyin']);
|
|
|
-
|
|
|
- if (empty($category)) {
|
|
|
- $parent_alias = '';
|
|
|
- $parent_pinyin = null;
|
|
|
- $imgArticles = [];
|
|
|
- $textArticles = [];
|
|
|
- } else {
|
|
|
- $parent_alias = $category->alias ?? '';
|
|
|
- $parent_pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
|
|
|
- // 查找子分类ID数组
|
|
|
- $childCategoryIds = WebsiteCategory::where('pid', $parentCatId)->where($website)->pluck('category_id')->toArray();
|
|
|
- array_push($childCategoryIds, $parentCatId);
|
|
|
- $childCategoryIds = json_encode(array_values(array_unique($childCategoryIds)));
|
|
|
- if ($parentImgNum != 0) {
|
|
|
- // 查询图片新闻
|
|
|
- $imgArticles = Article::where('article.status', 1)
|
|
|
- ->where(function ($query) use ($parentCatId) {
|
|
|
- $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
|
|
|
- ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
|
|
|
- })
|
|
|
- ->where(function ($query) use ($website) {
|
|
|
- $query->where(function ($subQuery) use ($website) {
|
|
|
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0")
|
|
|
- ->orWhereNull("ignore_ids");
|
|
|
- });
|
|
|
- })
|
|
|
- ->where('imgurl', '!=', '')
|
|
|
- ->leftJoin('website_category', function ($join) use ($website) {
|
|
|
- $join->on('article.catid', '=', 'website_category.category_id')
|
|
|
- ->where('website_category.website_id', '=', $website['website_id']);
|
|
|
- })
|
|
|
- ->select(
|
|
|
- 'article.id',
|
|
|
- 'article.title',
|
|
|
- 'article.imgurl',
|
|
|
- 'article.author',
|
|
|
- 'article.updated_at',
|
|
|
- 'article.introduce',
|
|
|
- 'article.islink',
|
|
|
- 'article.linkurl',
|
|
|
- 'article.copyfrom',
|
|
|
- 'article.catid',
|
|
|
- 'website_category.alias as category_name',
|
|
|
- DB::raw("CASE WHEN article.catid = $parentCatId THEN '$parent_pinyin'
|
|
|
- ELSE CONCAT('$parent_pinyin', '/', website_category.aLIas_pinyin) END as pinyin")
|
|
|
- )
|
|
|
- ->orderBy('updated_at', 'desc')
|
|
|
- ->limit($parentImgNum)
|
|
|
- ->get()->all();
|
|
|
-
|
|
|
- // 查询文字新闻
|
|
|
- }
|
|
|
- if ($parentTextNum != 0) {
|
|
|
+ // 修正传入的字符串,将单引号替换为双引号
|
|
|
+ $input['id'] = $data['id'];
|
|
|
+ $input['website_id'] = $data['website_id'];
|
|
|
+ // 将 JSON 字符串转换为 PHP 数组
|
|
|
+ $data = json_decode($input['id'], true);
|
|
|
+ // 使用 array_map 处理每个元素
|
|
|
+ $result = array_map(function ($item) use ($input) {
|
|
|
+ // 检查parent元素是否存在且不是undefined
|
|
|
+ if (isset($item['parent']) && $item['parent'] != 'undefined' && $item['parent']!= "") {
|
|
|
+ list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
|
|
|
+ $website = [
|
|
|
+ 'website_id' => $input['website_id'],
|
|
|
+ ];
|
|
|
+ // 查询栏目名称
|
|
|
+ $category = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id','aLIas_pinyin']);
|
|
|
+
|
|
|
+ if(empty($category)){
|
|
|
+ $parent_alias = '';
|
|
|
+ $parent_pinyin = null;
|
|
|
+ $imgArticles = [];
|
|
|
$textArticles = [];
|
|
|
- $textArticles = Article::where('article.status', 1)
|
|
|
- ->where(function ($query) use ($parentCatId) {
|
|
|
+ }else{
|
|
|
+ $parent_alias = $category->alias ?? '';
|
|
|
+ $parent_pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
|
|
|
+ // 查找子分类ID数组
|
|
|
+ $childCategoryIds = WebsiteCategory::where('pid', $parentCatId)->where($website)->pluck('category_id')->toArray();
|
|
|
+ array_push($childCategoryIds,$parentCatId);
|
|
|
+ $childCategoryIds = json_encode(array_values(array_unique($childCategoryIds)));
|
|
|
+ if($parentImgNum!=0){
|
|
|
+ // 查询图片新闻
|
|
|
+ $imgArticles = Article::where('article.status', 1)
|
|
|
+ ->where(function($query) use ($parentCatId) {
|
|
|
$query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
|
|
|
- ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
|
|
|
+ ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
|
|
|
})
|
|
|
->where(function ($query) use ($website) {
|
|
|
$query->where(function ($subQuery) use ($website) {
|
|
|
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0")
|
|
|
+ $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($website['website_id'])."') = 0")
|
|
|
->orWhereNull("ignore_ids");
|
|
|
});
|
|
|
})
|
|
|
- ->leftJoin('website_category', function ($join) use ($website) {
|
|
|
+ ->where('imgurl', '!=', '')
|
|
|
+ ->leftJoin('website_category', function($join) use ($website) {
|
|
|
$join->on('article.catid', '=', 'website_category.category_id')
|
|
|
->where('website_category.website_id', '=', $website['website_id']);
|
|
|
})
|
|
@@ -1584,100 +1547,138 @@ class NewsService implements NewsServiceInterface
|
|
|
ELSE CONCAT('$parent_pinyin', '/', website_category.aLIas_pinyin) END as pinyin")
|
|
|
)
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
- ->limit($parentTextNum)
|
|
|
+ ->limit($parentImgNum)
|
|
|
->get()->all();
|
|
|
+
|
|
|
+ // 查询文字新闻
|
|
|
+ }
|
|
|
+ if($parentTextNum!=0){
|
|
|
+ $textArticles = [];
|
|
|
+ $textArticles = Article::where('article.status', 1)
|
|
|
+ ->where(function($query) use ($parentCatId) {
|
|
|
+ $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
|
|
|
+ ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
|
|
|
+ })
|
|
|
+ ->where(function ($query) use ($website) {
|
|
|
+ $query->where(function ($subQuery) use ($website) {
|
|
|
+ $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($website['website_id'])."') = 0")
|
|
|
+ ->orWhereNull("ignore_ids");
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->leftJoin('website_category', function($join) use ($website) {
|
|
|
+ $join->on('article.catid', '=', 'website_category.category_id')
|
|
|
+ ->where('website_category.website_id', '=', $website['website_id']);
|
|
|
+ })
|
|
|
+ ->select(
|
|
|
+ 'article.id',
|
|
|
+ 'article.title',
|
|
|
+ 'article.imgurl',
|
|
|
+ 'article.author',
|
|
|
+ 'article.updated_at',
|
|
|
+ 'article.introduce',
|
|
|
+ 'article.islink',
|
|
|
+ 'article.linkurl',
|
|
|
+ 'article.copyfrom',
|
|
|
+ 'article.catid',
|
|
|
+ 'website_category.alias as category_name',
|
|
|
+ DB::raw("CASE WHEN article.catid = $parentCatId THEN '$parent_pinyin'
|
|
|
+ ELSE CONCAT('$parent_pinyin', '/', website_category.aLIas_pinyin) END as pinyin")
|
|
|
+ )
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->limit($parentTextNum)
|
|
|
+ ->get()->all();
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
- $resultItem = [
|
|
|
- 'alias' => $parent_alias ?? '',
|
|
|
- 'category_id' => $parentCatId ?? 0,
|
|
|
- 'pinyin' => $parent_pinyin ?? null,
|
|
|
- 'imgnum' => $imgArticles ?? [],
|
|
|
- 'textnum' => $textArticles ?? [],
|
|
|
- ];
|
|
|
- if (isset($item['child']) && $item['child'] != 'undefined' && $item['child'] != "") {
|
|
|
- $parent_pinyin_str = is_string($parent_pinyin) ? $parent_pinyin . '/' : '';
|
|
|
- $childCategory = WebsiteCategory::where('pid', $parentCatId)->where($website)
|
|
|
- ->selectRaw("category_id, alias, CONCAT( ?, aLIas_pinyin) as aLIas_pinyin", [$parent_pinyin_str])
|
|
|
- ->get()->all();
|
|
|
- if (!empty($childCategory)) {
|
|
|
- list($childCatId, $childImgNum, $childTextNum) = explode(',', $item['child']);
|
|
|
- // 查询子栏目名称
|
|
|
- $childCategoryInfo = WebsiteCategory::where('category_id', $childCatId)->where($website)
|
|
|
+ $resultItem = [
|
|
|
+ 'alias' => $parent_alias ?? '',
|
|
|
+ 'category_id' => $parentCatId ?? 0,
|
|
|
+ 'pinyin' => $parent_pinyin ?? null,
|
|
|
+ 'imgnum' => $imgArticles ?? [],
|
|
|
+ 'textnum' => $textArticles ?? [],
|
|
|
+ ];
|
|
|
+ if(isset($item['child']) && $item['child'] != 'undefined' && $item['child'] != ""){
|
|
|
+ $parent_pinyin_str = is_string($parent_pinyin) ? $parent_pinyin.'/' : '';
|
|
|
+ $childCategory = WebsiteCategory::where('pid', $parentCatId)->where($website)
|
|
|
->selectRaw("category_id, alias, CONCAT( ?, aLIas_pinyin) as aLIas_pinyin", [$parent_pinyin_str])
|
|
|
- ->first();
|
|
|
- if (empty($childCategoryInfo) || ($childImgNum == 0 && $childTextNum == 0)) {
|
|
|
- $childImgArticles = [];
|
|
|
- $childTextArticles = [];
|
|
|
- $resultItem['child'] = [];
|
|
|
- } else {
|
|
|
- $child_pinyin = $childCategoryInfo->aLIas_pinyin ? $childCategoryInfo->aLIas_pinyin : null;
|
|
|
- // 查询子栏目图片新闻
|
|
|
- $childImgArticles = Article::where('catid', $childCatId)
|
|
|
- ->where('status', 1)
|
|
|
- ->where(function ($query) use ($website) {
|
|
|
- $query->where(function ($subQuery) use ($website) {
|
|
|
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0");
|
|
|
- })->orWhereNull("ignore_ids");
|
|
|
- })
|
|
|
- ->select(
|
|
|
- 'article.id',
|
|
|
- 'article.title',
|
|
|
- 'article.imgurl',
|
|
|
- 'article.author',
|
|
|
- 'article.updated_at',
|
|
|
- 'article.introduce',
|
|
|
- 'article.islink',
|
|
|
- 'article.linkurl',
|
|
|
- 'article.copyfrom',
|
|
|
- DB::raw("'$child_pinyin' as pinyin")
|
|
|
- )
|
|
|
- ->where('imgurl', '!=', '')
|
|
|
- ->orderBy('updated_at', 'desc')
|
|
|
- ->limit($childImgNum)
|
|
|
- ->get()->all();
|
|
|
- // 查询子栏目文字新闻
|
|
|
- $childTextArticles = Article::where('catid', $childCatId)
|
|
|
- ->where('status', 1)
|
|
|
- ->where(function ($query) use ($website) {
|
|
|
- $query->where(function ($subQuery) use ($website) {
|
|
|
- $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($website['website_id']) . "') = 0");
|
|
|
- })->orWhereNull("ignore_ids");
|
|
|
- })
|
|
|
- ->select(
|
|
|
- 'article.id',
|
|
|
- 'article.title',
|
|
|
- 'article.author',
|
|
|
- 'article.updated_at',
|
|
|
- 'article.introduce',
|
|
|
- 'article.islink',
|
|
|
- 'article.linkurl',
|
|
|
- 'article.copyfrom',
|
|
|
- DB::raw("'$child_pinyin' as pinyin")
|
|
|
- )
|
|
|
- ->orderBy('updated_at', 'desc')
|
|
|
- ->limit($childTextNum)
|
|
|
- ->get()->all();
|
|
|
- $resultItem['child'] = [
|
|
|
- 'alias' => $childCategoryInfo ? $childCategoryInfo->alias : null,
|
|
|
- 'category_id' => $childCatId,
|
|
|
- 'pinyin' => $childCategoryInfo->aLIas_pinyin ?? '',
|
|
|
- 'all_childcat' => $childCategory,
|
|
|
- 'imgnum' => $childImgArticles,
|
|
|
- 'textnum' => $childTextArticles,
|
|
|
- ];
|
|
|
+ ->get()->all();
|
|
|
+ if (!empty($childCategory)) {
|
|
|
+ list($childCatId, $childImgNum, $childTextNum) = explode(',', $item['child']);
|
|
|
+ // 查询子栏目名称
|
|
|
+ $childCategoryInfo = WebsiteCategory::where('category_id', $childCatId)->where($website)
|
|
|
+ ->selectRaw("category_id, alias, CONCAT( ?, aLIas_pinyin) as aLIas_pinyin", [$parent_pinyin_str])
|
|
|
+ ->first();
|
|
|
+ if(empty($childCategoryInfo) || ($childImgNum==0 && $childTextNum==0)){
|
|
|
+ $childImgArticles = [];
|
|
|
+ $childTextArticles = [];
|
|
|
+ $resultItem['child'] = [];
|
|
|
+ }else{
|
|
|
+ $child_pinyin = $childCategoryInfo->aLIas_pinyin? $childCategoryInfo->aLIas_pinyin : null;
|
|
|
+ // 查询子栏目图片新闻
|
|
|
+ $childImgArticles = Article::where('catid', $childCatId)
|
|
|
+ ->where('status', 1)
|
|
|
+ ->where(function ($query) use ($website) {
|
|
|
+ $query->where(function ($subQuery) use ($website) {
|
|
|
+ $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($website['website_id'])."') = 0");
|
|
|
+ })->orWhereNull("ignore_ids");
|
|
|
+ })
|
|
|
+ ->select(
|
|
|
+ 'article.id',
|
|
|
+ 'article.title',
|
|
|
+ 'article.imgurl',
|
|
|
+ 'article.author',
|
|
|
+ 'article.updated_at',
|
|
|
+ 'article.introduce',
|
|
|
+ 'article.islink',
|
|
|
+ 'article.linkurl',
|
|
|
+ 'article.copyfrom',
|
|
|
+ DB::raw("'$child_pinyin' as pinyin"))
|
|
|
+ ->where('imgurl', '!=', '')
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->limit($childImgNum)
|
|
|
+ ->get()->all();
|
|
|
+ // 查询子栏目文字新闻
|
|
|
+ $childTextArticles = Article::where('catid', $childCatId)
|
|
|
+ ->where('status', 1)
|
|
|
+ ->where(function ($query) use ($website) {
|
|
|
+ $query->where(function ($subQuery) use ($website) {
|
|
|
+ $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($website['website_id'])."') = 0");
|
|
|
+ })->orWhereNull("ignore_ids");
|
|
|
+ })
|
|
|
+ ->select(
|
|
|
+ 'article.id',
|
|
|
+ 'article.title',
|
|
|
+ 'article.author',
|
|
|
+ 'article.updated_at',
|
|
|
+ 'article.introduce',
|
|
|
+ 'article.islink',
|
|
|
+ 'article.linkurl',
|
|
|
+ 'article.copyfrom',
|
|
|
+ DB::raw("'$child_pinyin' as pinyin"))
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->limit($childTextNum)
|
|
|
+ ->get()->all();
|
|
|
+ $resultItem['child'] = [
|
|
|
+ 'alias' => $childCategoryInfo ? $childCategoryInfo->alias : null,
|
|
|
+ 'category_id' => $childCatId,
|
|
|
+ 'pinyin' => $childCategoryInfo->aLIas_pinyin ?? '',
|
|
|
+ 'all_childcat' => $childCategory,
|
|
|
+ 'imgnum' => $childImgArticles,
|
|
|
+ 'textnum' => $childTextArticles,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ // $resultItem['pinyin'] = $childCategoryInfo->aLIas_pinyin ?? '';
|
|
|
}
|
|
|
-
|
|
|
- // $resultItem['pinyin'] = $childCategoryInfo->aLIas_pinyin ?? '';
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $resultItem['child'] = [];
|
|
|
}
|
|
|
- } else {
|
|
|
- $resultItem['child'] = [];
|
|
|
- }
|
|
|
return $resultItem;
|
|
|
}, $data);
|
|
|
return Result::success($result);
|
|
|
- // return Result::success($data);
|
|
|
+ // return Result::success($data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -2099,6 +2100,800 @@ class NewsService implements NewsServiceInterface
|
|
|
return $article;
|
|
|
});
|
|
|
}
|
|
|
+ // 封装处理由问题
|
|
|
+ function processJob($job, $data) {
|
|
|
+ return $job->map(function ($job) use ($data) {
|
|
|
+ $category = $job->cat_arr_id?? '';
|
|
|
+ $cityid = $job->city_arr_id?? '';
|
|
|
+ $city = json_decode($cityid, true);
|
|
|
+ $pinyin = '';
|
|
|
+ $level = json_decode($category, true);
|
|
|
+ // 路由
|
|
|
+ if(!empty($level) && is_array($level)){
|
|
|
+ $pinyin = WebsiteCategory::whereIn('category_id', $level)
|
|
|
+ ->where('website_id', $data['website_id']) // 添加网站ID条件
|
|
|
+ ->orderByRaw('FIELD(category_id, '. implode(',', $level). ')')
|
|
|
+ ->get(['aLIas_pinyin'])
|
|
|
+ ->pluck('aLIas_pinyin')
|
|
|
+ ->implode('/');
|
|
|
+ if(empty($pinyin)){
|
|
|
+ $pinyin = $pinyin->aLIas_pinyin?? '';
|
|
|
+ }
|
|
|
+ $job->pinyin = $pinyin;
|
|
|
+ }
|
|
|
+ // 取城市-市??省
|
|
|
+ if(!empty($city) && is_array($city)){
|
|
|
+ if(isset($city[1] ) && !empty($city[1])){
|
|
|
+ $city = District::where('id', $city[1])->first(['name']);
|
|
|
+ $job->city_name = $city->name?? '';
|
|
|
+ }else if(isset($city[0] ) && !empty($city[0])){
|
|
|
+ $city = District::where('id', $city[0])->first(['name']);
|
|
|
+ $job->city_name = $city->name?? '';
|
|
|
+ }else{
|
|
|
+ $job->city_name = '全国';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 取公司地址
|
|
|
+ if(isset($job->address_arr_id) && !empty($job->address_arr_id)){
|
|
|
+ $address_id = json_decode($job->address_arr_id, true) ?? [];
|
|
|
+ if(is_array($address_id) && !empty($address_id)){
|
|
|
+ $address = District::whereIn('id', $address_id)
|
|
|
+ ->orderBy('level', 'asc')
|
|
|
+ ->get(['name'])
|
|
|
+ ->pluck('name')
|
|
|
+ ->implode('');
|
|
|
+ // $job->address_name = $address ?? '';
|
|
|
+ $job->address_name = ($address ?? '') . ($job->address ?? '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 取行业
|
|
|
+ if(!empty($job->hy_id) || !empty($job->industry) || !empty($job->company_hy_id)){
|
|
|
+ $hy_name = JobIndustry::when($job, function ($query) use ($job) {
|
|
|
+ if(!empty($job->industry)){
|
|
|
+ $query->where('hyid', $job->industry);
|
|
|
+ }else if(!empty($job->hy_id)){
|
|
|
+ $query->where('hyid', $job->hy_id);
|
|
|
+ }else{
|
|
|
+ $query->where('hyid', $job->company_hy_id);
|
|
|
+ }
|
|
|
+ })->first(['hyname']);
|
|
|
+ $job->hy_name = $hy_name->hyname?? '';
|
|
|
+ }
|
|
|
+ // 取职位
|
|
|
+ if((isset($job->zw_id) && !empty($job->zw_id)) || (isset($job->job) && !empty($job->job))){
|
|
|
+ $zwid = $job->job?? $job->zw_id;
|
|
|
+ $zw_name = JobPosition::where('zwid', $zwid)->first(['zwname']);
|
|
|
+ $job->zw_name = $zw_name->zwname?? '';
|
|
|
+ }
|
|
|
+ // 取具体职位
|
|
|
+ if((isset($job->jtzw_id) &&!empty($job->jtzw_id)) || (isset($job->job_name_get) && !empty($job->job_name_get))){
|
|
|
+ $jtzwid = $job->job_name_get ?? $job->jtzw_id;
|
|
|
+ $jtzw_name = JobPosition::where('zwid', $jtzwid)->first(['zwname']);
|
|
|
+ $job->jtzw_name = $jtzw_name->zwname?? '';
|
|
|
+ }
|
|
|
+ // 取工作经验
|
|
|
+ if(isset($job->experience) &&!empty($job->experience)){
|
|
|
+ $experience = JobEnum::where('egroup','years')->where('evalue',$job->experience)->first(['ename']);
|
|
|
+ $job->experience_name = $experience->ename?? '';
|
|
|
+ }
|
|
|
+ // 取学历
|
|
|
+ if(isset($job->educational) &&!empty($job->educational)){
|
|
|
+ $education = JobEnum::where('egroup','education')->where('evalue',$job->educational)->first(['ename']);
|
|
|
+ $job->education_name = $education->ename?? '';
|
|
|
+ }
|
|
|
+ // 语言
|
|
|
+ if(isset($job->language) &&!empty($job->language)){
|
|
|
+ $language = JobEnum::where('egroup','language')->where('evalue',$job->language)->first(['ename']);
|
|
|
+ $job->language_name = $language->ename?? '';
|
|
|
+ }
|
|
|
+ // 薪资
|
|
|
+ if(isset($job->salary) &&!empty($job->salary)){
|
|
|
+ $salary = JobEnum::where('egroup','income')->where('evalue',$job->salary)->first(['ename']);
|
|
|
+ $job->salary_name = $salary->ename?? '';
|
|
|
+ }
|
|
|
+ // 职位性质
|
|
|
+ if(isset($job->nature_id) &&!empty($job->nature_id)){
|
|
|
+ $job_nature = JobEnum::where('egroup','nature')->where('evalue',$job->nature_id)->first(['ename']);
|
|
|
+ $job->job_nature_name = $job_nature->ename?? '';
|
|
|
+ }
|
|
|
+ // 公司规模
|
|
|
+ if(isset($job->company_size) &&!empty($job->company_size)){
|
|
|
+ $company_size = JobEnum::where('egroup','cosize')->where('evalue',$job->company_size)->first(['ename']);
|
|
|
+ $job->company_size_name = $company_size->ename?? '';
|
|
|
+ }
|
|
|
+ // 公司性质
|
|
|
+ if(isset($job->company_nature) && !empty($job->company_nature)){
|
|
|
+ $company_nature = JobNature::where('id',$job->company_nature)->first(['nature_name']);
|
|
|
+ $job->company_nature_name = $company_nature->nature_name?? '';
|
|
|
+ }
|
|
|
+ // $job->pinyin = $pinyin;
|
|
|
+ return $job;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取书籍模块
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ * */
|
|
|
+ public function getWebsiteBook(array $data): array
|
|
|
+ {
|
|
|
+ $input['id'] = $data['id'];
|
|
|
+ $input['website_id'] = $data['website_id'];
|
|
|
+ // 将 JSON 字符串转换为 PHP 数组
|
|
|
+ $data = json_decode($input['id'], true);
|
|
|
+ // 使用 array_map 处理每个元素
|
|
|
+ $result = array_map(function ($item) use ($input) {
|
|
|
+ // 检查parent元素是否存在且不是undefined
|
|
|
+ if (isset($item['parent']) && $item['parent'] != 'undefined' && $item['parent']!= "") {
|
|
|
+ list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
|
|
|
+ $website = [
|
|
|
+ 'website_id' => $input['website_id'],
|
|
|
+ ];
|
|
|
+ // 查询栏目名称
|
|
|
+ $category = WebsiteCategory::where('category_id', $parentCatId)->where($website)->first(['alias', 'category_id','aLIas_pinyin']);
|
|
|
+ if(empty($category)){
|
|
|
+ $parent_alias = '';
|
|
|
+ $parent_pinyin = null;
|
|
|
+ $imgBooks = [];
|
|
|
+ $textBooks = [];
|
|
|
+ }else{
|
|
|
+ $parent_alias = $category->alias ?? '';
|
|
|
+ $parent_pinyin = $category->aLIas_pinyin ? $category->aLIas_pinyin : null;
|
|
|
+ // 查找子分类ID数组
|
|
|
+ $childCategoryIds = WebsiteCategory::where('pid', $parentCatId)->where($website)->pluck('category_id')->toArray();
|
|
|
+ array_push($childCategoryIds,$parentCatId);
|
|
|
+ $childCategoryIds = json_encode(array_values(array_unique($childCategoryIds)));
|
|
|
+ if($parentImgNum!=0){
|
|
|
+ // 查询图片新闻
|
|
|
+ $imgBooks = Book::where(function($query) use ($parentCatId) {
|
|
|
+ $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
|
|
|
+ ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
|
|
|
+ })
|
|
|
+ ->where('book.status', 2)
|
|
|
+ ->where('book.img_url', '!=', '')
|
|
|
+ ->leftJoin('website_category', function($join) use ($website) {
|
|
|
+ $join->on('book.catid', '=', 'website_category.category_id')
|
|
|
+ ->where('website_category.website_id', '=', $website['website_id']);
|
|
|
+ })
|
|
|
+ ->select(
|
|
|
+ 'book.id',
|
|
|
+ 'book.title',
|
|
|
+ 'book.img_url',
|
|
|
+ 'book.price',
|
|
|
+ 'book.market_price',
|
|
|
+ 'book.description',
|
|
|
+ 'book.catid',
|
|
|
+ 'book.description',
|
|
|
+ 'book.updated_at',
|
|
|
+ 'website_category.alias as category_name',
|
|
|
+ DB::raw("CASE WHEN book.catid = $parentCatId THEN '$parent_pinyin'
|
|
|
+ ELSE CONCAT('$parent_pinyin', '/', website_category.aLIas_pinyin) END as pinyin")
|
|
|
+ )
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->limit($parentImgNum)
|
|
|
+ ->get()->all();
|
|
|
+ // 查询文字新闻
|
|
|
+ }
|
|
|
+ if($parentTextNum!=0){
|
|
|
+ $textBooks = [];
|
|
|
+ $textBooks = Book::where(function($query) use ($parentCatId) {
|
|
|
+ $query->whereRaw("JSON_CONTAINS(cat_arr_id, '\"$parentCatId\"')")
|
|
|
+ ->orWhereRaw("JSON_CONTAINS(cat_arr_id, '$parentCatId')");
|
|
|
+ })
|
|
|
+ ->where('book.status', 2)
|
|
|
+ ->leftJoin('website_category', function($join) use ($website) {
|
|
|
+ $join->on('book.catid', '=', 'website_category.category_id')
|
|
|
+ ->where('website_category.website_id', '=', $website['website_id']);
|
|
|
+ })
|
|
|
+ ->select(
|
|
|
+ 'book.id',
|
|
|
+ 'book.title',
|
|
|
+ 'book.img_url',
|
|
|
+ 'book.price',
|
|
|
+ 'book.market_price',
|
|
|
+ 'book.description',
|
|
|
+ 'book.catid',
|
|
|
+ 'book.description',
|
|
|
+ 'book.updated_at',
|
|
|
+ 'website_category.alias as category_name',
|
|
|
+ DB::raw("CASE WHEN book.catid = $parentCatId THEN '$parent_pinyin'
|
|
|
+ ELSE CONCAT('$parent_pinyin', '/', website_category.aLIas_pinyin) END as pinyin")
|
|
|
+ )
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->limit($parentTextNum)
|
|
|
+ ->get()->all();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $resultItem = [
|
|
|
+ 'alias' => $parent_alias ?? '',
|
|
|
+ 'category_id' => $parentCatId ?? 0,
|
|
|
+ 'pinyin' => $parent_pinyin ?? null,
|
|
|
+ 'imgnum' => $imgBooks ?? [],
|
|
|
+ 'textnum' => $textBooks ?? [],
|
|
|
+ ];
|
|
|
+ if(isset($item['child']) && $item['child'] != 'undefined' && $item['child'] != ""){
|
|
|
+ $parent_pinyin_str = is_string($parent_pinyin) ? $parent_pinyin.'/' : '';
|
|
|
+ $childCategory = WebsiteCategory::where('pid', $parentCatId)->where($website)
|
|
|
+ ->selectRaw("category_id, alias, CONCAT( ?, aLIas_pinyin) as aLIas_pinyin", [$parent_pinyin_str])
|
|
|
+ ->get()->all();
|
|
|
+ if (!empty($childCategory)) {
|
|
|
+ list($childCatId, $childImgNum, $childTextNum) = explode(',', $item['child']);
|
|
|
+ // 查询子栏目名称
|
|
|
+ $childCategoryInfo = WebsiteCategory::where('category_id', $childCatId)->where($website)
|
|
|
+ ->selectRaw("category_id, alias, CONCAT( ?, aLIas_pinyin) as aLIas_pinyin", [$parent_pinyin_str])
|
|
|
+ ->first();
|
|
|
+ if(empty($childCategoryInfo) || ($childImgNum==0 && $childTextNum==0)){
|
|
|
+ $childImgArticles = [];
|
|
|
+ $childTextArticles = [];
|
|
|
+ $resultItem['child'] = [];
|
|
|
+ }else{
|
|
|
+ $child_pinyin = $childCategoryInfo->aLIas_pinyin? $childCategoryInfo->aLIas_pinyin : null;
|
|
|
+ // 查询子栏目图片新闻
|
|
|
+ $childImgArticles = Book::where('catid', $childCatId)
|
|
|
+ ->where('status', 2)
|
|
|
+ ->where('img_url', '!=', '')
|
|
|
+ ->leftJoin('website_category', function($join) use ($website) {
|
|
|
+ $join->on('book.catid', '=', 'website_category.category_id')
|
|
|
+ ->where('website_category.website_id', '=', $website['website_id']);
|
|
|
+ })
|
|
|
+ ->select(
|
|
|
+ 'book.id',
|
|
|
+ 'book.title',
|
|
|
+ 'book.img_url',
|
|
|
+ 'book.price',
|
|
|
+ 'book.market_price',
|
|
|
+ 'book.description',
|
|
|
+ 'book.catid',
|
|
|
+ 'book.description',
|
|
|
+ 'book.updated_at',
|
|
|
+ DB::raw("'$child_pinyin' as pinyin"))
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->limit($childImgNum)
|
|
|
+ ->get()->all();
|
|
|
+ // 查询子栏目文字新闻
|
|
|
+ $childTextArticles = Book::where('catid', $childCatId)
|
|
|
+ ->where('status', 2)
|
|
|
+ ->leftJoin('website_category', function($join) use ($website) {
|
|
|
+ $join->on('book.catid', '=', 'website_category.category_id')
|
|
|
+ ->where('website_category.website_id', '=', $website['website_id']);
|
|
|
+ })
|
|
|
+ ->select(
|
|
|
+ 'book.id',
|
|
|
+ 'book.title',
|
|
|
+ 'book.img_url',
|
|
|
+ 'book.price',
|
|
|
+ 'book.market_price',
|
|
|
+ 'book.description',
|
|
|
+ 'book.catid',
|
|
|
+ 'book.description',
|
|
|
+ 'book.updated_at',
|
|
|
+ DB::raw("'$child_pinyin' as pinyin"))
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->limit($childTextNum)
|
|
|
+ ->get()->all();
|
|
|
+ $resultItem['child'] = [
|
|
|
+ 'alias' => $childCategoryInfo ? $childCategoryInfo->alias : null,
|
|
|
+ 'category_id' => $childCatId,
|
|
|
+ 'pinyin' => $childCategoryInfo->aLIas_pinyin ?? '',
|
|
|
+ 'all_childcat' => $childCategory,
|
|
|
+ 'imgnum' => $childImgArticles,
|
|
|
+ 'textnum' => $childTextArticles,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $resultItem['child'] = [];
|
|
|
+ }
|
|
|
+ return $resultItem;
|
|
|
+ }, $data);
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取书刊列表
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ * */
|
|
|
+ public function getWebsiteBookList(array $data): array
|
|
|
+ {
|
|
|
+ $web = Website::where('id', $data['website_id'])->first(['id','website_name']);
|
|
|
+ if(empty($web)){
|
|
|
+ return Result::error("查询失败", 0);
|
|
|
+ }
|
|
|
+ $catid = $data['id'];
|
|
|
+ // 此处代码在原逻辑中会依赖外部变量 $data、$catid,需确保这些变量在作用域内
|
|
|
+ $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id',$catid)->orderBy('sort')->first(['pid','category_id','aLias_pinyin']);
|
|
|
+ $parent_categpory = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id',$category['pid'])->orderBy('sort')->first(['aLias_pinyin']);
|
|
|
+ $parent_pinyin = $parent_categpory ? $parent_categpory->aLias_pinyin ?? '' : '';
|
|
|
+ $category_pinyin = $category ? $category->aLias_pinyin : '';
|
|
|
+ $pinyin = $parent_pinyin . '/' . $category_pinyin ;
|
|
|
+ $categorys = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ ->where('pid',$category['pid'])
|
|
|
+ ->select(
|
|
|
+ '*',
|
|
|
+ DB::raw("CONCAT('$parent_pinyin', '/', aLIas_pinyin) as pinyin")
|
|
|
+ )
|
|
|
+ ->orderBy('sort')
|
|
|
+ ->get()->all();
|
|
|
+ if(empty($category)){
|
|
|
+ return Result::error("查询失败", 0);
|
|
|
+ }
|
|
|
+ $query = Book::where('book.status', 2)
|
|
|
+ ->where('book.website_id', $data['website_id'])
|
|
|
+ ->where('book.catid', $catid)
|
|
|
+ ->select(
|
|
|
+ 'book.id',
|
|
|
+ 'book.title',
|
|
|
+ 'book.img_url',
|
|
|
+ 'book.description',
|
|
|
+ 'book.updated_at',
|
|
|
+ 'book.catid',
|
|
|
+ DB::raw("'$pinyin' as pinyin")
|
|
|
+ )
|
|
|
+ ->orderBy('book.updated_at', 'desc');
|
|
|
+ $count = $query->count();
|
|
|
+ $query = clone $query;
|
|
|
+ $Book = $query
|
|
|
+ ->limit($data['pageSize'])
|
|
|
+ ->offset(($data['page']-1)*$data['pageSize'])
|
|
|
+ ->get()->all();
|
|
|
+ if(empty($Book)){
|
|
|
+ return Result::error("查询失败", 0);
|
|
|
+ }
|
|
|
+ $result = [
|
|
|
+ 'category' => $categorys,
|
|
|
+ 'books' => $Book,
|
|
|
+ 'count' =>$count,
|
|
|
+ ];
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取书刊详情
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ * */
|
|
|
+ public function getWebsiteBookInfo(array $data): array
|
|
|
+ {
|
|
|
+ $web = Website::where('id', $data['website_id'])->first(['id','website_name']);
|
|
|
+ if(empty($web)){
|
|
|
+ return Result::error("查询失败", 0);
|
|
|
+ }
|
|
|
+ $category = WebsiteCategory::where('website_id', $data['website_id'])->where('pid',$data['id'])->orderBy('sort')->first(['pid','category_id']);
|
|
|
+ if(empty($category)){
|
|
|
+ return Result::error("查询失败", 0);
|
|
|
+ }
|
|
|
+ $book = Book::where('status', 2)
|
|
|
+ ->where('website_id', $data['website_id'])
|
|
|
+ ->where('id', $data['id'])
|
|
|
+ ->select(
|
|
|
+ 'book.*',
|
|
|
+ )
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->first();
|
|
|
+ if(empty($book)){
|
|
|
+ return Result::error("查询失败", 0);
|
|
|
+ }
|
|
|
+ $categorys = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ ->where('pid',$category['pid'])
|
|
|
+ ->select('category_id','alias','aLIas_pinyin')
|
|
|
+ ->orderBy('sort')->get()->all();
|
|
|
+ $result = [
|
|
|
+ 'category' => $categorys,
|
|
|
+ 'books' => $book,
|
|
|
+ ];
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 尝试
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ * */
|
|
|
+ public function test(array $data): array
|
|
|
+ {
|
|
|
+ $input['id'] = $data['id'];
|
|
|
+ $input['website_id'] = $data['website_id'];
|
|
|
+ // 将 JSON 字符串转换为 PHP 数组
|
|
|
+ $data = json_decode($input['id'], true);
|
|
|
+ $result = [];
|
|
|
+ $article = $data;
|
|
|
+ $result = array_map(function ($item) use ($input) {
|
|
|
+ $website = [
|
|
|
+ 'website_id' => $input['website_id'],
|
|
|
+ ];
|
|
|
+ list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['parent']);
|
|
|
+ $category = WebsiteCategory::where('pid', $parentCatId)->where($website)->first(['alias', 'category_id','aLIas_pinyin']);
|
|
|
+ $parent = [
|
|
|
+ 0 => $category['category_id'] ?? [],
|
|
|
+ 1 => $parentImgNum?? [],
|
|
|
+ 2 => $parentTextNum?? [],
|
|
|
+ ];
|
|
|
+ list($parentCatId, $parentImgNum, $parentTextNum) = explode(',', $item['child']);
|
|
|
+ $child = [];
|
|
|
+
|
|
|
+ $resultItem = [
|
|
|
+ // 'alias' => $parent_alias ?? '',
|
|
|
+ 'category_id' => $parentCatId ?? 0,
|
|
|
+ 'pinyin' => $parentImgNum ?? null,
|
|
|
+ 'imgnum' => $parentTextNum ?? [],
|
|
|
+ // 'textnum' => $textArticles ?? [],
|
|
|
+ ]; return $parent;
|
|
|
+ }, $data);
|
|
|
+ return Result::success($result);
|
|
|
+ // });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 封装处理文章的路由问题
|
|
|
+ * */
|
|
|
+ function processArticle($article, $data) {
|
|
|
+ $article['img'] = Article::where('article.status', 1)
|
|
|
+ ->whereIn('article.id', $$article[0])
|
|
|
+ ->where(function ($query) use ($data) {
|
|
|
+ $query->where(function ($subQuery) use ($data) {
|
|
|
+ $subQuery->whereRaw("JSON_CONTAINS(ignore_ids, '".intval($data['website_id'])."') = 0");
|
|
|
+ })->orWhereNull("ignore_ids");
|
|
|
+ })
|
|
|
+ ->select(
|
|
|
+ 'article.id',
|
|
|
+ 'article.title',
|
|
|
+ 'article.imgurl',
|
|
|
+ 'article.author',
|
|
|
+ );
|
|
|
+ return $article->map(function ($article) use ($data) {
|
|
|
+ $catid = $article->cat_arr_id?? '';
|
|
|
+ $level = json_decode($catid, true);
|
|
|
+ $pinyin = '';
|
|
|
+ $category = WebsiteCategory::where('category_id', $catid)->where('website_id', $data['website_id'])->first();
|
|
|
+ if (!empty($category->pid) && $category->pid!= 0) {
|
|
|
+ $pinyin = WebsiteCategory::whereIn('category_id', $level)
|
|
|
+ ->orderByRaw('FIELD(category_id, '. implode(',', $level). ')')
|
|
|
+ ->get(['aLIas_pinyin'])
|
|
|
+ ->pluck('aLIas_pinyin')
|
|
|
+ ->implode('/');
|
|
|
+ } else {
|
|
|
+ $pinyin = $category->aLIas_pinyin ?? '';
|
|
|
+ }
|
|
|
+ $article->pinyin = $pinyin;
|
|
|
+ return $article;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * c端-获取招工招聘
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ * */
|
|
|
+ public function getWebsiteJob(array $data): array
|
|
|
+ {
|
|
|
+ $web = Website::where('id', $data['website_id'])->first();
|
|
|
+ if(empty($web)){
|
|
|
+ return Result::error("该网站不存在", 0);
|
|
|
+ }
|
|
|
+ $job_hunting = JobHunting::where('job_hunting.status', 2)
|
|
|
+ ->where('job_hunting.website_id', $data['website_id'])
|
|
|
+ ->when(isset($data['city_id']) &&!empty($data['city_id']), function ($query) use ($data) {
|
|
|
+ $query->where(function($q) use ($data) {
|
|
|
+ $q->WhereRaw("JSON_CONTAINS(job_hunting.city_arr_id, '". intval($data['city_id']). "') = 1");
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->select('job_hunting.id','job_hunting.cat_arr_id','job_hunting.job','job_hunting.industry',
|
|
|
+ 'job_hunting.city_arr_id','job_hunting.experience','job_hunting.updated_at')
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->limit($data['job1_num'])
|
|
|
+ ->get();
|
|
|
+ $web['website_id'] = $data['website_id'];
|
|
|
+ if(empty($job_hunting)){
|
|
|
+ $job_huntings = "未查询到相关简历信息";
|
|
|
+ }else{
|
|
|
+ $job_huntings = $this->processJob($job_hunting, $web);
|
|
|
+ }
|
|
|
+ $job_recruiting = JobRecruiting::where('job_recruiting.status', 1)
|
|
|
+ ->where('job_recruiting.website_id', $data['website_id'])
|
|
|
+ ->when(isset($data['city_id']) &&!empty($data['city_id']), function ($query) use ($data) {
|
|
|
+ $query->where(function($q) use ($data) {
|
|
|
+ $q->WhereRaw("JSON_CONTAINS(job_recruiting.city_arr_id, '". intval($data['city_id']). "') = 1");
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
|
|
|
+ ->select('job_recruiting.id','job_recruiting.cat_arr_id','job_recruiting.title',
|
|
|
+ 'job_recruiting.jtzw_id','job_recruiting.hy_id','job_recruiting.city_arr_id',
|
|
|
+ 'job_recruiting.due_data','job_recruiting.updated_at','job_recruiting.experience',
|
|
|
+ 'job_recruiting.educational','job_company.business_name',)
|
|
|
+ ->orderBy('updated_at', 'desc')
|
|
|
+ ->limit($data['job2_num'])
|
|
|
+ ->get();
|
|
|
+ if(empty($job_recruiting->toArray())){
|
|
|
+ $job_recruitings = "未查询到相关职位信息";
|
|
|
+ }else{
|
|
|
+ $job_recruitings = $this->processJob($job_recruiting, $web);
|
|
|
+ }
|
|
|
+ $hy = JobIndustry::get()->all();
|
|
|
+ $zw = JobPosition::where('zwpid',0)->get()->all();
|
|
|
+ $jtzw = JobPosition::where('zwpid','!=',0)->get()->all();
|
|
|
+ $result = [
|
|
|
+ 'job_hunting' => $job_huntings,
|
|
|
+ 'job_recuiting' => $job_recruitings,
|
|
|
+ 'hy' => $hy,
|
|
|
+ 'zw' => $zw,
|
|
|
+ 'jtzw' => $jtzw,
|
|
|
+ ];
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * c端-获取招工招聘列表
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ * */
|
|
|
+ public function getWebsiteJobList(array $data): array
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ $web = Website::where('id', $data['website_id'])->first(['id','website_name']);
|
|
|
+ if(empty($web)){
|
|
|
+ return Result::error("此网站不存在", 0);
|
|
|
+ }
|
|
|
+ $website_id['website_id'] = $data['website_id'];
|
|
|
+ if(isset($data['hy_id']) && !empty($data['hy_id'])){
|
|
|
+ array_push($where, ['hy_id',$data['hy_id']]);
|
|
|
+ }
|
|
|
+ if(isset($data['zw_id']) && !empty($data['zw_id'])){
|
|
|
+ array_push($where, ['zw_id',$data['zw_id']]);
|
|
|
+ }
|
|
|
+ if(isset($data['jtzw_id']) &&!empty($data['jtzw_id'])){
|
|
|
+ array_push($where, ['jtzw_id',$data['jtzw_id']]);
|
|
|
+ }
|
|
|
+ $query = JobRecruiting::where('job_recruiting.status', 1)
|
|
|
+ ->where('job_recruiting.website_id', $data['website_id'])
|
|
|
+ ->where($where)
|
|
|
+ ->when(isset($data['city_id']) &&!empty($data['city_id']), function ($query) use ($data) {
|
|
|
+ $query->where(function($q) use ($data) {
|
|
|
+ $q->WhereRaw("JSON_CONTAINS(job_recruiting.city_arr_id, '". intval($data['city_id']). "') = 1");
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->when(isset($data['catid_id']) &&!empty($data['catid_id']), function ($query) use ($data) {
|
|
|
+ $query->where(function($q) use ($data) {
|
|
|
+ $q->WhereRaw("JSON_CONTAINS(job_recruiting.cat_arr_id, '". intval($data['catid_id']). "') = 1");
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->leftJoin('job_company', 'job_recruiting.id', '=', 'job_company.job_id')
|
|
|
+ ->select('job_recruiting.id','job_recruiting.hy_id','job_recruiting.title','job_recruiting.zw_id',
|
|
|
+ 'job_recruiting.jtzw_id','job_recruiting.city_arr_id','job_recruiting.due_data',
|
|
|
+ 'job_recruiting.cat_arr_id','job_recruiting.updated_at')
|
|
|
+ ->orderBy('updated_at', 'desc');
|
|
|
+ $recruit_count = $query->count();
|
|
|
+ $query = clone $query;
|
|
|
+ $JobRecruiting = $query
|
|
|
+ ->offset(($data['page']-1)*$data['pageSize'])
|
|
|
+ ->limit($data['pageSize'])
|
|
|
+ ->get();
|
|
|
+ if(empty($JobRecruiting)){
|
|
|
+ $JobRecruiting = "暂无相关职位信息";
|
|
|
+ }else{
|
|
|
+ $JobRecruiting = $this->processJob($JobRecruiting, $website_id);
|
|
|
+ }
|
|
|
+ $query = JobHunting::where('status', 2)
|
|
|
+ ->where('job_hunting.website_id', $data['website_id'])
|
|
|
+ ->where($where)
|
|
|
+ ->when(isset($data['city_id']) &&!empty($data['city_id']), function ($query) use ($data) {
|
|
|
+ $query->where(function($q) use ($data) {
|
|
|
+ $q->WhereRaw("JSON_CONTAINS(job_hunting.city_arr_id, '". intval($data['city_id']). "') = 1");
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->when(isset($data['catid_id']) &&!empty($data['catid_id']), function ($query) use ($data) {
|
|
|
+ $query->where(function($q) use ($data) {
|
|
|
+ $q->WhereRaw("JSON_CONTAINS(job_hunting.cat_arr_id, '". intval($data['catid_id']). "') = 1");
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->select('id','sexy','experience','origin','industry','name','job','job_name_get','city_arr_id','cat_arr_id','created_at','updated_at')
|
|
|
+ ->orderBy('updated_at', 'desc');
|
|
|
+ $hunt_count = $query->count();
|
|
|
+ $query = clone $query;
|
|
|
+ $JobHunting = $query
|
|
|
+ ->offset(($data['page']-1)*$data['pageSize'])
|
|
|
+ ->limit($data['pageSize'])
|
|
|
+ ->get();
|
|
|
+ if(empty($JobHunting)){
|
|
|
+ $JobRecruiting = "暂无相关简历信息";
|
|
|
+ }else{
|
|
|
+ $JobHunting = $this->processJob($JobHunting, $website_id);
|
|
|
+ }
|
|
|
+ $result = [
|
|
|
+ 'JobRecruiting' => $JobRecruiting,
|
|
|
+ 'recruit_count' =>$recruit_count,
|
|
|
+ 'JobHunting' => $JobHunting,
|
|
|
+ 'hunt_count' =>$hunt_count,
|
|
|
+ ];
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * c端-获取招工招聘详情
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ * */
|
|
|
+ public function getWebsiteJobInfo(array $data): array
|
|
|
+ {
|
|
|
+ $web = Website::where('id', $data['website_id'])->first(['id','website_name']);
|
|
|
+ if(empty($web)){
|
|
|
+ return Result::error("该网站不存在", 0);
|
|
|
+ }
|
|
|
+ $webid = [
|
|
|
+ 'website_id' => $data['website_id'],
|
|
|
+ ];
|
|
|
+ // 职位相关信息
|
|
|
+ if($data['type']==1){
|
|
|
+ $query = JobRecruiting::where('status', 1)
|
|
|
+ ->where('website_id', $data['website_id'])
|
|
|
+ ->select('*');
|
|
|
+ $job = $query->where('job_recruiting.id', $data['id'])->get();
|
|
|
+ $company = JobCompany::where('job_id', $data['id'])->select('id','business_name','company_hy_id','company_size','company_nature','address_arr_id','address')->get();
|
|
|
+ if(!empty($company)){
|
|
|
+ $result['company'] = $this->processJob($company, $webid);
|
|
|
+ }
|
|
|
+
|
|
|
+ $other_job =JobRecruiting::where('status', 1)
|
|
|
+ ->where('website_id', $data['website_id'])
|
|
|
+ ->select('title','id','updated_at','cat_arr_id','user_id')
|
|
|
+ ->where('id','!=',$data['id'])
|
|
|
+ ->where('user_id', '=', $job[0]['user_id'])
|
|
|
+ ->limit($data['pageSize'])
|
|
|
+ ->get();
|
|
|
+ if(!empty($other_job)){
|
|
|
+ $result['other_job'] = $this->processJob($other_job, $webid);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $job = JobHunting::where('job_hunting.status', 2)
|
|
|
+ ->where('job_hunting.website_id', $data['website_id'])
|
|
|
+ ->where('job_hunting.id', $data['id'])
|
|
|
+ ->leftJoin('user', 'user.id', '=', 'job_hunting.user_id')
|
|
|
+ ->select('job_hunting.*','user_name')
|
|
|
+ ->get();
|
|
|
+ $resume = JobRemuse::where('hunt_id',$data['id'])->get();
|
|
|
+ if(!empty($resume->toArray())){
|
|
|
+ $result['resume'] = 1;
|
|
|
+ } else{
|
|
|
+ $result['resume'] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(empty($job->toArray())){
|
|
|
+ return Result::error("id参数错误", 0);
|
|
|
+ }
|
|
|
+ $result['job'] = $this->processJob($job, $webid);
|
|
|
+ // 返现对应的栏目
|
|
|
+ $catid = json_decode($job[0]['cat_arr_id'],true) ?? '';
|
|
|
+ $category = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ ->whereIn('category_id', $catid)
|
|
|
+ ->select('category_id','alias','aLIas_pinyin','pid')
|
|
|
+ ->orderBy('pid')->get()->all();
|
|
|
+ if(!empty($category)){
|
|
|
+ $result['category'] = $category;
|
|
|
+ }
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("参数错误", 0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * c端-申请职位
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ * */
|
|
|
+ public function getWebsiteJobApply(array $data): array
|
|
|
+ {
|
|
|
+ // 首先验证网站是否存在
|
|
|
+ // return Result::success($data);
|
|
|
+ $web = Website::where('id', $data['website_id'])->first(['id','website_name']);
|
|
|
+ if(empty($web)){
|
|
|
+ return Result::error("该网站不存在", 0);
|
|
|
+ }
|
|
|
+ // 验证用户是否存在且为个人会员/管理员
|
|
|
+ $user = User::where('id', $data['user_id'])->first(['id','type_id']);
|
|
|
+ // 1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)
|
|
|
+ if(empty($user) || ($user['type_id'] != 1 && $user['type_id'] != 10000)){
|
|
|
+ return Result::error("用户不存在", 0);
|
|
|
+ }
|
|
|
+ // 去除重复元素和空元素,并保持原始顺序
|
|
|
+ $data['recruit_id'] = array_values(array_filter(array_unique($data['recruit_id']), function($value) {
|
|
|
+ return !empty($value);
|
|
|
+ }));
|
|
|
+ // 验证职位是否存在 1:审核通过
|
|
|
+ $recruiting = JobRecruiting::where('status', 1)
|
|
|
+ ->where('website_id', $data['website_id'])
|
|
|
+ ->whereIn('id',$data['recruit_id'])
|
|
|
+ ->get(['id as recruit_id','user_id as receiver_id'])->all();
|
|
|
+ if(empty($recruiting)){
|
|
|
+ return Result::error("该职位不存在", 0);
|
|
|
+ }
|
|
|
+ // 简历是否存在
|
|
|
+ $hunt_id = JobHunting::where('user_id', $data['user_id'])->where('status',2)->first(['id as hunt_id']);
|
|
|
+ if(empty($hunt_id)){
|
|
|
+ return Result::error("该简历不存在", 0);
|
|
|
+ }
|
|
|
+ $data['hunt_id'] = $hunt_id['hunt_id'];
|
|
|
+ // // 验证是否已投递过该职位
|
|
|
+ $apply = JobApply::where('user_id', $data['user_id'])
|
|
|
+ ->where('hunt_id', $data['hunt_id'])
|
|
|
+ ->where('website_id',$data['website_id'])
|
|
|
+ ->whereIn('recruit_id',$data['recruit_id'])
|
|
|
+ ->get(['recruit_id']);
|
|
|
+ if(!empty($apply->toArray())){
|
|
|
+ return Result::error("您已投递过该职位!");
|
|
|
+ }
|
|
|
+ $insertData = array_map(function($recruiting) use ($data) {
|
|
|
+ return [
|
|
|
+ 'user_id' => $data['user_id'],
|
|
|
+ 'hunt_id' => $data['hunt_id'],
|
|
|
+ 'website_id' => $data['website_id'],
|
|
|
+ 'recruit_id' => $recruiting['recruit_id'],
|
|
|
+ 'receiver_id' => $recruiting['receiver_id'],
|
|
|
+ 'status' => 1,
|
|
|
+ ];
|
|
|
+ }, $recruiting);
|
|
|
+
|
|
|
+ // 批量插入数据
|
|
|
+ $result = JobApply::insert($insertData);
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("投递失败", 0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 招工招聘-沟通简历
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ * */
|
|
|
+ public function getWebsiteJobResume(array $data): array
|
|
|
+ {
|
|
|
+ // 首先验证网站是否存在
|
|
|
+ $web = Website::where('id', $data['website_id'])->first(['id','website_name']);
|
|
|
+ if(empty($web)){
|
|
|
+ return Result::error("该网站不存在", 0);
|
|
|
+ }
|
|
|
+ // return Result::success($data);
|
|
|
+ // 验证用户是否存在且为企业会员/管理员
|
|
|
+ $user = User::where('id', $data['user_id'])->first(['id','type_id']);
|
|
|
+ // 1:个人会员 2:政务会员 3:企业会员 4:调研员 10000:管理员 20000:游客(小程序)
|
|
|
+ if(empty($user) || ($user['type_id']!= 3 && $user['type_id']!= 10000)){
|
|
|
+ return Result::error("用户不存在", 0);
|
|
|
+ }
|
|
|
+ // 去除重复元素和空元素,并保持原始顺序
|
|
|
+ $data['hunt_id'] = array_values(array_filter(array_unique($data['hunt_id']), function($value) {
|
|
|
+ return !empty($value);
|
|
|
+ }));
|
|
|
+ // 验证简历是否存在
|
|
|
+ $hunting = JobHunting::where('status', 2)
|
|
|
+ ->where('website_id', $data['website_id'])
|
|
|
+ ->whereIn('id',$data['hunt_id'])
|
|
|
+ ->get(['id as hunt_id','user_id as receiver_id'])->all();
|
|
|
+ if(empty($hunting)){
|
|
|
+ return Result::error("该简历不存在", 0);
|
|
|
+ }
|
|
|
+ // 验证是否已沟通过该简历
|
|
|
+ $remuse = JobRemuse::where('user_id', $data['user_id'])
|
|
|
+ ->where('recruit_id', $data['recruit_id'])
|
|
|
+ ->where('website_id',$data['website_id'])
|
|
|
+ ->whereIn('hunt_id',$data['hunt_id'])
|
|
|
+ ->get(['hunt_id']);
|
|
|
+ if(!empty($remuse->toArray())){
|
|
|
+ return Result::error("您已沟通过该简历!");
|
|
|
+ }
|
|
|
+ // 准备要插入的数据数组
|
|
|
+ $insertData = array_map(function($hunting) use ($data) {
|
|
|
+ return [
|
|
|
+ 'user_id' => $data['user_id'],
|
|
|
+ 'recruit_id' => $data['recruit_id'],
|
|
|
+ 'website_id' => $data['website_id'],
|
|
|
+ 'hunt_id' => $hunting['hunt_id'],
|
|
|
+ 'receiver_id' => $hunting['receiver_id'],
|
|
|
+ 'status' => 1,
|
|
|
+ ];
|
|
|
+ }, $hunting);
|
|
|
+
|
|
|
+ // 批量插入数据
|
|
|
+ $result = JobRemuse::insert($insertData);
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("沟通失败", 0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
/**
|
|
|
* 验证导航名称是否重复
|
|
|
* @return void
|