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
9f0382bd
Commit
9f0382bd
authored
Jun 20, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feature/ucenter
parents
0c8b28d9
b7af8d09
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
125 additions
and
28 deletions
+125
-28
GameBetController.php
api/controllers/GameBetController.php
+1
-0
ApplicationController.php
backend/controllers/ApplicationController.php
+2
-2
CoinApplicationForm.php
backend/models/coin/CoinApplicationForm.php
+5
-3
add.php
backend/views/application/add.php
+12
-1
edit.php
backend/views/application/edit.php
+12
-1
ApplicationBusiness.php
common/business/ApplicationBusiness.php
+2
-2
Chain33Business.php
common/business/Chain33Business.php
+29
-16
CoinGameBet.php
common/models/psources/CoinGameBet.php
+6
-3
ExchangeController.php
console/controllers/ExchangeController.php
+2
-0
GameBetController.php
console/controllers/GameBetController.php
+54
-0
No files found.
api/controllers/GameBetController.php
View file @
9f0382bd
...
...
@@ -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
();
...
...
backend/controllers/ApplicationController.php
View file @
9f0382bd
...
...
@@ -56,7 +56,7 @@ class ApplicationController extends BaseController
if
(
Yii
::
$app
->
request
->
isPost
){
Yii
::
$app
->
response
->
format
=
'json'
;
$category_id
=
Yii
::
$app
->
request
->
get
(
'category_id'
);
$fields
=
[
'category_id'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
];
$fields
=
[
'category_id'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'open_type_app'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
];
$params
=
array_merge
(
Yii
::
$app
->
request
->
post
(),[
'category_id'
=>
$category_id
,
'platform_id'
=>
Yii
::
$app
->
user
->
identity
->
platform_id
]);
$params
=
$this
->
initParams
(
$params
,
$fields
);
$coin_applicateion_form
=
new
CoinApplicationForm
();
...
...
@@ -80,7 +80,7 @@ class ApplicationController extends BaseController
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$fields
=
[
'category_id'
,
'id'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
];
$fields
=
[
'category_id'
,
'id'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'open_type_app'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
];
$params
=
array_merge
(
Yii
::
$app
->
request
->
post
(),[
'platform_id'
=>
Yii
::
$app
->
user
->
identity
->
platform_id
]);
$params
=
$this
->
initParams
(
$params
,
$fields
);
$coin_applicateion_form
=
new
CoinApplicationForm
();
...
...
backend/models/coin/CoinApplicationForm.php
View file @
9f0382bd
...
...
@@ -39,13 +39,14 @@ class CoinApplicationForm extends BaseForm
public
$show_width
;
public
$show_height
;
public
$open_type
;
public
$open_type_app
;
public
$platform_id
;
public
function
scenarios
()
{
return
[
self
::
SCENARIO_ADD
=>
[
'category_id'
,
'name'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
],
self
::
SCENARIO_EDIT
=>
[
'category_id'
,
'id'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
],
self
::
SCENARIO_ADD
=>
[
'category_id'
,
'name'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'open_type_app'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
],
self
::
SCENARIO_EDIT
=>
[
'category_id'
,
'id'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'open_type_app'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
],
];
}
...
...
@@ -73,7 +74,8 @@ class CoinApplicationForm extends BaseForm
'redirect_type'
=>
'跳转方式'
,
'show_width'
=>
'显示宽度'
,
'show_height'
=>
'显示高度'
,
'open_type'
=>
'H5打开方式'
,
'open_type'
=>
'H5打开方式 PC版'
,
'open_type_app'
=>
'H5打开方式 APP版'
,
'platform_id'
=>
'平台Id'
];
}
...
...
backend/views/application/add.php
View file @
9f0382bd
...
...
@@ -160,7 +160,7 @@
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
H5打开方式
</label>
<label
class=
"layui-form-label"
>
H5打开方式
(PC版)
</label>
<div
class=
"layui-input-block"
>
<select
name=
"open_type"
>
<option
value=
"0"
>
选择打开方式
</option>
...
...
@@ -171,6 +171,17 @@
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
H5打开方式(APP版)
</label>
<div
class=
"layui-input-block"
>
<select
name=
"open_type_app"
>
<option
value=
"0"
>
选择打开方式
</option>
<option
value=
"1"
>
钱包内打开
</option>
<option
value=
"2"
>
浏览器打开
</option>
</select>
</div>
</div>
<div
class=
"layui-form-item"
>
<button
class=
"layui-btn"
>
提交
</button>
</div>
</form>
...
...
backend/views/application/edit.php
View file @
9f0382bd
...
...
@@ -162,7 +162,7 @@
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
H5打开方式
</label>
<label
class=
"layui-form-label"
>
H5打开方式
(PC版)
</label>
<div
class=
"layui-input-block"
>
<select
name=
"open_type"
>
<option
value=
"0"
>
选择打开方式
</option>
...
...
@@ -171,6 +171,17 @@
</select>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
H5打开方式(APP版)
</label>
<div
class=
"layui-input-block"
>
<select
name=
"open_type_app"
>
<option
value=
"0"
>
选择打开方式
</option>
<option
value=
"1"
<?php
if
(
$item
[
'open_type_app'
]
==
1
)
echo
"selected"
?>
>
钱包内打开
</option>
<option
value=
"2"
<?php
if
(
$item
[
'open_type_app'
]
==
2
)
echo
"selected"
?>
>
浏览器打开
</option>
</select>
</div>
</div>
</form>
</div>
</div>
...
...
common/business/ApplicationBusiness.php
View file @
9f0382bd
...
...
@@ -97,12 +97,12 @@ class ApplicationBusiness
$app_cate_Model
=
CoinAppCate
::
find
();
if
(
array_key_exists
(
'platform_id'
,
$condition
)){
$query
=
$app_cate_Model
->
JoinWith
([
'application'
],
false
)
->
select
(
'cate_id,app_id,name,icon,type,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url,advertise,redirect_type,'
.
CoinAppCate
::
tableName
()
.
'.sort'
)
->
select
(
'cate_id,app_id,name,icon,type,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url,advertise,redirect_type,
open_type_app,
'
.
CoinAppCate
::
tableName
()
.
'.sort'
)
->
where
(
$condition
)
->
orderBy
(
CoinAppCate
::
tableName
()
.
'.sort asc'
);
}
else
{
$query
=
$app_cate_Model
->
JoinWith
([
'application'
],
false
)
->
select
(
'cate_id,app_id,name,icon,type,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url,advertise,redirect_type,'
.
CoinAppCate
::
tableName
()
.
'.sort'
)
->
select
(
'cate_id,app_id,name,icon,type,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url,advertise,redirect_type,
open_type_app,
'
.
CoinAppCate
::
tableName
()
.
'.sort'
)
->
orderBy
(
CoinAppCate
::
tableName
()
.
'.sort asc'
);
}
...
...
common/business/Chain33Business.php
View file @
9f0382bd
...
...
@@ -120,16 +120,6 @@ class Chain33Business
}
/**
* 获取最新的区块
*/
public
static
function
getLastHeader
()
{
$service
=
new
Chain33Service
();
$result
=
$service
->
getLastHeader
();
return
$result
;
}
/**
* 获取区块hash
*
* @param integer $height
...
...
@@ -183,22 +173,45 @@ class Chain33Business
* @param integer $end
* @return array
*/
public
static
function
getBetStatus
(
$start
,
$end
)
public
static
function
getBetStatus
(
$start
,
$end
,
$roundArr
=
[]
)
{
$node_params
=
\Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
];
$service
=
new
Chain33Service
(
$node_params
);
$execer
=
'wasm'
;
$funcName
=
'WasmGetContractTable'
;
$contractName
=
'user.p.tschain.user.wasm.dice'
;
for
(
$i
=
$start
+
1
;
$i
<=
$end
;
$i
++
){
$items
[]
=
[
'tableName'
=>
'roundinfo'
,
'key'
=>
'round:'
.
$i
];
if
(
empty
(
$roundArr
))
{
for
(
$i
=
$start
+
1
;
$i
<=
$end
;
$i
++
){
$items
[]
=
[
'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
);
}
/*
* 获取最新的区块头
* @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 @
9f0382bd
...
...
@@ -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/ExchangeController.php
View file @
9f0382bd
...
...
@@ -37,6 +37,8 @@ class ExchangeController extends Controller
public
function
actionQuotation
()
{
ExchangeBusiness
::
setQuotation
();
echo
date
(
'Y-m-d H:i:s'
)
.
'数据更新成功'
.
PHP_EOL
;
return
0
;
}
public
function
actionTest
()
...
...
console/controllers/GameBetController.php
View file @
9f0382bd
...
...
@@ -42,6 +42,7 @@ class GameBetController extends Controller
return
0
;
}
Yii
::
$app
->
redis
->
set
(
'chain33_game_bet_status'
,
$current_round
,
'EX'
,
300
);
$result
=
$service
->
getBetStatus
(
$cache_current_round
,
$current_round
);
if
(
0
!==
$result
[
'code'
]){
echo
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
...
...
@@ -64,4 +65,56 @@ 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
()
->
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
)
{
$valid_arr
[]
=
$model
->
round
;
}
$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
;
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