Przeglądaj źródła

[智价云] 清洗更新

tangyuanwang 1 dzień temu
rodzic
commit
a9469cb29e

+ 32 - 8
app/Jobs/Manager/Process/LowPriceGoodsDataJobs.php

@@ -94,14 +94,23 @@ class LowPriceGoodsDataJobs implements ShouldQueue
 
         //-------------------------------------- 清洗规则(开始) --------------------------------------
         //过滤没有链接数据
-        if (trim($product_data['link_url']) == '')  return true;
+        if (trim($product_data['link_url']) == ''){
+            // Log::info('job_error', '数据清洗-低价挂网商品队列日志,未命中链接数据', ['data' => $this->message_data]);
+            return true;
+        }
         //过滤售罄数据,是否售罄0=否1=是
         // if ($product_data['is_sold_out']  == 1)   return true;
         //数据是否命中低价
-        if ($product_data['number'] < 1 || $product_data['min_price'] < 0.01)   return true;
+        if ($product_data['number'] < 1 || $product_data['min_price'] < 0.01){
+            // Log::info('job_error', '数据清洗-低价挂网商品队列日志,未命中数量', ['data' => $this->message_data]);
+            return true;
+        }
         //计算单盒价格
         $unit_price = round($product_data['min_price'] / $product_data['number'], 2);
-        if ($unit_price > $suggested_price)   return true;
+        if ($unit_price > $suggested_price){
+            // Log::info('job_error', '数据清洗-低价挂网商品队列日志,未命中低价', ['data' => $this->message_data]);
+            return true;
+        }
         $product_data['unit_price'] = $unit_price;
         //数据是否命中商品名称
         if ($product_name != '') {
@@ -109,7 +118,10 @@ class LowPriceGoodsDataJobs implements ShouldQueue
             if (strpos($product_data['product_name'], $product_name) !== false) {
                 $hit_product_name = true;
             }
-            if ($hit_product_name != true)   return true;
+            if ($hit_product_name != true){
+            // Log::info('job_error', '数据清洗-低价挂网商品队列日志,未命中商品名称', ['data' => $this->message_data]);
+            return true;
+        }
         }
         //数据是否命中规格
         if ($enable_full_quantity == 1 && $product_specs) {
@@ -120,7 +132,10 @@ class LowPriceGoodsDataJobs implements ShouldQueue
             } else if (strpos($product_data['product_specs'], $product_specs) !== false) {
                 $hit_product_specs = true;
             }
-            if ($hit_product_specs != true)   return true;
+            if ($hit_product_specs != true){
+                // Log::info('job_error', '数据清洗-低价挂网商品队列日志,未命中规格', ['data' => $this->message_data]);
+                return true;
+            }
         }
 
         //数据是否命中关键字
@@ -134,7 +149,10 @@ class LowPriceGoodsDataJobs implements ShouldQueue
                     break;
                 }
             }
-            if ($hit_product_keywords != true)   return true;
+            if ($hit_product_keywords != true){
+                // Log::info('job_error', '数据清洗-低价挂网商品队列日志,未命中关键字', ['data' => $this->message_data]);
+                return true;
+            }
         }
         //数据是否命中指定公司
         if ($company_scope == 2 && $social_credit_code != '') {
@@ -142,7 +160,10 @@ class LowPriceGoodsDataJobs implements ShouldQueue
             if ($product_data['qualification_number'] == $social_credit_code) {
                 $hit_company_scope = true;
             }
-            if ($hit_company_scope != true)   return true;
+            if ($hit_company_scope != true){
+                // Log::info('job_error', '数据清洗-低价挂网商品队列日志,未命中指定公司', ['data' => $this->message_data]);
+                return true;
+            }
         }
 
         //数据是否命中平台
@@ -152,7 +173,10 @@ class LowPriceGoodsDataJobs implements ShouldQueue
             if (in_array($product_data['platform_id'], $platform)) {
                 $hit_platform = true;
             }
-            if ($hit_platform != true)   return true;
+            if ($hit_platform != true){
+                // Log::info('job_error', '数据清洗-低价挂网商品队列日志,未命中平台', ['data' => $this->message_data]);
+                return true;
+            }
         }
         //-------------------------------------- 清洗规则(结束) --------------------------------------
 

+ 10 - 8
app/Jobs/Manager/Process/LowPriceGoodsJobs.php

@@ -70,6 +70,7 @@ class LowPriceGoodsJobs implements ShouldQueue
                 $ConfigLowPriceGoodsModel = $ConfigLowPriceGoodsModel->where('washconfig_lowprice_product.company_id', $company_id);
             }
             $list_config_data = $ConfigLowPriceGoodsModel->with(['product_keyword'])->paginate($limit, ['*'], 'page', $page)->toarray();
+            $last_page   = $list_config_data['last_page'];
             if (!$list_config_data || empty($list_config_data['data'])) {
                 if ($page == 1 && $executeLog_id) {
                     $ExecuteLogModel->where('id', $executeLog_id)->update(['status' => 0, 'update_time' => time()]);
@@ -105,15 +106,16 @@ class LowPriceGoodsJobs implements ShouldQueue
                     'index_number'   => $index_number,
                     'data_totle'     => $data_totle,
                 ];
-                LowPriceGoodsDataJobs::dispatch($message_data);
-                // LowPriceGoodsDataJobs::dispatchSync($message_data);
+                // LowPriceGoodsDataJobs::dispatch($message_data);
+                LowPriceGoodsDataJobs::dispatchSync($message_data);
+            }
+            if ($page < $last_page) {
+                $now_message_data=$this->message_data;
+                $now_message_data['page'] = $page + 1;
+                $now_message_data['limit'] =$limit;
+                $now_message_data['executeLog_id'] = $executeLog_id;
+                LowPriceGoodsJobs::dispatch($now_message_data);
             }
-            $now_message_data = [
-                'limit' => $limit,
-                'page' => $page + 1,
-                'executeLog_id' => $executeLog_id,
-            ];
-            LowPriceGoodsJobs::dispatch($now_message_data)->delay(now()->addSeconds(1));
         } catch (\Exception $e) {
             Log::info('job_error', '数据清洗-低价挂网商品配置队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
         }

+ 9 - 3
app/Jobs/Manager/Process/ScrapeDataProductJobs.php

@@ -86,7 +86,10 @@ class ScrapeDataProductJobs implements ShouldQueue
                         //继续执行下一页
                         $message_data['page'] = $page + 1;
                         $message_data['limit'] = $limit;
-                        ScrapeDataProductJobs::dispatch($message_data)->delay(now()->addSeconds(1));
+                        $message_data['company_id'] = $company_id;
+                        $message_data['start_time'] = $start_time;
+                        $message_data['end_time'] = $end_time;
+                        ScrapeDataProductJobs::dispatch($message_data);
                     } else if ($page == $last_page) {
                         Cache::put($key_end_name, '1', 360); //缓存6分钟
                         $this->cleanData($company_id, $product_datas);
@@ -113,7 +116,10 @@ class ScrapeDataProductJobs implements ShouldQueue
                         //继续执行下一页
                         $message_data['page'] = $page + 1;
                         $message_data['limit'] = $limit;
-                        ScrapeDataProductJobs::dispatch($message_data)->delay(now()->addSeconds(1));
+                        $message_data['company_id'] = $company_id;
+                        $message_data['start_time'] = $start_time;
+                        $message_data['end_time'] = $end_time;
+                        ScrapeDataProductJobs::dispatch($message_data);
                     } else if ($page == $last_page) {
                         Cache::put($key_end_name, '1', 360); //缓存6分钟
                         $this->cleanData($company_id, $product_datas);
@@ -136,7 +142,7 @@ class ScrapeDataProductJobs implements ShouldQueue
         $index_number = 0;
         foreach ($cache_product_datas as $key => $product_data) {
             $index_number = $key + 1;
-            $message_data = ['company_id' => $company_id, 'page' => '1', 'limit' => '50', 'product_data' => $product_data, 'index_number' => $index_number, 'data_totle' => $data_totle];
+            $message_data = ['company_id' => $company_id, 'page' => '1', 'limit' => '10000', 'product_data' => $product_data, 'index_number' => $index_number, 'data_totle' => $data_totle];
             LowPriceGoodsJobs::dispatch($message_data);
             // LowPriceGoodsJobs::dispatchSync($message_data);
             ViolationProductJobs::dispatch($message_data);

+ 10 - 8
app/Jobs/Manager/Process/ViolationCompanyJobs.php

@@ -69,6 +69,7 @@ class ViolationCompanyJobs implements ShouldQueue
                 $ViolationCompanyModel = $ViolationCompanyModel->where('washconfig_violation_company.company_id', $company_id);
             }
             $list_config_data = $ViolationCompanyModel->paginate($limit, ['*'], 'page', $page)->toarray();
+            $last_page   = $list_config_data['last_page'];
             if (!$list_config_data || empty($list_config_data['data'])) {
                 if($page == 1 && $executeLog_id){
                     $ExecuteLogModel->where('id', $executeLog_id)->update(['status' => 0,'update_time'=> time()]);
@@ -91,15 +92,16 @@ class ViolationCompanyJobs implements ShouldQueue
                     'index_number'   => $index_number,
                     'data_totle'     => $data_totle,
                 ];
-                ViolationCompanyDataJobs::dispatch($message_data);
-                // ViolationCompanyDataJobs::dispatchSync($message_data);
+                // ViolationCompanyDataJobs::dispatch($message_data);
+                ViolationCompanyDataJobs::dispatchSync($message_data);
+            }
+            if ($page < $last_page) {
+                $now_message_data=$this->message_data;
+                $now_message_data['page'] = $page + 1;
+                $now_message_data['limit'] =$limit;
+                $now_message_data['executeLog_id'] = $executeLog_id;
+                ViolationCompanyJobs::dispatch($now_message_data);
             }
-            $now_message_data = [
-                'limit' => $limit,
-                'page' => $page + 1,
-                'executeLog_id' => $executeLog_id,
-            ];
-            ViolationCompanyJobs::dispatch($now_message_data)->delay(now()->addSeconds(3));
         } catch (\Exception $e) {
             Log::info('job_error', '数据清洗-违规挂网公司队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
         }

+ 24 - 6
app/Jobs/Manager/Process/ViolationProductDataJobs.php

@@ -92,7 +92,10 @@ class ViolationProductDataJobs implements ShouldQueue
 
         //-------------------------------------- 清洗规则(开始) --------------------------------------
         //过滤没有链接数据
-        if (trim($product_data['link_url']) == '')  return true;
+        if (trim($product_data['link_url']) == ''){
+            // Log::info('job_error', '数据清洗-违规挂网商品队列日志,未命中链接数据', ['data' => $this->message_data]);
+            return true;
+        }
         //过滤售罄数据,是否售罄0=否1=是
         // if ($product_data['is_sold_out']  == 1)   return true;
         //数据是否命中商品名称
@@ -101,7 +104,10 @@ class ViolationProductDataJobs implements ShouldQueue
             if (strpos($product_data['product_name'], $product_name) !== false) {
                 $hit_product_name = true;
             }
-            if ($hit_product_name != true)   return true;
+            if ($hit_product_name != true){
+            // Log::info('job_error', '数据清洗-违规挂网商品队列日志,未命中商品名称', ['data' => $this->message_data]);
+            return true;
+        }
         }
         //数据是否命中规格
         if ($enable_full_quantity == 1 && $product_specs) {
@@ -112,7 +118,10 @@ class ViolationProductDataJobs implements ShouldQueue
             } else if (strpos($product_data['product_specs'], $product_specs) !== false) {
                 $hit_product_specs = true;
             }
-            if ($hit_product_specs != true)   return true;
+            if ($hit_product_specs != true){
+                // Log::info('job_error', '数据清洗-违规挂网商品队列日志,未命中规格', ['data' => $this->message_data]);
+                return true;
+            }
         }
 
         //数据是否命中关键字
@@ -126,7 +135,10 @@ class ViolationProductDataJobs implements ShouldQueue
                     break;
                 }
             }
-            if ($hit_product_keywords != true)   return true;
+            if ($hit_product_keywords != true){
+                // Log::info('job_error', '数据清洗-违规挂网商品队列日志,未命中关键字', ['data' => $this->message_data]);
+                return true;
+            }
         }
         //数据是否命中指定公司
         if ($company_scope == 2 && $social_credit_code != '') {
@@ -134,7 +146,10 @@ class ViolationProductDataJobs implements ShouldQueue
             if ($product_data['qualification_number'] == $social_credit_code) {
                 $hit_company_scope = true;
             }
-            if ($hit_company_scope != true)   return true;
+            if ($hit_company_scope != true){
+                // Log::info('job_error', '数据清洗-违规挂网商品队列日志,未命中指定公司', ['data' => $this->message_data]);
+                return true;
+            }
         }
 
         //数据是否命中平台
@@ -144,7 +159,10 @@ class ViolationProductDataJobs implements ShouldQueue
             if (in_array($product_data['platform_id'], $platform)) {
                 $hit_platform = true;
             }
-            if ($hit_platform != true)   return true;
+            if ($hit_platform != true){
+                // Log::info('job_error', '数据清洗-违规挂网商品队列日志,未命中平台', ['data' => $this->message_data]);
+                return true;
+            }
         }
         //-------------------------------------- 清洗规则(结束) --------------------------------------
 

+ 10 - 8
app/Jobs/Manager/Process/ViolationProductJobs.php

@@ -70,6 +70,7 @@ class ViolationProductJobs implements ShouldQueue
                 $ConfigViolationProductModel = $ConfigViolationProductModel->where('washconfig_violation_product.company_id', $company_id);
             }
             $list_config_data = $ConfigViolationProductModel->with(['product_keyword'])->paginate($limit, ['*'], 'page', $page)->toarray();
+            $last_page   = $list_config_data['last_page'];
             if (!$list_config_data || empty($list_config_data['data'])) {
                 if($page == 1 && $executeLog_id){
                     $ExecuteLogModel->where('id', $executeLog_id)->update(['status' => 0,'update_time'=> time()]);
@@ -102,15 +103,16 @@ class ViolationProductJobs implements ShouldQueue
                     'index_number'   => $index_number,
                     'data_totle'     => $data_totle,
                 ];
-                ViolationProductDataJobs::dispatch($message_data);
-                // ViolationProductDataJobs::dispatchSync($message_data);
+                // ViolationProductDataJobs::dispatch($message_data);
+                ViolationProductDataJobs::dispatchSync($message_data);
+            }
+            if ($page < $last_page) {
+                $now_message_data=$this->message_data;
+                $now_message_data['page'] = $page + 1;
+                $now_message_data['limit'] =$limit;
+                $now_message_data['executeLog_id'] = $executeLog_id;
+                ViolationProductJobs::dispatch($now_message_data);
             }
-            $now_message_data = [
-                'limit' => $limit,
-                'page' => $page + 1,
-                'executeLog_id' => $executeLog_id,
-            ];
-            ViolationProductJobs::dispatch($now_message_data)->delay(now()->addSeconds(1));
         } catch (\Exception $e) {
             Log::info('job_error', '数据清洗-违规挂网商品队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
         }