Commit 93c690b1 authored by shajiaiming's avatar shajiaiming

fix

parent 4cffdb88
...@@ -23,10 +23,10 @@ class GameBetController extends BaseController ...@@ -23,10 +23,10 @@ class GameBetController extends BaseController
} }
$query = CoinGameBet::find() $query = CoinGameBet::find()
->select('round, player, amount, height, guess_num, guess_num, rand_num, player_win, platform') ->select('round, player, amount, height, guess_num, valid, rand_num, player_win, platform')
->where('player= :player',[':player' => $player]) ->where('player= :player',[':player' => $player])
->andWhere(['platform' => $platform]) ->andWhere(['platform' => $platform])
#->andWhere(['valid' => CoinGameBet::VAILD_TRUE]) ->andWhere(['valid' => CoinGameBet::VAILD_TRUE])
->orderBy('update_time desc'); ->orderBy('update_time desc');
$count = $query->count(); $count = $query->count();
......
...@@ -37,6 +37,7 @@ class GameBetController extends Controller ...@@ -37,6 +37,7 @@ class GameBetController extends Controller
$resultJSON = json_decode($queryResultItems['queryResultItems'][0]['resultJSON'], true); $resultJSON = json_decode($queryResultItems['queryResultItems'][0]['resultJSON'], true);
$current_round = $resultJSON['current_round']; $current_round = $resultJSON['current_round'];
$current_height = $resultJSON['height'];
$cache_current_round = Yii::$app->redis->get('chain33_game_bet_status_'.$key); $cache_current_round = Yii::$app->redis->get('chain33_game_bet_status_'.$key);
if (empty($cache_current_round)) { if (empty($cache_current_round)) {
$cache_current_round = CoinGameBet::find()->where(['platform' => $key])->max('round'); $cache_current_round = CoinGameBet::find()->where(['platform' => $key])->max('round');
...@@ -48,7 +49,7 @@ class GameBetController extends Controller ...@@ -48,7 +49,7 @@ class GameBetController extends Controller
continue; continue;
} }
Yii::$app->redis->set('chain33_game_bet_status_'.$key, $current_round, 'EX', 300); Yii::$app->redis->set('chain33_game_bet_status_'.$key, $current_round, 'EX', 300);
Yii::$app->redis->set('chain33_game_bet_status_height_'.$key, $current_height, 'EX', 300);
$result = $service->getBetStatus($cache_current_round, $current_round, '', $node); $result = $service->getBetStatus($cache_current_round, $current_round, '', $node);
if (0 !== $result['code']) { if (0 !== $result['code']) {
echo $key.':'.date('Y-m-d H:i:s') . '数据错误' . PHP_EOL; echo $key.':'.date('Y-m-d H:i:s') . '数据错误' . PHP_EOL;
...@@ -82,14 +83,35 @@ class GameBetController extends Controller ...@@ -82,14 +83,35 @@ class GameBetController 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;
} }
foreach ($nodes as $key => $node) { foreach ($nodes as $key => $node) {
$service = new Chain33Business(); $service = new Chain33Business();
$result = $service->getLastHeader($node); $result = $service->getGameStatus($node);
$height = $result['result']['height']; if (0 !== $result['code']) {
echo $key.':'.date('Y-m-d H:i:s') . $result['msg'].PHP_EOL;
continue;
}
$queryResultItems = $result['result'] ?? [];
if (empty($queryResultItems)) {
echo $key.':'.date('Y-m-d H:i:s') . 'error'.PHP_EOL;
continue;
}
$resultJSON = json_decode($queryResultItems['queryResultItems'][0]['resultJSON'], true);
$current_height = $resultJSON['height'];
$cache_current_height = Yii::$app->redis->get('chain33_game_bet_status_height_'.$key);
if(($cache_current_height + 12) < $current_height) {
echo $key.':'.date('Y-m-d H:i:s') . '区块高度小于12'.PHP_EOL;
continue;
}
$height = $cache_current_height - 12;
$models = CoinGameBet::find()->select('round')->where([ $models = CoinGameBet::find()->select('round')->where([
'and', 'and',
['valid' => CoinGameBet::VAILD_FALSE], ['valid' => CoinGameBet::VAILD_FALSE],
['<', 'height', $height - 12], ['<', 'height', $height],
['platform' => $key] ['platform' => $key]
])->all(); ])->all();
if(empty($models)){ if(empty($models)){
......
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