diff --git a/app/Components/Helpers.php b/app/Components/Helpers.php index 61ee1797..9a3fa0ac 100644 --- a/app/Components/Helpers.php +++ b/app/Components/Helpers.php @@ -269,7 +269,10 @@ class Helpers $standard = sysConfig('standard_currency', 'CNY'); $currencyLib = array_column(config('common.currency'), 'symbol', 'code'); if (! empty($currentCurrency) && isset($currencyLib[$currentCurrency]) && $currentCurrency !== $standard) { - return $currencyLib[$currentCurrency].CurrencyExchange::convert($currentCurrency, $amount); + $convert = CurrencyExchange::convert($currentCurrency, $amount); + if ($convert !== false) { + return $currencyLib[$currentCurrency].$convert; + } } return $currencyLib[$standard].$amount; @@ -278,10 +281,7 @@ class Helpers private static function getRandPort(): int { // 获取一个随机端口 $port = random_int(sysConfig('min_port'), sysConfig('max_port')); - $exists_port = array_merge( - User::where('port', '<>', 0)->pluck('port')->toArray(), - self::$denyPorts - ); + $exists_port = array_merge(User::where('port', '<>', 0)->pluck('port')->toArray(), self::$denyPorts); while (in_array($port, $exists_port, true)) { $port = random_int(sysConfig('min_port'), sysConfig('max_port')); diff --git a/app/Payments/PayPal.php b/app/Payments/PayPal.php index 048f94c2..76bc1d81 100644 --- a/app/Payments/PayPal.php +++ b/app/Payments/PayPal.php @@ -113,7 +113,11 @@ class PayPal extends Gateway protected function getCheckoutData($trade_no, $amount): array { - $amount = 0.3 + CurrencyExchange::convert('USD', $amount); + $converted = CurrencyExchange::convert('USD', $amount); + if ($converted === false) { + $converted = $amount / 7; + } + $amount = 0.3 + $converted; return [ 'invoice_id' => $trade_no,