Переглянути джерело

for has not callback provider

stanley-king 4 роки тому
батько
коміт
f9922a6de3

+ 4 - 0
helper/refill/IRefill.php

@@ -43,6 +43,10 @@ abstract class IRefill
         return $this->mOfficialSN === true;
     }
 
+    public function callback() {
+        return true;
+    }
+
     public function refill_type() {
         return $this->mRefillType;
     }

+ 19 - 5
helper/refill/RefillFactory.php

@@ -353,7 +353,8 @@ class RefillFactory
         usort($providers, $ascending);
 
         $refill_state = false;
-        foreach ($providers as $provider) {
+        foreach ($providers as $provider)
+        {
             $channel_name = $provider->name();
             [$goods_id, $price] = $provider->goods($amount);
 
@@ -373,7 +374,8 @@ class RefillFactory
             $result = $logic_buy_virtual->buyStep3($input, $buyer_id, [$calc, 'calc_vorder_amount'], true);
 
             $mod_refill = Model('refill_order');
-            if ($result['state'] === true) {
+            if ($result['state'] === true)
+            {
                 $order_sn = $result['data']['order_sn'];
                 $order_id = $result['data']['order_id'];
 
@@ -395,7 +397,8 @@ class RefillFactory
 
             $params = ['order_sn' => $order_sn, 'idcard' => $idcard, 'card_name' => $card_name];
             [$state, $err] = $provider->add($card_no, $card_type, $amount, $params);
-            if ($state) {
+            if ($state)
+            {
                 $trade_no = $err;
                 if ($provider->refill_type() == 'api') {
                     $logic_vr_order = Logic("vr_order");
@@ -404,8 +407,13 @@ class RefillFactory
 
                 $data = ['commit_time' => time(), 'ch_trade_no' => $trade_no];
                 $mod_refill->edit($order_id, $data);
-
                 $refill_state = true;
+
+                //如果对方没有回调能力,则启动主动查询.
+                if($provider->callback() === false) {
+                    QueueClient::async_push("QueryRefillState",['order_id' => $order_id],180);
+                }
+
                 break;
             } else {
                 Log::record("channel:{$channel_name} err:{$err}");
@@ -416,6 +424,8 @@ class RefillFactory
             }
         }
 
+
+
         if ($refill_state) {
             return [true, $order_sn];
         } else {
@@ -501,7 +511,7 @@ class RefillFactory
     public function query($order_id)
     {
         $mod_refill = Model('refill_order');
-        $refill_info = $mod_refill->getOrderInfo(['order_id' => $order_id]);
+        $refill_info = $mod_refill->getOrderInfo(['order_id' => $order_id,'inner_status' => 0]);
 
         $chname = $refill_info['channel_name'];
         $card_type = intval($refill_info['card_type']);
@@ -526,6 +536,10 @@ class RefillFactory
         $provider = $finder($chname, $card_type);
         [$state, $err] = $provider->query($refill_info);
 
+        if(!$provider->callback()) {
+
+        }
+
         if ($state === true) {
             $mod_refill->edit($order_id, ['notify_time' => time(), 'notify_state' => 1]);
             QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id]);

+ 2 - 1
helper/refill/saihu/RefillCallBack.php

@@ -40,7 +40,8 @@ class RefillCallBack implements refill\IRefillCallBack
 
         $body = "";
         $i = 0;
-        foreach ($params as $k => $v) {
+        foreach ($params as $k => $v)
+        {
             if (false === $this->check_empty($v) && "@" != substr($v, 0, 1)) {
                 if ($i == 0) {
                     $body .= "{$k}" . "=" . urldecode($v);

+ 4 - 0
helper/refill/saihu/RefillOil.php

@@ -89,4 +89,8 @@ class RefillOil extends refill\IRefillOil
             }
         }
     }
+
+    public function callback() {
+        return false;
+    }
 }