LiuJ 1 hari lalu
induk
melakukan
6ea85367e8
1 mengubah file dengan 42 tambahan dan 32 penghapusan
  1. 42 32
      app/JsonRpc/WebsiteService.php

+ 42 - 32
app/JsonRpc/WebsiteService.php

@@ -519,27 +519,28 @@ class WebsiteService implements WebsiteServiceInterface
             $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.name as place_name',
-                'ad_place.thumb',
-                'ad_place.ad_tag',
-                'ad_place.introduce',
-                '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);
+                ->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_place.introduce',
+                    '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);
     }
@@ -1001,7 +1002,7 @@ class WebsiteService implements WebsiteServiceInterface
      * @param array $data
      * @return array
      */
-    public function upWebsiteCategory(array $data): array 
+    public function upWebsiteCategory(array $data): array
     {
         $pinyin = new Pinyin();
         Db::beginTransaction();
@@ -1048,6 +1049,7 @@ class WebsiteService implements WebsiteServiceInterface
                         'seo_description' => $info->seo_description ?? "",
                         'is_url' => $info->is_url ?? 0,
                         'web_url' => $info->web_url ?? '',
+                        'type' => $info->type ?? 1,
                         'category_arr_id' => json_encode($arr)
                     ];
                     $handledCategoryIds[] = $categoryId;
@@ -1058,7 +1060,12 @@ class WebsiteService implements WebsiteServiceInterface
                         $upsertData,
                         ['website_id', 'category_id'],
                         [
-                             'aLIas_pinyin', 'pid', 'pid_arr', 'is_url', 'web_url', 'category_arr_id'
+                            'aLIas_pinyin',
+                            'pid',
+                            'pid_arr',
+                            'is_url',
+                            'web_url',
+                            'category_arr_id'
                         ]
                     );
                 }
@@ -1336,7 +1343,7 @@ class WebsiteService implements WebsiteServiceInterface
         }
         $website_head = Website::where('id', $data['website_id'])
             ->select('id', 'website_name', 'logo', 'title', 'keywords', 'description', 'suffix', 'website_url')->first();
-        $website_foot = WebsiteTemplateInfo::where('website_id',$data['website_id'])->first();
+        $website_foot = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
         if (empty($website_foot)) {
             return Result::error("暂无底部基础信息", 0);
         }
@@ -1509,7 +1516,7 @@ class WebsiteService implements WebsiteServiceInterface
             return Result::error("参数错误", 0);
         }
         if (isset($data['catid']) && !empty($data['catid'])) {
-            $result = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$data['catid'])->first();
+            $result = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->first();
         }
         if (empty($result)) {
             return Result::error("暂无导航", 0);
@@ -2140,13 +2147,13 @@ class WebsiteService implements WebsiteServiceInterface
             return Result::error("暂无该网站", 0);
         }
         // 1:图片 2:文字 3:底部
-        $result['foot_cate'] = FooterCategory::where('website_id',$data['website_id'])->get()->all();
-        $result['link_img'] = Link::where('website_id',$data['website_id'])->where('type',1)->where('status',1)->limit($data['link_imgnum'])->orderBy('sort')->get()->all(); 
-        $result['link_text'] = Link::where('website_id',$data['website_id'])->where('type',2)->where('status',1)->limit($data['link_textnum'])->orderBy('sort')->get()->all();
-        $result['link_foot'] = Link::where('website_id',$data['website_id'])->where('type',3)->where('status',1)->limit($data['link_footnum'])->orderBy('sort')->get()->all();
-        $result['foot_info'] = WebsiteTemplateInfo::where('website_id',$data['website_id'])->first();
-        if(empty($result)){
-            return Result::error("暂无此网站信息",0);
+        $result['foot_cate'] = FooterCategory::where('website_id', $data['website_id'])->get()->all();
+        $result['link_img'] = Link::where('website_id', $data['website_id'])->where('type', 1)->where('status', 1)->limit($data['link_imgnum'])->orderBy('sort')->get()->all();
+        $result['link_text'] = Link::where('website_id', $data['website_id'])->where('type', 2)->where('status', 1)->limit($data['link_textnum'])->orderBy('sort')->get()->all();
+        $result['link_foot'] = Link::where('website_id', $data['website_id'])->where('type', 3)->where('status', 1)->limit($data['link_footnum'])->orderBy('sort')->get()->all();
+        $result['foot_info'] = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
+        if (empty($result)) {
+            return Result::error("暂无此网站信息", 0);
         }
         return Result::success($result);
     }
@@ -2290,6 +2297,9 @@ class WebsiteService implements WebsiteServiceInterface
         if (isset($data['pid'])) {
             array_push($where, ['pid', '=', $data['pid']]);
         }
+        if (isset($data['type']) && !empty($data['type'])) {
+            array_push($where, ['type', '=', $data['type']]);
+        }
         $list = WebsiteCategory::query()->where($where)->get();
         if (empty($list)) {
             return Result::error("获取失败", 0);