|
@@ -14,12 +14,15 @@ use SixShop\Payment\Contracts\PaymentRefundRequest;
|
|
|
use SixShop\Payment\Contracts\PaymentRefundResult;
|
|
use SixShop\Payment\Contracts\PaymentRefundResult;
|
|
|
use SixShop\Payment\Contracts\PaymentResponse;
|
|
use SixShop\Payment\Contracts\PaymentResponse;
|
|
|
use SixShop\Payment\Entity\ExtensionPaymentEntity;
|
|
use SixShop\Payment\Entity\ExtensionPaymentEntity;
|
|
|
|
|
+use SixShop\Payment\Entity\ExtensionRefundEntity;
|
|
|
use SixShop\Payment\Enum\PaymentBizEnum;
|
|
use SixShop\Payment\Enum\PaymentBizEnum;
|
|
|
use SixShop\Payment\Enum\PaymentStatusEnum;
|
|
use SixShop\Payment\Enum\PaymentStatusEnum;
|
|
|
|
|
+use SixShop\Payment\Enum\RefundStatusEnum;
|
|
|
use SixShop\Payment\Event\PaymentSuccessEvent;
|
|
use SixShop\Payment\Event\PaymentSuccessEvent;
|
|
|
use SixShop\Wechat\Facade\WechatUser;
|
|
use SixShop\Wechat\Facade\WechatUser;
|
|
|
use SixShop\WechatPay\Trait\ApiTrait;
|
|
use SixShop\WechatPay\Trait\ApiTrait;
|
|
|
use SixShop\WechatPay\Trait\PaymentParamsTrait;
|
|
use SixShop\WechatPay\Trait\PaymentParamsTrait;
|
|
|
|
|
+use think\facade\Db;
|
|
|
use think\facade\Event;
|
|
use think\facade\Event;
|
|
|
use function SixShop\Core\throw_logic_exception;
|
|
use function SixShop\Core\throw_logic_exception;
|
|
|
|
|
|
|
@@ -29,7 +32,10 @@ class PaymentProvider implements PaymentProviderInterface
|
|
|
use ApiTrait;
|
|
use ApiTrait;
|
|
|
use PaymentParamsTrait;
|
|
use PaymentParamsTrait;
|
|
|
|
|
|
|
|
- public function __construct(private readonly ExtensionPaymentEntity $extensionPaymentEntity)
|
|
|
|
|
|
|
+ public function __construct(
|
|
|
|
|
+ private readonly ExtensionPaymentEntity $extensionPaymentEntity,
|
|
|
|
|
+ private readonly ExtensionRefundEntity $extensionRefundEntity,
|
|
|
|
|
+ )
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -119,7 +125,26 @@ class PaymentProvider implements PaymentProviderInterface
|
|
|
|
|
|
|
|
public function refund(int $recordID, PaymentRefundRequest $param): PaymentRefundResult
|
|
public function refund(int $recordID, PaymentRefundRequest $param): PaymentRefundResult
|
|
|
{
|
|
{
|
|
|
- throw new \Exception('Not implemented');
|
|
|
|
|
|
|
+ $payment = $this->extensionPaymentEntity->find($recordID);
|
|
|
|
|
+ $reund = Db::transaction(function () use ($param, $payment) {
|
|
|
|
|
+ $reund = $this->extensionRefundEntity->create([
|
|
|
|
|
+ 'payment_id' => $payment->id,
|
|
|
|
|
+ 'order_sn' => $payment->out_trade_no,
|
|
|
|
|
+ 'reason' => $param->getReason(),
|
|
|
|
|
+ 'amount' => $param->getAmount(),
|
|
|
|
|
+ 'status' => RefundStatusEnum::REFUNDING,
|
|
|
|
|
+ 'status_desc' => '正在申请微信接口退款',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $this->domesticRefunds(
|
|
|
|
|
+ $reund->out_refund_no,
|
|
|
|
|
+ $payment->out_trade_no,
|
|
|
|
|
+ $param->getAmount(),
|
|
|
|
|
+ $payment->amount,
|
|
|
|
|
+ $param->getReason()
|
|
|
|
|
+ );
|
|
|
|
|
+ return $reund;
|
|
|
|
|
+ });
|
|
|
|
|
+ return new PaymentRefundResult($reund);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function refundQuery(string $refundNo): PaymentRefundQueryResult
|
|
public function refundQuery(string $refundNo): PaymentRefundQueryResult
|