瀏覽代碼

优化:删除用户同时删除第三方用户信息

萤火科技 5 年之前
父節點
當前提交
88a690d87d
共有 3 個文件被更改,包括 32 次插入 和 0 次删除
  1. 2 0
      app/common/model/UserOauth.php
  2. 5 0
      app/store/model/User.php
  3. 25 0
      app/store/model/UserOauth.php

+ 2 - 0
app/common/model/UserOauth.php

@@ -35,6 +35,7 @@ class UserOauth extends BaseModel
     {
     {
         return $this->where('user_id', '=', $userId)
         return $this->where('user_id', '=', $userId)
             ->where('oauth_type', '=', $oauthType)
             ->where('oauth_type', '=', $oauthType)
+            ->where('is_delete', '=', 0)
             ->value($this->getPk());
             ->value($this->getPk());
     }
     }
 
 
@@ -48,6 +49,7 @@ class UserOauth extends BaseModel
     {
     {
         return (new static)->where('oauth_id', '=', $oauthId)
         return (new static)->where('oauth_id', '=', $oauthId)
             ->where('oauth_type', '=', $oauthType)
             ->where('oauth_type', '=', $oauthType)
+            ->where('is_delete', '=', 0)
             ->value('user_id');
             ->value('user_id');
     }
     }
 
 

+ 5 - 0
app/store/model/User.php

@@ -14,6 +14,7 @@ namespace app\store\model;
 
 
 use app\common\model\User as UserModel;
 use app\common\model\User as UserModel;
 
 
+use app\store\model\UserOauth as UserOauthModel;
 use app\store\model\user\GradeLog as GradeLogModel;
 use app\store\model\user\GradeLog as GradeLogModel;
 use app\store\model\user\PointsLog as PointsLogModel;
 use app\store\model\user\PointsLog as PointsLogModel;
 use app\store\model\user\BalanceLog as BalanceLogModel;
 use app\store\model\user\BalanceLog as BalanceLogModel;
@@ -130,6 +131,10 @@ class User extends UserModel
     public function setDelete()
     public function setDelete()
     {
     {
         return $this->transaction(function () {
         return $this->transaction(function () {
+            // 将第三方用户信息记录标记删除
+            UserOauthModel::updateBase(['is_delete' => 1], [
+                ['user_id', '=', $this['user_id']]
+            ]);
             // 标记为已删除
             // 标记为已删除
             return $this->save(['is_delete' => 1]);
             return $this->save(['is_delete' => 1]);
         });
         });

+ 25 - 0
app/store/model/UserOauth.php

@@ -0,0 +1,25 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types = 1);
+
+namespace app\store\model;
+
+use app\common\model\UserOauth as UserOauthModel;
+
+/**
+ * 模型类:第三方用户信息
+ * Class UserOauth
+ * @package app\store\model
+ */
+class UserOauth extends UserOauthModel
+{
+
+}