|
|
@@ -822,17 +822,17 @@ class NewsService implements NewsServiceInterface
|
|
|
{
|
|
|
$articleData = Article::where(['id' => $data['id']])->first();
|
|
|
//发送10次
|
|
|
- for ($i = 0; $i < 10; $i++) {
|
|
|
- $this->sendMessage([
|
|
|
- 'talk_type' => 100,
|
|
|
- 'title' => $i . $articleData['title'],
|
|
|
- 'content' => '审核通过',
|
|
|
- 'messageType' => 2,
|
|
|
- 'user_id' => $articleData['admin_user_id'],
|
|
|
- ]);
|
|
|
- }
|
|
|
- var_dump($data['status'], 'status');
|
|
|
- return Result::success();
|
|
|
+ // for ($i = 0; $i < 10; $i++) {
|
|
|
+ // $this->sendMessage([
|
|
|
+ // 'talk_type' => 100,
|
|
|
+ // 'title' => $i . $articleData['title'],
|
|
|
+ // 'content' => '审核通过',
|
|
|
+ // 'messageType' => 2,
|
|
|
+ // 'user_id' => $articleData['admin_user_id'],
|
|
|
+ // ]);
|
|
|
+ // }
|
|
|
+ // var_dump($data['status'], 'status');
|
|
|
+ // return Result::success();
|
|
|
|
|
|
if ($data['status'] == 1) {
|
|
|
$this->sendMessage([
|
|
|
@@ -917,9 +917,9 @@ class NewsService implements NewsServiceInterface
|
|
|
{
|
|
|
$website_id = $data['website_id'];
|
|
|
$website = Website::where('id', $data['website_id'])->first();
|
|
|
- if(empty($website)){
|
|
|
- return Result::error("网站不存在",0);
|
|
|
- }
|
|
|
+ if (empty($website)) {
|
|
|
+ return Result::error("网站不存在", 0);
|
|
|
+ }
|
|
|
$categorys = $this->processArticlePro($website_id);
|
|
|
$catiall = $categorys['catiall'];
|
|
|
$categoryIds = $categorys['categoryIds'];
|
|
|
@@ -927,13 +927,13 @@ class NewsService implements NewsServiceInterface
|
|
|
'status' => 1
|
|
|
];
|
|
|
// $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);
|
|
|
+ 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);
|
|
|
+ return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
}
|
|
|
|
|
|
// $website_id = $data['website_id'];
|
|
|
@@ -1125,12 +1125,12 @@ class NewsService implements NewsServiceInterface
|
|
|
$where[] = ['status', '=', 1];
|
|
|
$website_id = $data['website_id'];
|
|
|
$website = Website::where('id', $data['website_id'])->first();
|
|
|
- if(empty($website)){
|
|
|
- return Result::error("网站不存在",0);
|
|
|
+ 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);
|
|
|
+ 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'];
|
|
|
@@ -1138,7 +1138,7 @@ class NewsService implements NewsServiceInterface
|
|
|
$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::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');
|
|
|
@@ -1565,20 +1565,20 @@ class NewsService implements NewsServiceInterface
|
|
|
public function selectWebsiteArticle(array $data): array
|
|
|
{
|
|
|
$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);
|
|
|
- }
|
|
|
+ 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::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
}
|
|
|
// return Result::success(reset($diff_pid_categoryIds) == 0);
|
|
|
// $cat_1st_arr = $categorys['cat_1st_arr'];
|
|
|
@@ -1746,24 +1746,24 @@ class NewsService implements NewsServiceInterface
|
|
|
$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);
|
|
|
+ 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);
|
|
|
+ $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);
|
|
|
+ return Result::error("此为核心站,有父级导航" . implode(',', $diff_pid_categoryIds) . "未选择而选择了此子级!", 0);
|
|
|
}
|
|
|
$websiteInfoIndexed = $categorys['websiteInfoIndexed'];
|
|
|
// return Result::success($categorys);
|
|
|
@@ -2002,8 +2002,8 @@ class NewsService implements NewsServiceInterface
|
|
|
{
|
|
|
$website_id = $data['website_id'];
|
|
|
$website = Website::where('id', $website_id)->first();
|
|
|
- if(empty($website)){
|
|
|
- return Result::error("网站不存在",0);
|
|
|
+ if (empty($website)) {
|
|
|
+ return Result::error("网站不存在", 0);
|
|
|
}
|
|
|
// return Result::success($website);
|
|
|
$website_column = $website['website_column_arr_id'] ?? '[]';
|
|
|
@@ -2011,12 +2011,12 @@ class NewsService implements NewsServiceInterface
|
|
|
$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);
|
|
|
- $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);
|
|
|
- }
|
|
|
+ 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);
|
|
|
@@ -2447,63 +2447,63 @@ 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, '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,
|
|
|
- ];
|
|
|
+ // // $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,
|
|
|
+ ];
|
|
|
}
|
|
|
/**
|
|
|
* 封装处理文章的路由问题
|
|
|
@@ -3613,7 +3613,7 @@ class NewsService implements NewsServiceInterface
|
|
|
if (count($last_category) == 0) {
|
|
|
return Result::error("该栏目不存在", 0);
|
|
|
}
|
|
|
- if(count($last_category) > 1){
|
|
|
+ if (count($last_category) > 1) {
|
|
|
return Result::error("该栏目路由存在多个,路由验证失败!", 0);
|
|
|
}
|
|
|
if (count($last_category) == 1) {
|
|
|
@@ -3637,7 +3637,7 @@ class NewsService implements NewsServiceInterface
|
|
|
if (empty($article)) {
|
|
|
return Result::error("该文章不存在", 0);
|
|
|
}
|
|
|
- // return Result::success($article);
|
|
|
+ // return Result::success($article);
|
|
|
break;
|
|
|
case 2:
|
|
|
// 商品
|
|
|
@@ -3711,24 +3711,24 @@ class NewsService implements NewsServiceInterface
|
|
|
return Result::error("该数据不存在", 0);
|
|
|
break;
|
|
|
}
|
|
|
- // 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');
|
|
|
+ // 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{
|
|
|
@@ -3747,7 +3747,7 @@ class NewsService implements NewsServiceInterface
|
|
|
// if (empty($pinyin)) {
|
|
|
// return Result::error('非法路径!');
|
|
|
// } else {
|
|
|
- return Result::success( $last_category['path']);
|
|
|
+ return Result::success($last_category['path']);
|
|
|
// }
|
|
|
}
|
|
|
/**
|