|
|
@@ -1,5 +1,7 @@
|
|
|
<?php
|
|
|
+
|
|
|
declare(strict_types=1);
|
|
|
+
|
|
|
namespace SixShop\Payment;
|
|
|
|
|
|
use SixShop\Payment\Contracts\PaymentProviderInterface;
|
|
|
@@ -7,8 +9,6 @@ use SixShop\Payment\Contracts\PaymentQueryResult;
|
|
|
use SixShop\Payment\Contracts\PaymentRefundRequest;
|
|
|
use SixShop\Payment\Contracts\PaymentRefundResult;
|
|
|
use SixShop\Payment\Contracts\PaymentResponse;
|
|
|
-use SixShop\Payment\Entity\ExtensionPaymentEntity;
|
|
|
-use SixShop\Payment\Entity\ExtensionRefundEntity;
|
|
|
use SixShop\Payment\Enum\PaymentBizEnum;
|
|
|
use SixShop\Payment\Event\BeforePayEvent;
|
|
|
use SixShop\Payment\Event\GatheringPaymentEvent;
|
|
|
@@ -18,11 +18,9 @@ use think\facade\Event;
|
|
|
|
|
|
readonly class PaymentManager
|
|
|
{
|
|
|
-
|
|
|
public function __construct(
|
|
|
private ExtensionManager $extensionManager,
|
|
|
- )
|
|
|
- {
|
|
|
+ ) {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -30,13 +28,13 @@ readonly class PaymentManager
|
|
|
*
|
|
|
* @return PaymentInfo[]
|
|
|
*/
|
|
|
- public function getAllPayment():array
|
|
|
+ public function getAllPayment(): array
|
|
|
{
|
|
|
/* @var PaymentInfo[] $paymentList */
|
|
|
$paymentList = Event::trigger(GatheringPaymentEvent::class);
|
|
|
$paymentIDs = array_column($paymentList, 'id');
|
|
|
$statusMap = ExtensionModel::whereIn('id', $paymentIDs)->column(['status','id'], 'id', true);
|
|
|
- $payTypeList = extension_config('payment', 'pay_type')??[];
|
|
|
+ $payTypeList = extension_config('payment', 'pay_type') ?? [];
|
|
|
foreach ($paymentList as $payment) {
|
|
|
$payment->status = $statusMap[$payment->id]['status'];
|
|
|
$payment->enabled = in_array($payment->id, $payTypeList, true);
|
|
|
@@ -47,12 +45,12 @@ readonly class PaymentManager
|
|
|
/**
|
|
|
* 创建支付订单
|
|
|
*/
|
|
|
- public function create(string $paymentID, array $order, PaymentBizEnum $bizType = PaymentBizEnum::ORDER_PAY): PaymentResponse
|
|
|
+ public function create(string $paymentID, array $order, PaymentBizEnum $bizType = PaymentBizEnum::ORDER_PAY): PaymentResponse
|
|
|
{
|
|
|
Event::trigger(new BeforePayEvent($order, $paymentID, $bizType));
|
|
|
return $this->getPaymentProvider($paymentID)->create($order, $bizType);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 查询支付订单
|
|
|
*/
|
|
|
@@ -68,7 +66,7 @@ readonly class PaymentManager
|
|
|
{
|
|
|
return $this->getPaymentProvider($paymentID)->refund($recordID, $param);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 查询退款
|
|
|
*/
|
|
|
@@ -76,11 +74,11 @@ readonly class PaymentManager
|
|
|
{
|
|
|
return $this->getPaymentProvider($paymentID)->refundQuery($refundID);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 获取指定支付方式
|
|
|
*/
|
|
|
- public function getPayment($paymentID):array
|
|
|
+ public function getPayment($paymentID): array
|
|
|
{
|
|
|
return [
|
|
|
// todo
|
|
|
@@ -90,7 +88,7 @@ readonly class PaymentManager
|
|
|
/**
|
|
|
* 开启支付方式
|
|
|
*/
|
|
|
- public function enablePayment($paymentID):bool
|
|
|
+ public function enablePayment($paymentID): bool
|
|
|
{
|
|
|
// todo
|
|
|
return true;
|
|
|
@@ -99,7 +97,7 @@ readonly class PaymentManager
|
|
|
/**
|
|
|
* 关闭支付方式
|
|
|
*/
|
|
|
- public function disablePayment($paymentID):bool
|
|
|
+ public function disablePayment($paymentID): bool
|
|
|
{
|
|
|
// todo
|
|
|
return true;
|
|
|
@@ -111,4 +109,4 @@ readonly class PaymentManager
|
|
|
return $extension->getPaymentProvider();
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+}
|