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
ceca8b1a
Commit
ceca8b1a
authored
Jun 19, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/bet' into 'master'
Feature/bet See merge request
!40
parents
1e858c3a
b74973be
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
13 deletions
+41
-13
GameBetController.php
api/controllers/GameBetController.php
+1
-0
Chain33Business.php
common/business/Chain33Business.php
+12
-10
CoinGameBet.php
common/models/psources/CoinGameBet.php
+6
-3
GameBetController.php
console/controllers/GameBetController.php
+22
-0
No files found.
api/controllers/GameBetController.php
View file @
ceca8b1a
...
...
@@ -74,6 +74,7 @@ class GameBetController extends BaseController
$query
=
CoinGameBet
::
find
()
->
select
(
'round, player, amount, height, guess_num, guess_num, rand_num, player_win'
)
->
where
(
'player= :player'
,[
':player'
=>
$player
])
->
andWhere
([
'valid'
=>
CoinGameBet
::
VAILD_TRUE
])
->
orderBy
(
'update_time desc'
);
$count
=
$query
->
count
();
...
...
common/business/Chain33Business.php
View file @
ceca8b1a
...
...
@@ -120,16 +120,6 @@ class Chain33Business
}
/**
* 获取最新的区块
*/
public
static
function
getLastHeader
()
{
$service
=
new
Chain33Service
();
$result
=
$service
->
getLastHeader
();
return
$result
;
}
/**
* 获取区块hash
*
* @param integer $height
...
...
@@ -199,6 +189,18 @@ class Chain33Business
return
$service
->
chain33Query
(
$execer
,
$funcName
,
$contractName
,
$items
);
}
/*
* 获取最新的区块头
* @param null
* @return array
*/
public
static
function
getLastHeader
()
{
$node_params
=
\Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
];
$service
=
new
Chain33Service
(
$node_params
);
return
$service
->
getLastHeader
();
}
/**
* 获取地址下的所有交易记录
*
...
...
common/models/psources/CoinGameBet.php
View file @
ceca8b1a
...
...
@@ -18,6 +18,9 @@ class CoinGameBet extends BaseActiveRecord
const
SCENARIOS_ADD
=
'add'
;
const
SCENARIOS_UPDATE
=
'update'
;
const
VAILD_TRUE
=
1
;
const
VAILD_FALSE
=
0
;
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
...
...
@@ -44,7 +47,7 @@ class CoinGameBet extends BaseActiveRecord
public
function
rules
()
{
return
[
[[
'round'
,
'amount'
,
'height'
,
'guess_num'
,
'rand_num'
,
'player_win'
],
'int'
],
[[
'round'
,
'amount'
,
'height'
,
'guess_num'
,
'rand_num'
,
'player_win'
,
'vaild'
],
'int'
],
[[
'player'
],
'string'
]
];
}
...
...
@@ -52,8 +55,8 @@ class CoinGameBet extends BaseActiveRecord
public
function
sercians
()
{
return
[
self
::
SCENARIOS_ADD
=>
[
'round'
,
'amount'
,
'height'
,
'guess_num'
,
'rand_num'
,
'player_win'
,
'player'
],
self
::
SCENARIOS_UPDATE
=>
[
'round'
,
'amount'
,
'height'
,
'guess_num'
,
'rand_num'
,
'player_win'
,
'player'
],
self
::
SCENARIOS_ADD
=>
[
'round'
,
'amount'
,
'height'
,
'guess_num'
,
'rand_num'
,
'player_win'
,
'player'
,
'vaild'
],
self
::
SCENARIOS_UPDATE
=>
[
'round'
,
'amount'
,
'height'
,
'guess_num'
,
'rand_num'
,
'player_win'
,
'player'
,
'vaild'
],
];
}
...
...
console/controllers/GameBetController.php
View file @
ceca8b1a
...
...
@@ -64,4 +64,25 @@ class GameBetController extends Controller
echo
date
(
'Y-m-d H:i:s'
)
.
'数据更新成功'
.
PHP_EOL
;
return
0
;
}
public
function
actionBetUpdate
()
{
$service
=
new
Chain33Business
();
$result
=
$service
->
getLastHeader
();
$result
=
$result
[
'result'
]
??
[];
if
(
empty
(
$result
)){
echo
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
return
0
;
}
$height
=
$result
[
'height'
];
$models
=
CoinGameBet
::
find
()
->
where
([
'valid'
=>
CoinGameBet
::
VAILD_FALSE
])
->
all
();
foreach
(
$models
as
$model
)
{
if
(
$model
->
height
+
12
<
$height
){
$model
->
valid
=
1
;
$model
->
update
(
false
);
// skipping validation as no user input is involved
}
}
echo
date
(
'Y-m-d H:i:s'
)
.
'数据更新成功'
.
PHP_EOL
;
return
0
;
}
}
\ 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