|
@@ -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;
|
|
@@ -26,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);
|
|
@@ -74,7 +66,7 @@ class BeanRepository
|
|
|
->groupBy('related_content_id', 'content_author_id')->orderBy('count', 'desc')->limit(1)->get();
|
|
|
$collent = $collent->toArray();
|
|
|
foreach ($collent as $k=>$v){
|
|
|
- $collent[$k]['type'] = 'collent';
|
|
|
+ $collent[$k]['type'] = 'collect';
|
|
|
}
|
|
|
|
|
|
//文章被喜欢最多用户
|
|
@@ -142,8 +134,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 +148,67 @@ class BeanRepository
|
|
|
return $excellent_residents;
|
|
|
}
|
|
|
|
|
|
- public function registeredMost($request)
|
|
|
+ public function rankingList($request)
|
|
|
{
|
|
|
- $registered_most = Redis::get('yesterday_registered_most');
|
|
|
-
|
|
|
- return $registered_most;
|
|
|
+ if ($request['type'] == 0){//排行榜赚豆达人
|
|
|
+ $yesterday = Carbon::yesterday()->toDateString();
|
|
|
+ $all_beans = Redis::ZREVRANGEBYSCORE('user_rainbow_bean'.$yesterday, 100000000, 0, array('WITHSCORES'=>true,'limit' => array(0, 20)));
|
|
|
+ $new_arr = [];
|
|
|
+ $i = 0;
|
|
|
+ foreach ($all_beans as $key => $val) {
|
|
|
+ $new_arr[$i]['uid'] = $key;
|
|
|
+ $new_arr[$i]['count'] = $val;
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ $uids = implode(',', array_column($new_arr,'uid'));
|
|
|
+ $user_data = $this->getFollowMembersStatus($uids);
|
|
|
+ if ($user_data){
|
|
|
+ foreach ($new_arr as $k=>$v){
|
|
|
+ if(!isset($user_data[$v['uid']])) continue;
|
|
|
+ $new_arr[$k]['follow_status'] = $user_data[$v['uid']]['follow_status'];
|
|
|
+ $new_arr[$k]['username'] = $user_data[$v['uid']]['username'];
|
|
|
+ $new_arr[$k]['avatar'] = $user_data[$v['uid']]['avatar'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $new_arr;
|
|
|
|
|
|
- }
|
|
|
+ }elseif ($request['type'] == 1){//排行榜人脉达人
|
|
|
+ $registered_mosts = Redis::get('yesterday_registered_most');
|
|
|
+ $registered_most = json_decode($registered_mosts,true);
|
|
|
|
|
|
- public function bestAuthor($request)
|
|
|
- {
|
|
|
- $all_best_author = Redis::get('yesterday_best_author');
|
|
|
+ $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;
|
|
|
|
|
|
- return $all_best_author;
|
|
|
+ }else{//排行榜最佳作者
|
|
|
+ $all_best_authors = Redis::get('yesterday_best_author');
|
|
|
+ $all_best_author = json_decode($all_best_authors,true);
|
|
|
|
|
|
+ $content_author_id = array_column($all_best_author,'content_author_id');
|
|
|
+ $uids = implode(',', array_unique($content_author_id));
|
|
|
+ $user_data = $this->getFollowMembersStatus($uids);
|
|
|
+ if ($user_data){
|
|
|
+ foreach ($all_best_author as $k=>$v){
|
|
|
+ if(!isset($user_data[$v['content_author_id']])) continue;
|
|
|
+ $all_best_author[$k]['follow_status'] = $user_data[$v['content_author_id']]['follow_status'];
|
|
|
+ $all_best_author[$k]['username'] = $user_data[$v['content_author_id']]['username'];
|
|
|
+ $all_best_author[$k]['avatar'] = $user_data[$v['content_author_id']]['avatar'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $all_best_author;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
function getFollowMembersStatus($uids) {
|
|
|
try {
|
|
|
$url = config("customer.app_service_url").'/user/v2/member/getMemberIds';
|
|
@@ -187,4 +223,53 @@ class BeanRepository
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public function starHome($request)
|
|
|
+ {
|
|
|
+ $star_home = [];
|
|
|
+ $user_bean = Redis::get('my_bean');
|
|
|
+ $user_bean = json_decode($user_bean,true);
|
|
|
+ $yesterday_quantity_issued = Redis::get('yesterday_quantity_issued');
|
|
|
+ $star_home['mybean']['user_all_bean'] = $user_bean['user_all_bean'] ?? 0;//用户总彩虹豆
|
|
|
+ $star_home['mybean']['yesterday_add_bean'] = $user_bean['yesterday_add_bean'] ?? 0;//昨日发放彩虹豆
|
|
|
+ $star_home['mybean']['user_count'] = $user_bean['user_count'] ?? 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['excellent_residents'] = $this->excellentResidents($request);
|
|
|
+ $star_home['daily_news'] = $this->getNews($request);
|
|
|
+ $star_home['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 [];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|