ソースを参照

feat(store-order): 添加订单搜索功能支持按产品关键词筛选

- 实现了通过产品关键词搜索订单的功能
- 集成了 StoreOrderProductRepository 来获取匹配的订单ID列表
- 使用 when 条件判断来处理 product_keywords 参数的存在性检查
- 通过子查询将产品关键词匹配的订单ID关联到主查询中
shichen 5 ヶ月 前
コミット
11f3ab95c0
共有1 個のファイルを変更した8 個の追加0 個の削除を含む
  1. 8 0
      app/common/dao/store/order/StoreOrderDao.php

+ 8 - 0
app/common/dao/store/order/StoreOrderDao.php

@@ -123,6 +123,14 @@ class StoreOrderDao extends BaseDao
123 123
                         ->whereOr('order_id', 'in', $orderIdList);
124 124
                 });
125 125
             })
126
+            ->when(isset($where['product_keywords']) && $where['product_keywords'] !== '', function ($query) use ($where) {
127
+                $query->where(function ($query) use ($where) {
128
+                    /** @var StoreOrderProductRepository $storeOrderProductRepository */
129
+                    $storeOrderProductRepository = app()->make(StoreOrderProductRepository::class);
130
+                    $orderIdList = $storeOrderProductRepository->getOrderIdListByKeyword($where['keywords']);
131
+                    $query->where('order_id', 'in', $orderIdList);
132
+                });
133
+            })
126 134
             ->when(isset($where['reconciliation_type']) && $where['reconciliation_type'] !== '', function ($query) use ($where) {
127 135
                 $query->when($where['reconciliation_type'], function ($query) use ($where) {
128 136
                     $query->where('reconciliation_id', '<>', 0);