瀏覽代碼

将golf近期的用户调整和bug修复同步到golf1.0.2

phperli 3 年之前
父節點
當前提交
d98cb1882a

+ 2 - 0
app/Http/Controllers/V1/ChatTeamController.php

xqd xqd
@@ -52,6 +52,7 @@ class ChatTeamController extends Controller
             $chatTeam->FaceUrl = $data['file_avatar'];
             $chatTeam->MaxMemberCount = 20;
             $chatTeam->ApplyJoinOption = 'FreeAccess';
+            $chatTeam->type = 1;
             $chatTeam->save();
 
             //发一条群公告,目的是为了让群自动发一条消息
@@ -94,6 +95,7 @@ class ChatTeamController extends Controller
                 throw new \Exception(trans('api.GROUP_CHAT_DOES_NOT_EXIST'));
             }
             $res = $this->groupService->getGroupInfo($groupId);
+            $res['type'] = $chatTeam->type ?: 1;
             if ($res['ErrorCode'] == 0 && !empty($res['GroupInfo'])) {
                 if (!empty($res['GroupInfo'][0]['MemberList'])) {
                     foreach ($res['GroupInfo'][0]['MemberList'] as &$v) {

+ 8 - 0
app/Http/Controllers/V1/FeedsController.php

xqd
@@ -47,6 +47,14 @@ class FeedsController extends Controller
     public function release(FeedsRequest $request)
     {
         try {
+            $content    = $request->input('content', '');
+            $fileUrl    = $request->input('file_url', '');
+            $gameUserId = $request->input('game_per_id', '');
+
+            if(empty($content) && empty($fileUrl) && empty($gameUserId)){
+                throw new Exception(trans('api.NOT_EMPTY'));
+            }
+
             $user = auth('api')->user();
             $lock = Cache::lock(ApiEnum::FEED_RELEASE . $user->id, 1);
             if ($lock->get()) {

+ 1 - 1
app/Http/Controllers/V1/GameController.php

xqd
@@ -83,7 +83,7 @@ class GameController extends Controller
                 $info['end_time'] = date('Y-m-d H:i', strtotime($info['end_time']));
             }
 
-            $info['game_users'] = $this->GameService->getGamePlayers($info['id']);
+            $info['game_users'] = $this->GameService->getGameUsers($info['id']);
 
             return $this->success($info);
 

+ 19 - 2
app/Http/Controllers/V1/TeamController.php

xqd xqd xqd
@@ -82,6 +82,7 @@ class TeamController extends Controller
             $chatTeam->FaceUrl = $request->img;
             $chatTeam->MaxMemberCount = 20;
             $chatTeam->ApplyJoinOption = 'FreeAccess';
+            $chatTeam->type = 2;
             $chatTeam->save();
             if (!$team->save()) {
                 throw new Exception(trans('api.DATA_SAVE_FALSE'));
@@ -136,13 +137,14 @@ class TeamController extends Controller
                 throw new Exception(trans('api.USER_NO_AUTH'));
             }
             $team = TeamModel::find($request->id);
-
+            $preName = $team->name;
             $actualCount = TeamService::getTeamUserCount($request->id);
 
             if($request->member_counts < $actualCount){
                 throw new Exception(trans('api.MEMBER_COUNT_IllEGAL'));
             }
-            $team->name = $request->name;
+            $teamName = $request->name;
+            $team->name = $teamName;
             $team->address = $request->address;
             $team->member_counts = $request->member_counts; //人数上限
             $team->slogan = $request->slogan;
@@ -154,6 +156,21 @@ class TeamController extends Controller
             if (!$team->save()) {
                 throw new Exception(trans('api.DATA_SAVE_FALSE'));
             }
+
+            if($teamName != $preName){ //如果群聊名称发生改变,更新群聊名称
+                $groupData['GroupId'] = $team->GroupId;
+                $groupData['name'] = $teamName;
+                $groupService = TencentImGroupService::getInstance();
+                $groupService->modifyGroupBaseInfo($groupData);
+                //修改本地数据
+                $chatTeam = ChatTeam::query()
+                    ->where('GroupId', $team->GroupId)
+                    ->whereNull('deleted_at')
+                    ->first();
+                $chatTeam->group_name = $teamName;
+                $chatTeam->save();
+            }
+
         } catch (\Exception $exception) {
             return $this->error($exception->getMessage());
         }

+ 2 - 3
app/Http/Requests/FeedsRequest.php

xqd
@@ -24,21 +24,20 @@ class FeedsRequest extends Request
     }
 
     /**
-     * Get the validation rules that apply to the request.
+     * Get the validation rules that apply to the request.['
      *
      * @return array
      */
     public function rules()
     {
         return [
-            'content'  => 'required|max:100|min:2',
+            'content'  => 'max:200|min:1',
         ];
     }
 
     public function messages()
     {
         return [
-            'content.required' => trans('api.CONTENT_REQUIRED'),
             'content.max' => trans('api.CONTENT_TOO_LONG'),
             'content.min' => trans('api.CONTENT_TOO_SHORT'),
         ];

+ 2 - 0
app/Http/Requests/StoreTeam.php

xqd xqd
@@ -25,6 +25,7 @@ class StoreTeam extends Request
         return [
             'name' => 'bail|required|max:20|min:2|unique:teams,name,' . $id,
             'member_counts' => 'required',
+            'desc' => 'max:100',
         ];
     }
 
@@ -36,6 +37,7 @@ class StoreTeam extends Request
             'name.max'      => trans('api.NAME_TOO_LONG'),
             'name.min'      => trans('api.NAME_TOO_SHORT'),
             'member_counts.required' => trans('api.MEMBER_COUNTS_REQUIRED'),
+            'desc.max'      => trans('api.DESC_TOO_LONG'),
         ];
     }
 

+ 24 - 9
app/Services/Api/FeedsService.php

xqd xqd xqd xqd xqd xqd xqd
@@ -5,6 +5,7 @@ namespace App\Services\Api;
 
 
 use App\Http\Requests\FeedsRequest;
+use App\Models\Course;
 use App\Models\Feed;
 use App\Models\FeedComment;
 use App\Models\FeedForward;
@@ -27,8 +28,10 @@ class FeedsService
     {
         $user = auth('api')->user();
         $type = $request->input('type', 1); // 1全部  2关注  3热门
+        $page = $request->input('page', 1);
         $teamId = $request->input('team_id', 0);
         $userId = $request->input('user_id', 0);
+
         //注销或被删除的用户 User::query() 不生效 , 需 DB::table('users')
         $disableUserId = DB::table('users')->whereNotNull('deleted_at')->pluck('id');
         $disableUserId = $disableUserId->isNotEmpty() ? $disableUserId->toArray() : [];
@@ -40,7 +43,6 @@ class FeedsService
             ->whereNull('deleted_at');
 
         $desc = 'id';
-
         if (!empty($type) && $type > 1) {
             $followIds = UserFollow::query()->where(['user_id' => $user->id, 'status' => 1])->pluck('target_id');
             $followIds = $followIds->isNotEmpty() ? $followIds->toArray() : [];
@@ -54,13 +56,17 @@ class FeedsService
         if (!empty($userId)) {
             $feeds->where('user_id', $userId);
         }
-        $feeds = $feeds->orderByDesc($desc)->paginate(request('perPage', 20));
+        $limit  = 10;
+        $offset = ($page - 1) * $limit;
+        $feeds  = $feeds->orderByDesc($desc)->limit($limit)->offset($offset)->get();
         if ($feeds->isEmpty()) {
-            return [];
+            return $data = [
+                'stop' => 1,
+                'data' => [],
+            ];
         }
         $feeds = $feeds->toArray();
-
-        foreach ($feeds['data'] as &$v) {
+        foreach ($feeds as &$v) {
             $v['have_user_course'] = UserService::haveUserCourse($v['user_id']);
             //查询评论数量
             $v['commemt_num'] = FeedComment::query()->where(['feed_id' => $v['id'], 'pid' => 0])->count();
@@ -89,7 +95,10 @@ class FeedsService
         if (!empty($user)) {
             MessageService::changeStatus($user->id, [9]);
         }
-        return $feeds;
+        return $data = [
+            'stop' => 0,
+            'data' => $feeds,
+        ];;
     }
 
     //用户动态列表
@@ -165,9 +174,15 @@ class FeedsService
     public static function queryScoreCard($game_user_id)
     {
         $gameId = GameUser::where('id', $game_user_id)->value('game_id');
-        $gameInfo = Game::query()->where('id', $gameId)->first();
+        $gameInfo = Game::query()->where('id', $gameId)->whereNull('deleted_at')->first();
+        if($gameInfo){
+            $gameInfo = $gameInfo->toArray();
+            $gameInfo['course_img'] = Course::find($gameInfo['course_id'])->img;
+        }else{
+            $gameInfo = null;
+        }
         return $scoreCard = [
-            'game_info' => $gameInfo ? $gameInfo->toArray() : null,
+            'game_info' => $gameInfo,
             'game_score' => GameService::getGameUserScore($game_user_id)
         ];
     }
@@ -316,7 +331,7 @@ class FeedsService
         $user = auth('api')->user();
         $feed = array();
         $feed['user_id'] = $user->id;
-        $feed['content'] = $feedsRequest->post('content');
+        $feed['content'] = $feedsRequest->post('content') ?: '';
         $feed['file_url'] = !empty($feedsRequest->post('file_url')) ? json_encode($feedsRequest->post('file_url')) : '';
         $feed['address_info'] = !empty($feedsRequest->post('address_info')) ? $feedsRequest->post('address_info') : '';
         $feed['match_title'] = $feedsRequest->post('match_title');

+ 19 - 20
app/Services/Api/GameService.php

xqd xqd xqd xqd xqd
@@ -260,6 +260,7 @@ class GameService
         try {
             if ($request->id) {
                 $game = Game::query()->find($request->id);
+                $preName = $game->name;
             }
             $game->creator = $this->user->id;
             $typeId = $request->game_type_id;
@@ -353,11 +354,25 @@ class GameService
                 $chatTeam->FaceUrl = $resData['file_avatar'];
                 $chatTeam->MaxMemberCount = 20;
                 $chatTeam->ApplyJoinOption = 'FreeAccess';
+                $chatTeam->type = 3;
                 $chatTeam->save();
 
                 $gameUser->addAll($data); //批量新增
             } else {
                 self::addOrUpdate($request->id, $data);
+                if($gameName != $preName){ //如果群聊名称发生改变,更新群聊名称
+                    $groupData['GroupId'] = $game->GroupId;
+                    $groupData['name'] = $gameName;
+                    $groupService = TencentImGroupService::getInstance();
+                    $groupService->modifyGroupBaseInfo($groupData);
+                    //修改本地数据
+                    $chatTeam = ChatTeam::query()
+                        ->where('GroupId', $game->GroupId)
+                        ->whereNull('deleted_at')
+                        ->first();
+                    $chatTeam->group_name = $gameName;
+                    $chatTeam->save();
+                }
             }
             DB::commit();
         } catch (\Exception $exception) {
@@ -754,7 +769,8 @@ class GameService
             ->where('gu.status', 1)
             ->whereNull('gu.deleted_at')
             ->where('gu.type', 1)
-            ->select('u.name', 'u.sex', 'u.avatar', 'u.is_auth', 'gu.id as game_user_id', 'gu.user_id')
+            ->select('u.name', 'u.sex', 'u.avatar', 'u.is_auth', 'gu.id as game_user_id', 'gu.user_id', 'gu.type', 'level')
+            ->orderBy('gu.id', 'asc')
             ->get();
 
         if($list1->isEmpty()){
@@ -772,7 +788,8 @@ class GameService
             ->where('gu.game_id', $gameId)
             ->whereNull('gu.deleted_at')
             ->where('gu.type', 2)
-            ->select('gf.name', 'gf.sex', 'gf.avatar', 'gu.id as game_user_id')
+            ->select('gf.name', 'gf.sex', 'gf.avatar', 'gu.user_id', 'gu.id as game_user_id', 'gu.type', 'level')
+            ->orderBy('gu.id', 'asc')
             ->get();
         if($list2->isEmpty()){
             $list2 = [];
@@ -1433,23 +1450,5 @@ class GameService
         return array_merge(['game_info' => $gameInfo], $best);
     }
 
-    //获取比赛球员
-    public function getGamePlayers($gameId)
-    {
-        $gameUsers = (new GameUser())->setTable('gu')->from('game_users as gu')
-            ->join('users as u', 'u.id', '=', 'gu.user_id')
-            ->where('gu.game_id', $gameId)
-            ->select('u.name', 'u.avatar', 'gu.user_id', 'gu.type', 'level', 'u.is_auth')
-            ->orderBy('gu.id', 'asc')
-            ->get();
-
-        $gameUsers = $gameUsers->isNotEmpty() ? $gameUsers->toArray() : [];
-
-        foreach ($gameUsers as $key => &$val) {
-            $val['have_user_course'] = UserService::haveUserCourse($val['user_id']);
-        }
-
-        return $gameUsers;
-    }
 
 }

+ 0 - 1
app/Services/Api/UserService.php

xqd
@@ -33,7 +33,6 @@ class UserService
     public static function getUserInfo($user_id)
     {
         $info = User::where('id', $user_id)
-            ->select('id', 'name', 'avatar', 'sex', 'tencent_im_user_id', 'bio', 'birthday', 'mobile', 'email', 'wx_openid', 'bg', 'fb_openid','apple_openid', 'is_auth', 'usga', 'ball_age')
             ->whereNull('deleted_at')
             ->first();
         if (!$info) {

+ 1 - 0
public/app-ads.txt

xqd
@@ -0,0 +1 @@
+ facebook.com,1096757440907832,RESELLER,c3e20eee3f780d68

+ 4 - 3
resources/lang/en/api.php

xqd xqd xqd
@@ -7,12 +7,13 @@ return [
     | Api Language Lines
     |--------------------------------------------------------------------------
     */
-    'SUCCESS' => 'Success',
+    'SUCCESS' => 'Changes Saved',
     'FAIL' => 'Fail',
+    'NOT_EMPTY' => 'Cannot be empty',
     'UPLOAD_SUCCESS' => 'Upload success',
     'REQUESTS_TOO_FREQUENTLY' => 'Requests too frequently',
     'NOT_LOGIN' => 'Not login',
-    'NOT_EXIST' => 'User not exist',
+    'NOT_EXIST' => 'Invalid',
     'PARAMS_ERROR' => 'Params error',
     'SAVE_ERROR' => 'Save error',
     'FEED_NOT_EXIST' => 'Feed not exist',
@@ -112,7 +113,6 @@ return [
     'PRAISED_YOUR_FEEDS' => 'Praised your feeds ',
     'COMMENTED_ON_YOUR_FEEDS' => 'Commented on your feeds ',
 
-    'NOT_EXIST' => 'Not exist',
     'DATA_NOT_EXIST_OR_DEL' => 'Data not exist or delete',
     'COUNT_IS_WRONGFUL' => 'Count is wrongful',
     'FOLLOW' => 'follow you',
@@ -153,6 +153,7 @@ return [
     'NAME_HAD_USED' => 'Name had used',
     'NAME_TOO_LONG' => 'Name too long',
     'NAME_TOO_SHORT' => 'Name too short',
+    'DESC_TOO_LONG' => 'Brief introduction is too long',
 
     //用户编辑
     'PROFILE_TOO_LONG' => 'Profile too long',

+ 2 - 0
resources/lang/zh/api.php

xqd xqd
@@ -10,6 +10,7 @@ return [
 
     'SUCCESS' => '操作成功',
     'FAIL' => '操作失败',
+    'NOT_EMPTY' => '不能为空!',
     'UPLOAD_SUCCESS' => '上传成功',
     'REQUESTS_TOO_FREQUENTLY' => '请求太频繁',
     'NOT_LOGIN' => '用户未登录',
@@ -170,6 +171,7 @@ return [
     'NAME_TOO_LONG' => '球队名称应太长',
     'NAME_TOO_SHORT' => '球队名称应太短',
     'MEMBER_COUNTS_REQUIRED' => '请填写成员数',
+    'DESC_TOO_LONG' => '简介过长',
 
     'YOU_HAVE_PASSED'=>'您已通过',
     'YOU_DO_NOT_HAVE_PASSED'=>'您未通过',