xiaogang 4 yıl önce
ebeveyn
işleme
465a628684

+ 0 - 3
app/Http/Controllers/Api/ChatController.php

xqd
@@ -24,16 +24,13 @@ class ChatController extends Controller
             if(empty($request->tencent_im_user_id)){
                 throw new Exception("参数错误");
             }
-
             $tencent_account =new TencentImAccountService();
             $tencent_friend =new TencentImFriendService();
-
             //检测是否已经导入IM账号
             $check_result = $tencent_account->accountCheck([$request->tencent_im_user_id]);
             if(!isset($check_result) || (isset($check_result['AccountStatus'])&&$check_result['AccountStatus']=="NotImported")){
                 throw new Exception("对方账户错误");
             }
-
             $res = $tencent_friend->friendAddItem($user->tencent_im_user_id,$request->tencent_im_user_id);
         }catch (\Exception $exception){
             return $this->response->errorForbidden($exception->getMessage());

+ 13 - 0
app/Http/Controllers/Api/HomeController.php

xqd
@@ -145,6 +145,19 @@ class HomeController extends Controller
         return response()->json(['message'=>'评价成功']);
     }
 
+    /**
+     * 解锁微信
+     * @param Request $request
+     * @return \Illuminate\Http\JsonResponse|void
+     */
+    public function get_weixin(Request $request){
+        try {
+            $res = $this->homeService->get_weixin($request->user_id);
+        }catch (\Exception $exception){
+            return $this->response->errorForbidden($exception->getMessage());
+        }
+        return response()->json(['weixin'=>$res]);
+    }
 
 
 }

+ 23 - 0
app/Http/Controllers/Api/UserController.php

xqd xqd
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
 use App\Http\Params\ProblemParam;
 use App\Models\User;
 use App\Models\UserInfoModel;
+use App\Models\UserVipLogModel;
 use App\Models\VipModel;
 use App\Services\UserService;
 use Illuminate\Http\Request;
@@ -232,6 +233,28 @@ class UserController extends Controller
         return response()->json($res);
     }
 
+    /**
+     * 获取当前vip信息
+     */
+    public function get_vip_info(){
+        try {
+            $user = auth('api')->user();
+            $user_info = UserInfoModel::query()->where('user_id',$user->id)->first();
+            $res['avatar'] = $user_info->avatar;
+            $res['nickname'] = $user_info->nickname;
+            $res['is_vip'] = $user->is_vip;
+            if($user->is_vip>0){
+                $info = UserVipLogModel::query()->where(['user_id'=>$user->id])->first();
+                $res['end_day'] = date("Y-m-d",$info->end_day);
+            }else{
+                $res['end_day'] = "";
+            }
+        }catch (\Exception $exception){
+            return $this->response->errorForbidden($exception->getMessage());
+        }
+        return response()->json($res);
+    }
+
     /**
      * 购买/续费vip
      * @param Request $request

+ 14 - 0
app/Services/HomeService.php

xqd xqd
@@ -8,6 +8,7 @@ use App\Http\Params\UserCommentParam;
 use App\Http\Params\UserLikeParam;
 use App\Models\User;
 use App\Models\UserComment;
+use App\Models\UserInfoModel;
 use App\Models\UserLikeModel;
 use Illuminate\Support\Facades\DB;
 use PHPUnit\Util\Exception;
@@ -152,4 +153,17 @@ class HomeService
         ]);
         return true;
     }
+
+    //解锁微信
+    public function get_weixin($user_id){
+        if(empty($user_id)){
+            throw new Exception('参数错误');
+        }
+        $user = User::query()->where(['id'=>$user_id])->first();
+        if(!$user){
+            throw new Exception("用户不存在");
+        }
+        $weixin = UserInfoModel::query()->where('user_id',$user_id)->value('weixin');
+        return $weixin;
+    }
 }

+ 2 - 0
routes/api.php

xqd xqd
@@ -108,6 +108,7 @@ $api->version('v1', [
             $api->post('/black_list', 'UserController@black_list')->name('user.black_list');
             $api->post('/del_black', 'UserController@del_black')->name('user.del_black');
             $api->post('/online_status', 'UserController@online_status')->name('user.online_status');
+            $api->post('/get_vip_info', 'UserController@get_vip_info')->name('user.get_vip_info');
         });
 
         /*
@@ -131,6 +132,7 @@ $api->version('v1', [
         $api->group(['prefix' => 'home'], function ($api) {
             $api->post('/do_like', 'HomeController@do_like')->name('home.do_like');
             $api->post('/do_comment', 'HomeController@do_comment')->name('home.do_comment');
+            $api->post('/get_weixin', 'HomeController@get_weixin')->name('home.get_weixin');
         });
 
         /*