duqinya лет назад: 5
Родитель
Сommit
eff87bd7b1
3 измененных файлов с 70 добавлено и 12 удалено
  1. 12 0
      app/Http/Controllers/V1/BeanDetailController.php
  2. 55 12
      app/Repositories/BeanRepository.php
  3. 3 0
      routes/api.php

+ 12 - 0
app/Http/Controllers/V1/BeanDetailController.php

@@ -75,4 +75,16 @@ class BeanDetailController extends Controller
         }
 
     }
+
+    //星球首页
+    public function starHome(Request $request)
+    {
+        $star_home = $this->beanRepository->starHome($request->all());
+        if ($star_home){
+            return $this->jsonSuccess($star_home);
+        }else{
+            return $this->jsonError('没有找到星球首页相关信息');
+        }
+
+    }
 }

+ 55 - 12
app/Repositories/BeanRepository.php

@@ -28,18 +28,8 @@ class BeanRepository
         }
     }
 
-    public function getBean($request)
-    {
-        $user_bean = [];
-        $user_bean['user_count'] = Redis::get('user_count');//已入驻居民
-        $user_bean['yesterday_add_user'] = Redis::get('yesterday_add_user');//昨日新增居民
-        $user_bean['yesterday_add_bean'] = Redis::get('yesterday_add_bean');//昨日发放彩虹豆
-        $user_bean['yesterday_quantity_issued'] = Redis::get('yesterday_quantity_issued');//昨日发放总彩虹豆
-
-        return $user_bean;
-    }
-
-    public function excellentResidents($request)
+    //获取优秀居民信息
+    function excellentResidents($request)
     {
 //        $get_excellent = Redis::get('yesterday_excellent_residents');
 //        $excellent_residents = json_decode($get_excellent);
@@ -272,4 +262,57 @@ class BeanRepository
 
     }
 
+    public function starHome($request)
+    {
+        $star_home['star'] = [];
+        $my_bean = [];
+        $star_home['star'][0]['mybean'] = $my_bean;
+//        $star_home['star'][0]['mybean']['user_all_bean'] = Redis::get('user_all_bean');//用户总彩虹豆
+        $star_home['star'][0]['mybean']['user_all_bean'] = 0;//用户总彩虹豆
+//        $star_home['star'][0]['yesterday_add_bean'] = Redis::get('yesterday_add_bean');//昨日发放彩虹豆
+        $star_home['star'][0]['mybean']['yesterday_add_bean'] = 3;//昨日新增彩虹豆
+//        $star_home['star'][0]['user_count'] = Redis::get('user_count');//已入驻居民
+        $star_home['star'][0]['mybean']['user_count'] = 1;//已入驻居民
+//        $star_home['star'][0]['yesterday_add_user'] = Redis::get('yesterday_add_user');//昨日新增居民
+        $star_home['star'][0]['mybean']['yesterday_add_user'] = 2;//昨日新增居民
+//        $star_home['star'][0]['yesterday_quantity_issued'] = Redis::get('yesterday_quantity_issued');//昨日发放总彩虹豆
+        $star_home['star'][0]['mybean']['yesterday_quantity_issued'] = 4;//昨日发放总彩虹豆
+
+        $star_home['star'][1]['excellent_residents'] = $this->excellentResidents($request);
+        $star_home['star'][2]['daily_news'] = $this->getNews($request);
+        $star_home['star'][3]['tips'] = $this->getPlatformContent($id = 1);
+
+        return $star_home;
+
+    }
+
+    //获取每日新闻
+    function getNews($request) {
+        try {
+            $url = config("customer.app_service_url").'/config/v2/starNews/lists';
+            $array = [
+                'json' => [], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
+            ];
+            return http($url,$array,'get');
+        } catch (\Exception $e) {
+            Log::debug($e->getMessage());
+            return [];
+        }
+
+    }
+    //获取平台内容
+    function getPlatformContent($id) {
+        try {
+            $url = config("customer.app_service_url").'/config/v2/platformContent/lists';
+            $array = [
+                'json' => ['id'=>$id], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
+            ];
+            return http($url,$array,'get');
+        } catch (\Exception $e) {
+            Log::debug($e->getMessage());
+            return [];
+        }
+
+    }
+
 }

+ 3 - 0
routes/api.php

@@ -74,6 +74,9 @@ $api->version('v1', [
         $api->get('excellentResidents', 'BeanDetailController@excellentResidents');
         //排行榜
         $api->get('rankingList', 'BeanDetailController@rankingList');
+        //星球首页
+        $api->get('starHome', 'BeanDetailController@starHome');
+
         //用户发布数,收藏数,转发数
         $api->get('post/memberPostStatistics', 'PostController@memberPostStatistics');
     });