Procházet zdrojové kódy

[智价云] 清洗更新

tangyuanwang před 1 týdnem
rodič
revize
e11ec1b223

+ 9 - 5
app/Jobs/Manager/Process/LowPriceGoodsDataJobs.php

@@ -110,14 +110,18 @@ class LowPriceGoodsDataJobs implements ShouldQueue
         // $where[] = ['one_box_price', '<', $suggested_price];
 
         $ScrapeDataModel= $ScrapeDataModel->whereRaw('(min_price / NULLIF(number, 0)) < '. floatval($suggested_price));//计算单盒价格
-        
         // if ($product_brand) $where[] = ['product_name', 'like', '%' . $product_brand . '%'];
         if ($product_brand) $where[] = ['product_brand', 'like', '%' . $category_name . '%'];
         if (!empty($product_keyword)) {
-            foreach ($product_keywords as $key => $keywords) {
-                if (trim($keywords) == '') continue;
-                $where[] = ['product_name', 'like', '%' . $keywords . '%'];
-            }
+            $ScrapeDataModel = $ScrapeDataModel->where(function ($query) use ($product_keywords) {
+                // 平台条件(固定)
+                $query->where(function ($query_li) use ($product_keywords) {
+                    foreach ($product_keywords as $product_keyword) {
+                        if (empty($product_keyword)) continue;
+                        $query_li->orWhere([['product_name', 'like', '%' . $product_keyword . '%']]);
+                    }
+                });
+            });
         }
         if ($company_scope == 2 && $social_credit_code != '') {
             $ScrapeDataModel->whereIn('qualification_number', $social_credit_code);

+ 9 - 4
app/Jobs/Manager/Process/ViolationProductDataJobs.php

@@ -108,10 +108,15 @@ class ViolationProductDataJobs implements ShouldQueue
         // if ($product_brand) $where[] = ['product_name', 'like', '%' . $product_brand . '%'];
         if ($product_brand) $where[] = ['product_brand', 'like', '%' . $category_name . '%'];
         if (!empty($product_keyword)) {
-            foreach ($product_keywords as $key => $keywords) {
-                if (trim($keywords) == '') continue;
-                $where[] = ['product_name', 'like', '%' . $keywords . '%'];
-            }
+            $ScrapeDataModel = $ScrapeDataModel->where(function ($query) use ($product_keywords) {
+                // 平台条件(固定)
+                $query->where(function ($query_li) use ($product_keywords) {
+                    foreach ($product_keywords as $product_keyword) {
+                        if (empty($product_keyword)) continue;
+                        $query_li->orWhere([['product_name', 'like', '%' . $product_keyword . '%']]);
+                    }
+                });
+            });
         }
         if ($company_scope == 2) {
             $ScrapeDataModel->whereIn('qualification_number', $social_credit_code);