|
|
@@ -916,13 +916,27 @@ class NewsService implements NewsServiceInterface
|
|
|
public function getWebsiteArticlett(array $data): array
|
|
|
{
|
|
|
$website_id = $data['website_id'];
|
|
|
+ $website = Website::where('id', $data['website_id'])->first();
|
|
|
+ if(empty($website)){
|
|
|
+ return Result::error("网站不存在",0);
|
|
|
+ }
|
|
|
$categorys = $this->processArticlePro($website_id);
|
|
|
$catiall = $categorys['catiall'];
|
|
|
$categoryIds = $categorys['categoryIds'];
|
|
|
$where = [
|
|
|
'status' => 1
|
|
|
];
|
|
|
- $website_id = $data['website_id'];
|
|
|
+ // $website_column = $website['column'];
|
|
|
+ if(!empty($website['website_column_arr_id']) && $website['website_column_arr_id'] != '[]'){
|
|
|
+ $website_column = json_decode($website['website_column_arr_id'],true);
|
|
|
+ }
|
|
|
+ $diff_pid_categoryIds = array_values($categorys['diff_pid_categoryIds']);
|
|
|
+ // return Result::success($diff_pid_categoryIds);
|
|
|
+ if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
|
|
|
+ return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // $website_id = $data['website_id'];
|
|
|
$month = date("Y-m-d H:i:s", strtotime("-30 day"));
|
|
|
//如果是4:最新资讯(数据库已不存在) 5:资讯推荐(数据库已不存在);
|
|
|
// 1:头条资讯;2:轮播图;6:热点资讯;(数据库)
|
|
|
@@ -1018,6 +1032,7 @@ class NewsService implements NewsServiceInterface
|
|
|
->get()->all();
|
|
|
foreach ($result['text'] as $k => $v) {
|
|
|
$result['text'][$k]->pinyin = $catiall[$v->catid]['pinyin'];
|
|
|
+ $result['text'][$k]->alias = $catiall[$v->catid]['alias'];
|
|
|
}
|
|
|
}
|
|
|
if ($data['imgnum'] > 0) {
|
|
|
@@ -1044,6 +1059,7 @@ class NewsService implements NewsServiceInterface
|
|
|
->get()->all();
|
|
|
foreach ($result['img'] as $k => $v) {
|
|
|
$result['img'][$k]->pinyin = $catiall[$v->catid]['pinyin'];
|
|
|
+ $result['img'][$k]->alias = $catiall[$v->catid]['alias'];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1108,6 +1124,22 @@ class NewsService implements NewsServiceInterface
|
|
|
// return Result::success($data);
|
|
|
$where[] = ['status', '=', 1];
|
|
|
$website_id = $data['website_id'];
|
|
|
+ $website = Website::where('id', $data['website_id'])->first();
|
|
|
+ if(empty($website)){
|
|
|
+ return Result::error("网站不存在",0);
|
|
|
+ }
|
|
|
+ // $website_column = $website['column'];
|
|
|
+ if(!empty($website['website_column_arr_id']) && $website['website_column_arr_id'] != '[]'){
|
|
|
+ $website_column = json_decode($website['website_column_arr_id'],true);
|
|
|
+ }
|
|
|
+ $categorys = $this->processArticlePro($website_id);
|
|
|
+ $cat_1st_arr = $categorys['cat_1st_arr'];
|
|
|
+ $catiall = $categorys['catiall'];
|
|
|
+ $diff_pid_categoryIds = array_values($categorys['diff_pid_categoryIds']);
|
|
|
+ // return Result::success($diff_pid_categoryIds);
|
|
|
+ if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
|
|
|
+ return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
+ }
|
|
|
if (isset($data['catid']) && !empty($data['catid'])) {
|
|
|
$category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->pluck('category_id');
|
|
|
if (empty($category)) {
|
|
|
@@ -1532,12 +1564,29 @@ class NewsService implements NewsServiceInterface
|
|
|
*/
|
|
|
public function selectWebsiteArticle(array $data): array
|
|
|
{
|
|
|
- $category = WebsiteCategory::where('website_id', $data['website_id'])->pluck('category_id');
|
|
|
+ $website = Website::where('id', $data['website_id'])->first();
|
|
|
+ if(empty($website)){
|
|
|
+ return Result::error("网站不存在",0);
|
|
|
+ }
|
|
|
+ // $website_column = $website['column'];
|
|
|
+ if(!empty($website['website_column_arr_id']) && $website['website_column_arr_id'] != '[]'){
|
|
|
+ $website_column = json_decode($website['website_column_arr_id'],true);
|
|
|
+ }
|
|
|
$website_id = $data['website_id'];
|
|
|
$categorys = $this->processArticlePro($website_id);
|
|
|
+ $diff_pid_categoryIds = array_values($categorys['diff_pid_categoryIds']);
|
|
|
+
|
|
|
+ // return Result::success($diff_pid_categoryIds);
|
|
|
+ if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
|
|
|
+ return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
+ }
|
|
|
+ // return Result::success(reset($diff_pid_categoryIds) == 0);
|
|
|
+ // $cat_1st_arr = $categorys['cat_1st_arr'];
|
|
|
$catiall = $categorys['catiall'];
|
|
|
+ $categoryIds = $categorys['categoryIds'];
|
|
|
+ // return Result::success($categoryIds);
|
|
|
$query = Article::where('status', 1)
|
|
|
- ->whereIn('catid', $category)
|
|
|
+ ->whereIn('catid', $categoryIds)
|
|
|
->leftJoinSub(function ($query) use ($website_id) {
|
|
|
$query->from('article_ignore')
|
|
|
->where('website_id', $website_id);
|
|
|
@@ -1548,7 +1597,8 @@ class NewsService implements NewsServiceInterface
|
|
|
$query->whereNull('article_ignore.article_id')
|
|
|
->orWhere('article_ignore.website_id', '!=', $website_id);
|
|
|
});
|
|
|
- // return Result::success($all_articles);
|
|
|
+ // ->get()->all();
|
|
|
+ // return Result::success($query);
|
|
|
if (isset($data['cityid']) && !empty($data['cityid'])) {
|
|
|
$query->whereRaw("JSON_CONTAINS(city_arr_id, '" . intval($data['cityid']) . "')");
|
|
|
}
|
|
|
@@ -1560,6 +1610,7 @@ class NewsService implements NewsServiceInterface
|
|
|
}
|
|
|
// 计算总数
|
|
|
$count = $query->count();
|
|
|
+ // return Result::success($count);
|
|
|
// 分页查询
|
|
|
$articles = $query
|
|
|
->select(
|
|
|
@@ -1581,7 +1632,7 @@ class NewsService implements NewsServiceInterface
|
|
|
->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
->limit($data['pageSize'])
|
|
|
->get();
|
|
|
-
|
|
|
+ // return Result::success($articles);
|
|
|
foreach ($articles as $k => $v) {
|
|
|
$articles[$k]->category_name = $catiall[$v->catid]['alias'];
|
|
|
$articles[$k]->pinyin = $catiall[$v->catid]['pinyin'];
|
|
|
@@ -1691,14 +1742,31 @@ class NewsService implements NewsServiceInterface
|
|
|
*/
|
|
|
public function getWebsiteAllArticle(array $data): array
|
|
|
{
|
|
|
+ // return Result::success($data);
|
|
|
$time1 = microtime(true);
|
|
|
$wetbsite_id = $data['website_id'] ?? 2;
|
|
|
$data = json_decode($data['id'], true);
|
|
|
+
|
|
|
+ $website = Website::where('id', $wetbsite_id)->first();
|
|
|
+ if(empty($website)){
|
|
|
+ return Result::error("网站不存在",0);
|
|
|
+ }
|
|
|
+ // return Result::success($website);
|
|
|
+ $website_column = $website['website_column_arr_id'] ?? '[]';
|
|
|
+
|
|
|
+ $website_column = json_decode($website_column,true);
|
|
|
|
|
|
$categorys = $this->processArticlePro($wetbsite_id);
|
|
|
$cat_1st_arr = $categorys['cat_1st_arr'];
|
|
|
$catiall = $categorys['catiall'];
|
|
|
+
|
|
|
+ // return Result::success($catiall);
|
|
|
+ $diff_pid_categoryIds = $categorys['diff_pid_categoryIds'];
|
|
|
+ if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
|
|
|
+ return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
+ }
|
|
|
$websiteInfoIndexed = $categorys['websiteInfoIndexed'];
|
|
|
+ // return Result::success($categorys);
|
|
|
$parent_category = array_column($data, 'parent');
|
|
|
$parent_cat = [];
|
|
|
$child_category = array_column($data, 'child');
|
|
|
@@ -1933,10 +2001,22 @@ class NewsService implements NewsServiceInterface
|
|
|
public function getWebsiteArticles(array $data): array
|
|
|
{
|
|
|
$website_id = $data['website_id'];
|
|
|
+ $website = Website::where('id', $website_id)->first();
|
|
|
+ if(empty($website)){
|
|
|
+ return Result::error("网站不存在",0);
|
|
|
+ }
|
|
|
+ // return Result::success($website);
|
|
|
+ $website_column = $website['website_column_arr_id'] ?? '[]';
|
|
|
+ $website_column = json_decode($website_column, true);
|
|
|
$catids = json_decode($data['id'], true);
|
|
|
$parent_category = array_column($catids, 'parent');
|
|
|
- if (!empty($parent_category) && is_array($parent_category)) {
|
|
|
- $categorys = $this->processArticlePro($website_id);
|
|
|
+
|
|
|
+ if(!empty($parent_category) && is_array($parent_category)) {
|
|
|
+ $categorys = $this->processArticlePro($website_id);
|
|
|
+ $diff_pid_categoryIds = $categorys['diff_pid_categoryIds'];
|
|
|
+ if (in_array(3, $website_column) && !empty($diff_pid_categoryIds)) {
|
|
|
+ return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
+ }
|
|
|
$catiall = $categorys['catiall'];
|
|
|
$cat_1st_arr = $categorys['cat_1st_arr'];
|
|
|
// return Result::success($categorys);
|
|
|
@@ -2366,40 +2446,64 @@ class NewsService implements NewsServiceInterface
|
|
|
*/
|
|
|
function processArticlePro($website_id)
|
|
|
{
|
|
|
- $categorys = WebsiteCategory::where('website_id', $website_id)->get()->all();
|
|
|
- $websiteInfoIndexed = array_column($categorys, null, 'category_id');
|
|
|
- // 取出category_id 对应的aLIas_pinyin
|
|
|
- $categoryIds = array_column($categorys, 'category_id');
|
|
|
- $categoryPIds = array_column($categorys, 'pid');
|
|
|
- $aliasPinyins = array_column($categorys, 'aLIas_pinyin');
|
|
|
- $cat_arr = array_combine($categoryIds, $aliasPinyins);
|
|
|
- // return Result::success($categorys);
|
|
|
- $catiall = [];
|
|
|
- //一级所有子级的记录
|
|
|
- $cat_1st_arr = [];
|
|
|
- foreach ($categorys as $key => $value) {
|
|
|
- $category_arr_id = json_decode($value->category_arr_id);
|
|
|
- $pinyin_str = '';
|
|
|
- // 算出一级 并且算出子级
|
|
|
- if ($value->pid != 0) {
|
|
|
- $cat_1st_arr[$value->pid][] = $value->category_id;
|
|
|
- }
|
|
|
- foreach ($category_arr_id as $k => $v) {
|
|
|
- $pinyin_str .= $cat_arr[$v] . '/';
|
|
|
- }
|
|
|
- $pinyin_str = rtrim($pinyin_str, '/');
|
|
|
- $catiall[$value->category_id]['alias'] = $value->alias;
|
|
|
- $catiall[$value->category_id]['category_id'] = $value->category_id;
|
|
|
- $catiall[$value->category_id]['type'] = $value->type;
|
|
|
- $catiall[$value->category_id]['pinyin'] = $pinyin_str;
|
|
|
- $websiteInfoIndexed[$value->category_id]->pinyin = $pinyin_str;
|
|
|
- }
|
|
|
- return [
|
|
|
- 'cat_1st_arr' => $cat_1st_arr,
|
|
|
- 'catiall' => $catiall,
|
|
|
- 'websiteInfoIndexed' => $websiteInfoIndexed,
|
|
|
- 'categoryIds' => $categoryIds,
|
|
|
- ];
|
|
|
+ // $categorys = WebsiteCategory::where('website_id', $website_id)->get()->all();
|
|
|
+ // // $websiteInfoIndexed = array_column($categorys, null, 'category_id');
|
|
|
+ // // 取出category_id 对应的aLIas_pinyin
|
|
|
+ // $categoryIds = array_column($categorys, 'category_id');
|
|
|
+ // $categoryPIds = array_column($categorys, 'pid');
|
|
|
+ // $aliasPinyins = array_column($categorys, 'path');
|
|
|
+ // $alias = array_column($categorys, 'alias');
|
|
|
+ // $cat_arr = array_combine($categoryIds, $aliasPinyins);
|
|
|
+ // $cat_alias_arr = array_combine($categoryIds, $categoryPIds);
|
|
|
+ // // return Result::success($cat_arr);
|
|
|
+ // // $catiall = [];
|
|
|
+ // //一级所有子级的记录
|
|
|
+ // $cat_alias_arr = array_combine($categoryIds, $alias);
|
|
|
+ // return [
|
|
|
+ // 'cat_1st_arr' => $cat_alias_arr,
|
|
|
+ // 'catiall' => $cat_arr,
|
|
|
+ // // 'websiteInfoIndexed' => $websiteInfoIndexed,
|
|
|
+ // 'categoryIds' => $categoryIds,
|
|
|
+ // ];
|
|
|
+ $categorys = WebsiteCategory::where('website_id', $website_id)->get()->all();
|
|
|
+ $websiteInfoIndexed = array_column($categorys, null, 'category_id');
|
|
|
+ // 取出category_id 对应的aLIas_pinyin
|
|
|
+ $categoryIds = array_column($categorys, 'category_id');
|
|
|
+ $categoryPIds = array_values(array_unique(array_filter(array_column($categorys, 'pid'), function($pid) {
|
|
|
+ return $pid != 0;
|
|
|
+ })));
|
|
|
+
|
|
|
+ $category_path = array_column($categorys, 'path');
|
|
|
+ $cat_arr = array_combine($categoryIds, $category_path);
|
|
|
+ // return Result::success(array_diff($categoryIds, $categoryPIds));
|
|
|
+ $catiall = [];
|
|
|
+ //一级所有子级的记录
|
|
|
+ $cat_1st_arr = [];
|
|
|
+ foreach ($categorys as $key => $value) {
|
|
|
+ // $category_arr_id = json_decode($value->category_arr_id);
|
|
|
+ // $pinyin_str = '';
|
|
|
+ // // 算出一级 并且算出子级
|
|
|
+ if ($value->pid != 0 && in_array($value->pid,$categoryIds)) {
|
|
|
+ $cat_1st_arr[$value->pid][] = $value->category_id;
|
|
|
+ }
|
|
|
+ // foreach ($category_arr_id as $k => $v) {
|
|
|
+ // $pinyin_str .= $cat_arr[$v] . '/';
|
|
|
+ // }
|
|
|
+ // $pinyin_str = rtrim($pinyin_str, '/');
|
|
|
+ $catiall[$value->category_id]['alias'] = $value->alias;
|
|
|
+ $catiall[$value->category_id]['category_id'] = $value->category_id;
|
|
|
+ $catiall[$value->category_id]['type'] = $value->type;
|
|
|
+ $catiall[$value->category_id]['pinyin'] = $cat_arr[$value->category_id];
|
|
|
+ $websiteInfoIndexed[$value->category_id]->pinyin = $cat_arr[$value->category_id];
|
|
|
+ }
|
|
|
+ return [
|
|
|
+ 'cat_1st_arr' => $cat_1st_arr,
|
|
|
+ 'catiall' => $catiall,
|
|
|
+ 'websiteInfoIndexed' => $websiteInfoIndexed,
|
|
|
+ 'categoryIds' => $categoryIds,
|
|
|
+ 'diff_pid_categoryIds' => array_diff($categoryPIds,$categoryIds),
|
|
|
+ 'categoryPIds' => $categoryPIds,
|
|
|
+ ];
|
|
|
}
|
|
|
/**
|
|
|
* 封装处理文章的路由问题
|
|
|
@@ -3504,13 +3608,13 @@ class NewsService implements NewsServiceInterface
|
|
|
}
|
|
|
// 验证栏目路由
|
|
|
$last_category = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
- ->where('aLIas_pinyin', $data['last_route'])
|
|
|
+ ->where('path', $data['all_route'])
|
|
|
->get()->all();
|
|
|
if (count($last_category) == 0) {
|
|
|
return Result::error("该栏目不存在", 0);
|
|
|
}
|
|
|
- if (count($last_category) > 1) {
|
|
|
- return Result::error("该子级栏目存在多个,路由验证失败!", 0);
|
|
|
+ if(count($last_category) > 1){
|
|
|
+ return Result::error("该栏目路由存在多个,路由验证失败!", 0);
|
|
|
}
|
|
|
if (count($last_category) == 1) {
|
|
|
$last_category = $last_category[0];
|
|
|
@@ -3529,11 +3633,11 @@ class NewsService implements NewsServiceInterface
|
|
|
$query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
|
|
|
->orWhereNull("ignore_ids");
|
|
|
})
|
|
|
- ->first(['cat_arr_id']);
|
|
|
+ ->first(['catid']);
|
|
|
if (empty($article)) {
|
|
|
return Result::error("该文章不存在", 0);
|
|
|
}
|
|
|
- // return Result::success($article);
|
|
|
+ // return Result::success($article);
|
|
|
break;
|
|
|
case 2:
|
|
|
// 商品
|
|
|
@@ -3607,36 +3711,44 @@ class NewsService implements NewsServiceInterface
|
|
|
return Result::error("该数据不存在", 0);
|
|
|
break;
|
|
|
}
|
|
|
- $catid = 0;
|
|
|
- $catidArray = json_decode($article['cat_arr_id'], true);
|
|
|
- $catid = !empty($catidArray) ? end($catidArray) : null;
|
|
|
- // return Result::success($article['cat_arr_id']);
|
|
|
- if (empty($catid)) {
|
|
|
- return Result::error("该数据不存在", 0);
|
|
|
- }
|
|
|
-
|
|
|
- $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
- ->where('category_id', $catid)
|
|
|
- ->select('path')
|
|
|
- ->pluck('path');
|
|
|
- } else {
|
|
|
- if ($last_category['pid'] != 0) {
|
|
|
- $cat_arr = json_decode($last_category['category_arr_id'], true);
|
|
|
- $catid = !empty($cat_arr) ? end($cat_arr) : null;
|
|
|
- $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
- ->where('category_id', $catid)
|
|
|
- ->where('path', $data['all_route'])
|
|
|
- ->pluck('path');
|
|
|
- } else {
|
|
|
- $pinyin[0] = $last_category['aLIas_pinyin'];
|
|
|
- }
|
|
|
- }
|
|
|
- // return Result::success($pinyin[0]);
|
|
|
- if (empty($pinyin) || count($pinyin) > 1 || $pinyin[0] != $data['all_route']) {
|
|
|
- return Result::error('非法路径!');
|
|
|
- } else {
|
|
|
- return Result::success($pinyin);
|
|
|
- }
|
|
|
+ // return Result::success($article);
|
|
|
+ // $catid =0 ;
|
|
|
+
|
|
|
+ // if(!isset($article['cat_arr_id'])){
|
|
|
+ // $catid = isset($article['catid']) ? $article['catid'] : (isset($article['category_id']) ? $article['category_id'] : null);
|
|
|
+ // }else{
|
|
|
+ // $catidArray = json_decode($article['cat_arr_id'], true);
|
|
|
+ // $catid = !empty($catidArray) ? end($catidArray) : null;
|
|
|
+ // }
|
|
|
+ // // return Result::success($catid);
|
|
|
+ // // return Result::success($article['cat_arr_id']);
|
|
|
+ // if (empty($catid)) {
|
|
|
+ // return Result::error("该数据不存在", 0);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ // ->where('category_id',$catid)
|
|
|
+ // ->first('path');
|
|
|
+ }
|
|
|
+
|
|
|
+ // else{
|
|
|
+ // // if ($last_category['pid'] != 0) {
|
|
|
+ // $cat_arr = json_decode($last_category['category_arr_id'], true);
|
|
|
+ // $catid = !empty($cat_arr) && is_array($cat_arr) ? end($cat_arr) : null;
|
|
|
+ // $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
+ // ->where('category_id',$catid)
|
|
|
+ // ->where('path',$data['all_route'])
|
|
|
+ // ->first('path');
|
|
|
+ // // } else {
|
|
|
+ // // $pinyin[0] = $last_category['aLIas_pinyin'];
|
|
|
+ // // }
|
|
|
+ // }
|
|
|
+ // return Result::success($pinyin);
|
|
|
+ // if (empty($pinyin)) {
|
|
|
+ // return Result::error('非法路径!');
|
|
|
+ // } else {
|
|
|
+ return Result::success( $last_category['path']);
|
|
|
+ // }
|
|
|
}
|
|
|
/**
|
|
|
* 招工招聘 - 获取推荐职位
|