瀏覽代碼

找回web三农相关代码

15313670163 2 月之前
父節點
當前提交
4b1828c4b2
共有 1 個文件被更改,包括 186 次插入0 次删除
  1. 186 0
      app/JsonRpc/WebsiteService.php

+ 186 - 0
app/JsonRpc/WebsiteService.php

@@ -473,6 +473,192 @@ class WebsiteService implements WebsiteServiceInterface
         }
     }
 
+    /**
+     * 查询网站的广告
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteAdvertisement(array $data): array
+    {
+
+        $where = [
+            'website_id' => 1,
+            'id' => $data['ad_placeid']
+        ];
+        
+        //查询这个广告位是否存在
+        $ad_place = AdPlace::where($where)->orderBy('id','asc')->first();    
+        
+        var_dump("==========",$ad_place);
+        if(empty($ad_place)){
+            return Result::error("error",0);
+        }else{
+            $adplaceid = $ad_place['id'];
+            //查找有没有广告
+            $ad=Ad::where('pid',$adplaceid['id'])->where('status',1)->orderBy('id','asc')->get();
+            if(empty($ad)){
+                //若没有生效的广告,则显示默认的缩略图
+                $result=$adplaceid;
+                return Result::success($result); 
+            }else{  
+                //查找在生效时间的广告    
+                $today = Carbon::now();              
+                foreach($ad as $i)
+                { 
+                    $starttime=Carbon::parse($i['fromtime']);
+                    $endtime=Carbon::parse($i['totime']);
+                    $time=$today->between($starttime,$endtime); 
+                    if($time)
+                    {
+                        $result=$i; 
+                    }
+                }
+                if(empty($result)){
+                    $result=$ad;
+                    return Result::success($result); 
+                }else{
+                    return Result::success($result);  
+                }
+            }   
+        } 
+    }
+
+     /**
+     * 
+     * @param array $data
+     * @return array
+     */
+    /**网站行政职能搜索 */
+    public function selectWebsiteDepartment(array $data): array
+    {
+
+        $depart = Department::where('pid',0)->orderBy('id','asc')->limit(10)->get(); 
+        if(isset($data['keyword']) && !empty($data['keyword'])){ 
+            $departments= Department::where('name', 'like', '%' . $data['keyword'] . '%')->get();
+            if(empty($departments)){
+                $result['message']="未查询到与此相关职能部门"; 
+            }else{ 
+                $count = Department::where('name','like',"%{$data['keyword']}%")->count();
+                $m = [
+                    'department'=>$depart, 
+                    'type'=>$departments,
+                    'count'=>$count
+                ]; 
+            }
+            
+            $result['sele'] = $m; 
+            return Result::success($result['sele']); 
+            
+        }
+        $result=$depart;
+        return Result::success($result['data']); 
+    }
+
+
+    /**
+     * 搜索地区
+     * @param array $data 
+     * @return array 
+     */ 
+    public function selectWebsiteArea(array $data): array 
+    { 
+        $provinces=District::where('pid',0)->where('status',1)->get();
+       
+        if(isset($data['province'])){ 
+            $province=District::where('pid',0)->where('status',1)->where('id',$data['province'])->orderBy('id')->get();
+            $province=$province->toArray(); 
+            if(!empty($province)){
+                $citys=District::where('pid',$data['province'])->where('status',1)->orderBy('id')->get();
+                if(!empty($citys) && isset($data['city']) && !empty($data['city'])){
+                    // $province = $province->toArray();
+                    $province_id=[];
+                    foreach($province as $val){
+                        array_push($province_id,$val['id']); 
+                    }
+                    // var_dump($province_id);
+                    $city=District::whereIn('pid',$province_id)->where('status',1)->where('id',$data['city'])->orderBy('id')->get();
+                    if(!empty($city)){
+                        $city_id=[];
+                        foreach($city as $val){
+                            array_push($city_id,$val['id']); 
+                        }
+                        $regions=District::whereIn('pid',$city_id)->where('status',1)->orderBy('id')->get();
+                       
+                            $result=[
+                                'province' => $province,
+                                'city' => $city,
+                                'region' => $regions
+                            ];
+                    }else{
+                        return Result::error("未查询到此城市",0);  
+                    }
+                }else{ 
+                    $result=[
+                        'province' => $province,
+                        'city' => $citys,
+                        'region' => null
+                    ];
+                }
+            }else{
+                return Result::error("未查询到此省份",0); 
+            }
+        }else{
+            // $keys = array('data');
+           $result =  $provinces;
+        } 
+        return Result::success($result);   
+    }
+
+    /**
+     * 获取栏目
+     * @param array $data
+     * @return array
+     */
+
+    public function getWebsiteModelCategory(array $data): array 
+    {
+        $website_id=[ 
+            'website_id' => $data['website_id'] 
+        ];
+        $placeid=$data['placeid']-1; 
+        $pid=[
+            'pid' => $data['pid'], 
+        ];
+        $num = $data['num'];
+        
+        $result=WebsiteCategory::where($website_id)->where($pid)->orderBy('sort')->offset($placeid)->limit($num)->get();
+        $result = $result->toArray(); 
+        if(!empty($result)){ 
+            return Result::success($result);  
+        }else{ 
+            return Result::error("本网站暂无栏目",0);  
+        } 
+
+    } 
+
+    /**
+     * 获取友情链接
+     * @param array $data
+     * @return array
+     */
+
+    public function selectWebsiteLinks(array $data): array 
+    { 
+        $where = [ 
+            'website_id' => $data['website_id'], 
+            'status' => 1,
+            'type' => $data['type'] 
+        ]; 
+        $num=$data['num'];
+        $result=Link::where($where)->orderBy('id')->limit($num)->get(); 
+        if(!empty($result)){ 
+            return Result::success($result);  
+        }else{ 
+            return Result::error("本网站暂无此类型友情链接",0); 
+        }
+    }
+
+
     /**
      * 网站首页数据统计, 管理员
      * @return void