Commit 1d33f3e2 authored by shajiaiming's avatar shajiaiming

撤消交易

parent a84ae5da
...@@ -14,13 +14,15 @@ class CoinIssueCoin extends CommonActiveRecord ...@@ -14,13 +14,15 @@ class CoinIssueCoin extends CommonActiveRecord
const ALLOW_PAY = 1; const ALLOW_PAY = 1;
const SUCCESS_PAY =2; const SUCCESS_PAY =2;
const UN_AUDIT = 0; const UN_AUDIT = 0; //允许发行(管理员)
const ALLOW_ISSUE = 1; const ALLOW_ISSUE = 1; //允许发行(管理员)
const REFUSE_ISSUE = 2; const REFUSE_ISSUE = 2; //拒绝发行
const SUCCESS_ISSUE = 3; const SUCCESS_ISSUE = 3; //发行成功
const FAIL_ISSUE = 4; const FAIL_ISSUE = 4; //发行失败
const CANCEL_ISSUE = 5; const CANCEL_ISSUE = 5; //已撤消
const ALLOWED_ISSUE = 6; const ALLOWED_ISSUE = 6; //允许发行(申请者)
const CANCEL_SUCCESS = 7; //撤消成功
const CANCEL_FAIL = 8; //撤消失败
//定义场景 //定义场景
const SCENARIOS_CREATE = 'create'; const SCENARIOS_CREATE = 'create';
......
...@@ -322,6 +322,15 @@ class Chain33Service ...@@ -322,6 +322,15 @@ class Chain33Service
return $this->send($params, 'token.CreateRawTokenFinishTx'); return $this->send($params, 'token.CreateRawTokenFinishTx');
} }
public function createRawTokenRevokeTx($symbol, $owner)
{
$params = [
'symbol' => $symbol,
'owner' => $owner
];
return $this->send($params, 'token.CreateRawTokenRevokeTx');
}
public function getBlock2MainInfo($start, $end) public function getBlock2MainInfo($start, $end)
{ {
$params = [ $params = [
......
...@@ -215,6 +215,47 @@ class IssueChainTransferController extends Controller ...@@ -215,6 +215,47 @@ class IssueChainTransferController extends Controller
return 0; return 0;
} }
public function actionCancel()
{
$issue_coin_model = CoinIssueCoin::find()->where(['status' => CoinIssueCoin::CANCEL_ISSUE])->all();
if (false == $issue_coin_model) {
echo date('Y-m-d H:i:s') . '暂无需要撤消的发行' . PHP_EOL;
return 0;
}
$node = Yii::$app->params['chain_nodes']['STO'];
$chain_service = new Chain33Service($node);
foreach ($issue_coin_model as $val) {
$data = [];
$result = $chain_service->createRawTokenRevokeTx($val->symbol, $val->owner);
if (null == $val->transfer) {
$status = CoinIssueCoin::CANCEL_FAIL;
goto doEnd;
}
if (null != $result['error']) {
$status = CoinIssueCoin::CANCEL_FAIL;
$data = [
'pre_query_transaction' => $result['error']
];
goto doEnd;
}
$status = CoinIssueCoin::CANCEL_SUCCESS;
$data = [
'pre_query_transaction' => $result['result']
];
doEnd :
CoinIssueCoin::updateAll(['status' => $status], [
'id' => $val->id,
]);
if (false != $data) {
CoinIssueChainRecord::updateAll($data, [
'issue_coin_id' => $val->id,
]);
}
}
echo date('Y-m-d H:i:s') . '已撤消' . PHP_EOL;
return 0;
}
public function syncCoin($params = []) public function syncCoin($params = [])
{ {
......
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