stanley-king пре 3 година
родитељ
комит
a54c3f8ca9
5 измењених фајлова са 63 додато и 4 уклоњено
  1. 2 2
      helper/stat_helper.php
  2. 31 0
      helper/statistics/stat_refill.php
  3. 1 1
      test/TestOrderErr.php
  4. 28 0
      test/TestRefillCommand.php
  5. 1 1
      test/TestRefund.php

+ 2 - 2
helper/stat_helper.php

@@ -151,6 +151,7 @@ class stat_helper
             Log::record($ex->getMessage(),Log::ERR);
         }
     }
+
     public static function onDaiyBehavior($time)
     {
         try
@@ -167,6 +168,5 @@ class stat_helper
     public static function onDailyRefill()
     {
         $refill = new statistics\stat_refill();
-
     }
-}
+}

+ 31 - 0
helper/statistics/stat_refill.php

@@ -81,6 +81,37 @@ class stat_refill
         }
     }
 
+
+    public function restat($dates)
+    {
+        $deleter = function ($daystamp)
+        {
+            Model('')->table('refill_stats')->where(['time_stamp' => $daystamp])->delete();
+        };
+
+        $flag =  strtotime('2021-01-01');
+        foreach ($dates as $date)
+        {
+            $time = strtotime($date);
+            $date = date('Ymd',$time);
+            $daystamp = strtotime($date);
+            if($daystamp < $flag) continue;
+
+            $deleter($daystamp);
+            $order_count = $this->system_stat($daystamp,'notify_time');
+            if ($order_count > 0) {
+                $this->merchant_stat($daystamp,'notify_time');
+                $this->provider_stat($daystamp,'notify_time');
+            }
+
+            $order_count = $this->system_stat($daystamp,'order_time');
+            if ($order_count > 0) {
+                $this->merchant_stat($daystamp,0,'order_time');
+                $this->provider_stat($daystamp,0,'order_time');
+            }
+        }
+    }
+
     private function system_stat($day_time, $order_time_type='notify_time')
     {
         $end_time = $day_time + stat_refill::DaySecs;

+ 1 - 1
test/TestOrderErr.php

@@ -435,7 +435,7 @@ line;
 
         $line = '[cordispatcher 7-114568 2021-12-28 15:22:02 0.861740] DEBUG: BeginGoFunction coroutin_num=2 memory=24006608';
         $begin = $beginer($line);
+    }
 
 
-    }
 }

+ 28 - 0
test/TestRefillCommand.php

@@ -0,0 +1,28 @@
+<?php
+
+
+use PHPUnit\Framework\TestCase;
+
+define('APP_ID', 'refill_stat');
+define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
+
+require_once(BASE_ROOT_PATH . '/global.php');
+require_once(BASE_CORE_PATH . '/lrlz.php');
+require_once(BASE_ROOT_PATH . '/fooder.php');
+require_once (BASE_ROOT_PATH . '/helper/statistics/stat_refill.php');
+
+class TestRefillCommand extends TestCase
+{
+    public static function setUpBeforeClass(): void
+    {
+        Base::run_util();
+    }
+
+    //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillCommand::testRefillStat)( .*)?$/" --test-suffix TestRefillCommand.php /var/www/html/test
+    public function testRefillStat()
+    {
+        $dates = ['2021-12-28', '2021-12-30', '2022-01-04'];
+        $refill = new statistics\stat_refill();
+        $refill->restat($dates);
+    }
+}

+ 1 - 1
test/TestRefund.php

@@ -35,4 +35,4 @@ class TestRefund extends PHPUnit_Framework_TestCase
         $helper = new refund_helper(36490);
         $helper->return_info('8000000000651001',10100,$err);
     }
-}
+}