1
0
Эх сурвалжийг харах

Add 币种获取失败容错

BrettonYe 2 жил өмнө
parent
commit
57f5c2c9d7

+ 5 - 5
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'));

+ 5 - 1
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,