stanley-king 1 年之前
父節點
當前提交
89829977e1
共有 3 個文件被更改,包括 35 次插入28 次删除
  1. 0 26
      helper/refill/EventManager.php
  2. 32 0
      helper/refill/event/card_crash.php
  3. 3 2
      helper/refill/util.php

+ 0 - 26
helper/refill/EventManager.php

@@ -7,7 +7,6 @@ require_once(BASE_HELPER_PATH . '/refill/event/crash.php');
 require_once(BASE_HELPER_PATH . '/refill/event/card_crash.php');
 
 use refill\event\card_crash;
-use mtopcard;
 
 class EventManager
 {
@@ -43,10 +42,6 @@ class EventManager
 
     public function onBeforeSubmit(order $order)
     {
-        if(!$order->is_phone()) {
-            return true;
-        }
-
         foreach ($this->mStubs as $stub)
         {
             if($stub->onBeforeSubmit($order) === false) {
@@ -58,10 +53,6 @@ class EventManager
     }
     public function onSubmit(order $order)
     {
-        if(!$order->is_phone()) {
-            return;
-        }
-
         foreach ($this->mStubs as $stub) {
             $stub->onSubmit($order);
         }
@@ -69,10 +60,6 @@ class EventManager
 
     public function onBeforeCommit(order $order, $ch_name): bool
     {
-        if(!$order->is_phone()) {
-            return true;
-        }
-
         foreach ($this->mStubs as $stub)
         {
             if ($stub->onBeforeCommit($order, $ch_name) === false) {
@@ -84,10 +71,6 @@ class EventManager
     }
     public function onCommit(order $order, $ch_name)
     {
-        if(!$order->is_phone()) {
-            return;
-        }
-
         foreach ($this->mStubs as $stub) {
             $stub->onCommit($order, $ch_name);
         }
@@ -95,10 +78,6 @@ class EventManager
 
     public function onNeterror(order $order, $ch_name)
     {
-        if(!$order->is_phone()) {
-            return;
-        }
-
         foreach ($this->mStubs as $stub) {
             $stub->onNeterror($order, $ch_name);
         }
@@ -106,11 +85,6 @@ class EventManager
 
     public function onNotify($refill_info, $order_info, $success)
     {
-        $card_type = intval($refill_info['card_type']);
-        if(!in_array($card_type,[mtopcard\ChinaMobileCard,mtopcard\ChinaUnicomCard,mtopcard\ChinaTelecomCard])) {
-            return;
-        }
-
         foreach ($this->mStubs as $stub) {
             $stub->onNotify($refill_info, $order_info, $success);
         }

+ 32 - 0
helper/refill/event/card_crash.php

@@ -4,6 +4,8 @@ namespace refill\event;
 
 use refill\order;
 use refill\util;
+use mtopcard;
+
 
 # 规避相同手机卡号撞单问题解
 class card_crash implements IEventRefill
@@ -31,6 +33,10 @@ class card_crash implements IEventRefill
 
     public function onBeforeSubmit(order $order)
     {
+        if(!$order->is_phone()) {
+            return true;
+        }
+
         $card_no = $order->card_no();
         $ret = $this->can_submit($card_no);
 
@@ -54,6 +60,10 @@ class card_crash implements IEventRefill
     }
     public function onSubmit(order $order)
     {
+        if(!$order->is_phone()) {
+            return;
+        }
+
         $card_no = $order->card_no();
         $oid = $order->unique_id();
 
@@ -63,6 +73,10 @@ class card_crash implements IEventRefill
 
     public function onBeforeCommit(order $order, $ch_name): bool
     {
+        if(!$order->is_phone()) {
+            return true;
+        }
+
         $card_no = $order->card_no();
         $oid = $order->unique_id();
 
@@ -71,6 +85,10 @@ class card_crash implements IEventRefill
 
     public function onCommit(order $order, $ch_name)
     {
+        if(!$order->is_phone()) {
+            return;
+        }
+
         $card_no = $order->card_no();
         $oid = $order->unique_id();
 
@@ -79,6 +97,10 @@ class card_crash implements IEventRefill
 
     public function onNeterror(order $order, $ch_name)
     {
+        if(!$order->is_phone()) {
+            return;
+        }
+
         $card_no = $order->card_no();
         $oid = $order->unique_id();
 
@@ -87,6 +109,11 @@ class card_crash implements IEventRefill
 
     public function onNotify($refill_info, $order_info, $success)
     {
+        $card_type = intval($refill_info['card_type']);
+        if(!in_array($card_type,[mtopcard\ChinaMobileCard,mtopcard\ChinaUnicomCard,mtopcard\ChinaTelecomCard])) {
+            return;
+        }
+
         $oid = "{$refill_info['mchid']}-{$refill_info['mch_order']}";
         $ch_name = $refill_info['channel_name'];
         $card_no = $refill_info['card_no'];
@@ -96,6 +123,11 @@ class card_crash implements IEventRefill
 
     public function onComplete($refill_info, $order_info, $success)
     {
+        $card_type = intval($refill_info['card_type']);
+        if(!in_array($card_type,[mtopcard\ChinaMobileCard,mtopcard\ChinaUnicomCard,mtopcard\ChinaTelecomCard])) {
+            return;
+        }
+
         $oid = "{$refill_info['mchid']}-{$refill_info['mch_order']}";
         $ch_name = $refill_info['channel_name'];
         $card_no = $refill_info['card_no'];

+ 3 - 2
helper/refill/util.php

@@ -429,8 +429,9 @@ class util
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public static function onEventBeforeSubmit(order $order) : bool
     {
-        Log::record("onEvent before submit {$order->unique_id()}",Log::DEBUG);
-        return EventManager::instance()->onBeforeSubmit($order);
+        $card_type = $order->card_type();
+        Log::record("onEvent before submit {$order->unique_id()} card_type=$card_type",Log::DEBUG);
+//        return EventManager::instance()->onBeforeSubmit($order);
     }
 
     public static function onEventSubmit(order $order)