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
->andWhere(['step' => $val['step']])
->andWhere(['<>', 'msg', 'success'])
->one();
if(false == $model) continue;
$node_params = $model->transfer_url;
$node_params = explode(':', $node_params);
$node_params = [
'scheme' => $node_params[0],
'host' => str_replace('//', '', $node_params[1]),
'port' => isset($node_params[2]) ? $node_params[2] : ''
];
$service = new Chain33Service($node_params);
$send_result = $model->send_result;
$result = $service->QueryTransaction($send_result);
if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
$model->query_result = 'success';
$model->msg = 'success';
$model->save();
continue;
} else if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']) {
$model->query_result = 'success';
$model->msg = 'success';
$model->save();
continue;
} else {
// $node_params = $model->transfer_url;
// $node_params = explode(':', $node_params);
// $node_params = [
// 'scheme' => $node_params[0],
// 'host' => str_replace('//', '', $node_params[1]),
// 'port' => isset($node_params[2]) ? $node_params[2] : ''
// ];
// $service = new Chain33Service($node_params);
// $send_result = $model->send_result;
// $result = $service->QueryTransaction($send_result);
// if (isset($result['result']['actionName']) && 'unknown' == $result['result']['actionName']) {
// $model->query_result = 'success';
// $model->msg = 'success';
// $model->save();
// continue;
// } else if (isset($result['result']['receipt']['ty']) && 2 == $result['result']['receipt']['ty']) {
// $model->query_result = 'success';
// $model->msg = 'success';
// $model->save();
// continue;
// } else {
$model->txhex = $val['tx'];
$model->transfer_url = $val['url'];
$model->send_result = 0;
......@@ -111,7 +112,7 @@ class CrossChainController extends BaseController
$model->msg = 0;
$model->save();
continue;
}
// }
}
$code = 0;
$msg = 'success';
......
......@@ -15,7 +15,6 @@ class Zhaobi extends Exchange implements ExchangeInterface
protected $supported_symbol = 'supported_symbol_zhaobi';
protected $quotation_prefix = 'quotation_zhaobi_';
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")
{
......
......@@ -92,12 +92,21 @@ class CrossChainController extends Controller
return 0;
}
//查询共识高度
//正式环境查询共识高度
//3步交易情况下需要做高度判断,2步交易无须判断
$node_params = [
'scheme' => 'https',
'host' => 'jiedian1.bityuan.com',
'port' => 8801
];
//测试环境查询共识高度
//2步交易情况下需要做高度判断
// $node_params = [
// 'scheme' => 'http',
// 'host' => '172.16.100.77',
// 'port' => 8801
// ];
$service = new Chain33Service($node_params);
$result = $service->getHeight();
$consensHeight = $result['result']['consensHeight'];
......@@ -111,10 +120,11 @@ class CrossChainController extends Controller
'host' => str_replace('//', '', $node_params[1]),
'port' => isset($node_params[2]) ? $node_params[2] : ''
];
$service = new Chain33Service($node_params);
$send_result = $val['send_result'];
$result = $service->QueryTransaction($send_result);
#$result = $service->QueryTransaction($send_result);
$switch = true;
$result = $this->queryTransaction($node_params, $send_result);
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';
......@@ -157,10 +167,10 @@ class CrossChainController extends Controller
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;
}
$currentModel = CoinCrossChain::findOne($val['id']);
$currentModel->query_result = $query_result;
$currentModel->msg = $msg;
......@@ -178,4 +188,24 @@ class CrossChainController extends Controller
echo date('Y-m-d H:i:s') . '查询完毕' . PHP_EOL;
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