Commit 745c73a4 authored by shajiaiming's avatar shajiaiming

修复已知问题

parent d611af37
......@@ -3,6 +3,7 @@
namespace api\controllers;
use common\models\psources\CoinIssueRecord;
use common\models\psources\CoinPlatform;
use Yii;
use yii\data\Pagination;
use api\base\BaseController;
......@@ -25,6 +26,14 @@ class IssueCoinController extends BaseController
$code = -1;
goto doEnd;
}
$coin_platform = CoinPlatform::findOne($platform_id);
if (false == $coin_platform) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
$model = new CoinIssueCoin();
$model->setScenario(CoinIssueCoin::SCENARIOS_CREATE);
......@@ -49,7 +58,8 @@ class IssueCoinController extends BaseController
'category' => isset($result['category']) ? $result['category'] : 0,
'platform_id' => $platform_id,
'chain_id' => $chain_id,
'charge_unit_id' => isset($result['charge_unit_id']) ? $result['charge_unit_id'] : ''
'charge_unit_id' => isset($result['charge_unit_id']) ? $result['charge_unit_id'] : '',
'charge' => $coin_platform->issue_charge
];
$model->load($result, '');
if (!$model->save()) {
......
......@@ -42,11 +42,20 @@ class CoinIssueCoin extends CommonActiveRecord
['msg', 'string', 'length' => [1, 10]],
['name', 'string', 'length' => [1, 6]],
#['status', 'in', 'range' => [1, 2, 0]],
#['symbol', 'unique'],
['symbol', 'verfiySymbol'],
['total', 'verfiyAmount']
];
}
public function verfiySymbol($attribute, $params)
{
$model = CoinIssueCoin::find()->where(['symbol' => $this->symbol, 'platform_id' => $this->platform_id])->orderBy('id desc')->one();
if (0 == $model->category) {
$this->addError($attribute, '名称已存在');
return false;
}
}
public function verfiyAmount($attribute, $params)
{
$issue_record = CoinIssueRecord::find()->where(['platform_id' => $this->platform_id])->sum('total');
......
......@@ -28,11 +28,11 @@ class IssueCoinController extends BaseController
$chain_id = \Yii::$app->request->get('chain_id', '');
if (1 == $platform_id) {
$query = CoinIssueCoin::find()
->select('id, name, total, status, chain_id, charge_unit_id, platform_id, owner, category, symbol, introduction, create_time')
->select('id, name, total, status, chain_id, charge_unit_id, charge, platform_id, owner, category, symbol, introduction, create_time')
->orderBy('create_time desc');
} else {
$query = CoinIssueCoin::find()
->select('id, name, total, status, chain_id, charge_unit_id, platform_id, owner, category, symbol, introduction, create_time')
->select('id, name, total, status, chain_id, charge_unit_id, charge, platform_id, owner, category, symbol, introduction, create_time')
->where(['platform_id' => $platform_id])
->orderBy('create_time desc');
}
......@@ -57,7 +57,6 @@ class IssueCoinController extends BaseController
foreach ($models as &$val) {
$platform = isset($val->chain->platform) ? $val->chain->platform : '';
$val->chain_name = $platform;
$val->charge = isset($val->platform->issue_charge) ? (int)$val->platform->issue_charge : 0;
$val->charge_unit = isset($val->gas->coin_name) ? $val->gas->coin_name : '';
$val->url = Yii::$app->redis->hget('platform_brower_info', $platform);
$val->total = (int)$val->total * 1e8;
......
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