Commit 0730c54b authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/cross_chain' into 'master'

Feature/cross chain See merge request !134
parents bba41db2 7bef5cb9
...@@ -82,28 +82,29 @@ class CrossChainController extends BaseController ...@@ -82,28 +82,29 @@ class CrossChainController extends BaseController
->andWhere(['step' => $val['step']]) ->andWhere(['step' => $val['step']])
->andWhere(['<>', 'msg', 'success']) ->andWhere(['<>', 'msg', 'success'])
->one(); ->one();
if(false == $model) continue; if(false == $model) continue;
$node_params = $model->transfer_url; // $node_params = $model->transfer_url;
$node_params = explode(':', $node_params); // $node_params = explode(':', $node_params);
$node_params = [ // $node_params = [
'scheme' => $node_params[0], // 'scheme' => $node_params[0],
'host' => str_replace('//', '', $node_params[1]), // 'host' => str_replace('//', '', $node_params[1]),
'port' => isset($node_params[2]) ? $node_params[2] : '' // 'port' => isset($node_params[2]) ? $node_params[2] : ''
]; // ];
$service = new Chain33Service($node_params); // $service = new Chain33Service($node_params);
$send_result = $model->send_result; // $send_result = $model->send_result;
$result = $service->QueryTransaction($send_result); // $result = $service->QueryTransaction($send_result);
if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) { // if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
$model->query_result = 'success'; // $model->query_result = 'success';
$model->msg = 'success'; // $model->msg = 'success';
$model->save(); // $model->save();
continue; // continue;
} else if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']) { // } else if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']) {
$model->query_result = 'success'; // $model->query_result = 'success';
$model->msg = 'success'; // $model->msg = 'success';
$model->save(); // $model->save();
continue; // continue;
} else { // } else {
$model->txhex = $val['tx']; $model->txhex = $val['tx'];
$model->transfer_url = $val['url']; $model->transfer_url = $val['url'];
$model->send_result = 0; $model->send_result = 0;
...@@ -111,7 +112,7 @@ class CrossChainController extends BaseController ...@@ -111,7 +112,7 @@ class CrossChainController extends BaseController
$model->msg = 0; $model->msg = 0;
$model->save(); $model->save();
continue; continue;
} // }
} }
$code = 0; $code = 0;
$msg = 'success'; $msg = 'success';
......
...@@ -15,7 +15,6 @@ class Zhaobi extends Exchange implements ExchangeInterface ...@@ -15,7 +15,6 @@ class Zhaobi extends Exchange implements ExchangeInterface
protected $supported_symbol = 'supported_symbol_zhaobi'; protected $supported_symbol = 'supported_symbol_zhaobi';
protected $quotation_prefix = 'quotation_zhaobi_'; protected $quotation_prefix = 'quotation_zhaobi_';
protected $base_url = 'https://api.biqianbao.top'; protected $base_url = 'https://api.biqianbao.top';
#protected $base_url = 'https://api.biqianbao.top/api/data/basecoinprice?base=CNY&coin=SFT&platform=zhaobi';
public function symbolExists($tag = 'SFT', $aim = "CNY") public function symbolExists($tag = 'SFT', $aim = "CNY")
{ {
......
...@@ -92,12 +92,21 @@ class CrossChainController extends Controller ...@@ -92,12 +92,21 @@ class CrossChainController extends Controller
return 0; return 0;
} }
//查询共识高度 //正式环境查询共识高度
//3步交易情况下需要做高度判断,2步交易无须判断
$node_params = [ $node_params = [
'scheme' => 'https', 'scheme' => 'https',
'host' => 'jiedian1.bityuan.com', 'host' => 'jiedian1.bityuan.com',
'port' => 8801 'port' => 8801
]; ];
//测试环境查询共识高度
//2步交易情况下需要做高度判断
// $node_params = [
// 'scheme' => 'http',
// 'host' => '172.16.100.77',
// 'port' => 8801
// ];
$service = new Chain33Service($node_params); $service = new Chain33Service($node_params);
$result = $service->getHeight(); $result = $service->getHeight();
$consensHeight = $result['result']['consensHeight']; $consensHeight = $result['result']['consensHeight'];
...@@ -111,10 +120,11 @@ class CrossChainController extends Controller ...@@ -111,10 +120,11 @@ class CrossChainController extends Controller
'host' => str_replace('//', '', $node_params[1]), 'host' => str_replace('//', '', $node_params[1]),
'port' => isset($node_params[2]) ? $node_params[2] : '' 'port' => isset($node_params[2]) ? $node_params[2] : ''
]; ];
$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; $switch = true;
$result = $this->queryTransaction($node_params, $send_result);
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';
...@@ -157,10 +167,10 @@ class CrossChainController extends Controller ...@@ -157,10 +167,10 @@ class CrossChainController extends Controller
doEnd : doEnd :
if (CoinCrossChain::RECHARGE == $val['is_with_draw'] && $val['step'] == 2 && $switch && isset($height) && ($consensHeight < $height)) { //3步交易情况下需要做高度判断,2步交易注释IF判断
if (CoinCrossChain::RECHARGE == (int)$val['is_with_draw'] && 2 == (int)$val['step'] && true == $switch && isset($height) && ($consensHeight < $height)) {
continue; 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;
...@@ -178,4 +188,24 @@ class CrossChainController extends Controller ...@@ -178,4 +188,24 @@ 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;
} }
protected function queryTransaction($node_params, $send_result)
{
static $result = [];
$service = new Chain33Service($node_params);
$result = $service->QueryTransaction($send_result);
if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
if (isset($result['result']['tx']['next'])) {
$this->queryTransaction($node_params, $result['result']['tx']['next']);
}
}
if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']){
if (isset($result['result']['tx']['next'])) {
$this->queryTransaction($node_params, $result['result']['tx']['next']);
}
}
return $result;
}
} }
\ 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