Commit c7303149 authored by shajiaiming's avatar shajiaiming

上链通

parent df373183
......@@ -56,7 +56,13 @@ class IssueCoinController extends BaseController
'charge' => $coin_platform->issue_charge,
];
$model = new CoinIssueCoin();
if (35 == $platform_id) {
$result['token_type'] = isset($result['token_type']) ? $result['token_type'] : 0;
$model->setScenario(CoinIssueCoin::SCENARIOS_CREATE_MALL);
} else {
$model->setScenario(CoinIssueCoin::SCENARIOS_CREATE);
}
$model->load($result, '');
if (!$model->validate()) {
$msg = $model->errors;
......@@ -95,9 +101,6 @@ class IssueCoinController extends BaseController
goto doEnd;
}
$model = new CoinIssueCoin();
$model->setScenario(CoinIssueCoin::SCENARIOS_CREATE);
if (!Yii::$app->request->isPost) {
$msg = '错误的请求方式';
$code = -1;
......@@ -118,9 +121,11 @@ class IssueCoinController extends BaseController
$code = -1;
goto doEnd;
}
foreach (Yii::$app->params['lang'] as $key => $val) {
$name[$val] = isset($result[$val]) ? $result[$val] : '';
}
$result = [
'name' => isset($result['name']) ? $result['name'] : '',
'name' => $name,
'symbol' => isset($result['symbol']) ? strtoupper($result['symbol']) : '',
'total' => isset($result['total']) ? $result['total'] : '',
'owner' => isset($result['owner']) ? $result['owner'] : '',
......@@ -132,6 +137,13 @@ class IssueCoinController extends BaseController
'charge_unit' => isset($result['charge_unit']) ? $result['charge_unit'] : '',
'charge' => (CoinIssueCoin::TYPE_NO == $result['type']) ? $coin_platform->issue_charge : 0,
];
$model = new CoinIssueCoin();
if (35 == $platform_id) {
$result['token_type'] = isset($result['token_type']) ? $result['token_type'] : 0;
$model->setScenario(CoinIssueCoin::SCENARIOS_CREATE_MALL);
} else {
$model->setScenario(CoinIssueCoin::SCENARIOS_CREATE);
}
$model->load($result, '');
if (!$model->save()) {
$msg = $model->errors;
......@@ -192,6 +204,7 @@ class IssueCoinController extends BaseController
$models = $query->offset(($page - 1) * $size)->limit($size)->all();
$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $size]);
foreach ($models as &$val) {
$val->name = isset($val->name['en-US']) ? $val->name['en-US'] : '';
$val->chain_id = $val->chain->platform;
$val->total = (int)$val->total * 1e4;
}
......@@ -231,6 +244,7 @@ class IssueCoinController extends BaseController
$code = -1;
goto doEnd;
}
$data->name = $data->name['en-US'];
$data->total = (int)$data->total * 1e4;
$data->chain_name = $data->chain->platform;
$data->issue_charge = rtrim(sprintf('%.3f', floatval($data->charge)), '0');
......
......@@ -32,6 +32,7 @@ class CoinIssueCoin extends CommonActiveRecord
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
const SCENARIOS_CANCEL = 'cancel';
const SCENARIOS_CREATE_MALL = 'create_mall';
public static function getDb()
{
......@@ -51,6 +52,7 @@ class CoinIssueCoin extends CommonActiveRecord
[['introduction', 'charge_unit'], 'string', 'length' => [1, 20]],
['symbol', 'string', 'length' => [1, 6]],
['name', 'string', 'length' => [1, 20]],
['token_type', 'safe'],
#['status', 'in', 'range' => [1, 2, 0]],
['name', 'verfiyName'],
['symbol', 'verfiySymbol'],
......@@ -62,6 +64,7 @@ class CoinIssueCoin extends CommonActiveRecord
{
$scenarios = [
self:: SCENARIOS_CREATE => ['name', 'symbol', 'total', 'owner', 'introduction', 'category', 'type', 'platform_id', 'chain_id', 'charge_unit', 'charge'],
self:: SCENARIOS_CREATE_MALL => ['name', 'symbol', 'total', 'owner', 'introduction', 'category', 'type', 'platform_id', 'chain_id', 'token_type'],
self:: SCENARIOS_UPDATE => ['status'],
self:: SCENARIOS_CANCEL => ['status'],
];
......
......@@ -373,8 +373,8 @@ class IssueChainTransferController extends Controller
if (false == $model_coin) {
$model = new Coin();
$model->name = $params['symbol'];
$model->sid = $params['name'];
$model->nickname = ['ja' => '', 'en-US' => '', 'zh-CN' => ''];
$model->sid = isset($params['name']['en-US']) ? $params['name']['en-US'] : '';
$model->nickname = $params['name'];
$model->platform = $params['platform'];
$model->publish_count = $params['total'] * 1e4;
$model->chain = 'BTY';
......
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