Commit c71f9826 authored by shajiaiming's avatar shajiaiming

fix

parent d2ec9547
......@@ -59,15 +59,15 @@ class IssueCoinController extends BaseController
'nickname' => isset($result['nickname']) ? $result['nickname'] : ''
];
$model = new CoinIssueCoin();
if (0 == $params['token_type']){
if (0 == $params['token_type']) {
$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);
}
if (in_array($params['token_type'], [3, 4])){
if (in_array($params['token_type'], [3, 4])) {
$params['template'] = isset($result['template']) ? $result['template'] : [];
$model->setScenario(CoinIssueCoin::SCENARIOS_VERIFY_MALL);
}
......@@ -147,15 +147,15 @@ class IssueCoinController extends BaseController
];
$model = new CoinIssueCoin();
if (0 == $params['token_type']){
if (0 == $params['token_type']) {
$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);
}
if (in_array($params['token_type'], [3, 4])){
if (in_array($params['token_type'], [3, 4])) {
$model->setScenario(CoinIssueCoin::SCENARIOS_CREATE_MALL);
}
......@@ -507,26 +507,46 @@ class IssueCoinController extends BaseController
$code = 0;
$msg = 'success';
$symbol = Yii::$app->request->post('symbol', '');
if (false == $symbol) {
$token_type = Yii::$app->request->post('token_type', '');
if (false == $symbol || false == $token_type) {
$msg = '缺少必要的参数';
$code = -1;
$data = null;
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)) {
$data = $symbol;
goto doEnd;
}
$data = $model['symbol'];
$suffix = substr($data, -1);
if (is_numeric($suffix)) {
$prefix = substr($data, 0, -1);
$data = $prefix . ($suffix + 1);
} else {
$data = $data . 1;
if ($symbol == $model['symbol']) {
$data = $model['symbol'] . '01';
goto doEnd;
}
$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 :
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