Browse Source

70卡 过滤流水号

lowkeyman 3 months ago
parent
commit
750f19801b

+ 1 - 1
helper/refill/api/xyz/kachong_new/RefillCallBack.php

@@ -36,7 +36,7 @@ class RefillCallBack implements refill\IRefillCallBack
         $order_id = $order_info['order_id'];
 
         if ($status === 2) {
-            Model('refill_order')->edit($order_id, ['official_sn' => $params['szRtnMsg']]);
+            Model('refill_order')->edit($order_id, ['official_sn' => config::extractOfficialSn($params['szRtnMsg'])]);
             return [$order_id, true, false,true];
         }
         elseif ($status === 3) {

+ 1 - 1
helper/refill/api/xyz/kachong_new/RefillPhone.php

@@ -85,7 +85,7 @@ class RefillPhone extends refill\IRefillPhone
             }
             $status = intval($resp['nRtn']);
             if ($status === 5012) {
-                Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $resp['szRtnMsg']]);
+                Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => config::extractOfficialSn($resp['szRtnMsg'])]);
                 $order_state = ORDER_STATE_SUCCESS;
             } elseif ($status === 5013) {
                 $order_state = ORDER_STATE_CANCEL;

+ 15 - 0
helper/refill/api/xyz/kachong_new/config.php

@@ -21,4 +21,19 @@ class config
     const ERR_NOS = [
         1000,1001,1003,1004,1023,1024,1025,1026,2001,2002,2003,2020,2021,2025,2026,1006,2030,3003
     ];
+
+    static function extractOfficialSn($officialSnStr): string
+    {
+        $officialSn = '';
+
+        if (preg_match_all("/(\d+)/", $officialSnStr, $matches)) {
+            foreach ($matches[1] as $item) {
+                if (strlen($officialSn) < strlen($item)) {
+                    $officialSn = $item;
+                }
+            }
+        }
+
+        return $officialSn;
+    }
 }

+ 1 - 1
helper/refill/api/xyz/kachong_sec/RefillCallBack.php

@@ -36,7 +36,7 @@ class RefillCallBack implements refill\IRefillCallBack
         $order_id = $order_info['order_id'];
 
         if ($status === 2) {
-            Model('refill_order')->edit($order_id, ['official_sn' => $params['szRtnMsg']]);
+            Model('refill_order')->edit($order_id, ['official_sn' => config::extractOfficialSn($params['szRtnMsg'])]);
             return [$order_id, true, false,true];
         }
         elseif ($status === 3) {

+ 1 - 1
helper/refill/api/xyz/kachong_sec/RefillPhone.php

@@ -85,7 +85,7 @@ class RefillPhone extends refill\IRefillPhone
             }
             $status = intval($resp['nRtn']);
             if ($status === 5012) {
-                Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $resp['szRtnMsg']]);
+                Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => config::extractOfficialSn($resp['szRtnMsg'])]);
                 $order_state = ORDER_STATE_SUCCESS;
             } elseif ($status === 5013) {
                 $order_state = ORDER_STATE_CANCEL;

+ 15 - 0
helper/refill/api/xyz/kachong_sec/config.php

@@ -21,4 +21,19 @@ class config
     const ERR_NOS = [
         1000,1001,1003,1004,1023,1024,1025,1026,2001,2002,2003,2020,2021,2025,2026,1006,2030,3003
     ];
+
+    static function extractOfficialSn($officialSnStr): string
+    {
+        $officialSn = '';
+
+        if (preg_match_all("/(\d+)/", $officialSnStr, $matches)) {
+            foreach ($matches[1] as $item) {
+                if (strlen($officialSn) < strlen($item)) {
+                    $officialSn = $item;
+                }
+            }
+        }
+
+        return $officialSn;
+    }
 }

+ 5 - 4
test/TestRefill.php

@@ -5606,10 +5606,11 @@ class TestRefill extends TestCase
 
             return $officialSn;
         };
-
-        $s0 = $extractOfficialSn('');
-        $s1 = $extractOfficialSn('1623091817214688');
-        $s3 = $extractOfficialSn('【中国石化】您尾号为869682的加油卡于09月18日 17时21分充值成功,金额200元,订单号:1623091817214688');
+//
+//        $s0 = $extractOfficialSn('');
+//        $s1 = $extractOfficialSn('1623091817214688');
+//        $s3 = $extractOfficialSn('【中国石化】您尾号为869682的加油卡于09月18日 17时21分充值成功,金额200元,订单号:1623091817214688');
+        $s4 = $extractOfficialSn('充值成功:982400036401654');
     }
 
     public function testYezifensheng_Balance()