Commit 37a3766a authored by shajiaiming's avatar shajiaiming

fix

parent d50da49e
......@@ -31,6 +31,63 @@ class IssueCoinController extends BaseController
exit;
}
public function actionValidate()
{
$data = null;
$header = Yii::$app->request->headers;
$platform_id = $header['FZM-PLATFORM-ID'] ?? null;
if (empty($platform_id)) {
$msg = '缺少必要的参数';
$code = -1;
goto doEnd;
}
$coin_platform = CoinPlatform::findOne($platform_id);
if (false == $coin_platform) {
$msg = '参数错误';
$code = -1;
goto doEnd;
}
$result = Yii::$app->request->post();
$chain_id = isset($result['chain_id']) ? $result['chain_id'] : 0;
if (false == $chain_id) {
$msg = '不存在的链';
$code = -1;
goto doEnd;
}
$result = [
'name' => isset($result['name']) ? $result['name'] : '',
'symbol' => isset($result['symbol']) ? strtoupper($result['symbol']) : '',
'total' => isset($result['total']) ? $result['total'] : '',
'owner' => isset($result['owner']) ? $result['owner'] : '',
'introduction' => isset($result['introduction']) ? $result['introduction'] : '',
'category' => isset($result['category']) ? $result['category'] : 0,
'type' => isset($result['type']) ? $result['type'] : 0,
'platform_id' => $platform_id,
'chain_id' => $chain_id,
'charge_unit_id' => isset($result['charge_unit_id']) ? $result['charge_unit_id'] : '',
'charge' => $coin_platform->issue_charge,
];
$model = new CoinIssueCoin();
$model->setScenario(CoinIssueCoin::SCENARIOS_CREATE);
$model->load($result, '');
if (!$model->validate()) {
$msg = $model->errors;
$code = -1;
goto doEnd;
}
$msg = 'ok';
$code = 0;
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
/**
* 发行申请
* @return array
......@@ -70,7 +127,13 @@ class IssueCoinController extends BaseController
goto doEnd;
}
$pre_create_tx = isset($result['pre_create_tx']) ? $result['pre_create_tx'] : '';
$pre_send_transaction = isset($result['pre_send_transaction']) ? $result['pre_send_transaction'] : '';
if (false == $pre_create_tx || false == $pre_send_transaction) {
$msg = '缺少必要的参数';
$code = -1;
goto doEnd;
}
$result = [
'name' => isset($result['name']) ? $result['name'] : '',
......@@ -95,6 +158,20 @@ class IssueCoinController extends BaseController
$code = 0;
$data = $model->getPrimaryKey();
$params = [
'pre_create_tx' => $pre_create_tx,
'pre_send_transaction' => $pre_send_transaction,
'pre_query_transaction' => 'standby',
'finish_tx' => 'standby',
'finish_send_transaction' => 'standby',
'finish_query_transaction' => 'standby',
'issue_coin_id' => $data,
];
$transfer_model = new CoinIssueChainRecord();
$transfer_model->setScenario(CoinIssueChainRecord::SCENARIOS_PRE_CREATE);
$transfer_model->load($params, '');
$transfer_model->save();
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
......@@ -200,7 +277,6 @@ class IssueCoinController extends BaseController
$id = isset($params['id']) ? (int)$params['id'] : 0;
$pre_create_tx = isset($params['pre_create_tx']) ? $params['pre_create_tx'] : '';
$pre_send_transaction = isset($params['pre_send_transaction']) ? $params['pre_send_transaction'] : '';
if (false == $id || false == $pre_create_tx || false == $pre_send_transaction) {
$msg = '缺少必要的参数';
$code = -1;
......
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