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
0ef821ef
Commit
0ef821ef
authored
Sep 10, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
3db8d0cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
25 deletions
+26
-25
GameBetController.php
console/controllers/GameBetController.php
+26
-25
No files found.
console/controllers/GameBetController.php
View file @
0ef821ef
...
@@ -17,46 +17,46 @@ class GameBetController extends Controller
...
@@ -17,46 +17,46 @@ class GameBetController extends Controller
public
function
actionGameStatus
()
public
function
actionGameStatus
()
{
{
$nodes
=
\Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
];
$nodes
=
\Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
];
if
(
empty
(
$nodes
))
{
if
(
empty
(
$nodes
))
{
echo
date
(
'Y-m-d H:i:s'
)
.
'无节点'
.
PHP_EOL
;
echo
date
(
'Y-m-d H:i:s'
)
.
'无节点'
.
PHP_EOL
;
return
0
;
return
0
;
}
}
foreach
(
$nodes
as
$key
=>
$node
)
{
foreach
(
$nodes
as
$key
=>
$node
)
{
$service
=
new
Chain33Business
();
$service
=
new
Chain33Business
();
$result
=
$service
->
getGameStatus
(
$node
);
$result
=
$service
->
getGameStatus
(
$node
);
if
(
0
!==
$result
[
'code'
])
{
if
(
0
!==
$result
[
'code'
])
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
$result
[
'msg'
]
.
PHP_EOL
;
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
$result
[
'msg'
]
.
PHP_EOL
;
continue
;
continue
;
}
}
$queryResultItems
=
$result
[
'result'
]
??
[];
$queryResultItems
=
$result
[
'result'
]
??
[];
if
(
empty
(
$queryResultItems
))
{
if
(
empty
(
$queryResultItems
))
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'error'
.
PHP_EOL
;
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'error'
.
PHP_EOL
;
continue
;
continue
;
}
}
$resultJSON
=
json_decode
(
$queryResultItems
[
'queryResultItems'
][
0
][
'resultJSON'
],
true
);
$resultJSON
=
json_decode
(
$queryResultItems
[
'queryResultItems'
][
0
][
'resultJSON'
],
true
);
$current_round
=
$resultJSON
[
'current_round'
];
$current_round
=
$resultJSON
[
'current_round'
];
$cache_current_round
=
Yii
::
$app
->
redis
->
get
(
'chain33_game_bet_status_'
.
$key
);
$cache_current_round
=
Yii
::
$app
->
redis
->
get
(
'chain33_game_bet_status_'
.
$key
);
if
(
empty
(
$cache_current_round
))
{
if
(
empty
(
$cache_current_round
))
{
$cache_current_round
=
CoinGameBet
::
find
()
->
where
([
'platform'
=>
$key
])
->
max
(
'round'
);
$cache_current_round
=
CoinGameBet
::
find
()
->
where
([
'platform'
=>
$key
])
->
max
(
'round'
);
Yii
::
$app
->
redis
->
set
(
'chain33_game_bet_status_'
.
$key
,
$cache_current_round
,
'EX'
,
300
);
Yii
::
$app
->
redis
->
set
(
'chain33_game_bet_status_'
.
$key
,
$cache_current_round
,
'EX'
,
300
);
}
}
$cache_current_round
=
(
false
==
$cache_current_round
?
0
:
$cache_current_round
);
$cache_current_round
=
(
false
==
$cache_current_round
?
0
:
$cache_current_round
);
if
(
$cache_current_round
>=
$current_round
)
{
if
(
$cache_current_round
>=
$current_round
)
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据已为最新'
.
PHP_EOL
;
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据已为最新'
.
PHP_EOL
;
continue
;
continue
;
}
}
Yii
::
$app
->
redis
->
set
(
'chain33_game_bet_status_'
.
$key
,
$current_round
,
'EX'
,
300
);
Yii
::
$app
->
redis
->
set
(
'chain33_game_bet_status_'
.
$key
,
$current_round
,
'EX'
,
300
);
$result
=
$service
->
getBetStatus
(
$cache_current_round
,
$current_round
,
''
,
$node
);
$result
=
$service
->
getBetStatus
(
$cache_current_round
,
$current_round
,
''
,
$node
);
if
(
0
!==
$result
[
'code'
])
{
if
(
0
!==
$result
[
'code'
])
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
continue
;
continue
;
}
}
$queryResultItems
=
$result
[
'result'
]
??
[];
$queryResultItems
=
$result
[
'result'
]
??
[];
if
(
empty
(
$queryResultItems
))
{
if
(
empty
(
$queryResultItems
))
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
continue
;
continue
;
}
}
$platform
=
$key
;
$platform
=
$key
;
...
@@ -68,7 +68,7 @@ class GameBetController extends Controller
...
@@ -68,7 +68,7 @@ class GameBetController extends Controller
];
];
}
}
CoinGameBet
::
loadArray
(
$datas
);
CoinGameBet
::
loadArray
(
$datas
);
echo
$platform
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据更新成功'
.
PHP_EOL
;
echo
$platform
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据更新成功'
.
PHP_EOL
;
continue
;
continue
;
}
}
return
0
;
return
0
;
...
@@ -77,34 +77,35 @@ class GameBetController extends Controller
...
@@ -77,34 +77,35 @@ class GameBetController extends Controller
public
function
actionBetUpdate
()
public
function
actionBetUpdate
()
{
{
$nodes
=
\Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
];
$nodes
=
\Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
];
if
(
empty
(
$nodes
))
{
if
(
empty
(
$nodes
))
{
echo
date
(
'Y-m-d H:i:s'
)
.
'无节点'
.
PHP_EOL
;
echo
date
(
'Y-m-d H:i:s'
)
.
'无节点'
.
PHP_EOL
;
return
0
;
return
0
;
}
}
foreach
(
$nodes
as
$key
=>
$node
)
{
foreach
(
$nodes
as
$key
=>
$node
)
{
$service
=
new
Chain33Business
();
$service
=
new
Chain33Business
();
$result
=
$service
->
getGameStatus
(
$node
);
$result
=
$service
->
getGameStatus
(
$node
);
if
(
0
!==
$result
[
'code'
])
{
if
(
0
!==
$result
[
'code'
])
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
$result
[
'msg'
]
.
PHP_EOL
;
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
$result
[
'msg'
]
.
PHP_EOL
;
continue
;
continue
;
}
}
$queryResultItems
=
$result
[
'result'
]
??
[];
$queryResultItems
=
$result
[
'result'
]
??
[];
if
(
empty
(
$queryResultItems
))
{
if
(
empty
(
$queryResultItems
))
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'error'
.
PHP_EOL
;
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'error'
.
PHP_EOL
;
continue
;
continue
;
}
}
$resultJSON
=
json_decode
(
$queryResultItems
[
'queryResultItems'
][
0
][
'resultJSON'
],
true
);
$resultJSON
=
json_decode
(
$queryResultItems
[
'queryResultItems'
][
0
][
'resultJSON'
],
true
);
$current_height
=
$resultJSON
[
'height'
];
$current_height
=
$resultJSON
[
'height'
];
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'当前高度为:'
.
$current_height
.
PHP_EOL
;
$models
=
CoinGameBet
::
find
()
->
select
(
'round'
)
->
where
([
$models
=
CoinGameBet
::
find
()
->
select
(
'round'
)
->
where
([
'and'
,
'and'
,
[
'valid'
=>
CoinGameBet
::
VAILD_FALSE
],
[
'valid'
=>
CoinGameBet
::
VAILD_FALSE
],
[
'<'
,
'height'
,
$current_height
-
14
],
[
'<'
,
'height'
,
$current_height
-
14
],
[
'platform'
=>
$key
]
[
'platform'
=>
$key
]
])
->
all
();
])
->
all
();
if
(
empty
(
$models
))
{
if
(
empty
(
$models
))
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'无需更新的数据'
.
PHP_EOL
;
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'无需更新的数据'
.
PHP_EOL
;
continue
;
continue
;
}
}
$valid_arr
=
[];
$valid_arr
=
[];
...
@@ -112,20 +113,20 @@ class GameBetController extends Controller
...
@@ -112,20 +113,20 @@ class GameBetController extends Controller
$valid_arr
[]
=
$model
->
round
;
$valid_arr
[]
=
$model
->
round
;
}
}
$result
=
$service
->
getBetStatus
(
''
,
''
,
$valid_arr
,
$node
);
$result
=
$service
->
getBetStatus
(
''
,
''
,
$valid_arr
,
$node
);
if
(
0
!==
$result
[
'code'
])
{
if
(
0
!==
$result
[
'code'
])
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
continue
;
continue
;
}
}
$queryResultItems
=
$result
[
'result'
]
??
[];
$queryResultItems
=
$result
[
'result'
]
??
[];
if
(
empty
(
$queryResultItems
))
{
if
(
empty
(
$queryResultItems
))
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
continue
;
continue
;
}
}
$platform
=
$key
;
$platform
=
$key
;
foreach
(
$queryResultItems
[
'queryResultItems'
]
as
$key
=>
$val
){
foreach
(
$queryResultItems
[
'queryResultItems'
]
as
$key
=>
$val
)
{
if
(
false
==
$val
[
'found'
])
continue
;
if
(
false
==
$val
[
'found'
])
continue
;
$resultArr
=
json_decode
(
$val
[
'resultJSON'
],
true
);
$resultArr
=
json_decode
(
$val
[
'resultJSON'
],
true
);
CoinGameBet
::
updateAll
([
CoinGameBet
::
updateAll
([
'amount'
=>
$resultArr
[
'amount'
],
'amount'
=>
$resultArr
[
'amount'
],
'height'
=>
$resultArr
[
'height'
],
'height'
=>
$resultArr
[
'height'
],
...
@@ -133,12 +134,12 @@ class GameBetController extends Controller
...
@@ -133,12 +134,12 @@ class GameBetController extends Controller
'rand_num'
=>
$resultArr
[
'rand_num'
],
'rand_num'
=>
$resultArr
[
'rand_num'
],
'player_win'
=>
$resultArr
[
'player_win'
],
'player_win'
=>
$resultArr
[
'player_win'
],
'valid'
=>
CoinGameBet
::
VAILD_TRUE
'valid'
=>
CoinGameBet
::
VAILD_TRUE
],[
],
[
'round'
=>
$resultArr
[
'round'
],
'round'
=>
$resultArr
[
'round'
],
'platform'
=>
$platform
'platform'
=>
$platform
]);
]);
}
}
echo
$platform
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据更新成功'
.
PHP_EOL
;
echo
$platform
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据更新成功'
.
PHP_EOL
;
continue
;
continue
;
}
}
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