|
|
@@ -15,9 +15,11 @@ use SixShop\Payment\Contracts\PaymentResponse;
|
|
|
use SixShop\Payment\Entity\ExtensionPaymentEntity;
|
|
|
use SixShop\Payment\Enum\PaymentBizEnum;
|
|
|
use SixShop\Payment\Enum\PaymentStatusEnum;
|
|
|
+use SixShop\Payment\Event\PaymentSuccessEvent;
|
|
|
use SixShop\Wechat\Facade\WechatUser;
|
|
|
use SixShop\WechatPay\Trait\ApiTrait;
|
|
|
use SixShop\WechatPay\Trait\PaymentParamsTrait;
|
|
|
+use think\facade\Event;
|
|
|
use WeChatPay\Crypto\Rsa;
|
|
|
use WeChatPay\Formatter;
|
|
|
|
|
|
@@ -89,14 +91,20 @@ class PaymentProvider implements PaymentProviderInterface
|
|
|
$payment = $this->extensionPaymentEntity->findOrEmpty($recordID);
|
|
|
if ($payment->status === PaymentStatusEnum::PENDING) {
|
|
|
try {
|
|
|
- $payment->payment_result = $this->queryByOutTradeNo($payment['out_trade_no']);
|
|
|
+ $paymentResult = $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 继续判断订单状态
|
|
|
+ $payment->payment_result = $paymentResult;
|
|
|
+ $payment->transaction_id = $paymentResult->transaction_id;
|
|
|
+ if ($paymentResult->return_code === 'SUCCESS' && $paymentResult->result_code === 'SUCCESS' && $paymentResult->trade_state === 'SUCCESS') {
|
|
|
+ $payment->status = PaymentStatusEnum::SUCCESS;
|
|
|
+ $payment->save();
|
|
|
+ Event::trigger(new PaymentSuccessEvent($order['order_sn'], self::PAYMENT_TYPE, $payment->toArray(), $payment->biz_type));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return new PaymentQueryResult(
|