Commit c71f9826 authored by shajiaiming's avatar shajiaiming

fix

parent d2ec9547
...@@ -59,15 +59,15 @@ class IssueCoinController extends BaseController ...@@ -59,15 +59,15 @@ class IssueCoinController extends BaseController
'nickname' => isset($result['nickname']) ? $result['nickname'] : '' 'nickname' => isset($result['nickname']) ? $result['nickname'] : ''
]; ];
$model = new CoinIssueCoin(); $model = new CoinIssueCoin();
if (0 == $params['token_type']){ if (0 == $params['token_type']) {
$model->setScenario(CoinIssueCoin::SCENARIOS_CREATE); $model->setScenario(CoinIssueCoin::SCENARIOS_CREATE);
} }
if (in_array($params['token_type'], [1, 2])){ if (in_array($params['token_type'], [1, 2])) {
$model->setScenario(CoinIssueCoin::SCENARIOS_NO_CHARGE); $model->setScenario(CoinIssueCoin::SCENARIOS_NO_CHARGE);
} }
if (in_array($params['token_type'], [3, 4])){ if (in_array($params['token_type'], [3, 4])) {
$params['template'] = isset($result['template']) ? $result['template'] : []; $params['template'] = isset($result['template']) ? $result['template'] : [];
$model->setScenario(CoinIssueCoin::SCENARIOS_VERIFY_MALL); $model->setScenario(CoinIssueCoin::SCENARIOS_VERIFY_MALL);
} }
...@@ -147,15 +147,15 @@ class IssueCoinController extends BaseController ...@@ -147,15 +147,15 @@ class IssueCoinController extends BaseController
]; ];
$model = new CoinIssueCoin(); $model = new CoinIssueCoin();
if (0 == $params['token_type']){ if (0 == $params['token_type']) {
$model->setScenario(CoinIssueCoin::SCENARIOS_CREATE); $model->setScenario(CoinIssueCoin::SCENARIOS_CREATE);
} }
if (in_array($params['token_type'], [1, 2])){ if (in_array($params['token_type'], [1, 2])) {
$model->setScenario(CoinIssueCoin::SCENARIOS_NO_CHARGE); $model->setScenario(CoinIssueCoin::SCENARIOS_NO_CHARGE);
} }
if (in_array($params['token_type'], [3, 4])){ if (in_array($params['token_type'], [3, 4])) {
$model->setScenario(CoinIssueCoin::SCENARIOS_CREATE_MALL); $model->setScenario(CoinIssueCoin::SCENARIOS_CREATE_MALL);
} }
...@@ -507,26 +507,46 @@ class IssueCoinController extends BaseController ...@@ -507,26 +507,46 @@ class IssueCoinController extends BaseController
$code = 0; $code = 0;
$msg = 'success'; $msg = 'success';
$symbol = Yii::$app->request->post('symbol', ''); $symbol = Yii::$app->request->post('symbol', '');
if (false == $symbol) { $token_type = Yii::$app->request->post('token_type', '');
if (false == $symbol || false == $token_type) {
$msg = '缺少必要的参数'; $msg = '缺少必要的参数';
$code = -1; $code = -1;
$data = null; $data = null;
goto doEnd; goto doEnd;
} }
$model = CoinIssueCoin::find()->where(['symbol' => $symbol, 'platform_id' => 35])->asArray()->one(); $model = CoinIssueCoin::find()
->where(['like', 'symbol', $symbol . '%', false])
->andWhere(['platform_id' => 35])
->andWhere(['token_type' => (int)$token_type])
->orderBy('id desc')
->asArray()
->one();
if (empty($model)) { if (empty($model)) {
$data = $symbol; $data = $symbol;
goto doEnd; goto doEnd;
} }
$data = $model['symbol'];
$suffix = substr($data, -1); if ($symbol == $model['symbol']) {
if (is_numeric($suffix)) { $data = $model['symbol'] . '01';
$prefix = substr($data, 0, -1); goto doEnd;
$data = $prefix . ($suffix + 1); }
} else {
$data = $data . 1; $prefix = (explode($symbol, $model['symbol']))[1];
$prefix++;
if ($prefix < 10) {
$data = $symbol . '0' . $prefix;
goto doEnd;
} }
$data = $symbol . $prefix;
// $suffix = substr($data, -1);
// if (is_numeric($suffix)) {
// $prefix = substr($data, 0, -1);
// $data = $prefix . ($suffix + 1);
// } else {
// $data = $data . 1;
// }
doEnd : doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data]; return ['code' => $code, 'msg' => $msg, 'data' => $data];
......
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