Ver código fonte

Merge branch 'develop' of http://git.caihongxingqiu.net/rainbow/community-service into develop

xielin 5 anos atrás
pai
commit
4e03ccfae4

+ 35 - 39
app/Console/Commands/ExcellentResidents.php

@@ -5,6 +5,7 @@
  * Date: 2019/6/19
  * Date: 2019/6/19
  * Time: 下午3:45
  * Time: 下午3:45
  */
  */
+
 namespace App\Console\Commands;
 namespace App\Console\Commands;
 
 
 
 
@@ -53,6 +54,17 @@ class ExcellentResidents extends Command
         $this->releaseRecord = $releaseRecord;
         $this->releaseRecord = $releaseRecord;
     }
     }
 
 
+    private function _condition($model, $virus_behavior_id)
+    {
+        $yesterday_start = Carbon::now()->addDays(-1)->startOfDay()->toDateTimeString();
+        $yesterday_end = Carbon::now()->addDays(-1)->endOfDay()->toDateTimeString();
+        return $model
+            ->where('virus_behavior_id', $virus_behavior_id)
+            ->whereBetween('created_at', [$yesterday_start, $yesterday_end])
+            ->select(DB::raw('count(*) as count'), 'content_author_id', 'related_content_id')
+            ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
+    }
+
     /**
     /**
      * Execute the console command.
      * Execute the console command.
      *
      *
@@ -64,14 +76,14 @@ class ExcellentResidents extends Command
         $yesterday_start = Carbon::now()->addDays(-1)->startOfDay()->toDateTimeString();
         $yesterday_start = Carbon::now()->addDays(-1)->startOfDay()->toDateTimeString();
         $yesterday_end = Carbon::now()->addDays(-1)->endOfDay()->toDateTimeString();
         $yesterday_end = Carbon::now()->addDays(-1)->endOfDay()->toDateTimeString();
         $sum_quantity_issued = $this->behavior
         $sum_quantity_issued = $this->behavior
-            ->leftJoin('comment_account_record as c','behavior.virus_behavior_id','=','c.virus_behavior_id')
-            ->leftJoin('general_ledger_record as g','behavior.virus_behavior_id','=','g.virus_behavior_id')
-            ->leftJoin('registered_accounts_record as a','behavior.virus_behavior_id','=','a.virus_behavior_id')
-            ->leftJoin('release_record as r','behavior.virus_behavior_id','=','r.virus_behavior_id')
-            ->whereBetween('c.created_at', [$yesterday_start,$yesterday_end])
-            ->orwhereBetween('g.created_at', [$yesterday_start,$yesterday_end])
-            ->orwhereBetween('a.created_at', [$yesterday_start,$yesterday_end])
-            ->orwhereBetween('r.created_at', [$yesterday_start,$yesterday_end])
+            ->leftJoin('comment_account_record as c', 'behavior.virus_behavior_id', '=', 'c.virus_behavior_id')
+            ->leftJoin('general_ledger_record as g', 'behavior.virus_behavior_id', '=', 'g.virus_behavior_id')
+            ->leftJoin('registered_accounts_record as a', 'behavior.virus_behavior_id', '=', 'a.virus_behavior_id')
+            ->leftJoin('release_record as r', 'behavior.virus_behavior_id', '=', 'r.virus_behavior_id')
+            ->whereBetween('c.created_at', [$yesterday_start, $yesterday_end])
+            ->orwhereBetween('g.created_at', [$yesterday_start, $yesterday_end])
+            ->orwhereBetween('a.created_at', [$yesterday_start, $yesterday_end])
+            ->orwhereBetween('r.created_at', [$yesterday_start, $yesterday_end])
             ->get(array(
             ->get(array(
                     DB::raw('SUM(c.quantity_issued) as c_quantity_issued'),
                     DB::raw('SUM(c.quantity_issued) as c_quantity_issued'),
                     DB::raw('SUM(g.quantity_issued) as g_quantity_issued'),
                     DB::raw('SUM(g.quantity_issued) as g_quantity_issued'),
@@ -81,27 +93,27 @@ class ExcellentResidents extends Command
             )->toArray();
             )->toArray();
         //昨日发放总豆
         //昨日发放总豆
         $all_quantity_issued = 0;
         $all_quantity_issued = 0;
-        foreach ($sum_quantity_issued as $k=>$v){
+        foreach ($sum_quantity_issued as $k => $v) {
             $all_quantity_issued += $v['c_quantity_issued'] + $v['g_quantity_issued'] + $v['a_quantity_issued'] + $v['r_quantity_issued'];
             $all_quantity_issued += $v['c_quantity_issued'] + $v['g_quantity_issued'] + $v['a_quantity_issued'] + $v['r_quantity_issued'];
         }
         }
 
 
         //文章被评论最多用户
         //文章被评论最多用户
         $comment = $this->commentRecord
         $comment = $this->commentRecord
-            ->whereBetween('created_at', [$yesterday_start,$yesterday_end])
+            ->whereBetween('created_at', [$yesterday_start, $yesterday_end])
             ->select(DB::raw('count(*) as count'), 'content_author_id', 'related_content_id')
             ->select(DB::raw('count(*) as count'), 'content_author_id', 'related_content_id')
             ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
             ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
         $comment = $comment->toArray();
         $comment = $comment->toArray();
-        foreach ($comment as $k=>$v){
+        foreach ($comment as $k => $v) {
             $comment[$k]['type'] = 'comment';//类型
             $comment[$k]['type'] = 'comment';//类型
         }
         }
 
 
         //昨日拉新最多用户
         //昨日拉新最多用户
         $registered = $this->registeredRecord
         $registered = $this->registeredRecord
-            ->whereBetween('created_at', [$yesterday_start,$yesterday_end])
+            ->whereBetween('created_at', [$yesterday_start, $yesterday_end])
             ->select(DB::raw('count(*) as count'), 'superior_uid as content_author_id')//作为用户ID
             ->select(DB::raw('count(*) as count'), 'superior_uid as content_author_id')//作为用户ID
             ->groupBy('superior_uid')->orderBy('count', 'desc')->limit(1)->get();
             ->groupBy('superior_uid')->orderBy('count', 'desc')->limit(1)->get();
         $registered = $registered->toArray();
         $registered = $registered->toArray();
-        foreach ($registered as $k=>$v){
+        foreach ($registered as $k => $v) {
             $registered[$k]['type'] = 'registered';
             $registered[$k]['type'] = 'registered';
         }
         }
 
 
@@ -110,13 +122,9 @@ class ExcellentResidents extends Command
             ->select('virus_behavior_id')
             ->select('virus_behavior_id')
             ->where('behavior_identification', 'collect')
             ->where('behavior_identification', 'collect')
             ->first();
             ->first();
-        $collent = $this->generalRecord
-            ->where('virus_behavior_id', $virus_id->virus_behavior_id)
-            ->whereBetween('created_at', [$yesterday_start,$yesterday_end])
-            ->select(DB::raw('count(*) as count'), 'content_author_id', 'related_content_id')
-            ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
+        $collent = $this->_condition($this->generalRecord, $virus_id->virus_behavior_id);
         $collent = $collent->toArray();
         $collent = $collent->toArray();
-        foreach ($collent as $k=>$v){
+        foreach ($collent as $k => $v) {
             $collent[$k]['type'] = 'collent';
             $collent[$k]['type'] = 'collent';
         }
         }
 
 
@@ -125,13 +133,9 @@ class ExcellentResidents extends Command
             ->select('virus_behavior_id')
             ->select('virus_behavior_id')
             ->where('behavior_identification', 'like')
             ->where('behavior_identification', 'like')
             ->first();
             ->first();
-        $like = $this->generalRecord
-            ->where('virus_behavior_id', $virus_id->virus_behavior_id)
-            ->whereBetween('created_at', [$yesterday_start,$yesterday_end])
-            ->select(DB::raw('count(*) as count'), 'content_author_id', 'related_content_id')
-            ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
+        $like = $this->_condition($this->generalRecord, $virus_id->virus_behavior_id);
         $like = $like->toArray();
         $like = $like->toArray();
-        foreach ($like as $k=>$v){
+        foreach ($like as $k => $v) {
             $like[$k]['type'] = 'like';
             $like[$k]['type'] = 'like';
         }
         }
 
 
@@ -140,13 +144,9 @@ class ExcellentResidents extends Command
             ->select('virus_behavior_id')
             ->select('virus_behavior_id')
             ->where('behavior_identification', 'forward')
             ->where('behavior_identification', 'forward')
             ->first();
             ->first();
-        $forward = $this->generalRecord
-            ->where('virus_behavior_id', $virus_id->virus_behavior_id)
-            ->whereBetween('created_at', [$yesterday_start,$yesterday_end])
-            ->select(DB::raw('count(*) as count'), 'content_author_id', 'related_content_id')
-            ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
+        $forward = $this->_condition($this->generalRecord, $virus_id->virus_behavior_id);
         $forward = $forward->toArray();
         $forward = $forward->toArray();
-        foreach ($forward as $k=>$v){
+        foreach ($forward as $k => $v) {
             $forward[$k]['type'] = 'forward';
             $forward[$k]['type'] = 'forward';
         }
         }
 
 
@@ -155,20 +155,16 @@ class ExcellentResidents extends Command
             ->select('virus_behavior_id')
             ->select('virus_behavior_id')
             ->where('behavior_identification', 'read')
             ->where('behavior_identification', 'read')
             ->first();
             ->first();
-        $read = $this->generalRecord
-            ->where('virus_behavior_id', $virus_id->virus_behavior_id)
-            ->whereBetween('created_at', [$yesterday_start,$yesterday_end])
-            ->select(DB::raw('count(*) as count'), 'content_author_id', 'related_content_id')
-            ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
+        $read = $this->_condition($this->generalRecord, $virus_id->virus_behavior_id);
         $read = $read->toArray();
         $read = $read->toArray();
-        foreach ($read as $k=>$v){
+        foreach ($read as $k => $v) {
             $read[$k]['type'] = 'read';
             $read[$k]['type'] = 'read';
         }
         }
         $all_merge = array_merge($comment, $registered, $collent, $like, $forward, $read);
         $all_merge = array_merge($comment, $registered, $collent, $like, $forward, $read);
         $all_excellent_residents = json_encode($all_merge);
         $all_excellent_residents = json_encode($all_merge);
 
 
-        Log::info('统计昨日优秀居民内容'.json_encode($all_excellent_residents));
-        Log::info('昨日发放总彩虹豆'.json_encode($all_quantity_issued));
+        Log::info('统计昨日优秀居民内容' . json_encode($all_excellent_residents));
+        Log::info('昨日发放总彩虹豆' . json_encode($all_quantity_issued));
 
 
         Redis::set('yesterday_excellent_residents', $all_excellent_residents);
         Redis::set('yesterday_excellent_residents', $all_excellent_residents);
         Redis::set('yesterday_quantity_issued', $all_quantity_issued);
         Redis::set('yesterday_quantity_issued', $all_quantity_issued);

+ 15 - 15
app/Console/Commands/RankingList.php

@@ -78,39 +78,39 @@ class RankingList extends Command
         $yesterday_end = Carbon::now()->addDays(-1)->endOfDay()->toDateTimeString();
         $yesterday_end = Carbon::now()->addDays(-1)->endOfDay()->toDateTimeString();
         //昨日拉新最多前十人
         //昨日拉新最多前十人
         $registered_most = $this->registeredRecord
         $registered_most = $this->registeredRecord
-            ->whereBetween('created_at', [$yesterday_start,$yesterday_end])
-            ->select(DB::raw('count(*) as count'),'superior_uid')
-            ->groupBy('superior_uid')->orderBy('count','desc')->limit(10)->get();
+            ->whereBetween('created_at', [$yesterday_start, $yesterday_end])
+            ->select(DB::raw('count(*) as count'), 'superior_uid')
+            ->groupBy('superior_uid')->orderBy('count', 'desc')->limit(10)->get();
         $registered_most = $registered_most->toArray();
         $registered_most = $registered_most->toArray();
 
 
         //昨日文章产生彩虹豆最多前十人
         //昨日文章产生彩虹豆最多前十人
         $comment_author = $this->_condition($this->commentRecord);
         $comment_author = $this->_condition($this->commentRecord);
         $comment_best_author = $comment_author->toArray();
         $comment_best_author = $comment_author->toArray();
-        foreach ($comment_best_author as $k=>$v){
+        foreach ($comment_best_author as $k => $v) {
             $comment_best_author[$k]['type'] = 'comment';
             $comment_best_author[$k]['type'] = 'comment';
         }
         }
         $general_author = $this->_condition($this->commentRecord);
         $general_author = $this->_condition($this->commentRecord);
         $general_best_author = $general_author->toArray();
         $general_best_author = $general_author->toArray();
-        foreach ($general_best_author as $k=>$v){
+        foreach ($general_best_author as $k => $v) {
             $general_best_author[$k]['type'] = 'general';
             $general_best_author[$k]['type'] = 'general';
         }
         }
         $release_author = $this->releaseRecord
         $release_author = $this->releaseRecord
-            ->whereBetween('created_at', [$yesterday_start,$yesterday_end])
-            ->select(DB::raw('count(*) as count'),'generation_quantity','uid as content_author_id','related_content_id')
-            ->groupBy('generation_quantity','content_author_id','related_content_id')->orderBy('generation_quantity','desc')->limit(10)->get();
+            ->whereBetween('created_at', [$yesterday_start, $yesterday_end])
+            ->select(DB::raw('count(*) as count'), 'generation_quantity', 'uid as content_author_id', 'related_content_id')
+            ->groupBy('generation_quantity', 'content_author_id', 'related_content_id')->orderBy('generation_quantity', 'desc')->limit(10)->get();
         $release_best_author = $release_author->toArray();
         $release_best_author = $release_author->toArray();
-        foreach ($release_best_author as $k=>$v){
+        foreach ($release_best_author as $k => $v) {
             $release_best_author[$k]['type'] = 'release';
             $release_best_author[$k]['type'] = 'release';
         }
         }
-        $all_best_author = array_merge($comment_best_author,$general_best_author,$release_best_author);
+        $all_best_author = array_merge($comment_best_author, $general_best_author, $release_best_author);
 
 
-        $column = array_column($all_best_author,'generation_quantity');
-        array_multisort($column,SORT_DESC,$all_best_author);
+        $column = array_column($all_best_author, 'generation_quantity');
+        array_multisort($column, SORT_DESC, $all_best_author);
 
 
-        $all_best_author = array_slice($all_best_author,0,10);
+        $all_best_author = array_slice($all_best_author, 0, 10);
 
 
-        Log::debug('昨日拉新最多前十人'.json_encode($registered_most));
-        Log::debug('昨日文章产生彩虹豆最多前十人'.json_encode($all_best_author));
+        Log::debug('昨日拉新最多前十人' . json_encode($registered_most));
+        Log::debug('昨日文章产生彩虹豆最多前十人' . json_encode($all_best_author));
 
 
         Redis::set('yesterday_registered_most', json_encode($registered_most));
         Redis::set('yesterday_registered_most', json_encode($registered_most));
         Redis::set('yesterday_best_author', json_encode($all_best_author));
         Redis::set('yesterday_best_author', json_encode($all_best_author));

+ 2 - 9
app/Http/Controllers/V1/PostController.php

@@ -86,7 +86,6 @@ class PostController extends Controller
     {
     {
         $userInfo = $this->getUserInfo();
         $userInfo = $this->getUserInfo();
         if (empty($userInfo)) {
         if (empty($userInfo)) {
-            Log::info('获取用户信息失败');
             return jsonError('获取用户信息失败');
             return jsonError('获取用户信息失败');
         }
         }
         $list = $this->postRepositories->lists($request->all());
         $list = $this->postRepositories->lists($request->all());
@@ -105,7 +104,6 @@ class PostController extends Controller
     {
     {
         $userInfo = $this->getUserInfo();
         $userInfo = $this->getUserInfo();
         if (empty($userInfo)) {
         if (empty($userInfo)) {
-            Log::info('获取用户信息失败');
             return jsonError('获取用户信息失败');
             return jsonError('获取用户信息失败');
         }
         }
         $list = $this->postRepositories->video($request->all());
         $list = $this->postRepositories->video($request->all());
@@ -131,7 +129,6 @@ class PostController extends Controller
 
 
         $userInfo = $this->getUserInfo();
         $userInfo = $this->getUserInfo();
         if (empty($userInfo)) {
         if (empty($userInfo)) {
-            Log::info('获取用户信息失败');
             return jsonError('获取用户信息失败');
             return jsonError('获取用户信息失败');
         }
         }
         $param = $request->all();
         $param = $request->all();
@@ -157,7 +154,6 @@ class PostController extends Controller
     {
     {
         $userInfo = $this->getUserInfo();
         $userInfo = $this->getUserInfo();
         if (empty($userInfo)) {
         if (empty($userInfo)) {
-            Log::info('获取用户信息失败');
             return jsonError('获取用户信息失败');
             return jsonError('获取用户信息失败');
         }
         }
 
 
@@ -168,7 +164,7 @@ class PostController extends Controller
         $resource->setPaginator(new IlluminatePaginatorAdapter($list));
         $resource->setPaginator(new IlluminatePaginatorAdapter($list));
         $data = $fractal->createData($resource)->toArray();
         $data = $fractal->createData($resource)->toArray();
 
 
-        if (!(isset($param['current_page']) && $param['current_page'] > 1)) {
+        if (!(isset($param['page']) && $param['page'] > 1)) {
             $key = 'suggest_post_floor';
             $key = 'suggest_post_floor';
             $floor = Redis::get($key);
             $floor = Redis::get($key);
             if (!$floor) {
             if (!$floor) {
@@ -240,7 +236,6 @@ class PostController extends Controller
         }
         }
         $userInfo = $this->getUserInfo();
         $userInfo = $this->getUserInfo();
         if (empty($userInfo)) {
         if (empty($userInfo)) {
-            Log::info('获取用户信息失败');
             return jsonError('获取用户信息失败');
             return jsonError('获取用户信息失败');
         }
         }
         $detail = $this->postRepositories->detail($request['id']);
         $detail = $this->postRepositories->detail($request['id']);
@@ -248,7 +243,7 @@ class PostController extends Controller
             return jsonError('获取内容信息失败');
             return jsonError('获取内容信息失败');
         }
         }
         $fractal = new Manager();
         $fractal = new Manager();
-        $res = new Item($detail, new DetailTransformer($userInfo['uid']));
+        $res = new Item($detail, new DetailTransformer($userInfo['uid'], $userInfo['invite_code']));
         $data = $fractal->createData($res)->toArray();
         $data = $fractal->createData($res)->toArray();
 
 
         return jsonSuccess($data);
         return jsonSuccess($data);
@@ -323,7 +318,6 @@ class PostController extends Controller
         }
         }
         $userInfo = $this->getUserInfo();
         $userInfo = $this->getUserInfo();
         if (empty($userInfo)) {
         if (empty($userInfo)) {
-            Log::info('获取用户信息失败');
             return jsonError('获取用户信息失败');
             return jsonError('获取用户信息失败');
         }
         }
         $detail = $this->postRepositories->topicDetail($request['id']);
         $detail = $this->postRepositories->topicDetail($request['id']);
@@ -344,7 +338,6 @@ class PostController extends Controller
     {
     {
         $userInfo = $this->getUserInfo();
         $userInfo = $this->getUserInfo();
         if (empty($userInfo)) {
         if (empty($userInfo)) {
-            Log::info('获取用户信息失败');
             return jsonError('获取用户信息失败');
             return jsonError('获取用户信息失败');
         }
         }
         $list = $this->postRepositories->topicPost($request->all());
         $list = $this->postRepositories->topicPost($request->all());

+ 30 - 109
app/Repositories/BeanRepository.php

@@ -31,117 +31,37 @@ class BeanRepository
     //获取优秀居民信息
     //获取优秀居民信息
     function excellentResidents($request)
     function excellentResidents($request)
     {
     {
-//        $get_excellent = Redis::get('yesterday_excellent_residents');
-//        $excellent_residents = json_decode($get_excellent);
-
-        //文章被评论最多用户
-        $comment = CommentRecord::
-//            where('created_at', '>=', $time)
-            select(DB::raw('count(*) as count'), 'content_author_id', 'related_content_id')
-            ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
-        $comment = $comment->toArray();
-        foreach ($comment as $k=>$v){
-            $comment[$k]['type'] = 'comment';//类型
-        }
-
-        //昨日拉新最多用户
-        $registered = RegisteredRecord::
-//            ->where('created_at', '>=', $time)
-            select(DB::raw('count(*) as count'), 'superior_uid as content_author_id')//作为用户ID
-            ->groupBy('superior_uid')->orderBy('count', 'desc')->limit(1)->get();
-        $registered = $registered->toArray();
-        foreach ($registered as $k=>$v){
-            $registered[$k]['type'] = 'registered';
-        }
-
-        //文章被收藏最多用户
-        $virus_id = Behavior::
-            select('virus_behavior_id')
-            ->where('behavior_identification', 'collect')
-            ->first();
-        $collent = GeneralRecord::
-            where('virus_behavior_id', $virus_id->virus_behavior_id)
-//            ->where('created_at', '>=', $time)
-            ->select(DB::raw('count(*) as count'), 'content_author_id', 'related_content_id')
-            ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
-        $collent = $collent->toArray();
-        foreach ($collent as $k=>$v){
-            $collent[$k]['type'] = 'collect';
-        }
-
-        //文章被喜欢最多用户
-        $virus_id = Behavior::
-            select('virus_behavior_id')
-            ->where('behavior_identification', 'like')
-            ->first();
-        $like = GeneralRecord::
-            where('virus_behavior_id', $virus_id->virus_behavior_id)
-//            ->where('created_at', '>=', $time)
-            ->select(DB::raw('count(*) as count'), 'content_author_id', 'related_content_id')
-            ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
-        $like = $like->toArray();
-        foreach ($like as $k=>$v){
-            $like[$k]['type'] = 'like';
-        }
-
-        //文章被转发最多用户
-        $virus_id = Behavior::
-            select('virus_behavior_id')
-            ->where('behavior_identification', 'forward')
-            ->first();
-        $forward = GeneralRecord::
-            where('virus_behavior_id', $virus_id->virus_behavior_id)
-//            ->where('created_at', '>=', $time)
-            ->select(DB::raw('count(*) as count'), 'content_author_id', 'related_content_id')
-            ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
-        $forward = $forward->toArray();
-        foreach ($forward as $k=>$v){
-            $forward[$k]['type'] = 'forward';
-        }
-
-        //文章被阅读最多用户
-        $virus_id = Behavior::
-            select('virus_behavior_id')
-            ->where('behavior_identification', 'read')
-            ->first();
-        $read = GeneralRecord::
-            where('virus_behavior_id', $virus_id->virus_behavior_id)
-//            ->where('created_at', '>=', $time)
-            ->select(DB::raw('count(*) as count'), 'content_author_id', 'related_content_id')
-            ->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
-        $read = $read->toArray();
-        foreach ($read as $k=>$v){
-            $read[$k]['type'] = 'read';
-        }
-        $excellent_residents = array_merge($comment, $registered, $collent, $like, $forward, $read);
-//        $excellent_residents = json_encode($all_merge);
-
-        //获取评论内容
-        $post_ids = array_column($excellent_residents,'related_content_id');
-        $comment_content = Post::select('id', 'title', 'content')->whereIn('id', $post_ids)->get();
-
-        foreach ($comment_content->toArray() as $value) {
-            foreach ($excellent_residents as $k=>$v) {
-                if (isset($v['related_content_id']) && $v['related_content_id'] == $value['id']) {
-                    if (!empty($value['title'])) {
-                        $excellent_residents[$k]['post_title'] = $value['title'];
-                    }
-                    if (empty($value['title']) && !empty($value['content'])){
-                        $content = strip_tags($value['content']);
-                        $excellent_residents[$k]['post_title'] = mb_substr($content, 0, 20);
+        $get_excellent = Redis::get('yesterday_excellent_residents');
+        $excellent_residents = json_decode($get_excellent,true);
+
+        if ($excellent_residents){
+            //获取评论内容
+            $post_ids = array_column($excellent_residents,'related_content_id');
+            $comment_content = Post::select('id', 'title', 'content')->whereIn('id', $post_ids)->get();
+
+            foreach ($comment_content->toArray() as $value) {
+                foreach ($excellent_residents as $k=>$v) {
+                    if (isset($v['related_content_id']) && $v['related_content_id'] == $value['id']) {
+                        if (!empty($value['title'])) {
+                            $excellent_residents[$k]['post_title'] = $value['title'];
+                        }
+                        if (empty($value['title']) && !empty($value['content'])){
+                            $content = strip_tags($value['content']);
+                            $excellent_residents[$k]['post_title'] = mb_substr($content, 0, 20);
+                        }
                     }
                     }
                 }
                 }
             }
             }
-        }
-        $content_author_id = array_column($excellent_residents,'content_author_id');
-        $uids = implode(',', array_unique($content_author_id));
-        $author_data = $this->getFollowMembersStatus($uids);
-        if ($author_data){
-            foreach ($excellent_residents as $k=>$v){
-                if(!isset($author_data[$v['content_author_id']])) continue;
-                        $excellent_residents[$k]['follow_status'] = $author_data[$v['content_author_id']]['follow_status'];
-                        $excellent_residents[$k]['username'] = $author_data[$v['content_author_id']]['username'];
-                        $excellent_residents[$k]['avatar'] = $author_data[$v['content_author_id']]['avatar'];
+            $content_author_id = array_column($excellent_residents,'content_author_id');
+            $uids = implode(',', array_unique($content_author_id));
+            $author_data = $this->getFollowMembersStatus($uids);
+            if ($author_data){
+                foreach ($excellent_residents as $k=>$v){
+                    if(!isset($author_data[$v['content_author_id']])) continue;
+                    $excellent_residents[$k]['follow_status'] = $author_data[$v['content_author_id']]['follow_status'];
+                    $excellent_residents[$k]['username'] = $author_data[$v['content_author_id']]['username'];
+                    $excellent_residents[$k]['avatar'] = $author_data[$v['content_author_id']]['avatar'];
+                }
             }
             }
         }
         }
 
 
@@ -228,6 +148,7 @@ class BeanRepository
 
 
     }
     }
 
 
+    //星球首页
     public function starHome($request)
     public function starHome($request)
     {
     {
         $star_home = [];
         $star_home = [];
@@ -240,7 +161,7 @@ class BeanRepository
         $star_home['mybean']['yesterday_add_user'] = $user_bean['yesterday_add_user'] ?? 0;//昨日新增居民
         $star_home['mybean']['yesterday_add_user'] = $user_bean['yesterday_add_user'] ?? 0;//昨日新增居民
         $star_home['mybean']['yesterday_quantity_issued'] = $yesterday_quantity_issued ?? 0;//昨日发放总彩虹豆
         $star_home['mybean']['yesterday_quantity_issued'] = $yesterday_quantity_issued ?? 0;//昨日发放总彩虹豆
 
 
-        $star_home['excellent_residents'] = $this->excellentResidents($request);
+        $star_home['excellent_residents'] = $this->excellentResidents($request) ?? [];
         $star_home['daily_news'] = $this->getNews($request);
         $star_home['daily_news'] = $this->getNews($request);
         $star_home['tips'] = $this->getPlatformContent($id = 1);
         $star_home['tips'] = $this->getPlatformContent($id = 1);
 
 

+ 1 - 3
app/Repositories/PostRepositories.php

@@ -64,7 +64,6 @@ class PostRepositories
         //验证小号
         //验证小号
         $userInfo = $this->getUserInfo();
         $userInfo = $this->getUserInfo();
         if (empty($userInfo)) {
         if (empty($userInfo)) {
-            Log::info('获取用户信息失败');
             return jsonError('获取用户信息失败');
             return jsonError('获取用户信息失败');
         }
         }
         $isValid = 0;
         $isValid = 0;
@@ -183,7 +182,7 @@ class PostRepositories
             foreach($topicIds as $id){
             foreach($topicIds as $id){
                 Redis::zincrby('topic.user_uid'.$userInfo['uid'], 1, $id);
                 Redis::zincrby('topic.user_uid'.$userInfo['uid'], 1, $id);
             }
             }
-            return jsonSuccess();
+            return jsonSuccess(['h5url' => config('customer.share_post_h5url')."?post_id={$post->id}&invite_code={$userInfo['invite_code']}", 'bean' => config('customer.share_post_bean')]);
 
 
         }catch (QueryException $exception){
         }catch (QueryException $exception){
             DB::rollBack();
             DB::rollBack();
@@ -200,7 +199,6 @@ class PostRepositories
         //验证小号
         //验证小号
         $userInfo = $this->getUserInfo();
         $userInfo = $this->getUserInfo();
         if (empty($userInfo)) {
         if (empty($userInfo)) {
-            Log::info('获取用户信息失败');
             return jsonError('获取用户信息失败');
             return jsonError('获取用户信息失败');
         }
         }
 
 

+ 5 - 1
app/Transformers/Post/DetailTransformer.php

@@ -19,9 +19,10 @@ use League\Fractal\TransformerAbstract;
 class DetailTransformer extends TransformerAbstract
 class DetailTransformer extends TransformerAbstract
 {
 {
     use UserTrait;
     use UserTrait;
-    public function __construct($uid)
+    public function __construct($uid, $invite_code)
     {
     {
         $this->uid = $uid;
         $this->uid = $uid;
+        $this->invite_code = $invite_code;
     }
     }
     public function transform(Post $post)
     public function transform(Post $post)
     {
     {
@@ -58,6 +59,7 @@ class DetailTransformer extends TransformerAbstract
             'video' => $post['video'],
             'video' => $post['video'],
             'pv' => $post->data->pv,
             'pv' => $post->data->pv,
             'praise_count' => $post->data->praise_count,
             'praise_count' => $post->data->praise_count,
+            'collect_count' => $post->data->collect_count,
             'comment_count' => $post->data->comment_count,
             'comment_count' => $post->data->comment_count,
             'available_bean' => $post->data->available_bean,
             'available_bean' => $post->data->available_bean,
             'will_collect_bean' => $post->data->will_collect_bean,
             'will_collect_bean' => $post->data->will_collect_bean,
@@ -65,6 +67,8 @@ class DetailTransformer extends TransformerAbstract
             'is_dislike' => PostDislike::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'is_dislike' => PostDislike::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'is_collect' => PostCollect::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'is_collect' => PostCollect::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'is_follow' => $isFollow,
             'is_follow' => $isFollow,
+            'h5url' => config('customer.share_post_h5url')."?post_id={$post['id']}&invite_code={$this->invite_code}",
+            'desc_url' => $post['type'] == 'html'?config('customer.app_service_url').'/community/fragment/detail/'.$post['id']:'',
         ];
         ];
     }
     }
 }
 }

+ 2 - 0
app/Transformers/Post/SuggestTransformer.php

@@ -81,12 +81,14 @@ class SuggestTransformer extends TransformerAbstract
             'pv' => $post->data->pv,
             'pv' => $post->data->pv,
             'praise_count' => $post->data->praise_count,
             'praise_count' => $post->data->praise_count,
             'comment_count' => $post->data->comment_count,
             'comment_count' => $post->data->comment_count,
+            'collect_count' => $post->data->collect_count,
             'will_collect_bean' => $post->data->will_collect_bean,
             'will_collect_bean' => $post->data->will_collect_bean,
             'is_like' => PostLike::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'is_like' => PostLike::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'is_dislike' => PostDislike::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'is_dislike' => PostDislike::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'is_collect' => PostCollect::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'is_collect' => PostCollect::where('post_id', $post['id'])->where('uid', $this->uid)->exists()?1:0,
             'comment' => $comment,
             'comment' => $comment,
             'is_follow' => $isFollow,
             'is_follow' => $isFollow,
+            'desc_url' => $post['type'] == 'html'?config('customer.app_service_url').'/community/fragment/detail/'.$post['id']:'',
         ];
         ];
     }
     }
 }
 }

+ 2 - 0
config/customer.tpl

@@ -4,4 +4,6 @@ return [
     'app_secret' => '{app_secret}',
     'app_secret' => '{app_secret}',
     'jwt_secret' => '{jwt_secret}',
     'jwt_secret' => '{jwt_secret}',
     'app_service_url' => '{app_service_url}',
     'app_service_url' => '{app_service_url}',
+    'share_post_h5url' => '{share_post_h5url}',
+    'share_post_bean' => '{share_post_bean}',
 ];
 ];

Diferenças do arquivo suprimidas por serem muito extensas
+ 18 - 0
resources/views/post/detail.php


+ 5 - 0
routes/web.php

@@ -19,3 +19,8 @@ $router->get('/', function () use ($router) {
 $router->get('/test', function () use ($router) {
 $router->get('/test', function () use ($router) {
     return 'test';
     return 'test';
 });
 });
+
+$router->get('/fragment/detail/{id:[0-9]+}', ['as'=> 'fragment.detail', function ($id) use ($router) {
+    $desc = \App\Models\Post::where('id',$id)->value('content');
+    return view('post.detail', ['desc'=>$desc]);
+}]);