|
@@ -1,13 +1,8 @@
|
|
<?php
|
|
<?php
|
|
namespace App\Repositories;
|
|
namespace App\Repositories;
|
|
-use App\Models\Behavior;
|
|
|
|
-use App\Models\CommentRecord;
|
|
|
|
-use App\Models\GeneralRecord;
|
|
|
|
use App\Models\Post;
|
|
use App\Models\Post;
|
|
-use App\Models\RegisteredRecord;
|
|
|
|
-use App\Models\ReleaseRecord;
|
|
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Carbon;
|
|
-use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
+use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Tymon\JWTAuth\Facades\JWTAuth;
|
|
use Tymon\JWTAuth\Facades\JWTAuth;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use Illuminate\Support\Facades\Redis;
|
|
@@ -59,7 +54,7 @@ class BeanRepository
|
|
foreach ($excellent_residents as $k=>$v){
|
|
foreach ($excellent_residents as $k=>$v){
|
|
if(!isset($author_data[$v['content_author_id']])) continue;
|
|
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]['follow_status'] = $author_data[$v['content_author_id']]['follow_status'];
|
|
- $excellent_residents[$k]['username'] = $author_data[$v['content_author_id']]['username'];
|
|
|
|
|
|
+ $excellent_residents[$k]['username'] = subtext($author_data[$v['content_author_id']]['username'], 5);
|
|
$excellent_residents[$k]['avatar'] = $author_data[$v['content_author_id']]['avatar'];
|
|
$excellent_residents[$k]['avatar'] = $author_data[$v['content_author_id']]['avatar'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -88,7 +83,9 @@ class BeanRepository
|
|
foreach ($new_arr as $k => $v) {
|
|
foreach ($new_arr as $k => $v) {
|
|
if (!isset($user_data[$v['uid']])) continue;
|
|
if (!isset($user_data[$v['uid']])) continue;
|
|
$new_arr[$k]['follow_status'] = $user_data[$v['uid']]['follow_status'];
|
|
$new_arr[$k]['follow_status'] = $user_data[$v['uid']]['follow_status'];
|
|
- $new_arr[$k]['username'] = $user_data[$v['uid']]['username'];
|
|
|
|
|
|
+ $username = subtext($user_data[$v['uid']]['username'], 10);
|
|
|
|
+
|
|
|
|
+ $new_arr[$k]['username'] = $username;
|
|
$new_arr[$k]['avatar'] = $user_data[$v['uid']]['avatar'];
|
|
$new_arr[$k]['avatar'] = $user_data[$v['uid']]['avatar'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -105,8 +102,11 @@ class BeanRepository
|
|
if ($user_data){
|
|
if ($user_data){
|
|
foreach ($registered_most as $k=>$v){
|
|
foreach ($registered_most as $k=>$v){
|
|
if(!isset($user_data[$v['superior_uid']])) continue;
|
|
if(!isset($user_data[$v['superior_uid']])) continue;
|
|
|
|
+ $registered_most[$k]['count'] = intval($v['count']);
|
|
$registered_most[$k]['follow_status'] = $user_data[$v['superior_uid']]['follow_status'];
|
|
$registered_most[$k]['follow_status'] = $user_data[$v['superior_uid']]['follow_status'];
|
|
- $registered_most[$k]['username'] = $user_data[$v['superior_uid']]['username'];
|
|
|
|
|
|
+ $username = subtext($user_data[$v['superior_uid']]['username'], 10);
|
|
|
|
+
|
|
|
|
+ $registered_most[$k]['username'] = $username;
|
|
$registered_most[$k]['avatar'] = $user_data[$v['superior_uid']]['avatar'];
|
|
$registered_most[$k]['avatar'] = $user_data[$v['superior_uid']]['avatar'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -123,8 +123,11 @@ class BeanRepository
|
|
if ($user_data){
|
|
if ($user_data){
|
|
foreach ($all_best_author as $k=>$v){
|
|
foreach ($all_best_author as $k=>$v){
|
|
if(!isset($user_data[$v['content_author_id']])) continue;
|
|
if(!isset($user_data[$v['content_author_id']])) continue;
|
|
|
|
+ $all_best_author[$k]['count'] = intval($v['count']);
|
|
$all_best_author[$k]['follow_status'] = $user_data[$v['content_author_id']]['follow_status'];
|
|
$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'];
|
|
|
|
|
|
+ $username = subtext($user_data[$v['content_author_id']]['username'], 10);
|
|
|
|
+
|
|
|
|
+ $all_best_author[$k]['username'] = $username;
|
|
$all_best_author[$k]['avatar'] = $user_data[$v['content_author_id']]['avatar'];
|
|
$all_best_author[$k]['avatar'] = $user_data[$v['content_author_id']]['avatar'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -153,13 +156,18 @@ class BeanRepository
|
|
{
|
|
{
|
|
$star_home = [];
|
|
$star_home = [];
|
|
$user_bean = Redis::get('my_bean');
|
|
$user_bean = Redis::get('my_bean');
|
|
|
|
+ Log::debug($user_bean);
|
|
$user_bean = json_decode($user_bean,true);
|
|
$user_bean = json_decode($user_bean,true);
|
|
$yesterday_quantity_issued = Redis::get('yesterday_quantity_issued');
|
|
$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;//昨日发放总彩虹豆
|
|
|
|
|
|
+ Log::debug($user_bean);
|
|
|
|
+ $token = JWTAuth::decode(JWTAuth::getToken());
|
|
|
|
+ $uid = $token['user']->uid;
|
|
|
|
+ $my_bean = $this->get_user_bean($uid);
|
|
|
|
+ $star_home['mybean']['user_all_bean'] = intval($my_bean['user_all_bean']) ?? 0;//用户总彩虹豆
|
|
|
|
+ $star_home['mybean']['yesterday_add_bean'] = intval($my_bean['yesterday_add_bean']) ?? 0;//昨日发放彩虹豆
|
|
|
|
+ $star_home['mybean']['user_count'] = intval($user_bean['user_count']) ?? 0;//已入驻居民
|
|
|
|
+ $star_home['mybean']['yesterday_add_user'] = intval($user_bean['yesterday_add_user']) ?? 0;//昨日新增居民
|
|
|
|
+ $star_home['mybean']['yesterday_quantity_issued'] = intval($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);
|
|
@@ -169,6 +177,21 @@ class BeanRepository
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //获取某用户豆数
|
|
|
|
+ function get_user_bean($uid)
|
|
|
|
+ {
|
|
|
|
+ try {
|
|
|
|
+ $url = config("customer.app_service_url").'/user/v2/user_bean';
|
|
|
|
+ $array = [
|
|
|
|
+ 'json' => ['uid' => $uid], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
|
|
|
|
+ ];
|
|
|
|
+ return http($url,$array,'get');
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ return [];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
//获取每日新闻
|
|
//获取每日新闻
|
|
function getNews($request) {
|
|
function getNews($request) {
|
|
try {
|
|
try {
|
|
@@ -198,4 +221,72 @@ class BeanRepository
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function starDetail($request)
|
|
|
|
+ {
|
|
|
|
+ $star_detail = [];
|
|
|
|
+ $user_bean = Redis::get('my_bean');
|
|
|
|
+ $user_bean = json_decode($user_bean,true);
|
|
|
|
+ $yesterday_quantity_issued = Redis::get('yesterday_quantity_issued');
|
|
|
|
+ $exchange = Redis::ZREVRANGEBYSCORE('post_purchase_message','+inf','-inf');
|
|
|
|
+ foreach ($exchange as $k=>$v){
|
|
|
|
+ $exchange[$k] = json_decode($v,true);
|
|
|
|
+ }
|
|
|
|
+ Log::debug($user_bean);
|
|
|
|
+ Log::debug($yesterday_quantity_issued);
|
|
|
|
+ Log::debug($exchange);
|
|
|
|
+
|
|
|
|
+ $post_detail = new Post();
|
|
|
|
+ if (isset($request['post_id'])){
|
|
|
|
+ $post = $post_detail->
|
|
|
|
+ join('post_data', 'post_data.post_id', '=', 'post.id')
|
|
|
|
+ ->select('post.*','post_data.pv')
|
|
|
|
+ ->find($request['post_id']);
|
|
|
|
+ if ($post){
|
|
|
|
+ $post->created_time = Carbon::parse($post->created_at)->diffForHumans();
|
|
|
|
+ $imgs = [];
|
|
|
|
+ foreach($post->imgs as $img){
|
|
|
|
+ $imgs[] = $img['img'];
|
|
|
|
+ }
|
|
|
|
+ unset($post->imgs);
|
|
|
|
+ $post->imgs = $imgs;
|
|
|
|
+ $post->topic = $post->topic();
|
|
|
|
+ $star_detail['post'] = $post;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $user_info = $this->getUserInfo($invite_code = $request['invite_code']);
|
|
|
|
+ if ($user_info){
|
|
|
|
+ $star_detail['invite']['uid'] = $user_info['uid'] ?? 0;
|
|
|
|
+ $star_detail['invite']['username'] = $user_info['username'] ?? '';
|
|
|
|
+ $star_detail['invite']['avatar'] = $user_info['avatar'] ?? '';
|
|
|
|
+ $star_detail['invite']['bean'] = config("customer.share_post_bean") ?? 0;
|
|
|
|
+ }else{
|
|
|
|
+ return jsonError('邀请码有误');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $star_detail['mybean']['user_count'] = intval($user_bean['user_count']) ?? 0;//已入驻居民
|
|
|
|
+ $star_detail['mybean']['yesterday_add_user'] = intval($user_bean['yesterday_add_user']) ?? 0;//昨日新增居民
|
|
|
|
+ $star_detail['mybean']['yesterday_quantity_issued'] = intval($yesterday_quantity_issued) ?? 0;//昨日发放总彩虹豆
|
|
|
|
+
|
|
|
|
+ $star_detail['daily_news'] = $this->getNews($request);
|
|
|
|
+ $star_detail['exchange'] = $exchange;
|
|
|
|
+
|
|
|
|
+ return $star_detail;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //根据邀请码获取用户信息
|
|
|
|
+ function getUserInfo($invite_code) {
|
|
|
|
+ try {
|
|
|
|
+ $sign = generateSign(['invite_code' => $invite_code], config('customer.app_secret'));
|
|
|
|
+ $url = config("customer.app_service_url").'/user/v2/member/getInviteCodeMember';
|
|
|
|
+ $array = [
|
|
|
|
+ 'json' => ['sign' => $sign,'invite_code' => $invite_code], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
|
|
|
|
+ ];
|
|
|
|
+ return http($url,$array,'get');
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ return [];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|