Commit f3fa169f authored by shajiaiming's avatar shajiaiming

fix

parent 6cd520d8
......@@ -306,6 +306,14 @@ class Chain33Service
return $this->send($params, 'Chain33.SendTransaction');
}
public function getHeight($params = [])
{
$params = [
"data" => 'user.p.game.',
];
return $this->send($params, 'paracross.GetHeight');
}
/**
* 获取最新的区块
*/
......
......@@ -84,6 +84,17 @@ class CrossChainController extends Controller
echo date('Y-m-d H:i:s') . '暂无跨链交易计划' . PHP_EOL;
return 0;
}
//查询共识高度
$node_params = [
'scheme' => 'https',
'host' => 'jiedian1.bityuan.com',
'port' => 8801
];
$service = new Chain33Service($node_params);
$result = $service->getHeight();
$consensHeight = $result['result']['consensHeight'];
$current_time = time();
foreach ($model as $val) {
$node_params = $val['transfer_url'];
......@@ -96,16 +107,18 @@ class CrossChainController extends Controller
$service = new Chain33Service($node_params);
$send_result = $val['send_result'];
$result = $service->QueryTransaction($send_result);
$switch = true;
if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
$redis->hdel(CoinCrossChain::CROSS_CHAIN_CACHE_FAIL, $val['address'] . ':' . $val['is_with_draw']);
$query_result = 'success';
$msg = 'success';
$height = isset($result['result']['height']) ? $result['result']['height'] : 0;
goto doEnd;
} else if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']) {
$redis->hdel(CoinCrossChain::CROSS_CHAIN_CACHE_FAIL, $val['address'] . ':' . $val['is_with_draw']);
$query_result = 'success';
$msg = 'success';
$height = isset($result['result']['height']) ? $result['result']['height'] : 0;
goto doEnd;
} else {
$cache_error_time = $redis->hget(CoinCrossChain::CROSS_CHAIN_CACHE_FAIL, $val['address'] . ':' . $val['is_with_draw']);
......@@ -122,6 +135,7 @@ class CrossChainController extends Controller
if (-1 == $result['code']) {
$msg = $result['msg'];
$query_result = $result['code'];
$switch = false;
goto doEnd;
} else {
$query_result = 'fail';
......@@ -129,11 +143,17 @@ class CrossChainController extends Controller
if (is_array($log['log'])) continue;
$msg = isset($log['log']) ? $log['log'] : '查询错误';
}
$switch = false;
goto doEnd;
}
}
doEnd :
if (CoinCrossChain::RECHARGE == $val['is_with_draw'] && $switch && isset($height) && ($consensHeight < $height)) {
continue;
}
$currentModel = CoinCrossChain::findOne($val['id']);
$currentModel->query_result = $query_result;
$currentModel->msg = $msg;
......
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