stanley-king 1 year atrás
parent
commit
9a7459e987
2 changed files with 26 additions and 9 deletions
  1. 24 7
      helper/refill/api/xyz/weisanhuo/RefillPhone.php
  2. 2 2
      test/TestRefill.php

+ 24 - 7
helper/refill/api/xyz/weisanhuo/RefillPhone.php

@@ -6,7 +6,6 @@ require_once(BASE_HELPER_RAPI_PATH . '/weisanhuo/config.php');
 
 use refill;
 use Log;
-use refill\util;
 
 class RefillPhone extends refill\IRefillPhone
 {
@@ -64,9 +63,17 @@ class RefillPhone extends refill\IRefillPhone
     public function query($refill_info): array
     {
         $params['secretId'] = config::SECRET_ID;
-        $params['outTradeNo'] = $refill_info['order_sn'];
 
-        $sign = config::sign($params, ['outTradeNo']);
+        if(!empty($refill_info['ch_trade_no'])) {
+            $params['inTradeNo'] = $refill_info['ch_trade_no'];
+            $sign = config::sign($params, ['inTradeNo']);
+            $commit_check = false;
+        }
+        else {
+            $params['outTradeNo'] = $refill_info['order_sn'];
+            $sign = config::sign($params, ['outTradeNo']);
+            $commit_check = true;
+        }
         $params['sign'] = $sign;
 
         $resp = http_request(config::QUERY_URL, $params, 'GET');
@@ -91,13 +98,23 @@ class RefillPhone extends refill\IRefillPhone
                     $offical_sn = $resp['data']['inTradeNo'];
                     Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $offical_sn]);
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($status == 'failed') {
-                    $order_state = ORDER_STATE_CANCEL;
-                } elseif ($status == 'waiting') {
+                }
+                elseif ($status == 'failed')
+                {
+                    if(!$commit_check) {
+                        $order_state = ORDER_STATE_CANCEL;
+                    }
+                    elseif((time() - $refill_info['commit_time']) >= 600) {
+                        $order_state = ORDER_STATE_NOEXIST;
+                    }
+                }
+                elseif ($status == 'waiting') {
                     $order_state = ORDER_STATE_SEND;
-                } else {
+                }
+                else {
                     return [false, $status, $offical_sn];
                 }
+
                 return [true, $order_state, $offical_sn];
             }
             else

+ 2 - 2
test/TestRefill.php

@@ -5810,8 +5810,8 @@ class TestRefill extends TestCase
     public function testweisanhuo()
     {
         $provider = $this->getProvider('weisanhuo');
-        $resp = $provider->balance();
-        $resp = $provider->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->balance();
+//        $resp = $provider->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
         $resp = $provider->query(['order_sn' => '24271700815859899563']);
 
         $post = '{"operatorTradeNo":"","statusDesc":"交易成功","phone":"18780103116","outTradeNo":"202309250000000006","sign":"d793406757c1bb920fe518e9673a28ea","inTradeNo":"202309251766523539","status":"success","reportTime":"1695607732705"}';