stanley-king il y a 3 ans
Parent
commit
8997cf9a62

+ 8 - 15
helper/refill/api/xyz/yunlingfs/RefillPhone.php

@@ -43,10 +43,12 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = $this->xmlToArray($resp);
-            if (empty($resp)) {
+            $resp = refill\util::xmlToArray($resp);
+
+            if (empty($resp)|| !isset($resp['resultno'])) {
                 return [false, '网络错误', true];
             }
+
             $resultno = intval($resp['resultno']);
             if (in_array($resultno, [0,2])) {
                 return [true, $resp['orderid'], false];
@@ -72,10 +74,11 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = $this->xmlToArray($resp);
-            if (empty($resp)) {
+            $resp = refill\util::xmlToArray($resp);
+            if (empty($resp) || !isset($resp['resultno'])) {
                 return [false, '网络错误'];
             }
+
             $resultno = intval($resp['resultno']);
             if ($resultno === 1) {
                 $order_state = ORDER_STATE_SUCCESS;
@@ -108,7 +111,7 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = $this->xmlToArray($resp);
+            $resp = refill\util::xmlToArray($resp);
             if (empty($resp)) {
                 return [false, '网络错误'];
             }
@@ -129,14 +132,4 @@ class RefillPhone extends refill\IRefillPhone
         $content .= "&sporderid={$params['sporderid']}&key={$key}";
         return md5($content);
     }
-
-    public function xmlToArray($xml)
-    {
-        //禁止引用外部xml实体
-        libxml_disable_entity_loader(true);
-        $xmlstring = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
-        $val = json_decode(json_encode($xmlstring), true);
-
-        return $val;
-    }
 }

+ 11 - 0
helper/refill/util.php

@@ -644,6 +644,17 @@ class util
             return false;
         }
     }
+
+    public static function xmlToArray($xml)
+    {
+        $object = simplexml_load_string($xml);
+        $val = json_decode(json_encode($object), true);
+
+        $msg = json_encode($val);
+        Log::record("xmlToArray result={$msg}", Log::DEBUG);
+
+        return $val;
+    }
     
     //for tester
     public static function send_normal($order_sn)

Fichier diff supprimé car celui-ci est trop grand
+ 30 - 0
test/TestBigData.php


+ 5 - 0
test/TestRefillNotify.php

@@ -102,6 +102,11 @@ class TestRefillNotify extends TestCase
     {
         $provider = $this->getProvider('xianghongrui');
         $provider->xxx('<!DOCTYPE html>');
+    }
 
+    public function testYunlingfs()
+    {
+        $provider = $this->getProvider('yunlingfs');
+        $provider->query(['order_sn' => '7861850691582899658106']);
     }
 }