Explorar o código

feat(auth): 登录时增加用户实名认证状态判断

- 在登录逻辑中查询用户实名信息
- 新增获取用户实名信息的方法
- 根据实名信息设置用户是否已实名的状态- 引入 UserCertificationDao 和 UserCertification 类支持实名查询功能
shichen hai 9 meses
pai
achega
155934ee25
Modificáronse 2 ficheiros con 23 adicións e 1 borrados
  1. 14 1
      app/common/dao/user/UserCertificationDao.php
  2. 9 0
      app/controller/api/Auth.php

+ 14 - 1
app/common/dao/user/UserCertificationDao.php

@@ -85,5 +85,18 @@ class UserCertificationDao extends BaseDao
85 85
         return $entityList;
86 86
     }
87 87
 
88
-
88
+    /**
89
+     * @param $mobile
90
+     * @return array|\think\db\BaseQuery|\think\Model|null
91
+     * @throws DataNotFoundException
92
+     * @throws DbException
93
+     * @throws ModelNotFoundException
94
+     * @author 史晨
95
+     * @date 2025/10/20 17:21
96
+     * 获取用户实名信息
97
+     */
98
+    public function getUserCertification($mobile)
99
+    {
100
+        return $this->getModel()->getDB()->where('mobile', $mobile)->find();
101
+    }
89 102
 }

+ 9 - 0
app/controller/api/Auth.php

@@ -12,7 +12,9 @@ namespace app\controller\api;
12 12
 
13 13
 use AlibabaCloud\Client\AlibabaCloud;
14 14
 use app\common\dao\store\order\StoreOrderDao;
15
+use app\common\dao\user\UserCertificationDao;
15 16
 use app\common\model\user\User;
17
+use app\common\model\user\UserCertification;
16 18
 use app\common\repositories\merchant\order\OrderGzcRepository;
17 19
 use app\common\repositories\merchant\order\OrderMerchantRepository;
18 20
 use app\common\repositories\store\order\StoreGroupOrderRepository;
@@ -476,6 +478,13 @@ class Auth extends BaseController
476 478
         if (!$useragree){
477 479
             $repository->createUserOperatingRecord($user->uid, 1, 1, '用户同意用户协议记录');
478 480
         }
481
+        // 登录增加是否实名字段
482
+        $userCertificationDao = new UserCertificationDao();
483
+        $isCertification = $userCertificationDao->getUserCertification($account);
484
+        $user['is_ertification'] = 0;
485
+        if (!empty($isCertification)) {
486
+            $user['is_ertification'] = 1;
487
+        }
479 488
         return app('json')->success($repository->returnToken($user, $tokenInfo));
480 489
     }
481 490