Commit f3fa169f authored by shajiaiming's avatar shajiaiming

fix

parent 6cd520d8
...@@ -306,6 +306,14 @@ class Chain33Service ...@@ -306,6 +306,14 @@ class Chain33Service
return $this->send($params, 'Chain33.SendTransaction'); 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 ...@@ -84,6 +84,17 @@ class CrossChainController extends Controller
echo date('Y-m-d H:i:s') . '暂无跨链交易计划' . PHP_EOL; echo date('Y-m-d H:i:s') . '暂无跨链交易计划' . PHP_EOL;
return 0; 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(); $current_time = time();
foreach ($model as $val) { foreach ($model as $val) {
$node_params = $val['transfer_url']; $node_params = $val['transfer_url'];
...@@ -96,16 +107,18 @@ class CrossChainController extends Controller ...@@ -96,16 +107,18 @@ class CrossChainController extends Controller
$service = new Chain33Service($node_params); $service = new Chain33Service($node_params);
$send_result = $val['send_result']; $send_result = $val['send_result'];
$result = $service->QueryTransaction($send_result); $result = $service->QueryTransaction($send_result);
$switch = true;
if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) { if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
$redis->hdel(CoinCrossChain::CROSS_CHAIN_CACHE_FAIL, $val['address'] . ':' . $val['is_with_draw']); $redis->hdel(CoinCrossChain::CROSS_CHAIN_CACHE_FAIL, $val['address'] . ':' . $val['is_with_draw']);
$query_result = 'success'; $query_result = 'success';
$msg = 'success'; $msg = 'success';
$height = isset($result['result']['height']) ? $result['result']['height'] : 0;
goto doEnd; goto doEnd;
} else if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']) { } 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']); $redis->hdel(CoinCrossChain::CROSS_CHAIN_CACHE_FAIL, $val['address'] . ':' . $val['is_with_draw']);
$query_result = 'success'; $query_result = 'success';
$msg = 'success'; $msg = 'success';
$height = isset($result['result']['height']) ? $result['result']['height'] : 0;
goto doEnd; goto doEnd;
} else { } else {
$cache_error_time = $redis->hget(CoinCrossChain::CROSS_CHAIN_CACHE_FAIL, $val['address'] . ':' . $val['is_with_draw']); $cache_error_time = $redis->hget(CoinCrossChain::CROSS_CHAIN_CACHE_FAIL, $val['address'] . ':' . $val['is_with_draw']);
...@@ -122,6 +135,7 @@ class CrossChainController extends Controller ...@@ -122,6 +135,7 @@ class CrossChainController extends Controller
if (-1 == $result['code']) { if (-1 == $result['code']) {
$msg = $result['msg']; $msg = $result['msg'];
$query_result = $result['code']; $query_result = $result['code'];
$switch = false;
goto doEnd; goto doEnd;
} else { } else {
$query_result = 'fail'; $query_result = 'fail';
...@@ -129,11 +143,17 @@ class CrossChainController extends Controller ...@@ -129,11 +143,17 @@ class CrossChainController extends Controller
if (is_array($log['log'])) continue; if (is_array($log['log'])) continue;
$msg = isset($log['log']) ? $log['log'] : '查询错误'; $msg = isset($log['log']) ? $log['log'] : '查询错误';
} }
$switch = false;
goto doEnd; goto doEnd;
} }
} }
doEnd : doEnd :
if (CoinCrossChain::RECHARGE == $val['is_with_draw'] && $switch && isset($height) && ($consensHeight < $height)) {
continue;
}
$currentModel = CoinCrossChain::findOne($val['id']); $currentModel = CoinCrossChain::findOne($val['id']);
$currentModel->query_result = $query_result; $currentModel->query_result = $query_result;
$currentModel->msg = $msg; $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