Преглед изворни кода

[智价云] 连续挂网数据统计更新

tangyuanwang пре 4 дана
родитељ
комит
8d86346eef

+ 23 - 4
app/Models/Manager/Process/LowPriceGoods.php

@@ -242,17 +242,26 @@ class LowPriceGoods extends Model
         if (trim($collect_config_info) == '') return $product_data_info;
         $collect_config_info = json_decode($collect_config_info, true); //{"sampling_cycle": "", "sampling_start_time": "", "sampling_end_time": ""}
         //采集周期
-        $sampling_cycle = isset($collect_config_info['sampling_cycle']) ? $collect_config_info['sampling_cycle'] : '';
+        $sampling_cycle = isset($collect_config_info['sampling_cycle']) ? explode(',',$collect_config_info['sampling_cycle']) : '';
         //采集开始时间
         $sampling_start_time = isset($collect_config_info['sampling_start_time']) ? $collect_config_info['sampling_start_time'] : '';
         //采集结束时间
         $sampling_end_time = isset($collect_config_info['sampling_end_time']) ? $collect_config_info['sampling_end_time'] : '';
-        if (!is_numeric($sampling_cycle)) return $product_data_info;
+        if (!is_array($sampling_cycle)) return $product_data_info;
         $current_time = time();
         //如果当前时间在采集开始时间结束时间范围内,则进行连续挂网和累计挂网统计
         if ($sampling_start_time != '' && $sampling_end_time != '' && $current_time >= $sampling_start_time && $current_time <= $sampling_end_time) {
+            // 获取采集时间是星期几
+            $collection_time = strtotime($product_data_info['collection_time']);
+            $now_week = date('w', $collection_time);
+            if ($now_week == 0) {
+                $now_week = 7;
+            }
+            if(!in_array($now_week, $sampling_cycle)){
+                return $product_data_info;
+            }
             //查询当前商品是否在上一个周期采集中过
-            $up_scrape_date_time = $current_time - $sampling_cycle * 24 * 3600;
+            $up_scrape_date_time = $collection_time - 7 * 24 * 3600;//查询上周这个时间点
             $up_scrape_date = date('Y-m-d', $up_scrape_date_time);
             $source_last_week_where[] = ['company_id', '=', $product_data_info['company_id']]; //品牌方公司ID
             $source_last_week_where[] = ['platform', '=', $product_data_info['platform']]; //挂网平台ID
@@ -280,8 +289,18 @@ class LowPriceGoods extends Model
             }
         } else if ($sampling_start_time != '' && $sampling_end_time == '' && $current_time >= $sampling_start_time) {
             //如果当前时间在采集开始时间结束时间未设置,则进行连续挂网和累计挂网统计
+            // 获取采集时间是星期几
+            $collection_time = strtotime($product_data_info['collection_time']);
+            $now_week = date('w', $collection_time);
+            if ($now_week == 0) {
+                $now_week = 7;
+            }
+            if(!in_array($now_week, $sampling_cycle)){
+                return $product_data_info;
+            }
+            //查询当前商品是否在上一个周期采集中过
+            $up_scrape_date_time = $collection_time - 7 * 24 * 3600;//查询上周这个时间点
             //查询当前商品上次采集记录
-            $up_scrape_date_time = $current_time - $sampling_cycle * 24 * 3600;
             $up_scrape_date = date('Y-m-d', $up_scrape_date_time);
             $source_last_week_where[] = ['company_id', '=', $product_data_info['company_id']]; //品牌方公司ID
             $source_last_week_where[] = ['platform', '=', $product_data_info['platform']]; //挂网平台ID

+ 23 - 5
app/Models/Manager/Process/ViolationProduct.php

@@ -232,17 +232,26 @@ class ViolationProduct extends Model
         if (trim($collect_config_info) == '') return $product_data_info;
         $collect_config_info = json_decode($collect_config_info, true); //{"sampling_cycle": "", "sampling_start_time": "", "sampling_end_time": ""}
         //采集周期
-        $sampling_cycle = isset($collect_config_info['sampling_cycle']) ? $collect_config_info['sampling_cycle'] : '';
+        $sampling_cycle = isset($collect_config_info['sampling_cycle']) ? explode(',',$collect_config_info['sampling_cycle']) : '';
         //采集开始时间
         $sampling_start_time = isset($collect_config_info['sampling_start_time']) ? $collect_config_info['sampling_start_time'] : '';
         //采集结束时间
         $sampling_end_time = isset($collect_config_info['sampling_end_time']) ? $collect_config_info['sampling_end_time'] : '';
-        if (!is_numeric($sampling_cycle)) return $product_data_info;
+        if (!is_array($sampling_cycle)) return $product_data_info;
         $current_time = time();
         //如果当前时间在采集开始时间结束时间范围内,则进行连续挂网和累计挂网统计
         if ($sampling_start_time != '' && $sampling_end_time != '' && $current_time >= $sampling_start_time && $current_time <= $sampling_end_time) {
+            // 获取采集时间是星期几
+            $collection_time = strtotime($product_data_info['collection_time']);
+            $now_week = date('w', $collection_time);
+            if ($now_week == 0) {
+                $now_week = 7;
+            }
+            if(!in_array($now_week, $sampling_cycle)){
+                return $product_data_info;
+            }
             //查询当前商品是否在上一个周期采集中过
-            $up_scrape_date_time = $current_time - $sampling_cycle * 24 * 3600;
+            $up_scrape_date_time = $collection_time - 7 * 24 * 3600;//查询上周这个时间点
             $up_scrape_date = date('Y-m-d', $up_scrape_date_time);
             $source_last_week_where[] = ['company_id', '=', $product_data_info['company_id']]; //品牌方公司ID
             $source_last_week_where[] = ['platform', '=', $product_data_info['platform']]; //挂网平台ID
@@ -270,8 +279,18 @@ class ViolationProduct extends Model
             }
         } else if ($sampling_start_time != '' && $sampling_end_time == '' && $current_time >= $sampling_start_time) {
             //如果当前时间在采集开始时间结束时间未设置,则进行连续挂网和累计挂网统计
+            // 获取采集时间是星期几
+            $collection_time = strtotime($product_data_info['collection_time']);
+            $now_week = date('w', $collection_time);
+            if ($now_week == 0) {
+                $now_week = 7;
+            }
+            if(!in_array($now_week, $sampling_cycle)){
+                return $product_data_info;
+            }
+            //查询当前商品是否在上一个周期采集中过
+            $up_scrape_date_time = $collection_time - 7 * 24 * 3600;//查询上周这个时间点
             //查询当前商品上次采集记录
-            $up_scrape_date_time = $current_time - $sampling_cycle * 24 * 3600;
             $up_scrape_date = date('Y-m-d', $up_scrape_date_time);
             $source_last_week_where[] = ['company_id', '=', $product_data_info['company_id']]; //品牌方公司ID
             $source_last_week_where[] = ['platform', '=', $product_data_info['platform']]; //挂网平台ID
@@ -301,7 +320,6 @@ class ViolationProduct extends Model
         return $product_data_info;
     }
 
-
     /**
      * 处理通知消息
      * @author 唐远望