|
|
@@ -3,6 +3,8 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace SixShop\WechatPay;
|
|
|
|
|
|
+use GuzzleHttp\Exception\ClientException;
|
|
|
+use SixShop\Core\Exception\NotFoundException;
|
|
|
use SixShop\Core\Helper;
|
|
|
use SixShop\Payment\Contracts\PaymentNotifyResult;
|
|
|
use SixShop\Payment\Contracts\PaymentProviderInterface;
|
|
|
@@ -84,7 +86,25 @@ class PaymentProvider implements PaymentProviderInterface
|
|
|
|
|
|
public function query(int $recordID): PaymentQueryResult
|
|
|
{
|
|
|
- throw new \Exception('Not implemented');
|
|
|
+ $payment = $this->extensionPaymentEntity->findOrEmpty($recordID);
|
|
|
+ if ($payment->status === PaymentStatusEnum::PENDING) {
|
|
|
+ try {
|
|
|
+ $payment->payment_result = $this->queryByOutTradeNo($payment['out_trade_no']);
|
|
|
+ } catch (ClientException $e) {
|
|
|
+ if ($e->getCode() === 404) {
|
|
|
+ throw new NotFoundException(sprintf('订单%s不存在', $payment['out_trade_no']));
|
|
|
+ }
|
|
|
+ throw $e;
|
|
|
+ }
|
|
|
+ // todo 继续判断订单状态
|
|
|
+ }
|
|
|
+
|
|
|
+ return new PaymentQueryResult(
|
|
|
+ orderNo: $payment['out_trade_no'],
|
|
|
+ status: $payment['status'],
|
|
|
+ amount: $payment['amount'],
|
|
|
+ raw: $payment->toArray()
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
public function refund(array $refund): PaymentRefundResult
|