Browse Source

update bjb resp and taobao check phone request

ayHaru 4 years ago
parent
commit
ffe1d407e8

+ 1 - 1
helper/mtopcard/mtopcard.php

@@ -126,7 +126,7 @@ function card_type($cardno)
         $checker = function ($phone) {
             if (empty($phone)) return false;  //手机号不能为空
             $url = "https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel={$phone}";
-            $resp = file_get_contents($url);  //获取API返回 的数据
+            $resp = http_request($url);  //获取API返回 的数据
             $resp = mb_convert_encoding($resp, 'UTF-8', 'UTF-8,GBK,GB2312,BIG5'); //解决中文乱码
 
             $datas = explode('=', $resp);

+ 3 - 3
helper/refill/bjb/RefillPhone.php

@@ -66,10 +66,10 @@ class RefillPhone extends refill\IRefillPhone
         {
             Log::record($resp,Log::DEBUG);
             $resp = ltrim($resp , '|');
-            if(!preg_match( '/^[0-3]\|[0-9]+-*[\x{4e00}-\x{9fa5}]+\|[0-9]*$/u',$resp,$matches)) {
-                return [false,'matching error'];
-            }
             $resp = explode('|' , $resp);
+            if(count($resp) != 3) {
+                return [false,'返回值错误'];
+            }
             $order_state = '';
             if ($resp[0] == 1) {
                 $order_state = ORDER_STATE_SUCCESS;

+ 3 - 3
helper/refill/bjbyd/RefillPhone.php

@@ -64,10 +64,10 @@ class RefillPhone extends refill\IRefillPhone
         {
             Log::record($resp,Log::DEBUG);
             $resp = ltrim($resp , '|');
-            if(!preg_match( '/^[0-3]\|[0-9]+-*[\x{4e00}-\x{9fa5}]+\|[0-9]+$/u',$resp,$matches)) {
-                return [false,'matching error'];
-            }
             $resp = explode('|' , $resp);
+            if(count($resp) != 3) {
+                return [false,'返回值错误'];
+            }
             $order_state = '';
             if ($resp[0] == 1) {
                 $order_state = ORDER_STATE_SUCCESS;

+ 10 - 5
test/TestRefill.php

@@ -918,15 +918,20 @@ class TestRefill extends TestCase
     }
 
     public function testCheckData(){
-        $str = '2|110667993758599771-充值失败|';
-        $str = '0|提交成功|-36557.7400';
+        $str = '|2|110667993758599771-充值失败|';
+//        $str = '0|提交成功|-36557.7400';
 //        if(preg_match( '/^-*[0-9]{1,3}\|[\x{4e00}-\x{9fa5}]+\|-*[0-9]+\.*[0-9]+$/u',$str,$matches)) {
 //            return true;
 //        }
-        if(preg_match('/^[0-3]\|[0-9]+-*[\x{4e00}-\x{9fa5}]+\|[0-9]*$/u',$str,$matches)){
-            return true;
+//        if(preg_match('/^[0-3]\|[0-9]+-*[\x{4e00}-\x{9fa5}]+\|[0-9]*$/u',$str,$matches)){
+//            return true;
+//        }
+//        return false;
+        $resp = ltrim($str , '|');
+        $resp = explode('|' , $resp);
+        if(count($resp) != 3) {
+            return [false,'返回值错误'];
         }
-        return false;
     }
 
     public function testErrre()