Răsfoiți Sursa

开始同步时间超过当前时间,往前移动7分

dong025 4 zile în urmă
părinte
comite
35b122ef95
2 a modificat fișierele cu 77 adăugiri și 30 ștergeri
  1. 39 14
      app/admin/command/FengSu.php
  2. 38 16
      app/admin/command/JuShuiTan.php

+ 39 - 14
app/admin/command/FengSu.php

@@ -50,6 +50,13 @@ class FengSu extends Command
 
     // 打单平台 1:风速  2:聚水潭
     protected $type_id = 1;
+
+    //时间间隔
+    protected $start_end_space_time=10*60;
+    //下一次时间间隔
+    protected $next_time_space=7*60;
+
+
     // 指令配置
     protected function configure()
     {
@@ -85,12 +92,29 @@ class FengSu extends Command
                 //dump($resquet);
             } else {
 
-                $fengsu=[
-                    'startTime'=>$fengsu['startTime']+$fengsu['next_time_space'],
-                    'endTime'=>$fengsu['endTime']+$fengsu['next_time_space'],
-                    'pageNum'=>1,
-                    'next_time_space'=>$fengsu['next_time_space']
-                ];
+                $now_time = time();
+                if ($fengsu['startTime']>=$now_time||($now_time - $fengsu['startTime']) < ($this->next_time_space)) {
+                    // dump("超时了");
+                    $pre_time_stamp = $this->next_time_space;
+                    
+                    $startTime_stamp = $now_time - $pre_time_stamp;
+                    $endTime_stamp = $startTime_stamp + $this->start_end_space_time;
+                    $fengsu = [
+                        'startTime' => $startTime_stamp,
+                        'endTime' => $endTime_stamp,
+                        'pageNum' => 1,
+                        'next_time_space' => $fengsu['next_time_space']
+                    ];
+                }else{
+                    $fengsu = [
+                        'startTime' => $fengsu['startTime'] + $fengsu['next_time_space'],
+                        'endTime' => $fengsu['endTime'] + $fengsu['next_time_space'],
+                        'pageNum' => 1,
+                        'next_time_space' => $fengsu['next_time_space']
+                    ];
+                }
+
+
                 Cache::set('fengsu',$fengsu);
 
 
@@ -120,9 +144,9 @@ class FengSu extends Command
         ];
 
         //时间间隔
-        $start_end_space_time=10*60;
+        // $start_end_space_time=10*60;
         //下一次时间间隔
-        $next_time_space=7*60;
+        // $next_time_space=7*60;
 
 
         //将查询分为,"2026-01-05 00:00:00~2026-01-05 00:05:00",查询该区间的订单,但是该时间区间单独数量可能超过50条,为了性能又不能一次性查询太多,从而进行分页查询,
@@ -131,14 +155,14 @@ class FengSu extends Command
 
         $startTime_stamp = strtotime($todayTime . ' 00:00:00');
         // $startTime_stamp = strtotime($todayTime . ' 07:20:00');
-        $endTime_stamp=$startTime_stamp+$start_end_space_time;
+        $endTime_stamp=$startTime_stamp+$this->start_end_space_time;
         $pageNum=1;
 
         $fengsu=[
             'startTime'=>$startTime_stamp,
             'endTime'=>$endTime_stamp,
             'pageNum'=>$pageNum,
-            'next_time_space'=>$next_time_space
+            'next_time_space'=>$this->next_time_space
         ];
 
         $fengsu_cache_data=Cache::get('fengsu');
@@ -151,16 +175,17 @@ class FengSu extends Command
         // 无数据时,获取数据的开始时间会大于现在的时间,这是一个错误的,会导致一直无法获取数据,开始时间一直往后
         //当开始时间大于现在时间,将开始时间向前调整3分钟
         $now_time = time();
-        if ($fengsu['startTime']>=$now_time||($now_time - $fengsu['startTime']) < ($start_end_space_time - $next_time_space)) {
-            $pre_time_stamp = 6*60;
+        if ($fengsu['startTime']>=$now_time||($now_time - $fengsu['startTime']) < ($this->start_end_space_time - $this->next_time_space)) {
+            // dump("超时了");
+            $pre_time_stamp =$this->next_time_space;
             
             $startTime_stamp = $now_time - $pre_time_stamp;
-            $endTime_stamp = $startTime_stamp + $start_end_space_time;
+            $endTime_stamp = $startTime_stamp + $this->start_end_space_time;
             $fengsu = [
                 'startTime' => $startTime_stamp,
                 'endTime' => $endTime_stamp,
                 'pageNum' => 1,
-                'next_time_space' => $next_time_space
+                'next_time_space' => $this->next_time_space
             ];
         }
         Cache::set('jushuitan', $fengsu);

+ 38 - 16
app/admin/command/JuShuiTan.php

@@ -35,7 +35,11 @@ class JuShuiTan extends Command
 
     //抖音请求地址
     protected $url = 'https://innerapi.scm121.com/api/inner/supOrder/getErpNormalOrders';
-
+    //时间间隔
+    protected $start_end_space_time=10*60;
+    //下一次时间间隔
+    protected $next_time_space=7*60;
+    
     //抖音请求头部
     protected $headers = [
         //'Host' => 'fsdy2.fengsutb.com',
@@ -82,12 +86,30 @@ class JuShuiTan extends Command
                 $this->insertOrder($list);
                 //dump($resquet);
             } else {
-                $jushuitan = [
-                    'startTime' => $jushuitan['startTime'] + $jushuitan['next_time_space'],
-                    'endTime' => $jushuitan['endTime'] + $jushuitan['next_time_space'],
-                    'pageNum' => 1,
-                    'next_time_space' => $jushuitan['next_time_space']
-                ];
+                
+                
+                $now_time = time();
+                if ($jushuitan['startTime']>=$now_time||($now_time - $jushuitan['startTime']) < ($this->next_time_space)) {
+                    // dump("超时了");
+                    $pre_time_stamp = $this->next_time_space;
+                    
+                    $startTime_stamp = $now_time - $pre_time_stamp;
+                    $endTime_stamp = $startTime_stamp + $this->start_end_space_time;
+                    $jushuitan = [
+                        'startTime' => $startTime_stamp,
+                        'endTime' => $endTime_stamp,
+                        'pageNum' => 1,
+                        'next_time_space' => $jushuitan['next_time_space']
+                    ];
+                }else{
+                    $jushuitan = [
+                        'startTime' => $jushuitan['startTime'] + $jushuitan['next_time_space'],
+                        'endTime' => $jushuitan['endTime'] + $jushuitan['next_time_space'],
+                        'pageNum' => 1,
+                        'next_time_space' => $jushuitan['next_time_space']
+                    ];
+                }
+        
                 Cache::set('jushuitan', $jushuitan);
 
                 $output->writeln('没有数据');
@@ -114,9 +136,9 @@ class JuShuiTan extends Command
         ];
 
         //时间间隔
-        $start_end_space_time = 10 * 60;
+        // $this->start_end_space_time = 10 * 60;
         //下一次时间间隔
-        $next_time_space = 7 * 60;
+        // $this->next_time_space = 7 * 60;
 
 
         //将查询分为,"2026-01-05 00:00:00~2026-01-05 00:05:00",查询该区间的订单,但是该时间区间单独数量可能超过50条,为了性能又不能一次性查询太多,从而进行分页查询,
@@ -125,14 +147,14 @@ class JuShuiTan extends Command
 
         $startTime_stamp = strtotime($todayTime . ' 00:00:00');
         // $startTime_stamp = strtotime($todayTime . ' 07:20:00');
-        $endTime_stamp = $startTime_stamp + $start_end_space_time;
+        $endTime_stamp = $startTime_stamp + $this->start_end_space_time;
         $pageNum = 1;
 
         $jushuitan = [
             'startTime' => $startTime_stamp,
             'endTime' => $endTime_stamp,
             'pageNum' => $pageNum,
-            'next_time_space' => $next_time_space
+            'next_time_space' => $this->next_time_space
         ];
 
         $jushuitan_cache_data = Cache::get('jushuitan');
@@ -145,24 +167,24 @@ class JuShuiTan extends Command
         // 无数据时,获取数据的开始时间会大于现在的时间,这是一个错误的,会导致一直无法获取数据,开始时间一直往后
         //当开始时间大于现在时间,将开始时间向前调整3分钟
         $now_time = time();
-        if ($jushuitan['startTime']>=$now_time||($now_time - $jushuitan['startTime']) < ($start_end_space_time - $next_time_space)) {
+        if ($jushuitan['startTime']>=$now_time||($now_time - $jushuitan['startTime']) < ($this->start_end_space_time - $this->next_time_space)) {
             // dump("超时了");
-            $pre_time_stamp = 6*60;
+            $pre_time_stamp = $this->next_time_space;
             
             $startTime_stamp = $now_time - $pre_time_stamp;
-            $endTime_stamp = $startTime_stamp + $start_end_space_time;
+            $endTime_stamp = $startTime_stamp + $this->start_end_space_time;
             $jushuitan = [
                 'startTime' => $startTime_stamp,
                 'endTime' => $endTime_stamp,
                 'pageNum' => 1,
-                'next_time_space' => $next_time_space
+                'next_time_space' => $this->next_time_space
             ];
         }
         Cache::set('jushuitan', $jushuitan);
         $startTime = date('Y-m-d H:i:s', $jushuitan['startTime']);
         $endTime = date('Y-m-d H:i:s', $jushuitan['endTime']);
         $pageNum = (int)$jushuitan['pageNum'];
-        // dump($startTime);
+        
         $body = [
             'startTime'     => $startTime,     // 动态时间变量
             'endTime'       => $endTime,       // 动态时间变量