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
2d9ffe72
Commit
2d9ffe72
authored
Jun 19, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/bet' into 'master'
投注信息增加区块高度判断 fix See merge request
!41
parents
ceca8b1a
f39e20e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
11 deletions
+54
-11
Chain33Business.php
common/business/Chain33Business.php
+17
-6
GameBetController.php
console/controllers/GameBetController.php
+37
-5
No files found.
common/business/Chain33Business.php
View file @
2d9ffe72
...
@@ -173,19 +173,30 @@ class Chain33Business
...
@@ -173,19 +173,30 @@ class Chain33Business
* @param integer $end
* @param integer $end
* @return array
* @return array
*/
*/
public
static
function
getBetStatus
(
$start
,
$end
)
public
static
function
getBetStatus
(
$start
,
$end
,
$roundArr
=
[]
)
{
{
$node_params
=
\Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
];
$node_params
=
\Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
];
$service
=
new
Chain33Service
(
$node_params
);
$service
=
new
Chain33Service
(
$node_params
);
$execer
=
'wasm'
;
$execer
=
'wasm'
;
$funcName
=
'WasmGetContractTable'
;
$funcName
=
'WasmGetContractTable'
;
$contractName
=
'user.p.tschain.user.wasm.dice'
;
$contractName
=
'user.p.tschain.user.wasm.dice'
;
for
(
$i
=
$start
+
1
;
$i
<=
$end
;
$i
++
){
if
(
empty
(
$roundArr
))
{
$items
[]
=
[
for
(
$i
=
$start
+
1
;
$i
<=
$end
;
$i
++
){
'tableName'
=>
'roundinfo'
,
$items
[]
=
[
'key'
=>
'round:'
.
$i
'tableName'
=>
'roundinfo'
,
];
'key'
=>
'round:'
.
$i
];
}
}
if
(
!
empty
(
$roundArr
)){
foreach
(
$roundArr
as
$key
=>
$round
){
$items
[]
=
[
'tableName'
=>
'roundinfo'
,
'key'
=>
'round:'
.
$round
];
}
}
}
return
$service
->
chain33Query
(
$execer
,
$funcName
,
$contractName
,
$items
);
return
$service
->
chain33Query
(
$execer
,
$funcName
,
$contractName
,
$items
);
}
}
...
...
console/controllers/GameBetController.php
View file @
2d9ffe72
...
@@ -42,6 +42,7 @@ class GameBetController extends Controller
...
@@ -42,6 +42,7 @@ class GameBetController extends Controller
return
0
;
return
0
;
}
}
Yii
::
$app
->
redis
->
set
(
'chain33_game_bet_status'
,
$current_round
,
'EX'
,
300
);
Yii
::
$app
->
redis
->
set
(
'chain33_game_bet_status'
,
$current_round
,
'EX'
,
300
);
$result
=
$service
->
getBetStatus
(
$cache_current_round
,
$current_round
);
$result
=
$service
->
getBetStatus
(
$cache_current_round
,
$current_round
);
if
(
0
!==
$result
[
'code'
]){
if
(
0
!==
$result
[
'code'
]){
echo
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
echo
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
...
@@ -75,12 +76,43 @@ class GameBetController extends Controller
...
@@ -75,12 +76,43 @@ class GameBetController extends Controller
return
0
;
return
0
;
}
}
$height
=
$result
[
'height'
];
$height
=
$result
[
'height'
];
$models
=
CoinGameBet
::
find
()
->
where
([
'valid'
=>
CoinGameBet
::
VAILD_FALSE
])
->
all
();
$models
=
CoinGameBet
::
find
()
->
select
(
'round'
)
->
where
([
'and'
,
[
'valid'
=>
CoinGameBet
::
VAILD_FALSE
],
[
'<'
,
'height'
,
$height
-
12
]
])
->
all
();
if
(
empty
(
$models
)){
echo
date
(
'Y-m-d H:i:s'
)
.
'无需更新的数据'
.
PHP_EOL
;
return
0
;
}
$valid_arr
=
[];
foreach
(
$models
as
$model
)
{
foreach
(
$models
as
$model
)
{
if
(
$model
->
height
+
12
<
$height
){
$valid_arr
[]
=
$model
->
round
;
$model
->
valid
=
1
;
}
$model
->
update
(
false
);
// skipping validation as no user input is involved
$result
=
$service
->
getBetStatus
(
''
,
''
,
$valid_arr
);
}
if
(
0
!==
$result
[
'code'
]){
echo
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
return
0
;
}
$queryResultItems
=
$result
[
'result'
]
??
[];
if
(
empty
(
$queryResultItems
)){
echo
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
return
0
;
}
foreach
(
$queryResultItems
[
'queryResultItems'
]
as
$key
=>
$val
){
if
(
false
==
$val
[
'found'
])
continue
;
$resultArr
=
json_decode
(
$val
[
'resultJSON'
],
true
);
CoinGameBet
::
updateAll
([
'amount'
=>
$resultArr
[
'amount'
],
'height'
=>
$resultArr
[
'height'
],
'guess_num'
=>
$resultArr
[
'guess_num'
],
'rand_num'
=>
$resultArr
[
'rand_num'
],
'player_win'
=>
$resultArr
[
'player_win'
],
'valid'
=>
CoinGameBet
::
VAILD_TRUE
],[
'round'
=>
$resultArr
[
'round'
]
]);
}
}
echo
date
(
'Y-m-d H:i:s'
)
.
'数据更新成功'
.
PHP_EOL
;
echo
date
(
'Y-m-d H:i:s'
)
.
'数据更新成功'
.
PHP_EOL
;
return
0
;
return
0
;
...
...
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