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
a38496ed
Commit
a38496ed
authored
Sep 20, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
b73937b9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
10 deletions
+70
-10
AwardController.php
console/controllers/AwardController.php
+2
-0
AwardJob.php
h5/job/AwardJob.php
+2
-2
JugdeAwardJob.php
h5/job/JugdeAwardJob.php
+66
-8
No files found.
console/controllers/AwardController.php
View file @
a38496ed
...
...
@@ -10,6 +10,7 @@ namespace console\controllers;
use
common\business\Chain33Business
;
use
common\business\CoinBusiness
;
use
h5\job\JugdeAwardJob
;
use
Yii
;
use
yii\console\Controller
;
use
common\models\psources\CoinGuessResult
;
...
...
@@ -70,6 +71,7 @@ class AwardController extends Controller
$guess_result
->
is_award
=
0
;
if
(
$guess_result
->
save
())
{
//添加派奖任务到队列
Yii
::
$app
->
queue
->
push
(
new
JugdeAwardJob
());
Yii
::
info
(
"竞猜开奖成功! [期数]:
$stage
"
,
__CLASS__
);
}
else
{
Yii
::
info
(
"保存开奖记录失败! [期数]:
$stage
"
,
__CLASS__
);
...
...
h5/job/AwardJob.php
View file @
a38496ed
...
...
@@ -34,10 +34,10 @@ class AwardJob extends BaseObject implements JobInterface
*/
public
function
execute
(
$queue
)
{
$result
=
Chain33Business
::
transToken
(
$this
->
from
,
$this
->
to
,
$this
->
amount
,
$this
->
note
,
$this
->
is_token
,
$this
->
token
);
$result
=
Chain33Business
::
transToken
(
$this
->
from
,
$this
->
to
,
$this
->
amount
,
$this
->
note
,
$this
->
is_token
,
$this
->
token
);
if
(
is_string
(
$result
))
{
//派奖记录到数据库中
Yii
::
info
(
"派奖成功! 奖励[
{
$this
->
to
}
][
$this->token
][
$this->amount
]个"
,
__CLASS__
);
}
else
{
Yii
::
info
(
"失败的派奖: [to]:
{
$this
->
to
}
, [amount]:
{
$this
->
amount
}
, [is_token] :
{
$this
->
is_token
}
, [token]:
{
$this
->
token
}
"
,
__CLASS__
);
...
...
h5/job/JugdeAwardJob.php
View file @
a38496ed
...
...
@@ -36,26 +36,83 @@ class JugdeAwardJob extends BaseObject implements JobInterface
if
(
$guess_result
)
{
$config
=
Yii
::
$app
->
params
[
'h5_activity'
][
'ZWG_GUESS_NEWBEE'
];
//获取区块间的所有交易(正常竞猜)
// $trans_normal = Chain33Business::getTxByAddrInRange($config['from_normal'], 2, 0, $guess_result->start_height, $guess_result->end_height);
$trans_normal
=
Chain33Business
::
getTxByAddrInRange
(
'14o9MHrrLfpsXf7wu4H4YRwvy84fjd7uaj'
,
2
,
0
,
710900
,
715345
);
$trans_new
=
Chain33Business
::
getTxByAddrInRange
(
$config
[
'to'
],
2
,
0
,
$guess_result
->
start_height
,
$guess_result
->
end_height
);
$trans
=
array_merge
(
$trans_normal
,
$trans_new
);
$txhashs
=
array_column
(
$trans
,
'hash'
);
$trans_info
=
Chain33Business
::
getTxByHashs
(
$txhashs
);
$trans_normal
=
Chain33Business
::
getTxByAddrInRange
(
$config
[
'to_normal'
],
2
,
0
,
$guess_result
->
start_height
,
$guess_result
->
end_height
-
1
);
$trans_new
=
Chain33Business
::
getTxByAddrInRange
(
$config
[
'to'
],
2
,
0
,
$guess_result
->
start_height
,
$guess_result
->
end_height
-
1
);
$trans
=
array_merge
(
$trans_normal
,
$trans_new
);
$txhashs
=
array_column
(
$trans
,
'hash'
);
$trans_info
=
Chain33Business
::
getTxByHashs
(
$txhashs
);
if
(
$trans_info
[
'code'
]
==
0
)
{
$trans_info
=
$trans_info
[
'result'
][
'txs'
];
if
(
is_array
(
$trans_info
))
{
$txs
=
[];
foreach
(
$trans_info
as
$k
=>
$v
)
{
//收集数据
$temp
=
[];
$temp
[
'amount'
]
=
$v
[
'amount'
];
$temp
[
'from'
]
=
$v
[
'fromAddr'
];
$temp
[
'to'
]
=
$v
[
'tx'
][
'to'
];
$temp
[
'note'
]
=
$v
[
'tx'
][
'payload'
][
'Value'
][
'Transfer'
][
'note'
]
??
''
;
if
(
$temp
[
'amount'
]
==
intval
(
$config
[
'amount'
]
*
1e8
)
||
$temp
[
'amount'
]
==
2
*
1e8
)
{
$matchs
=
[];
if
(
preg_match
(
'/^\d\d$/'
,
$temp
[
'note'
],
$matchs
))
{
$temp
[
'guess'
]
=
$matchs
[
0
];
$txs
[]
=
$temp
;
}
if
(
preg_match
(
'/^(\d\d) (\w+)$/'
,
$temp
[
'note'
],
$matchs
))
{
$temp
[
'guess'
]
=
$matchs
[
1
];
$temp
[
'from'
]
=
$matchs
[
2
];
$txs
[]
=
$temp
;
}
}
}
//为所有参与用户判断中奖情况
// $this->doAward($txs, $guess_result->result);
}
}
$loop
=
false
;
$guess_result
->
is_award
=
1
;
if
(
$guess_result
->
save
())
{
Yii
::
info
(
"第
{
$guess_result
->
stage
}
期开奖成功"
,
__CLASS__
);
}
else
{
Yii
::
warning
(
"第
{
$guess_result
->
stage
}
期开奖成功, 修改竞猜开奖情况失败"
,
__CLASS__
);
}
print
"ok
\n
"
;
}
else
{
$loop
=
false
;
}
}
while
(
$loop
);
return
0
;
}
private
function
doAward
(
$txs
,
$result
)
{
foreach
(
$txs
as
$item
)
{
$flag
=
false
;
if
(
preg_match
(
'/^'
.
$result
.
'$/'
,
$item
[
'guess'
]))
{
$flag
=
true
;
$amount
=
1
;
}
else
{
$guess
=
[];
$guess
[]
=
intval
(
$item
[
'guess'
]
/
10
);
$guess
[]
=
intval
(
$item
[
'guess'
]
%
10
);
$ans
=
[];
$ans
[]
=
intval
(
$result
/
10
);
$ans
[]
=
intval
(
$result
%
10
);
if
(
!
empty
(
array_intersect
(
$ans
,
$guess
)))
{
$flag
=
true
;
$amount
=
0.2
;
}
}
if
(
!
$flag
)
{
continue
;
}
Yii
::
$app
->
queue
->
push
(
new
AwardJob
([
'from'
=>
Yii
::
$app
->
params
[
'h5_activity'
][
'ZWG_GUESS_NEWBEE'
][
'from'
],
'to'
=>
$item
[
'from'
],
'is_token'
=>
true
,
'token'
=>
'ZWGYBA'
,
'amount'
=>
$amount
*
1e8
,
'note'
=>
'竞猜奖励'
,
]));
}
}
}
\ No newline at end of file
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