Bläddra i källkod

平台后台-订单列表-支持关键字搜索订单数据

Xpy 8 månader sedan
förälder
incheckning
b350949fca

+ 13 - 0
app/common/repositories/store/order/StoreOrderProductRepository.php

@@ -31,4 +31,17 @@ class StoreOrderProductRepository extends BaseRepository
31 31
     {
32 32
         $this->dao = $dao;
33 33
     }
34
+
35
+    /**
36
+     * 根据关键字 获取订单ID列表
37
+     * @param $keyword
38
+     * @return array
39
+     * @throws \think\db\exception\DataNotFoundException
40
+     * @throws \think\db\exception\DbException
41
+     * @throws \think\db\exception\ModelNotFoundException
42
+     */
43
+    public function getOrderIdListByKeyword($keyword): array
44
+    {
45
+        return $this->dao->selectWhere(['cart_info', 'like', '%' . $keyword . '%'])->column('order_id');
46
+    }
34 47
 }

+ 6 - 0
app/common/repositories/store/order/StoreOrderRepository.php

@@ -5074,6 +5074,12 @@ class StoreOrderRepository extends BaseRepository
5074 5074
             }
5075 5075
             $query->whereIn('order_id', $ids);
5076 5076
         }
5077
+        if (!empty($where['keywords'])) {
5078
+            /** @var StoreOrderProductRepository $storeOrderProductRepository */
5079
+            $storeOrderProductRepository = app()->make(StoreOrderProductRepository::class);
5080
+            $orderIdList = $storeOrderProductRepository->getOrderIdListByKeyword($where['keywords']);
5081
+            $query->whereIn('order_id', $orderIdList);
5082
+        }
5077 5083
         $count = $query->count();
5078 5084
         $list = $query->with([
5079 5085
             'orderProduct', 'merchant' => function ($query) {