浏览代码

修复支付宝支付驱动加载

Anyon 4 年之前
父节点
当前提交
aba2f12fae

+ 2 - 2
app/data/controller/api/Notify.php

@@ -2,7 +2,7 @@
 
 namespace app\data\controller\api;
 
-use app\data\service\payment\AliPaymentService;
+use app\data\service\payment\AlipayPaymentService;
 use app\data\service\payment\JoinPaymentService;
 use app\data\service\payment\WechatPaymentService;
 use think\admin\Controller;
@@ -46,7 +46,7 @@ class Notify extends Controller
     public function alipay(string $scene = 'order', string $param = ''): string
     {
         if (strtolower($scene) === 'order') {
-            return AliPaymentService::instance()->notify($param);
+            return AlipayPaymentService::instance()->notify($param);
         } else {
             return 'success';
         }

+ 9 - 5
app/data/service/PaymentService.php

@@ -2,7 +2,7 @@
 
 namespace app\data\service;
 
-use app\data\service\payment\AliPaymentService;
+use app\data\service\payment\AlipayPaymentService;
 use app\data\service\payment\JoinPaymentService;
 use app\data\service\payment\WechatPaymentService;
 use think\admin\Service;
@@ -99,14 +99,14 @@ abstract class PaymentService extends Service
 
     /**
      * 支付服务对象
-     * @var JoinPaymentService|WechatPaymentService|AliPaymentService
+     * @var JoinPaymentService|WechatPaymentService|AlipayPaymentService
      */
     protected static $driver = [];
 
     /**
      * 根据配置实例支付服务
      * @param string $payid 支付通道编号
-     * @return JoinPaymentService|WechatPaymentService|AliPaymentService
+     * @return JoinPaymentService|WechatPaymentService|AlipayPaymentService
      * @throws \think\Exception
      */
     public static function build(string $payid): PaymentService
@@ -131,10 +131,14 @@ abstract class PaymentService extends Service
         }
         // 实例化具体支付通道类型
         static::$type = $payment['type'];
-        if (stripos(static::$type, 'wechat_') === 0) {
+        if (stripos(static::$type, 'alipay_') === 0) {
+            return static::$driver[$payid] = AlipayPaymentService::instance();
+        } elseif (stripos(static::$type, 'wechat_') === 0) {
             return static::$driver[$payid] = WechatPaymentService::instance();
-        } else {
+        } elseif (stripos(static::$type, 'joinpay_') === 0) {
             return static::$driver[$payid] = JoinPaymentService::instance();
+        } else {
+            throw new \think\Exception("支付驱动[{$payment['type']}]未定义");
         }
     }
 

+ 3 - 3
app/data/service/payment/AliPaymentService.php → app/data/service/payment/AlipayPaymentService.php

@@ -6,10 +6,10 @@ use app\data\service\PaymentService;
 
 /**
  * 支付宝支付基础服务
- * Class AliPaymentService
+ * Class AlipayPaymentService
  * @package app\store\service\payment
  */
-class AliPaymentService extends PaymentService
+class AlipayPaymentService extends PaymentService
 {
 
     /**
@@ -22,7 +22,7 @@ class AliPaymentService extends PaymentService
      * 支付服务初始化
      * @return $this
      */
-    protected function initialize(): AliPaymentService
+    protected function initialize(): AlipayPaymentService
     {
         $this->params = [
             // 沙箱模式