diff --git a/app/data/controller/api/Notify.php b/app/data/controller/api/Notify.php index 623af1f7c..5de17999e 100644 --- a/app/data/controller/api/Notify.php +++ b/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'; } diff --git a/app/data/service/PaymentService.php b/app/data/service/PaymentService.php index 5bfa1e0d9..7c9a13983 100644 --- a/app/data/service/PaymentService.php +++ b/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']}]未定义"); } } diff --git a/app/data/service/payment/AliPaymentService.php b/app/data/service/payment/AlipayPaymentService.php similarity index 97% rename from app/data/service/payment/AliPaymentService.php rename to app/data/service/payment/AlipayPaymentService.php index c3a9c4b6a..da21f92b3 100644 --- a/app/data/service/payment/AliPaymentService.php +++ b/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 = [ // 沙箱模式