|
@@ -5,6 +5,8 @@ use App\Models\CommentRecord;
|
|
|
use App\Models\GeneralRecord;
|
|
|
use App\Models\Post;
|
|
|
use App\Models\RegisteredRecord;
|
|
|
+use App\Models\ReleaseRecord;
|
|
|
+use Illuminate\Support\Carbon;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
use Tymon\JWTAuth\Facades\JWTAuth;
|
|
@@ -142,8 +144,7 @@ class BeanRepository
|
|
|
}
|
|
|
}
|
|
|
$content_author_id = array_column($excellent_residents,'content_author_id');
|
|
|
- $content_author_id = array_unique($content_author_id);
|
|
|
- $uids = implode(',', $content_author_id);
|
|
|
+ $uids = implode(',', array_unique($content_author_id));
|
|
|
$author_data = $this->getFollowMembersStatus($uids);
|
|
|
if ($author_data){
|
|
|
foreach ($excellent_residents as $k=>$v){
|
|
@@ -157,22 +158,89 @@ class BeanRepository
|
|
|
return $excellent_residents;
|
|
|
}
|
|
|
|
|
|
- public function registeredMost($request)
|
|
|
+ public function rankingList($request)
|
|
|
{
|
|
|
- $registered_most = Redis::get('yesterday_registered_most');
|
|
|
+ $time = Carbon::now()->startOfDay()->toDateTimeString();
|
|
|
+ if ($request['type'] == 0){//排行榜赚豆达人
|
|
|
+ $all_bean = Redis::get('yesterday_all_bean');
|
|
|
+ $all_beans = json_decode($all_bean,true);
|
|
|
|
|
|
- return $registered_most;
|
|
|
|
|
|
- }
|
|
|
+ }elseif ($request['type'] == 1){//排行榜人脉达人
|
|
|
+// $registered_most = Redis::get('yesterday_registered_most');
|
|
|
+// $registered_mosts = json_decode($registered_most,true);
|
|
|
|
|
|
- public function bestAuthor($request)
|
|
|
- {
|
|
|
- $all_best_author = Redis::get('yesterday_best_author');
|
|
|
+ //昨日拉新最多前十人
|
|
|
+ $registered_most = RegisteredRecord::
|
|
|
+ where('created_at', '>=',$time)
|
|
|
+ ->select(DB::raw('count(*) as count'),'superior_uid')
|
|
|
+ ->groupBy('superior_uid')->orderBy('count','desc')->limit(10)->get();
|
|
|
+ $registered_most = $registered_most->toArray();
|
|
|
+
|
|
|
+ $superior_uid = array_column($registered_most,'superior_uid');
|
|
|
+ $uids = implode(',', array_unique($superior_uid));
|
|
|
+ $user_data = $this->getFollowMembersStatus($uids);
|
|
|
+ if ($user_data){
|
|
|
+ foreach ($registered_most as $k=>$v){
|
|
|
+ if(!isset($user_data[$v['superior_uid']])) continue;
|
|
|
+ $registered_most[$k]['follow_status'] = $user_data[$v['superior_uid']]['follow_status'];
|
|
|
+ $registered_most[$k]['username'] = $user_data[$v['superior_uid']]['username'];
|
|
|
+ $registered_most[$k]['avatar'] = $user_data[$v['superior_uid']]['avatar'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $registered_most;
|
|
|
+
|
|
|
+ }else{//排行榜最佳作者
|
|
|
+// $all_best_author = Redis::get('yesterday_best_author');
|
|
|
+// $all_best_authors = json_decode($all_best_author,true);
|
|
|
+ //昨日文章产生彩虹豆最多前十人
|
|
|
+ $comment_author = CommentRecord::select(DB::raw('count(*) as count'),'generation_quantity','content_author_id','related_content_id')->groupBy('generation_quantity','related_content_id','content_author_id')
|
|
|
+ ->orderBy('generation_quantity','desc')
|
|
|
+ ->limit(10)
|
|
|
+ ->get();;
|
|
|
+ $comment_best_author = $comment_author->toArray();
|
|
|
+ foreach ($comment_best_author as $k=>$v){
|
|
|
+ $comment_best_author[$k]['type'] = 'comment';
|
|
|
+ }
|
|
|
+ $general_author = GeneralRecord::select(DB::raw('count(*) as count'),'generation_quantity','content_author_id','related_content_id')->groupBy('generation_quantity','related_content_id','content_author_id')
|
|
|
+ ->orderBy('generation_quantity','desc')
|
|
|
+ ->limit(10)
|
|
|
+ ->get();;;
|
|
|
+ $general_best_author = $general_author->toArray();
|
|
|
+ foreach ($general_best_author as $k=>$v){
|
|
|
+ $general_best_author[$k]['type'] = 'general';
|
|
|
+ }
|
|
|
+ $release_author =ReleaseRecord::
|
|
|
+// ->where('created_at', '>=', $time)
|
|
|
+ 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();
|
|
|
+ foreach ($release_best_author as $k=>$v){
|
|
|
+ $release_best_author[$k]['type'] = 'release';
|
|
|
+ }
|
|
|
+ $all_best_author = array_merge($comment_best_author,$general_best_author,$release_best_author);
|
|
|
|
|
|
- return $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);
|
|
|
+ $related_content_id = array_column($all_best_author,'related_content_id');
|
|
|
+ $uids = implode(',', array_unique($related_content_id));
|
|
|
+ $user_data = $this->getFollowMembersStatus($uids);
|
|
|
+ if ($user_data){
|
|
|
+ foreach ($all_best_author as $k=>$v){
|
|
|
+ if(!isset($user_data[$v['related_content_id']])) continue;
|
|
|
+ $all_best_author[$k]['follow_status'] = $user_data[$v['related_content_id']]['follow_status'];
|
|
|
+ $all_best_author[$k]['username'] = $user_data[$v['related_content_id']]['username'];
|
|
|
+ $all_best_author[$k]['avatar'] = $user_data[$v['related_content_id']]['avatar'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $all_best_author;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
function getFollowMembersStatus($uids) {
|
|
|
try {
|
|
|
$url = config("customer.app_service_url").'/user/v2/member/getMemberIds';
|