瀏覽代碼

清除数据接口

allen 3 年之前
父節點
當前提交
54208df45b
共有 2 個文件被更改,包括 29 次插入0 次删除
  1. 16 0
      app/index/controller/Index.php
  2. 13 0
      app/middleware/Safe.php

+ 16 - 0
app/index/controller/Index.php

@@ -594,6 +594,22 @@ class Index extends Controller
         return $this->successResponse($res);
     }
 
+    public function clearGameData()
+    {
+        // 更新用户参与状态
+        Db::table('awards_user_info')->where('uid', Safe::$user['uid'])->update([
+            'is_share' => 0,
+            'share_at' => 0,
+            'count' => 1,
+        ]);
+
+        Db::table('awards_user_task_log')->where('uid', Safe::$user['uid'])->delete();
+
+        Db::table('awards_order')->where('uid', Safe::$user['uid'])->delete();
+
+        return $this->successResponse(null, '清除成功');
+    }
+
     /**
      * 品牌任务关注接口
      * @throws FuncNotFoundException

+ 13 - 0
app/middleware/Safe.php

@@ -61,6 +61,19 @@ class Safe
             );
             return null;
         }
+
+        if (empty(Cache::get('u:' . $token))) {
+            abort(
+                json(
+                    [
+                        'code' => 403,
+                        'message' => 'token invalid.',
+                    ]
+                )
+            );
+            return null;
+        }
+
         $user = json_decode(Cache::get('u:' . $token), true);
         if (empty($user)) {
             abort(