Переглянути джерело

Merge branch 'master' of http://git.bjzxtw.org.cn:3000/zxt/news_producer

LiuJ 6 днів тому
батько
коміт
9743348aa1
1 змінених файлів з 11 додано та 9 видалено
  1. 11 9
      app/JsonRpc/NewsService.php

+ 11 - 9
app/JsonRpc/NewsService.php

@@ -1887,11 +1887,12 @@ class NewsService implements NewsServiceInterface
     {
         return $goods->map(function ($good) use ($data) {
             $catid = $good->catid ?? 0;
-            $pinyin = '';
+            //     $pinyin = '';
             $category = WebsiteCategory::where('category_id', $catid)->where('website_id', $data['website_id'])->first();
             if (!empty($category->pid) && $category->pid != 0) {
                 $level = json_decode($category->category_arr_id);
-                $pinyin = WebsiteCategory::whereIn('category_id', $level)
+                $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
+                    ->whereIn('category_id', $level)
                     ->orderByRaw('FIELD(category_id, ' . implode(',', $level) . ')')
                     ->get(['aLIas_pinyin'])
                     ->pluck('aLIas_pinyin')
@@ -1945,7 +1946,6 @@ class NewsService implements NewsServiceInterface
                         break;
                     case 6:
                         $goods = $query->where('type_id', 2);
-
                         break;
                     default:
                         return [];
@@ -1967,7 +1967,8 @@ class NewsService implements NewsServiceInterface
                     ->offset($goodStart)
                     ->limit($goodNum)
                     ->get();
-                $all_goods = $this->processGoods($all_goods, $website);
+                $web['website_id'] = $website;
+                $all_goods = $this->processGoods($all_goods, $web);
             }
             return  $all_goods;
         }, $data);
@@ -1979,7 +1980,7 @@ class NewsService implements NewsServiceInterface
         })
             ->where('catid', $catid)
             ->where('article.status', 1)
-            ->leftJoin('article_data', 'article_data.article_id', 'article.catid')
+            ->leftJoin('article_data', 'article_data.article_id', 'article.id')
             ->select('article.id', 'article.title', 'article.updated_at', 'introduce', 'islink', 'linkurl', 'article_data.content')
             ->orderBy('article.updated_at', 'desc')
             ->first();
@@ -2018,7 +2019,8 @@ class NewsService implements NewsServiceInterface
         if (empty($category)) {
             return Result::error("栏目查询失败", 0);
         }
-        // $cat_tree = $this->processGoods($cat, $website);
+        $cat_tree = Result::buildMenuTree($category);
+        $web['website_id'] = $website;
         $goods = Good::where('website_id', $website)
             ->where('status', 2)
             ->select('good.id as good_id', 'name', 'imgurl', 'description', 'updated_at', 'catid', 'type_id', 'website_id')
@@ -2026,11 +2028,12 @@ class NewsService implements NewsServiceInterface
             ->offset(($data['page'] - 1) * $data['pageSize'])
             ->limit($data['pageSize'])
             ->get();
+
         if ($goods->isEmpty()) {
             return Result::error("商品查询失败", 0);
         }
-        if (count($goods) > 1) {
-            $goods = $this->processGoods($goods, $website);
+        if ($goods->count() > 1) {
+            $goods = $this->processGoods($goods, $web);
         } else {
             $catid = $goods[0]['catid'] ?? 0;
             $good_category = WebsiteCategory::where('category_id', $catid)->where('website_id', $data['website_id'])->first();
@@ -2046,7 +2049,6 @@ class NewsService implements NewsServiceInterface
             }
             $goods[0]['pinyin'] = $pinyin;
         }
-        $cat_tree = Result::buildMenuTree($category);
         $result = [
             'category' => $cat_tree,
             'goods' => $goods,