Переглянути джерело

后台-订单列表-新增商品关键字查询(待测试)

Xpy 8 місяців тому
батько
коміт
7b3b4942f3

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

@@ -5064,6 +5064,16 @@ class StoreOrderRepository extends BaseRepository
5064
     {
5064
     {
5065
         $where['paid'] = 1;
5065
         $where['paid'] = 1;
5066
         $query = $this->dao->search($where, null);
5066
         $query = $this->dao->search($where, null);
5067
+        $kw = trim($where['product_keywords'] ?? '');//从where取出去除空格
5068
+        if ($kw !== '') {
5069
+            $ids =Db::name('store_order_product')
5070
+                ->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(cart_info, '$.product.store_name')) LIKE ?", ["%{$kw}%"])
5071
+                ->column('order_id');
5072
+            if (empty($ids)) {
5073
+                return ['count' => 0, 'list' => []];
5074
+            }
5075
+            $query->whereIn('order_id', $ids);
5076
+        }
5067
         $count = $query->count();
5077
         $count = $query->count();
5068
         $list = $query->with([
5078
         $list = $query->with([
5069
             'orderProduct', 'merchant' => function ($query) {
5079
             'orderProduct', 'merchant' => function ($query) {
@@ -5125,6 +5135,15 @@ class StoreOrderRepository extends BaseRepository
5125
                     return $query->field('uid,phone,nickname');
5135
                     return $query->field('uid,phone,nickname');
5126
                 }
5136
                 }
5127
             ]);
5137
             ]);
5138
+
5139
+        $kw = trim($where['product_keywords'] ?? '');
5140
+        if ($kw !== '') {
5141
+            $ids = Db::name('store_order_product')
5142
+                ->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(cart_info, '$.product.store_name')) LIKE ?", ["%{$kw}%"]) 
5143
+                ->column('order_id');
5144
+            $ids = $ids ?: [-1];
5145
+            $query->whereIn('order_id', $ids);
5146
+        }
5128
         $query1 = clone ($query);
5147
         $query1 = clone ($query);
5129
         $query2 = clone ($query);
5148
         $query2 = clone ($query);
5130
 
5149
 

+ 2 - 0
app/controller/admin/order/Order.php

@@ -33,8 +33,10 @@ class Order extends BaseController
33
     {
33
     {
34
         [$page, $limit] = $this->getPage();
34
         [$page, $limit] = $this->getPage();
35
         $where = $this->request->params(['date','order_sn','order_type','keywords','username']);
35
         $where = $this->request->params(['date','order_sn','order_type','keywords','username']);
36
+        $productKeywords = $this->request->param('product_keywords');//商品关键字
36
         $where['reconciliation_type'] = $this->request->param('status', 1);
37
         $where['reconciliation_type'] = $this->request->param('status', 1);
37
         $where['mer_id'] = $id;
38
         $where['mer_id'] = $id;
39
+        $where['product_keywords'] = $productKeywords;
38
         return app('json')->success($this->repository->adminGetList($where, $page, $limit));
40
         return app('json')->success($this->repository->adminGetList($where, $page, $limit));
39
     }
41
     }
40
 
42