Update PaymentService.php

This commit is contained in:
邹景立 2021-05-08 15:57:53 +08:00
parent 2a5d0af7fe
commit 5f121221cf

View File

@ -10,7 +10,6 @@ use app\data\service\payment\VoucherPaymentService;
use app\data\service\payment\WechatPaymentService; use app\data\service\payment\WechatPaymentService;
use think\admin\Exception; use think\admin\Exception;
use think\App; use think\App;
use think\Container;
/** /**
* 支付基础服务 * 支付基础服务
@ -169,22 +168,22 @@ abstract class PaymentService
{ {
if ($code === 'empty') { if ($code === 'empty') {
$vars = ['code' => 'empty', 'type' => 'empty', 'params' => []]; $vars = ['code' => 'empty', 'type' => 'empty', 'params' => []];
return static::$driver[$code] = Container::getInstance()->make(EmptyPaymentService::class, $vars); return static::$driver[$code] = app()->make(EmptyPaymentService::class, $vars);
} }
[, $type, $params] = self::config($code); [, $type, $params] = self::config($code);
if (isset(static::$driver[$code])) return static::$driver[$code]; if (isset(static::$driver[$code])) return static::$driver[$code];
$vars = ['code' => $code, 'type' => $type, 'params' => $params]; $vars = ['code' => $code, 'type' => $type, 'params' => $params];
// 实例化具体支付参数类型 // 实例化具体支付参数类型
if (stripos($type, 'balance') === 0) { if (stripos($type, 'balance') === 0) {
return static::$driver[$code] = Container::getInstance()->make(BalancePyamentService::class, $vars); return static::$driver[$code] = app()->make(BalancePyamentService::class, $vars);
} elseif (stripos($type, 'voucher') === 0) { } elseif (stripos($type, 'voucher') === 0) {
return static::$driver[$code] = Container::getInstance()->make(VoucherPaymentService::class, $vars); return static::$driver[$code] = app()->make(VoucherPaymentService::class, $vars);
} elseif (stripos($type, 'alipay_') === 0) { } elseif (stripos($type, 'alipay_') === 0) {
return static::$driver[$code] = Container::getInstance()->make(AlipayPaymentService::class, $vars); return static::$driver[$code] = app()->make(AlipayPaymentService::class, $vars);
} elseif (stripos($type, 'wechat_') === 0) { } elseif (stripos($type, 'wechat_') === 0) {
return static::$driver[$code] = Container::getInstance()->make(WechatPaymentService::class, $vars); return static::$driver[$code] = app()->make(WechatPaymentService::class, $vars);
} elseif (stripos($type, 'joinpay_') === 0) { } elseif (stripos($type, 'joinpay_') === 0) {
return static::$driver[$code] = Container::getInstance()->make(JoinpayPaymentService::class, $vars); return static::$driver[$code] = app()->make(JoinpayPaymentService::class, $vars);
} else { } else {
throw new Exception(sprintf('支付驱动[%s]未定义', $type)); throw new Exception(sprintf('支付驱动[%s]未定义', $type));
} }