Prechádzať zdrojové kódy

fix(backend): 修复商户订单号查询订单接口

runphp 6 mesiacov pred
rodič
commit
b7d889753b

+ 5 - 2
src/Trait/ApiTrait.php

@@ -62,7 +62,10 @@ trait ApiTrait
         // https://pay.weixin.qq.com/doc/v3/merchant/4012791900
         // 【GET】/v3/pay/transactions/out-trade-no/{out_trade_no}
         return $this->handleAsyncRequest(function (BuilderChainable $builder, Config $config, string $outTradeNo): PromiseInterface {
-            return $builder->v3->pay->transactions->_out_trade_no_->getAsync([
+            return $builder->v3->pay->transactions->outTradeNo->_out_trade_no_->getAsync([
+                'query' => [
+                    'mchid' => $config->mchid,
+                ],
                 'out_trade_no' => $outTradeNo,
             ]);
         }, $outTradeNo);
@@ -78,7 +81,7 @@ trait ApiTrait
         $total = $total ?? $refund;
         // https://pay.weixin.qq.com/doc/v3/merchant/4012791862
         // 【POST】/v3/refund/domestic/refunds
-        return $this->handleAsyncRequest(function (BuilderChainable $builder, Config $config, $outRefundNo, $outTradeNo, $refund, $total, $reason) : PromiseInterface {
+        return $this->handleAsyncRequest(function (BuilderChainable $builder, Config $config, $outRefundNo, $outTradeNo, $refund, $total, $reason): PromiseInterface {
             return $builder->v3->refund->domestic->refunds->postAsync([
                 'json' => [
                     'out_refund_no' => $outRefundNo,

+ 1 - 1
src/Trait/HandleAsyncRequestTrait.php

@@ -29,7 +29,7 @@ trait HandleAsyncRequestTrait
                     Log::error('微信支付异步回调错误:' . $content);
                     if (json_validate($content)) {
                         $errorBody = json_decode($content);
-                        throw new ErrorException(severity:$e->getCode(), message: trim($errorBody->message));
+                        throw new ErrorException(severity: $e->getCode(), message: trim($errorBody->message));
                     }
                 }
                 throw $e;

+ 11 - 3
test/WechatPayBuilderTest.php

@@ -13,13 +13,14 @@ class WechatPayBuilderTest extends TestCase
     use MiniAppTrait;
 
     use ApiTrait;
+
     public function testCreate()
     {
         $result = \SixShop\WechatPay\Facade\WechatPayBuilder::getBuilderChainable();
         $this->assertInstanceOf(BuilderChainable::class, $result);
     }
 
-    public  function testOpSpecialOrder()
+    public function testOpSpecialOrder()
     {
 
         $this->expectException(\InvalidArgumentException::class);
@@ -27,9 +28,16 @@ class WechatPayBuilderTest extends TestCase
         $result = $this->opSpecialOrder('errororderid', 2);
     }
 
-    public function testDemo()
+    public function testDomesticRefunds()
+    {
+        $result = $this->domesticRefunds('20250904131736025655', '20250904131736025655', 0.01);
+        $this->assertObjectHasProperty('amount', $result);
+        dump($result);
+    }
+
+    public function testQueryByOutTradeNo()
     {
-        $result = $this->domesticRefunds('20250904123534022660', '20250904123534022660', 0.01);
+        $result = $this->queryByOutTradeNo('20250904131736025655');
         dump($result);
     }
 }