Pārlūkot izejas kodu

Merge branch 'raccount' of 39.97.239.116:gyfl/xyzshop into raccount

xiaoyu 3 gadi atpakaļ
vecāks
revīzija
546ebfb136
3 mainītis faili ar 15 papildinājumiem un 16 dzēšanām
  1. 3 12
      admin/control/merchant.php
  2. 6 4
      helper/refill/functional.php
  3. 6 0
      test/TestRefill.php

+ 3 - 12
admin/control/merchant.php

@@ -10,7 +10,8 @@ include(BASE_CONFIG_PATH . CONFIG_PREFIX . '/refill.ini.php');
 require_once(BASE_HELPER_PATH . '/stat_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/refill/functional.php');
 require_once(BASE_HELPER_PATH . '/task/task_helper.php');
-use refill\Quality;
+require_once(BASE_HELPER_PATH . '/refill/functional.php');
+
 use refill\quality_ploy;
 
 class merchantControl extends SystemControl
@@ -1222,7 +1223,7 @@ class merchantControl extends SystemControl
             $night_timeout += $retry_times_cfg['qualities'][$quality]['night_secs'];
         }
 
-        if ($this->is_day()) {
+        if (refill\functional::isDay()) {
             $time_out = $day_timeout;
         } else {
             $time_out = $night_timeout;
@@ -1234,16 +1235,6 @@ class merchantControl extends SystemControl
         $model_merchant->editMerchant($update, ['mchid' => $mchid]);
     }
 
-    private function is_day(): bool
-    {
-        $hour = date("H");
-        if ($hour >= 23 || $hour <= 7) {
-            return false;
-        } else {
-            return true;
-        }
-    }
-
     private function merchant_intercept($merchant)
     {
         $intercept_cfg = $merchant['intercept_cfg'];

+ 6 - 4
helper/refill/functional.php

@@ -6,9 +6,11 @@ class functional
 {
     public static function isDay()
     {
-        $cur = time();
-        $start = strtotime(date('Y-m-d',$cur));
-
-        return ($cur > $start + 3600 * 6);
+        $hour = date("H");
+        if ($hour >= 23 || $hour <= 7) {
+            return false;
+        } else {
+            return true;
+        }
     }
 }

+ 6 - 0
test/TestRefill.php

@@ -15,6 +15,7 @@ require_once(BASE_CORE_PATH . '/framework/function/http.php');
 require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
 require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
 
+
 const LocalTest = 1;
 const NetTest = 2;
 
@@ -42,6 +43,11 @@ class TestRefill extends TestCase
         }
     }
 
+    public function testIsDay()
+    {
+        $ret = refill\functional::isDay();
+    }
+
     public static function setUpBeforeClass(): void
     {
         Base::run_util();