Răsfoiți Sursa

Merge branch 'web_sannong_fr'

15313670163 2 săptămâni în urmă
părinte
comite
cb5b08e64c
1 a modificat fișierele cu 23 adăugiri și 41 ștergeri
  1. 23 41
      app/JsonRpc/WebsiteService.php

+ 23 - 41
app/JsonRpc/WebsiteService.php

@@ -519,20 +519,27 @@ class WebsiteService implements WebsiteServiceInterface
             $now = Carbon::now()->format('Y-m-d H:i:s'); // 获取当前时间
             $where[] = ['ad_place.ad_tag', 'like', '%' . $data['ad_tag'] . '%'];
             // return Result::success($where);
-            $result = AdPlace::where($where)
-                ->leftJoin("ad", function ($join) use ($now) {
-                    $join->on("ad.pid", "=", "ad_place.id")
-                        ->where('ad.status', 1)
-                        ->where('ad.fromtime', '<=', $now)
-                        ->where('ad.totime', '>=', $now);
-                })
-                ->select("ad_place.*", 'ad.*', "ad_place.id as ad_place_id", "ad.name as ad_name")
-                ->get()->all();
-            if (empty($result)) {
-                return Result::error("此广告位不存在!", 0);
-            }
-        } else {
-            return Result::error("请选择广告位!", 0);
+            $result =  AdPlace::where($where)
+            ->leftJoin("ad", function ($join) use ($now) {
+                $join->on("ad.pid", "=", "ad_place.id")
+                     ->where('ad.status', 1)
+                     ->where('ad.fromtime', '<=', $now)
+                     ->where('ad.totime', '>=', $now);
+            })
+            ->select(
+                'ad_place.name as place_name',
+                'ad_place.thumb',
+                'ad_place.ad_tag',
+                'ad.name as ad_name',
+                'ad.image_src',
+                'ad.image_url',
+                'ad.image_alt')
+            ->get()->all();
+            if(empty($result)){
+                return Result::error("此广告位不存在!",0);
+            } 
+        }else{
+            return Result::error("请选择广告位!",0);
         }
         return Result::success($result);
 
@@ -2094,6 +2101,7 @@ class WebsiteService implements WebsiteServiceInterface
      * */
     public function getWebsiteParentCategory(array $data): array
     {
+        // return Result::success($data);
         if (isset($data['website_id']) && !empty($data['website_id'])) {
             $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
         }
@@ -2105,19 +2113,8 @@ class WebsiteService implements WebsiteServiceInterface
             // 因此,需要先调用 `get()` 方法获取查询结果集合,再使用 `map` 方法进行处理。
             $category['parent'] = WebsiteCategory::where('website_id', $data['website_id'])
                 ->where('pid', 0)
-                ->select('aLIas_pinyin', 'category_id', 'alias')
+                ->selectRaw("category_id as cid, alias as name, CONCAT('/', '', aLIas_pinyin, '/') as path")
                 ->get() // 添加 get() 方法获取结果集合
-                ->map(function ($item) {
-                    $result = [
-                        'name' => $item->alias,
-                        'cid' => $item->category_id
-                    ];
-                    if (!empty($item->aLIas_pinyin)) {
-                        $result['path'] = "/{$item->aLIas_pinyin}/";
-                    }
-                    return $result;
-                })
-                ->values()
                 ->all();
         // } else if($data['id'] == 1){
             // 不使用 with 方法,直接查询父级栏目需要的字段
@@ -2143,21 +2140,6 @@ class WebsiteService implements WebsiteServiceInterface
                 return $result;
             })->values()->all();
         // }else if($data['id'] == 2){
-            $foot = FooterCategory::where('website_id', $data['website_id'])
-                ->get();
-            $category['foot'] = $foot->map(function ($item) {
-                    $name = $item->name;
-                    $id = $item->id;
-                    $alias_pinyin = $item->name_pinyin;
-                    $result = [
-                        'name' => $name,
-                        'cid' => $id
-                    ];
-                    if (!empty($alias_pinyin)) {
-                        $result['path'] = "/{$alias_pinyin}/";
-                    }
-                    return $result;
-                })->values()->all();
         // }else{
         //     return Result::error("请输入正确的id", 0);
         // }