Sfoglia il codice sorgente

获取栏目、随机获取模板

FengR 1 mese fa
parent
commit
699c422845
2 ha cambiato i file con 29 aggiunte e 10 eliminazioni
  1. 12 8
      app/JsonRpc/PublicRpcService.php
  2. 17 2
      app/JsonRpc/WebsiteService.php

+ 12 - 8
app/JsonRpc/PublicRpcService.php

@@ -3196,7 +3196,7 @@ class PublicRpcService implements PublicRpcServiceInterface
         $query = WebsiteCategory::where('website_id', $data['website_id']);
         $cate_num = $query->where('is_show', 1)->count();
         if ($cate_num < 5) {
-            return Result::error('此网站栏目过少,无法进行随机模板!');
+            return'此网站栏目过少,无法进行随机模板!';
         }
         $cate_num = min($cate_num, 24);
         // return Result::success($data);
@@ -3926,7 +3926,7 @@ class PublicRpcService implements PublicRpcServiceInterface
         $cate_num = count($all_cate);
         // return $all_cate;
         if ($cate_num < 5) {
-            return Result::error('此网站栏目过少,无法进行随机模板!');
+            return 此网站栏目过少,无法进行随机模板!;
         }
         $cate_num = min($cate_num, 24);
         $all_sector_type = array_column($sectors, 'sector_type');
@@ -4180,7 +4180,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                 $date = substr($date, 0, 9); // 截取前9位
             }
             $random_num = intval(intval($date) . rand(1000, 9999)); // 拼接4位随机数,组成13位随机数
-            $y_num = $y_num + $value['pic_height'];
+            
             $sector_width = $value['sector_width'] / 100;
             $canvas_data[$key] = [
                 'i' => $random_num,
@@ -4193,6 +4193,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                     'sectorName' => $value['sector_id'],
                 ]
             ];
+            $y_num = $y_num + $value['pic_height'];
             // $componentData = [];
             $sector_component = [];
             for ($i = 0; $i < $value['component_num']; $i++) {
@@ -4204,18 +4205,21 @@ class PublicRpcService implements PublicRpcServiceInterface
                 $list_type = json_decode($value['sector_components'][$i]['component']['component_column'] ?? '[]',true) ?? [];
                 if(!empty($component_data) && !empty($list_type)){
                     $componentData = $component_data['componentData'];
-                    $componentData['listType'] = $list_type['listType'];
+                    if($component_type != 10){
+                        $componentData['listType'] = $list_type['listType'];
+                    }
+                    
                 }
                 if(in_array($component_type,[7,14,15,23,24]) && ($page == 1 || $page == 2)){
                     if($page == 1){
                         if(in_array($component_type,[23,24])){
-                            $componentData[0]['name'] = $all_cate[$cat_key]['name'];
+                            $componentData[0]['name'] = $all_cate[$cat_key]['alias'];
                             $componentData[0]['category_arr'] = $all_cate[$cat_key]['category_arr_id'];
-                            $componentData[1]['name'] = $all_cate[$cat_key+1]['name'];
+                            $componentData[1]['name'] = $all_cate[$cat_key+1]['alias'];
                             $componentData[1]['category_arr'] = $all_cate[$cat_key+1]['category_arr_id'];
                             $cat_key += 2;
                         }else{
-                            $componentData['name'] = $all_cate[$cat_key]['name'];
+                            $componentData['name'] = $all_cate[$cat_key]['alias'];
                             $componentData['category_arr'] = $all_cate[$cat_key]['category_arr_id'];
                             $cat_key ++;
                         }
@@ -4247,7 +4251,7 @@ class PublicRpcService implements PublicRpcServiceInterface
                     'component_type' => $value['sector_components'][$i]['component']['component_type'],
                     'sort' => $value['sector_components'][$i]['sort_id'],
                     'type_id' => $component_type,
-                    'page' => $page,
+                    // 'page' => $page,
                     'component_style' => $component_imgids[array_rand($component_imgids)], // 若是上个数组为[1]随机为0,原因:array_rand 在单元素数组时必然返回 0
                     'componentData' => $componentData,
 

+ 17 - 2
app/JsonRpc/WebsiteService.php

@@ -716,6 +716,12 @@ class WebsiteService implements WebsiteServiceInterface
         $website_id = [
             'website_id' => $data['website_id'],
         ];
+        $website_column_arr = Website::where('id', $data['website_id'])->value('website_column_arr_id');
+        if (empty($website_column_arr)) {
+            return Result::error("未查询到此网站所属网系!", 0);
+        }
+        $website_column_arr = json_decode($website_column_arr, true);
+        // return Result::success(!in_array(3,$website_column_arr) && $data['pid'] == 0);
         // 初始化 $pid 数组
         // $pid = [];
         // 以下注释掉的代码是之前的逻辑,用于获取非顶级分类的 pid
@@ -727,7 +733,12 @@ class WebsiteService implements WebsiteServiceInterface
         $pid = array_values(array_unique($pid->toArray()));
         // 构建查询语句
         $query = WebsiteCategory::where($website_id)
-            ->where('pid', $data['pid'])
+            ->when(!in_array(3, $website_column_arr) && $data['pid'] == 0, function ($query) use ($website_column_arr) {
+                $query->where('is_show', 1);
+            })
+            ->when(in_array(3, $website_column_arr) ||  $data['pid'] != 0, function ($query) use ($data) {
+                $query->where('pid', $data['pid']);
+            })
             ->offset($data['placeid'])
             ->limit($data['num'])
             ->orderBy('sort')
@@ -760,7 +771,11 @@ class WebsiteService implements WebsiteServiceInterface
                 });
             } else {
                 $pidMap = $pidResults->keyBy('pid');
-                $result->each(function ($record) use ($pidMap) {
+                $result->each(function ($record) use ($pidMap, $data) {
+                    if ($data['pid'] == 0) {
+                        $record->aLIas_pinyin = $record->path;
+                    }
+                    // $record->aLIas_pinyin = $record->path;
                     if ($pidMap->has($record->category_id)) {
                         $pidResult = $pidMap->get($record->category_id);
                         $record->chilid_id = $pidResult->category_id;