Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
1e46c54d
Commit
1e46c54d
authored
Sep 21, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
627d9386
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
AwardController.php
console/controllers/AwardController.php
+9
-5
JugdeAwardJob.php
h5/job/JugdeAwardJob.php
+3
-2
No files found.
console/controllers/AwardController.php
View file @
1e46c54d
...
...
@@ -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
;
...
...
h5/job/JugdeAwardJob.php
View file @
1e46c54d
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment