Przeglądaj źródła

update playercontrol cancel

ssvfdn 3 miesięcy temu
rodzic
commit
89be81c075
2 zmienionych plików z 15 dodań i 1 usunięć
  1. 14 1
      app/controller/PlayerControl.php
  2. 1 0
      route/app.php

+ 14 - 1
app/controller/PlayerControl.php

@@ -175,6 +175,7 @@ class PlayerControl extends BaseController
 
 
         $controlWhere = [];
+        $controlWhere[] = ['user_id', '=', $userInfo['user_id']];
 
 
         $where = [];
@@ -292,11 +293,12 @@ class PlayerControl extends BaseController
      */
     public function cancelPlayerControlInfo()
     {
+        $userInfo = $this->getUserInfo();
         $control_id = Request::post('control_id','', 'trim');
         if(empty($control_id)) {
             return json_error([], '参数错误');
         }
-        $info = PlayerControlModel::find($control_id);
+        $info = PlayerControlModel::where(['control_id' => $control_id, 'user_id' => $userInfo['user_id']]);
         if(!empty($info)) {
             $info->end_time = time();
             $info->status = 0;
@@ -305,4 +307,15 @@ class PlayerControl extends BaseController
         return json_success([],'操作成功');
     }
 
+    /**
+     * 一键取消全部点控
+     * @return \think\response\Json
+     */
+    public function cancelAllPlayerControlInfo()
+    {
+        $userInfo = $this->getUserInfo();
+        PlayerControlModel::where(['user_id' => $userInfo['user_id']])->save(['status' => 0, 'end_time' => time()]);
+        return json_success([],'操作成功');
+    }
+
 }

+ 1 - 0
route/app.php

@@ -62,6 +62,7 @@ Route::group('player_control', function () {
     Route::post('update', 'PlayerControl/updatePlayerControl');
     Route::get('list', 'PlayerControl/getPlayerControlList');
     Route::post('cancel', 'PlayerControl/cancelPlayerControlInfo');
+    Route::post('all_cancel', 'PlayerControl/cancelAllPlayerControlInfo');
 })->middleware([\app\middleware\AuthMiddleware::class, \app\middleware\BehaviorLogMiddleware::class]);