stanley-king преди 1 година
родител
ревизия
d830f1e92b

+ 9 - 6
helper/refill/api/mh/sohan_fast/RefillCallBack.php

@@ -16,11 +16,14 @@ class RefillCallBack implements refill\IRefillCallBack
         $body = '';
         foreach ($keys as $key)
         {
-            $body  .= "$key=$params[$key]";
 
-            if($key != 'Password') {
-                $body .= "&";
+            if($key == 'Password') {
+                $body  .= "$key=" . config::appSecret;
             }
+            else{
+                $body  .= "$key=$params[$key]&";
+            }
+
         }
 
         return md5($body);
@@ -29,7 +32,7 @@ class RefillCallBack implements refill\IRefillCallBack
     public function verify($params): bool
     {
         $sign = $this->sign($params);
-        if ($params['sign'] == $sign) {
+        if ($params['Sign'] == $sign) {
             return true;
         } else {
             return false;
@@ -49,12 +52,12 @@ class RefillCallBack implements refill\IRefillCallBack
         $order_id = $order_info['order_id'];
 
         $status = intval($params['Orderstatu_int']);
-        if ($status == 1) {
+        if (in_array($status, [11, 16])) {
             $official_sn = config::get_osn($params['Orderstatu_text']);
             Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no, 'official_sn' => $official_sn]);
             return [$order_id, true, false, true, $official_sn];
         }
-        elseif ($status == 9) {
+        elseif (in_array($status, [20, 21, 26])) {
             Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no]);
             return [$order_id, false, true, true, ''];
         }

+ 4 - 4
helper/refill/api/mh/sohan_fast/RefillPhone.php

@@ -47,7 +47,7 @@ class RefillPhone extends refill\IRefillPhone
 
             $code = $resp['errorCode'];
             if ($code === 1) {
-                return [true, $resp['orderId'], false];
+                return [true, $resp['chargeId'], false];
             } else {
                 return [false, $resp['errorDesc'], false];
             }
@@ -96,10 +96,10 @@ class RefillPhone extends refill\IRefillPhone
 
                 if (in_array($status, [11, 16])) {
 
-                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $resp['orderId'], 'official_sn' => $official_sn]);
+                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $resp['chargeId'], 'official_sn' => $official_sn]);
                     $order_state = ORDER_STATE_SUCCESS;
                 } elseif (in_array($status, [20, 21, 26])) {
-                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $resp['orderId']]);
+                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $resp['chargeId']]);
                     $order_state = ORDER_STATE_CANCEL;
                 } else {
                     $order_state = ORDER_STATE_SEND;
@@ -131,7 +131,7 @@ class RefillPhone extends refill\IRefillPhone
             $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '系统错误'];
-            } elseif ($resp['code'] === 1) {
+            } elseif ($resp['errorCode'] === 1) {
                 return [true, ncPriceFormat($resp['agentBalance'])];
             } else {
                 return [false, $resp['errorDesc']];

+ 7 - 1
helper/refill/api/mh/sohan_fast/config.php

@@ -9,6 +9,7 @@ class config
     public const ORDER_URL = 'http://api.sohan.hk:50080/API';
 
     public const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/mh/sohan_fast.php";
+//    public const NOTIFY_URL = "https://api.mhigh.cn/racc/callback/mh/testcb.php";
     public const ExtHeaders = [
         'User-Agent:Apifox/1.0.0 (https://apifox.com)',
         'Content-Type:application/json;charset=GBK'
@@ -28,6 +29,11 @@ class config
 
     public static function get_osn($str)
     {
-        return "";
+        $ret = preg_match("/[\s]+(?P<osn>[0-9a-zA-Z]*)/i",$str,$arr);
+        if($ret > 0) {
+            return $arr['osn'];
+        } else {
+            return "";
+        }
     }
 }

+ 14 - 0
racc/callback/mh/sohan_fast.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *   sohan_fast.php
+ *   stanley-king
+ *   2023/12/27
+ *   PhpStorm
+ *   PHPProject
+ */
+
+$content = json_encode($_POST);
+Log::record("sohan_fast content=$content",Log::DEBUG);
+
+refill\util::push_notify('sohan_fast',$_POST);
+echo ('ok');

+ 35 - 9
test/mh/TestRefill.php

@@ -140,17 +140,43 @@ class TestRefill extends TestCase
 
     public function testSohanFastCB()
     {
-        $post = '{"operatorTradeNo":"202312198256229371","statusDesc":"交易成功","phone":"13911220681","outTradeNo":"91791702973663689415","sign":"c81575ceb8d2b28cd37e33c65141361c","inTradeNo":"20231219161425561173378018037","status":"success","reportTime":"1702974060008"}';
-        $data = json_decode($post, true);
-        $provider = $this->getProvider('weisanhuo_normal', 'RefillCallBack');
-
-        $ret = $provider->verify($data);
-        $resp = $provider->notify($data);
-    }
+        $post = [
+            'Action' => 'CX',
+            'AgentAccount' => 'api_test',
+            'Agentbalance' => '-400.000',
+            'Orderid' => '40661703685798184367',
+            'Chargeid' => '3386490685',
+            'Orderstatu_int' => '20',
+            'TransCash' => '1.000',
+            'OrderPayment' => '1.000',
+            'Errorcode' => '0000',
+            'Errormsg' => '',
+            'Sign' => '2fee99fc128de20c150d8d55ea8bb008'
+        ];
+        $provider = $this->getProvider('sohan_fast', 'RefillCallBack');
+
+        $ret = $provider->verify($post);
+        $resp = $provider->notify($post);
+    }
+
+
+    public function testGetOSN()
+    {
+        $get_osn = function($str)
+        {
+            $ret = preg_match("/[\s]+(?P<osn>[0-9a-zA-Z]*)/i",$str,$arr);
+            if($ret > 0) {
+                return $arr['osn'];
+            } else {
+                return "";
+            }
+        };
+        $str = "缴费成功 8940247595202312075787697476";
+        $osn = $get_osn($str);
+
+//        $ret = preg_match('/[\w\W]+UPDATE[\w\W]+available_predeposit=available_predeposit(?P<oper>[-+]+)(?P<amount>[.\d]+)/i', $line, $matches);
 
 
-    public function testJson()
-    {
         $val = json_encode(['account' => '13911129867']);
     }