Browse Source

feat: EK-856: 管理员增加“Country”属性.

kevinElken 9 months ago
parent
commit
612ad2c79e
1 changed files with 14 additions and 4 deletions
  1. 14 4
      frontendApi/modules/v1/controllers/ShopController.php

+ 14 - 4
frontendApi/modules/v1/controllers/ShopController.php

@@ -143,17 +143,31 @@ class ShopController extends BaseController {
                 $allAddress[$key]['COUNTY_NAME'] = Region::getCnName($row['COUNTY']);
             }
         }
+
+        // 账户币种
+        $country = Countries::getById($user['COUNTRY_ID']);
+        $coin = Currency::getById($country['LOCAL_CURRENCY_ID']);
+
+        $decCountryId = User::getEnCodeInfo(\Yii::$app->user->id)['COUNTRY_ID'];
+        $decCountry = Countries::getById($decCountryId);
+        $decUserCurrencyRate = CurrencyConversions::getToUSDRate($decCountry['LOCAL_CURRENCY_ID']);
+        $currencyRate = CurrencyConversions::getToUSDRate($country['LOCAL_CURRENCY_ID']);
+
         $userBalance = [
             'cash' => 0,
             'prp' => 0,
+            'localCash' => 0,
+            'localRrp' => 0,
         ];
 
         if ($userCashResult = UserWallet::findOneAsArray(['USER_ID' => $user['ID']])) {
             $userBalance['cash'] = $userCashResult['CASH'];
+            $userBalance['localCash'] = Tool::convertAmount($userCashResult['CASH'], $decUserCurrencyRate, $currencyRate);
         }
 
         if ($userPerformance = UserPerformance::getAmounts($user['ID'])) {
             $userBalance['prp'] = $userPerformance;
+            $userBalance['localCash'] = Tool::convertAmount($userPerformance, $decUserCurrencyRate, $currencyRate);
         }
 
         // 运费模板
@@ -165,10 +179,6 @@ class ShopController extends BaseController {
 
         $isDec = User::getEnCodeInfo(\Yii::$app->user->id)['IS_DEC'];
 
-        // 账户币种
-        $country = Countries::getById($user['COUNTRY_ID']);
-        $coin = Currency::getById($country['LOCAL_CURRENCY_ID']);
-
         return static::notice(
             [
                 'payList'=>$payList,