Browse Source

修改c端接口:修改获取广告位

15313670163 17 giờ trước cách đây
mục cha
commit
7035e1a15b
1 tập tin đã thay đổi với 37 bổ sung36 xóa
  1. 37 36
      app/JsonRpc/WebsiteService.php

+ 37 - 36
app/JsonRpc/WebsiteService.php

@@ -559,45 +559,46 @@ 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();
-        } else {
+            ->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',
+                'ad_place.ad_url')
+            ->get()->all();
+            
+        }else{
             $now = Carbon::now()->format('Y-m-d H:i:s'); // 获取当前时间
             // return Result::success($where);
             $result =  AdPlace::where($where)
-                ->where('ad_place.website_id', $data['website_id'])
-                ->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();
+            ->where('ad_place.website_id',$data['website_id'])
+            ->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',
+                'ad_place.ad_url',)
+            ->get()->all();
             // return Result::error("请选择广告位!",0);
         }
         if (empty($result)) {