修复支付宝支付驱动加载

This commit is contained in:
Anyon 2020-12-16 10:03:54 +08:00
parent 5c90ed8ecf
commit aba2f12fae
3 changed files with 14 additions and 10 deletions

View File

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

View File

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

View File

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