stanley-king 1 ano atrás
pai
commit
ccd1d065b3

+ 10 - 0
helper/refill/EventManager.php

@@ -5,6 +5,7 @@ namespace refill;
 require_once(BASE_HELPER_PATH . '/refill/event/IEventRefill.php');
 require_once(BASE_HELPER_PATH . '/refill/event/crash.php');
 require_once(BASE_HELPER_PATH . '/refill/event/card_crash.php');
+require_once(BASE_HELPER_PATH . '/refill/event/cbparams_pick.php');
 
 use refill\event\card_crash;
 use Cache;
@@ -55,6 +56,8 @@ class EventManager
             $crash->load($cfgs['cfgs_crash'] ?? []);
             $this->mStubs[] = $crash;
         }
+
+
     }
 
     public function onBeforeSubmit(order $order)
@@ -120,4 +123,11 @@ class EventManager
             $stub->onComplete($refill_info, $order_info, $success);
         }
     }
+    public function onEventCallback($refill_info, $mch_info, &$ctls)
+    {
+        $stubs = $this->mStubs;
+        foreach ($stubs as $stub) {
+            $stub->onComplete($refill_info, $mch_info, $ctls);
+        }
+    }
 }

+ 37 - 10
helper/refill/event/IEventRefill.php

@@ -4,15 +4,42 @@ namespace refill\event;
 
 use refill\order;
 
-interface IEventRefill
+class IEventRefill
 {
-    public function load(array $cfgs);
-    public function onBeforeSubmit(order $order);
-    public function onSubmit(order $order);
-    public function onBeforeCommit(order $order, $ch_name): bool;
-    public function onCommit(order $order, $ch_name);
-    public function onNeterror(order $order, $ch_name);
-    public function onNotify($refill_info, $order_info, $success);
-    public function onComplete($refill_info, $order_info, $success);
-    public function onEventCallback($refill_info, $mch_info, &$ctls);
+    public function load(array $cfgs)
+    {
+
+    }
+    public function onBeforeSubmit(order $order) : bool
+    {
+        return true;
+    }
+    public function onSubmit(order $order)
+    {
+
+    }
+    public function onBeforeCommit(order $order, $ch_name): bool
+    {
+        return true;
+    }
+    public function onCommit(order $order, $ch_name)
+    {
+
+    }
+    public function onNeterror(order $order, $ch_name)
+    {
+
+    }
+    public function onNotify($refill_info, $order_info, $success)
+    {
+
+    }
+    public function onComplete($refill_info, $order_info, $success)
+    {
+
+    }
+    public function onEventCallback($refill_info, $mch_info, &$ctls)
+    {
+
+    }
 }

+ 2 - 7
helper/refill/event/card_crash.php

@@ -8,7 +8,7 @@ use mtopcard;
 use Log;
 
 # 规避相同手机卡号撞单问题解
-class card_crash implements IEventRefill
+class card_crash extends IEventRefill
 {
     use crash;
     public const cache_name = 'card_crash';
@@ -32,7 +32,7 @@ class card_crash implements IEventRefill
         $this->mSuccInterval = intval($cfgs['succ_interval'] ?? 900);
     }
 
-    public function onBeforeSubmit(order $order)
+    public function onBeforeSubmit(order $order) : bool
     {
         if(!$order->is_phone()) {
             return true;
@@ -136,9 +136,4 @@ class card_crash implements IEventRefill
 
         $this->complete($card_no, $oid, $ch_name, $success);
     }
-
-    public function onEventCallback($refill_info, $mch_info, &$ctls)
-    {
-
-    }
 }

+ 23 - 0
helper/refill/event/cbparams_pick.php

@@ -0,0 +1,23 @@
+<?php
+/**
+ *   cb_filter.php
+ *   stanley-king
+ *   2023/11/29
+ *   PhpStorm
+ *   PHPProject
+ */
+
+namespace refill\event;
+
+class cbparams_pick extends IEventRefill
+{
+    public function load(array $cfgs)
+    {
+
+    }
+
+    public function onEventCallback($refill_info, $mch_info, &$ctls)
+    {
+
+    }
+}

+ 3 - 1
helper/refill/util.php

@@ -477,7 +477,7 @@ class util
 
     public static function onEventCallback($refill_info, $mch_info, &$ctls)
     {
-
+        EventManager::instance()->onEventCallback($refill_info, $mch_info, $ctls);
     }
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public static function set_order_channels($mchid,$mchorder,$datas)
@@ -756,6 +756,7 @@ class util
             sleep(3);
             while (true)
             {
+                $net_errno = 0;
                 $resp = http_request($url,['status' => $status,'order_sn' => $order_sn],'GET', false, [], $net_errno);
                 if($resp == 'SUCCESS') {
                     break;
@@ -781,6 +782,7 @@ class util
             sleep(3);
             while (true)
             {
+                $net_errno = 0;
                 $resp = http_request($url,['status' => $status,'order_sn' => $order_sn],'GET', false, [], $net_errno);
                 if($resp == 'SUCCESS') {
                     break;

+ 11 - 4
test/TestRefillUtil.php

@@ -12,10 +12,10 @@ require_once(BASE_ROOT_PATH . '/fooder.php');
 
 require_once(BASE_HELPER_PATH . '/refill/XYZRefillFactory.php');
 
-//require_once(BASE_HELPER_PATH . '/refill/util.php');
-//require_once(BASE_HELPER_PATH . '/refill/EventManager.php');
-//require_once(BASE_HELPER_PATH . '/refill/event/test_crash.php');
-//require_once(BASE_HELPER_PATH . '/refill/order.php');
+require_once(BASE_HELPER_PATH . '/refill/util.php');
+require_once(BASE_HELPER_PATH . '/refill/EventManager.php');
+require_once(BASE_HELPER_PATH . '/refill/event/test_crash.php');
+require_once(BASE_HELPER_PATH . '/refill/order.php');
 
 class TestRefillUtil extends TestCase
 {
@@ -102,6 +102,13 @@ class TestRefillUtil extends TestCase
         $crasher->testCommit($card_no_a,$oid_a,'b');
     }
 
+    public function testCbparamsPick()
+    {
+        $cacher = Cache::getInstance('cacheredis');
+        $cfgs = $cacher->get('event-config', 'refill-');
+
+    }
+
     public function testGetDetail()
     {
         $mod_refill = Model('refill_order');