Commit 1d717ea8 authored by shajiaiming's avatar shajiaiming

fix

parent 9a9a1dc7
...@@ -27,7 +27,7 @@ class CoinSupportedCurrency extends BaseActiveRecord ...@@ -27,7 +27,7 @@ class CoinSupportedCurrency extends BaseActiveRecord
{ {
return [ return [
[['platform_id', 'currency_id'], 'required'], [['platform_id', 'currency_id'], 'required'],
[['platform_id', 'currency_id'], 'integer'], [['platform_id', 'currency_id', 'sort'], 'integer'],
]; ];
} }
...@@ -42,8 +42,8 @@ class CoinSupportedCurrency extends BaseActiveRecord ...@@ -42,8 +42,8 @@ class CoinSupportedCurrency extends BaseActiveRecord
public function scenarios() public function scenarios()
{ {
$scenarios = [ $scenarios = [
self:: SCENARIOS_CREATE => ['platform_id', 'currency_id'], self:: SCENARIOS_CREATE => ['platform_id', 'currency_id', 'sort'],
self:: SCENARIOS_UPDATE => ['id', 'platform_id', 'currency_id'], self:: SCENARIOS_UPDATE => ['id', 'platform_id', 'currency_id', 'sort'],
]; ];
return array_merge(parent:: scenarios(), $scenarios); return array_merge(parent:: scenarios(), $scenarios);
} }
......
...@@ -108,16 +108,15 @@ class WalletController extends BaseController ...@@ -108,16 +108,15 @@ class WalletController extends BaseController
$code = 0; $code = 0;
$msg = 'success'; $msg = 'success';
$data = null; $data = null;
$current_platform_id = Yii::$app->request->getPlatformId();
if (Yii::$app->request->isGet) { if (Yii::$app->request->isGet) {
if (1 === $current_platform_id) { $platform_id = Yii::$app->request->get('platform_id', 0);
$platform_id = Yii::$app->request->get('platform_id', 1); if (false == $platform_id) {
$platform_id = empty($platform_id) ? 1 : $platform_id; $msg = '参数错误';
} else { $code = -1;
$platform_id = Yii::$app->request->getPlatformId(); goto doEnd;
} }
$coin_currency = CoinCurrency::find()->select('id, pj_name, pj_symbol')->asArray()->all();
$coin_currency = CoinCurrency::find()->select('id, pj_name')->asArray()->all();
$coin_supported_currency = CoinSupportedCurrency::find()->where(['platform_id' => $platform_id])->asArray()->all(); $coin_supported_currency = CoinSupportedCurrency::find()->where(['platform_id' => $platform_id])->asArray()->all();
$coin_supported_currency_id = ArrayHelper::getColumn($coin_supported_currency, 'currency_id'); $coin_supported_currency_id = ArrayHelper::getColumn($coin_supported_currency, 'currency_id');
...@@ -131,23 +130,94 @@ class WalletController extends BaseController ...@@ -131,23 +130,94 @@ class WalletController extends BaseController
goto doEnd; goto doEnd;
} }
if (Yii::$app->request->isPut) { if (Yii::$app->request->isPost) {
$platform_id = Yii::$app->request->getPlatformId();
if (1 != $platform_id) {
$msg = '权限未开通';
$code = -1;
goto doEnd;
}
$params = Yii::$app->request->post(); $params = Yii::$app->request->post();
$currency_ids = isset($params['currency_id']) ? $params['currency_id'] : null; $platform_id = isset($params['platform_id']) ? $params['platform_id'] : null;
if (false == $currency_ids) { $currency_id = isset($params['currency_id']) ? $params['currency_id'] : null;
$msg = '参数错误'; $sort = isset($params['sort']) ? $params['sort'] : 1;
$datas = [
'platform_id' => $platform_id,
'currency_id' => $currency_id,
'sort' => $sort
];
$isExist = CoinSupportedCurrency::find()->where(['platform_id' => $platform_id, 'currency_id' => $currency_id])->one();
if (false != $isExist) {
$msg = '记录已存在';
$code = -1;
goto doEnd;
}
$model = new CoinSupportedCurrency();
$model->setScenario(CoinSupportedCurrency::SCENARIOS_CREATE);
$model->load($datas, '');
if (!$model->validate()) {
$msg = $model->errors;
$code = -1; $code = -1;
goto doEnd; goto doEnd;
} }
CoinSupportedCurrency::deleteAll(['in', 'platform_id', $current_platform_id]); $model->save();
goto doEnd;
}
$currency_id_arr = explode(',', $currency_ids); if (Yii::$app->request->isPut) {
foreach ($currency_id_arr as $val) { $platform_id = Yii::$app->request->getPlatformId();
$datas[] = [ if (1 != $platform_id) {
$current_platform_id, (int)$val $msg = '权限未开通';
$code = -1;
goto doEnd;
}
$params = Yii::$app->request->post();
$id = isset($params['id']) ? $params['id'] : null;
$platform_id = isset($params['platform_id']) ? $params['platform_id'] : null;
$currency_id = isset($params['currency_id']) ? $params['currency_id'] : null;
$sort = isset($params['sort']) ? $params['sort'] : 1;
$datas = [
'platform_id' => $platform_id,
'currency_id' => $currency_id,
'sort' => $sort,
'id' => $id
]; ];
$model = CoinSupportedCurrency::find()->where(['id' => $id])->one();
if (false == $model) {
$msg = '记录未存在';
$code = -1;
goto doEnd;
}
$model->setScenario(CoinSupportedCurrency::SCENARIOS_UPDATE);
$model->load($datas, '');
if (!$model->validate()) {
$msg = $model->errors;
$code = -1;
goto doEnd;
}
$model->save();
goto doEnd;
}
if (Yii::$app->request->isDelete) {
$platform_id = Yii::$app->request->getPlatformId();
if (1 != $platform_id) {
$msg = '权限未开通';
$code = -1;
goto doEnd;
}
$params = Yii::$app->request->get();
$id = isset($params['id']) ? $params['id'] : null;
$model = CoinSupportedCurrency::find()->where(['id' => $id])->one();
if (false == $model) {
$msg = '记录未存在';
$code = -1;
goto doEnd;
} }
CoinSupportedCurrency::loadArray($datas); $model->delete();
goto doEnd; goto doEnd;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment