Browse Source

bjb resp add match

ayHaru 4 years atrás
parent
commit
05d1fe3005

+ 1 - 1
data/config/prod/refill.ini.php

@@ -155,7 +155,7 @@ $weit_phone = ['name' => 'weit', 'store_id' => 18, 'card_type' => ['chinaunicom'
         300 => ['goods_id' => 6335, 'price' => 285],
         500 => ['goods_id' => 6336, 'price' => 475]], 'official_sn' => true, 'refill_type' => 'api'];
 
-$afand_phone = ['name' => 'afand', 'store_id' => 26, 'card_type' => ['chinaunicom', 'chinatelecom'],
+$afand_phone = ['name' => 'afand', 'store_id' => 26, 'card_type' => ['chinamobile', 'chinaunicom', 'chinatelecom'],
     'amount' => [
         30 => ['goods_id' => 6374, 'price' => 28.5],
         50 => ['goods_id' => 6375, 'price' => 47.5],

+ 1 - 1
helper/refill/afand/RefillCallBack.php

@@ -38,9 +38,9 @@ class RefillCallBack implements refill\IRefillCallBack
         $order_id = $order_info['order_id'];
         
         $data['official_sn'] = strtolower($params['op_order_id']) == 'null' ? '' : $params['op_order_id'];
-        Model('refill_order')->edit($order_id, $data);
 
         if ($status === 1) {
+            Model('refill_order')->edit($order_id, $data);
             return [$order_id, true, false,true];
         }
         elseif ($status === 0) {

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

@@ -36,9 +36,10 @@ class RefillCallBack implements refill\IRefillCallBack
         }
         $order_id = $order_info['order_id'];
         $data['official_sn'] = $params['bz'];
-        Model('refill_order')->edit($order_id, $data);
+
 
         if ($status === 1) {
+            Model('refill_order')->edit($order_id, $data);
             return [$order_id, true, false,true];
         }
         elseif ($status === 2) {

+ 18 - 4
helper/refill/bjb/RefillPhone.php

@@ -38,6 +38,10 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp,Log::DEBUG);
+            $resp = ltrim($resp , '|');
+            if(!preg_match( '/^-*[0-9]{1,3}\|[0-3]-*[\x{4e00}-\x{9fa5}]+\|[0-9]+$/u',$resp,$matches)) {
+                return [false,'matching error'];
+            }
             $resp = explode('|' , $resp);
             if($resp[0] == 0) {
                 return [true,''];
@@ -60,13 +64,23 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             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($resp['ack'] == 'success') {
-                return [true,$resp['message']];
+            $order_state = '';
+            if ($resp[0] == 1) {
+                $order_state = ORDER_STATE_SUCCESS;
+            } elseif ($resp[0] == 2) {
+                $order_state = ORDER_STATE_CANCEL;
+            } elseif ($resp[0] == 0){
+                $order_state = ORDER_STATE_SEND;
             }
-            else {
-                return [false,$resp['message']];
+            if (empty($order_state)) {
+                return [false, $resp[0]];
             }
+            return [true, $order_state];
         }
     }
 

+ 1 - 1
helper/refill/bjb/config.php

@@ -7,7 +7,7 @@ namespace refill\bjb;
 class config
 {
     const PAY_PHONE_URL = 'http://47.96.37.53:806/webInface/PayPhone.ashx';
-    const QUERY_URL= 'http://47.96.37.53/webInface/GetOrderState.ashx';
+    const QUERY_URL= 'http://47.96.37.53:806/webInface/GetOrderState.ashx';
     const USR= '13699279618';
     const KEY = 'd2dba2c0870b03a21ffd59df9c0cc774';
     const API_IP = NET_IP;

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

@@ -36,9 +36,10 @@ class RefillCallBack implements refill\IRefillCallBack
         }
         $order_id = $order_info['order_id'];
         $data['official_sn'] = $params['bz'];
-        Model('refill_order')->edit($order_id, $data);
+
 
         if ($status === 1) {
+            Model('refill_order')->edit($order_id, $data);
             return [$order_id, true, false,true];
         }
         elseif ($status === 2) {

+ 17 - 4
helper/refill/bjbyd/RefillPhone.php

@@ -38,6 +38,9 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp,Log::DEBUG);
+            if(!preg_match( '/^-*[0-9]{1,3}\|[\x{4e00}-\x{9fa5}]+\|-*[0-9]+\.*[0-9]+$/u',$resp,$matches)) {
+                return [false,'matching error'];
+            }
             $resp = explode('|' , $resp);
             if($resp[0] == 0) {
                 return [true,''];
@@ -60,13 +63,23 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             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($resp['ack'] == 'success') {
-                return [true,$resp['message']];
+            $order_state = '';
+            if ($resp[0] == 1) {
+                $order_state = ORDER_STATE_SUCCESS;
+            } elseif ($resp[0] == 2) {
+                $order_state = ORDER_STATE_CANCEL;
+            } elseif ($resp[0] == 0){
+                $order_state = ORDER_STATE_SEND;
             }
-            else {
-                return [false,$resp['message']];
+            if (empty($order_state)) {
+                return [false, $resp[0]];
             }
+            return [true, $order_state];
         }
     }
 

+ 1 - 1
helper/refill/bjbyd/config.php

@@ -7,7 +7,7 @@ namespace refill\bjbyd;
 class config
 {
     const PAY_PHONE_URL = 'http://47.96.37.53:806/webInface/PayPhone.ashx';
-    const QUERY_URL= 'http://47.96.37.53/webInface/GetOrderState.ashx';
+    const QUERY_URL= 'http://47.96.37.53:806/webInface/GetOrderState.ashx';
     const USR= '13699279618';
     const KEY = 'd2dba2c0870b03a21ffd59df9c0cc774';
     const API_IP = NET_IP;

+ 20 - 0
test/TestRefill.php

@@ -2,6 +2,7 @@
 
 
 use PHPUnit\Framework\TestCase;
+use const mtopcard\SinopecCard;
 
 define('APP_ID', 'test');
 define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
@@ -161,6 +162,13 @@ class TestRefill extends TestCase
         refill\RefillFactory::instance()->notify('yifa',$input);
     }
 
+    public function testBjbQuery()
+    {
+        $providers = new refill\bjb\RefillPhone([]);
+        $refill_info = ['order_sn' => 110667993758599771, 'ch_trade_no' => 499, 'card_no' => 1000111200005252927];
+        $resp = $providers->query($refill_info);
+    }
+
     public function testXcQuery()
     {
         $providers = new refill\xc\RefillPhone([]);
@@ -899,6 +907,18 @@ class TestRefill extends TestCase
 
     }
 
+    public function testCheckData(){
+        $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;
+        }
+        return false;
+    }
+
     public function testErrre()
     {
         $line = '[13 2021-01-24 16:07:03] DEBUG: type = application/json;charset=utf-8, content={"channelOrderNumber":"610664819621371793","orderNumber":"GYFL1611475621525437","message":"充值失败","signature":"6c28c15b9ce2b2243742ecebbd929ac5","status":109}';