Commit acc05dff authored by shajiaiming's avatar shajiaiming

fix

parent 0693640e
......@@ -25,6 +25,8 @@ class CoinIssueCoin extends CommonActiveRecord
const TYPE_NO = 0; //不是增发
const TYPE_YES = 1; //是增发
const ISSUE_TOKEN = 'issue_token';
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
......
......@@ -127,6 +127,7 @@ class IssueChainTransferController extends Controller
public function actionQueryTransaction($step)
{
$redis = Yii::$app->redis;
if (1 == $step) {
$model = CoinIssueChainRecord::find()->where(['pre_query_transaction' => 'standby'])->all();
}
......@@ -142,6 +143,7 @@ class IssueChainTransferController extends Controller
$node = Yii::$app->params['chain_nodes']['STO'];
$service = new Chain33Service($node);
$current_time = time();
foreach ($model as $val) {
if (1 == $step) {
$result = $service->QueryTransaction($val->pre_send_transaction);
......@@ -167,6 +169,7 @@ class IssueChainTransferController extends Controller
} else {
$status = CoinIssueCoin::STATUS_SUCCESS;
}
$redis->hdel(CoinIssueCoin::ISSUE_TOKEN, $val->id);
goto doEnd;
} else if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']) {
$data = [
......@@ -184,6 +187,7 @@ class IssueChainTransferController extends Controller
} else {
$status = CoinIssueCoin::STATUS_SUCCESS;
}
$redis->hdel(CoinIssueCoin::ISSUE_TOKEN, $val->id);
goto doEnd;
} else {
$status = CoinIssueCoin::STATUS_FAILED;
......@@ -206,11 +210,21 @@ class IssueChainTransferController extends Controller
$data['finish_send_transaction'] = 'failed';
$data['finish_query_transaction'] = 'failed';
}
$cache_error_time = $redis->hget(CoinIssueCoin::ISSUE_TOKEN, $val->id);
if (false == $cache_error_time) {
$redis->hmset(CoinIssueCoin::ISSUE_TOKEN, $val->id, $current_time);
continue;
}
if (($current_time - $cache_error_time) < 10) {
continue;
}
$redis->hdel(CoinIssueCoin::ISSUE_TOKEN, $val->id);
goto doEnd;
}
doEnd :
#echo json_encode($data).PHP_EOL;
#echo $status.PHP_EOL;exit;
CoinIssueChainRecord::updateAll($data, [
'id' => $val->id,
]);
......
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