|
|
@@ -9,6 +9,8 @@ use common\helpers\Form;
|
|
|
use common\helpers\LoggerTool;
|
|
|
use common\helpers\Tool;
|
|
|
use common\libs\logging\operate\AdminOperate;
|
|
|
+use common\models\Countries;
|
|
|
+use common\models\Currency;
|
|
|
use common\models\CurrencyConversions;
|
|
|
use common\models\Instalment;
|
|
|
use common\models\Period;
|
|
|
@@ -144,12 +146,14 @@ class UserBasicForm extends Model {
|
|
|
$userModel = User::findOne(['ID' => $this->userId]);
|
|
|
// 原国家
|
|
|
$beforeCountry = $userModel->COUNTRY_ID;
|
|
|
+ $beforeCurrencyId = Countries::getCurrency($beforeCountry);
|
|
|
// 移民前汇率
|
|
|
- $beforeCurrency = CurrencyConversions::getToUSDRate($beforeCountry);
|
|
|
+ $beforeCurrencyRate = CurrencyConversions::getToUSDRate($beforeCurrencyId);
|
|
|
// 移民后汇率
|
|
|
- $afterCurrency = CurrencyConversions::getToUSDRate($this->country);
|
|
|
- LoggerTool::debug(json_encode(['modifyProfile', $beforeCountry, $this->country, $afterCurrency]));
|
|
|
- if (!$afterCurrency) {
|
|
|
+ $beforeCurrencyId = Countries::getCurrency($this->country);
|
|
|
+ $afterCurrencyRate = CurrencyConversions::getToUSDRate($beforeCurrencyId);
|
|
|
+ LoggerTool::debug(json_encode(['modifyProfile', $beforeCountry, $this->country, $afterCurrencyRate]));
|
|
|
+ if (!$afterCurrencyRate) {
|
|
|
throw new Exception(Yii::t('app', 'currencyDoesNotExist'));
|
|
|
}
|
|
|
// 如果移民,则需要进行移民条件检查
|
|
|
@@ -187,7 +191,7 @@ class UserBasicForm extends Model {
|
|
|
// 现金钱包余额转换
|
|
|
$userWallet = UserWallet::findOne(['USER_ID' => $this->userId]);
|
|
|
if ($userWallet && $userWallet->CASH > 0) {
|
|
|
- $userWallet->CASH = Tool::convertAmount($userWallet->CASH, $beforeCurrency, $afterCurrency);
|
|
|
+ $userWallet->CASH = Tool::convertAmount($userWallet->CASH, $beforeCurrencyRate, $afterCurrencyRate);
|
|
|
if (!$userWallet->save()) {
|
|
|
$transaction->rollBack();
|
|
|
throw new Exception($userModel->getErrors());
|