Commit cf53079d authored by shajiaiming's avatar shajiaiming

后台接口

parent 7f71a544
...@@ -10,6 +10,13 @@ class CoinIssueCoin extends CommonActiveRecord ...@@ -10,6 +10,13 @@ class CoinIssueCoin extends CommonActiveRecord
const STATUS_SUCCESS = 1; //发行成功 const STATUS_SUCCESS = 1; //发行成功
const STATUS_FAIL = 0; //发行失败 const STATUS_FAIL = 0; //发行失败
const UN_AUDIT = 0;
const ALLOW_ISSUE = 1;
const REFUSE_ISSUE = 2;
const SUCCESS_ISSUE = 3;
const FAIL_ISSUE = 4;
const CANCEL_ISSUE = 5;
//定义场景 //定义场景
const SCENARIOS_CREATE = 'create'; const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update'; const SCENARIOS_UPDATE = 'update';
...@@ -31,7 +38,9 @@ class CoinIssueCoin extends CommonActiveRecord ...@@ -31,7 +38,9 @@ class CoinIssueCoin extends CommonActiveRecord
[['total', 'category', 'platform_id', 'chain_id'], 'integer'], [['total', 'category', 'platform_id', 'chain_id'], 'integer'],
['introduction', 'string', 'length' => [1, 20]], ['introduction', 'string', 'length' => [1, 20]],
['symbol', 'string', 'length' => [1, 20]], ['symbol', 'string', 'length' => [1, 20]],
['msg', 'string', 'length' => [1, 10]],
['name', 'string', 'length' => [1, 6]], ['name', 'string', 'length' => [1, 6]],
['status', 'in', 'range' => [1, 2, 0]],
['symbol', 'unique'], ['symbol', 'unique'],
]; ];
} }
...@@ -40,7 +49,7 @@ class CoinIssueCoin extends CommonActiveRecord ...@@ -40,7 +49,7 @@ class CoinIssueCoin extends CommonActiveRecord
{ {
$scenarios = [ $scenarios = [
self:: SCENARIOS_CREATE => ['name', 'symbol', 'total', 'owner', 'introduction', 'category', 'platform_id', 'chain_id', 'charge'], self:: SCENARIOS_CREATE => ['name', 'symbol', 'total', 'owner', 'introduction', 'category', 'platform_id', 'chain_id', 'charge'],
self:: SCENARIOS_UPDATE => ['name', 'symbol', 'total', 'owner', 'introduction', 'category', 'platform_id', 'chain_id', 'charge'], self:: SCENARIOS_UPDATE => ['status', 'msg'],
]; ];
return array_merge(parent:: scenarios(), $scenarios); return array_merge(parent:: scenarios(), $scenarios);
} }
...@@ -69,7 +78,9 @@ class CoinIssueCoin extends CommonActiveRecord ...@@ -69,7 +78,9 @@ class CoinIssueCoin extends CommonActiveRecord
'introduction' => 'Token简介', 'introduction' => 'Token简介',
'category' => '是否增发', 'category' => '是否增发',
'chain_id' => '平行链名称', 'chain_id' => '平行链名称',
'charge' => '手续费' 'charge' => '手续费',
'msg' => '失败原因',
'status' => '状态'
]; ];
} }
......
<?php
namespace wallet\controllers;
use Yii;
use wallet\base\BaseController;
use common\models\psources\CoinIssueChain;
use common\service\chain33\Chain33Service;
class IssueChainController extends BaseController
{
/**
* landing
* @return array
* @throws \yii\base\Exception
* @throws \yii\base\InvalidConfigException
*/
public function actionIndex()
{
$data = null;
$platform_id = Yii::$app->request->getPlatformId();
if (1 == $platform_id) {
$chain_model = CoinIssueChain::find()->select('id, chain_name, charge')->asArray()->all();
} else {
$chain_model = CoinIssueChain::find()->select('id, chain_name, charge')->where(['platform_id' => $platform_id])->asArray()->one();
}
if (false == $chain_model) {
$msg = '不存在的链';
$code = -1;
goto doEnd;
}
$msg = 'ok';
$code = 0;
$data = $chain_model;
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
public function actionSetCharge()
{
}
}
\ No newline at end of file
...@@ -2,100 +2,115 @@ ...@@ -2,100 +2,115 @@
namespace wallet\controllers; namespace wallet\controllers;
use common\models\psources\CoinIssueChain;
use Yii; use Yii;
use common\models\Admin; use yii\data\Pagination;
use wallet\base\BaseController;
use common\models\psources\CoinIssueCoin;
class IssueCoinController extends BaseController class IssueCoinController extends BaseController
{ {
/** public function actionApplyList()
* landing
* @return array
* @throws \yii\base\Exception
* @throws \yii\base\InvalidConfigException
*/
public function actionList()
{ {
$platform_id = Yii::$app->request->getPlatformId(); $platform_id = Yii::$app->request->getPlatformId();
if (1 === $platform_id) { $page = \Yii::$app->request->get('page', 1);
$platforms = CoinPlatform::find()->select('id, name')->asArray()->all(); $size = \Yii::$app->request->get('size', 10);
$status = \Yii::$app->request->get('status', '');
if (1 == $platform_id) {
$query = CoinIssueCoin::find()
->select('name, total, create_time, status, chain_id, owner, category, charge')
->orderBy('create_time desc');
} else { } else {
$platforms = CoinPlatform::find()->select('id, name')->where(['id' => $platform_id])->asArray()->all(); $query = CoinIssueCoin::find()
->select('name, total, create_time, status, chain_id, owner, category, charge')
->where(['platform_id' => $platform_id])
->orderBy('create_time desc');
} }
if (false != $status) {
return ['code' => 0, 'msg' => 'ok', 'data' => $platforms]; $query->where(['status' => $status]);
} }
public function actionWalletBallance() $countQuery = clone $query;
{ $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $size]);
$current_platform_id = Yii::$app->request->getPlatformId(); $models = $query->offset($pages->offset)
if(1 === $current_platform_id) { ->limit($pages->limit)
$platform_id = Yii::$app->request->get('platform_id', 1); ->all();
$platform_id = empty($platform_id) ? 1 : $platform_id; foreach ($models as &$val) {
} else { $val->chain_id = $val->chain->chain_name;
$platform_id = Yii::$app->request->getPlatformId();
}
if(!isset(Yii::$app->params['trusteeship']['node_'. $platform_id])){
return ['code' => -1, 'data' => [], 'msg' => '此钱包节点尚未开通'];
} }
$node_params = Yii::$app->params['trusteeship']['node_'. $platform_id]; $data = [
'list' => $models,
$type = Yii::$app->request->get('type', 1); 'page' => [
$page = Yii::$app->request->get('page', 1); 'pageCount' => $pages->pageCount,
$size = Yii::$app->request->get('size', 15); 'pageSize' => $size,
$currency = Yii::$app->request->get('currency ', ''); 'currentPage' => $page,
$params = [ ]
'type' => $type,
'page' => $page,
'size' => $size,
'currency' => $currency
]; ];
$time = time(); $msg = 'ok';
$appKey = isset($node_params['appKey']) ? $node_params['appKey'] : null; $code = 0;
$appSecret = isset($node_params['appSecret']) ? $node_params['appSecret'] : null;
$signature = self::getSign($params, $appKey, $appSecret, $time);
$headers = [ doEnd :
'FZM-Wallet-Signature' => $signature, return ['code' => $code, 'msg' => $msg, 'data' => $data];
'FZM-Wallet-Timestamp' => $time, }
'FZM-Wallet-AppKey' => $appKey,
'FZM-Wallet-AppIp' => Yii::$app->request->userIP
];
$service = new TrusteeShipService($node_params, $headers); public function actionApplyDetail()
$result = $service->getWalletBalance($params); {
if (200 !== $result['code']) { $id = Yii::$app->request->get('id', '');
return ['code' => $result['code'], 'data' => [], 'msg' => $result['msg']]; $data = null;
if (empty($id)) {
$msg = '缺少必要的参数';
$code = -1;
goto doEnd;
} }
return ['code' => 1, 'data' => $result['msg'], 'msg' => 'success'];
$data = CoinIssueCoin::find()->where(['id' => $id])->asArray()->one();
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
} }
public function actionUserAsset() public function actionVerify()
{ {
$platform_id = Yii::$app->request->getPlatformId(); $id = Yii::$app->request->post('id', '');
$node_params = Yii::$app->params['trusteeship']['node_'. $platform_id]; $status = Yii::$app->request->post('status', '');
$uid = Yii::$app->request->get('uid', ''); $msg = Yii::$app->request->post('msg', '');
$params = [ if (false == $id || false == $status) {
'uid' => $uid $msg = '缺少必要的参数';
]; $code = -1;
$time = time(); goto doEnd;
$appKey = isset($node_params['appKey']) ? $node_params['appKey'] : null; }
$appSecret = isset($node_params['appSecret']) ? $node_params['appSecret'] : null;
$signature = self::getSign($params, $appKey, $appSecret, $time);
$headers = [ if (!in_array($status, [CoinIssueCoin::UN_AUDIT, CoinIssueCoin::ALLOW_ISSUE, CoinIssueCoin::REFUSE_ISSUE])) {
'FZM-Wallet-Signature' => $signature, $msg = '状态值错误';
'FZM-Wallet-Timestamp' => $time, $code = -1;
'FZM-Wallet-AppKey' => $appKey, goto doEnd;
'FZM-Wallet-AppIp' => Yii::$app->request->userIP }
];
$service = new TrusteeShipService($node_params, $headers); $model = CoinIssueCoin::findOne($id);
$result = $service->getUserAsset($params); if (false == $model) {
if (200 !== $result['code']) { $msg = '不存在的记录';
return ['code' => $result['code'], 'data' => [], 'msg' => $result['msg']]; $code = -1;
goto doEnd;
} }
return ['code' => 1, 'data' => $result['msg'], 'msg' => 'success']; $data = [
'status' => $status,
'msg' => $msg
];
$model->setScenario(CoinIssueCoin::SCENARIOS_UPDATE);
$model->load($data, '');
if (!$model->save()) {
$msg = current($model->firstErrors);
$code = -1;
goto doEnd;
} }
$code = 0;
$msg = 'success';
doEnd :
return ['code' => $code, 'msg' => $msg];
}
} }
\ No newline at end of file
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