Ver código fonte

创建订单-修复下单问题

sunxbiao 5 meses atrás
pai
commit
edc045b43b

+ 26 - 1
app/common/dao/shared/SharedProsperityUserDao.php

@@ -19,6 +19,31 @@ class SharedProsperityUserDao extends BaseDao
19 19
     }
20 20
 
21 21
     /**
22
+     * @param array $idList
23
+     * @return SharedProsperityUserEntity[]
24
+     */
25
+    public function getSharedProsperityUserEntityListByIdList(array $idList): array
26
+    {
27
+        $entityList = [];
28
+        try {
29
+            /** @var SharedProsperityUser $model */
30
+            $model = $this->getModel();
31
+            $dataRes = $model::getDB()
32
+                ->whereIn('id', $idList)
33
+                ->select()
34
+                ->toArray();
35
+            if (!empty($dataRes)) {
36
+                $entityList = array_map(function ($data) {
37
+                    return SharedProsperityUserEntity::newInstance($data);
38
+                }, $dataRes);
39
+            }
40
+        } catch (\Exception $e) {
41
+
42
+        }
43
+        return $entityList;
44
+    }
45
+
46
+    /**
22 47
      * @param array $userIdList
23 48
      * @return SharedProsperityUserEntity[]
24 49
      */
@@ -269,7 +294,7 @@ class SharedProsperityUserDao extends BaseDao
269 294
                 ->field('partner_level, user_id')
270 295
                 ->select()
271 296
                 ->toArray();
272
-            
297
+
273 298
             $grouped = [];
274 299
             foreach ($dataRes as $row) {
275 300
                 $level = $row['partner_level'];

+ 26 - 1
app/common/repositories/shared/SharedProsperityUserRepository.php

@@ -24,6 +24,31 @@ class SharedProsperityUserRepository extends BaseRepository
24 24
     }
25 25
 
26 26
     /**
27
+     * @param int $id
28
+     * @return SharedProsperityUserEntity
29
+     */
30
+    public function getSharedProsperityUserEntityById(int $id): SharedProsperityUserEntity
31
+    {
32
+        $entityList = $this->getSharedProsperityUserEntityListByIdList([$id]);
33
+        $entity = array_shift($entityList);
34
+        if ($entity instanceof SharedProsperityUserEntity) {
35
+            return $entity;
36
+        } else {
37
+            /** @var SharedProsperityUserEntity */
38
+            return SharedProsperityUserEntity::newInstance();
39
+        }
40
+    }
41
+
42
+    /**
43
+     * @param array $idList
44
+     * @return SharedProsperityUserEntity[]
45
+     */
46
+    public function getSharedProsperityUserEntityListByIdList(array $idList): array
47
+    {
48
+        return $this->dao->getSharedProsperityUserEntityListByIdList($idList);
49
+    }
50
+
51
+    /**
27 52
      * @param int $userId
28 53
      * @return SharedProsperityUserEntity
29 54
      */
@@ -111,7 +136,7 @@ class SharedProsperityUserRepository extends BaseRepository
111 136
         }
112 137
         $result = $this->update($sharedProsperityUserEntity->getId(), $sharedProsperityUserEntity->toUnderlineArray());
113 138
         if ($result > 0) {
114
-            return $this->getSharedProsperityUserEntityByUserId($sharedProsperityUserEntity->getUserId());
139
+            return $this->getSharedProsperityUserEntityById($sharedProsperityUserEntity->getId());
115 140
         }
116 141
         return SharedProsperityUserEntity::newInstance();
117 142
     }