Browse Source

[智价云] 统计更新

tangyuanwang 11 hours ago
parent
commit
e1c2bea38f
1 changed files with 8 additions and 3 deletions
  1. 8 3
      app/Models/Manager/Process/LowPriceGoods.php

+ 8 - 3
app/Models/Manager/Process/LowPriceGoods.php

@@ -336,7 +336,7 @@ class LowPriceGoods extends Model
             if (!empty($source_last_time_log)) {
                 $product_data_info['online_posting_count'] = $source_last_time_log->online_posting_count + 1; //累计挂网次数+1
             }
-        } else if ($sampling_start_time != '' && $sampling_end_time == '' && $current_time >= $sampling_start_time) {
+        } else if ($sampling_start_time != '' && $sampling_end_time == '0' && $current_time >= $sampling_start_time) {
             //如果当前时间在采集开始时间结束时间未设置,则进行连续挂网和累计挂网统计
             // 获取采集时间是星期几
             $collection_time = strtotime($product_data_info['collection_time']);
@@ -347,8 +347,13 @@ class LowPriceGoods extends Model
             if (!in_array($now_week, $sampling_cycle)) {
                 return $product_data_info;
             }
-            //查询当前商品是否在上一个周期采集中过
-            $up_scrape_date_time = $collection_time - 7 * 24 * 3600; //查询上周这个时间点
+            //排序$sampling_cycle从小到大
+            sort($sampling_cycle);
+            // 使用
+            $result = $this->getLastSamplingInfo($now_week, $sampling_cycle);
+            $days_to_subtract = isset($result['days_to_subtract']) ? $result['days_to_subtract'] : 0;
+
+            $up_scrape_date_time = $collection_time - $days_to_subtract * 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