Commit 1e46c54d authored by rlgy's avatar rlgy

update

parent 627d9386
......@@ -28,6 +28,7 @@ class AwardController extends Controller
*/
public function actionIndex()
{
$config = Yii::$app->params['h5_activity']['ZWG_GUESS_NEWBEE'];
//获取最新的区块高度
$last_header = Chain33Business::getLastHeader();
if ($last_header['code'] != 0) {
......@@ -42,10 +43,10 @@ class AwardController extends Controller
$start_height = $last->end_height;
} else {
//第一次计算开奖
$stage = intval($last_header['height'] / 50);
$start_height = ($stage - 1) * 50;
$stage = intval($last_header['height'] / $config['do_award_step']);
$start_height = ($stage - 1) * $config['do_award_step'];
}
$end_height = $start_height + 50;
$end_height = $start_height + $config['do_award_step'];
//判断区块是否超前了
if ($end_height > $last_header['height']) {
return 0;
......@@ -56,12 +57,15 @@ class AwardController extends Controller
Yii::info('获取区块hash失败: ' . $hash['msg'], __CLASS__);
return 0;
}
$hash = $hash['result']['hash'];
$hash = substr($hash, -2);
$hash = $hash['result']['hash'];
$matchs = preg_match_all('/\d+/', $hash, $matchs);
$hash = implode('', $matchs[0]);
$hash = substr($hash, -2);
if (!ctype_digit($hash)) {
$hash = hexdec($hash) % 100;
$hash = sprintf("%02d", $hash);
}
$hash = strval($hash);
//保存开奖结果到数据库
$guess_result = new CoinGuessResult();
$guess_result->stage = $stage;
......
......@@ -84,11 +84,12 @@ class JugdeAwardJob extends BaseObject implements JobInterface
private function doAward($txs, $result)
{
$config = Yii::$app->params['h5_activity']['ZWG_GUESS_NEWBEE'];
foreach ($txs as $item) {
$flag = false;
if (preg_match('/^' . $result . '$/', $item['guess'])) {
$flag = true;
$amount = 1;
$amount = $config['award_beta'];
} else {
$guess = [];
$guess[] = intval($item['guess'] % 10);
......@@ -98,7 +99,7 @@ class JugdeAwardJob extends BaseObject implements JobInterface
$ans[] = intval($result / 10);
if ($ans[0] == $guess[0] || $ans[1] == $guess[1]) {
$flag = true;
$amount = 0.2;
$amount = $config['award_normal'];
}
}
if (!$flag) {
......
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