Просмотр исходного кода

物业用户存在时更新 用户类型为 “物业用户”

liugc 1 год назад
Родитель
Сommit
0a508c5fd7

+ 1 - 1
app/adminapi/controller/property/PropertyHeadController.php

@@ -56,7 +56,7 @@ class PropertyHeadController extends BaseAdminController
         $result = PropertyHeadLogic::add($params);
         if (true === $result) {
             // 通过手机号查询用户是否注册 - 已注册绑定id ,未注册注册再绑定id
-            $userId = UserLogic::getUserIdByMobile($params['head_mobile']);
+            $userId = UserLogic::getUserIdByMobile($params['head_mobile'], true);
             PropertyHeadLogic::updateUserId($params['head_mobile'],$userId);
             return $this->success('添加成功', [], 1, 1);
         }

+ 5 - 1
app/adminapi/logic/user/UserLogic.php

@@ -117,7 +117,7 @@ class UserLogic extends BaseLogic
         }
     }
 
-    public static function getUserIdByMobile(string $mobile)
+    public static function getUserIdByMobile(string $mobile, bool $isProperty = false)
     {
         $user = User::where(['mobile' => $mobile])->findOrEmpty();
         if ($user->isEmpty()) {
@@ -128,6 +128,10 @@ class UserLogic extends BaseLogic
             $params['user_type'] = 2;
             $user = LoginLogic::register($params);
         }
+        if ($isProperty) {
+            $user->user_type = 1;
+            $user->save();
+        }
         return $user->id;
     }