Sfoglia il codice sorgente

feat(repository): 实现手机号和昵称模糊搜索功能

- 修改账号搜索逻辑为模糊匹配模式
- 添加昵称模糊搜索支持
- 更新数据库查询方法以支持LIKE操作
- 实现多用户ID返回机制
- 重构搜索参数处理流程
shichen 5 mesi fa
parent
commit
848c8b8b52

+ 7 - 2
app/common/dao/user/UserDao.php

@@ -272,9 +272,14 @@ class UserDao extends BaseDao
272
         return User::getDB()->where('account', $account)->where('is_del', 0)->find();
272
         return User::getDB()->where('account', $account)->where('is_del', 0)->find();
273
     }
273
     }
274
 
274
 
275
-    public function nicknameByUser($nickname)
275
+    public function accountLikeByUser($account)
276
     {
276
     {
277
-        return User::getDB()->where('nickname', $nickname)->where('is_del', 0)->find();
277
+        return User::getDB()->where('account', 'like',$account)->where('is_del', 0)->select()->toArray();
278
+    }
279
+
280
+    public function nicknameLikeByUser($nickname)
281
+    {
282
+        return User::getDB()->where('nickname', 'like', $nickname)->where('is_del', 0)->select()->toArray();
278
     }
283
     }
279
 
284
 
280
     /**
285
     /**

+ 10 - 8
app/common/repositories/shared/SharedProsperityUserRepository.php

@@ -681,23 +681,25 @@ class SharedProsperityUserRepository extends BaseRepository
681
 
681
 
682
         // 手机号搜索
682
         // 手机号搜索
683
         if (isset($params['account']) && $params['account']) {
683
         if (isset($params['account']) && $params['account']) {
684
-            $userData = $userDao->accountByUser($params['account']);
685
-            $uid = 0;
684
+            $params['account'] = '%' . $params['account'] . '%';
685
+            $userData = $userDao->accountLikeByUser($params['account']);
686
+            $uids = [];
686
             if ($userData) {
687
             if ($userData) {
687
-                $uid = $userData->uid;
688
+                $uids = array_column($userData,'uid');
688
             }
689
             }
689
 
690
 
690
-            $where[] = ['a.user_id', '=', $uid];
691
+            $where[] = ['a.user_id', 'in', $uids];
691
         }
692
         }
692
 
693
 
693
         // 昵称搜索
694
         // 昵称搜索
694
         if (isset($params['nickname']) && $params['nickname']) {
695
         if (isset($params['nickname']) && $params['nickname']) {
695
-            $userData = $userDao->nicknameByUser($params['nickname']);
696
-            $uid = 0;
696
+            $params['nickname'] = '%' . $params['nickname'] . '%';
697
+            $userData = $userDao->nicknameLikeByUser($params['nickname']);
698
+            $uids = [];
697
             if ($userData) {
699
             if ($userData) {
698
-                $uid = $userData->uid;
700
+                $uids = array_column($userData,'uid');
699
             }
701
             }
700
-            $where[] = ['a.user_id', '=', $uid];
702
+            $where[] = ['a.user_id', 'in', $uids];
701
         }
703
         }
702
 
704
 
703
         // 合伙人等级搜索
705
         // 合伙人等级搜索