Commit 1e46c54d authored by rlgy's avatar rlgy

update

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