wesmiler il y a 2 ans
Parent
commit
c603be9f6c
1 fichiers modifiés avec 9 ajouts et 8 suppressions
  1. 9 8
      app/Services/Api/AcceptorService.php

+ 9 - 8
app/Services/Api/AcceptorService.php

@@ -148,24 +148,25 @@ class AcceptorService extends BaseService
         $currencyPrice = $currency=='CNY'? 1 : WalletService::make()->getRateByCNY($currency);
 
         // 买价
+        $xdPrice = ConfigService::make()->getConfigByCode('xd_price', 100);
+        $buyPrice = moneyFormat($money/$xdPrice,2);  // 星豆价格
+        $cnyPrice = moneyFormat($buyPrice * $usdtPrice,2); // 币种价格
+
         if($tradeType == 1){
             $xdBuyPriceRate = ConfigService::make()->getConfigByCode('trade_buy_price_rate', 0);
             $xdBuyPriceRate = $xdBuyPriceRate>0 && $xdBuyPriceRate<100? $xdBuyPriceRate : 0;
 
-            $buyPrice = moneyFormat($money + ($money * $xdBuyPriceRate / 100), 2);
-            $cnyBuyPrice = moneyFormat($buyPrice / $usdtPrice , 2);
-            return moneyFormat($cnyBuyPrice * $currencyPrice, 2);
+            $cnyBuyPrice = moneyFormat($cnyPrice + ($cnyPrice * $xdBuyPriceRate/100), 2); // 上浮价格
+            return moneyFormat($cnyBuyPrice * $currencyPrice, 2); // 汇率价格
         }else if($tradeType == 2){
             $xdSellPriceRate = ConfigService::make()->getConfigByCode('trade_sell_price_rate', 0);
             $xdSellPriceRate = $xdSellPriceRate>0 && $xdSellPriceRate<100? $xdSellPriceRate : 0;
 
-            $sellPrice = moneyFormat($money + ($money * $xdSellPriceRate / 100), 2);
-            $cnySellPrice = moneyFormat($sellPrice / $usdtPrice , 2);
-            return moneyFormat($cnySellPrice * $currencyPrice, 2);
+            $cnyBuyPrice = moneyFormat($cnyPrice - ($cnyPrice * $xdSellPriceRate/100), 2); // 下浮价格
+            return moneyFormat($cnyBuyPrice * $currencyPrice, 2); // 汇率价格
         }
 
-        $cnyPrice = moneyFormat($money / $usdtPrice , 2);
-        return moneyFormat($cnyPrice * $currencyPrice, 2);
+        return moneyFormat($cnyPrice * $currencyPrice, 2); // 汇率价格
     }
 
     /**