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
281e9f71
Commit
281e9f71
authored
Jan 10, 2019
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加托管币种旷工费
parent
74fc1f52
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
190 additions
and
21 deletions
+190
-21
CoinController.php
api/controllers/CoinController.php
+6
-4
ServiceController.php
api/controllers/ServiceController.php
+19
-0
BaseController.php
backend/controllers/BaseController.php
+1
-1
MinerFeeController.php
backend/controllers/MinerFeeController.php
+40
-2
MinerFeeForm.php
backend/models/coin/MinerFeeForm.php
+3
-3
form.php
backend/views/miner-fee/form.php
+9
-0
index.php
backend/views/miner-fee/index.php
+53
-11
Trusteeship.php
common/service/trusteeship/Trusteeship.php
+59
-0
No files found.
api/controllers/CoinController.php
View file @
281e9f71
...
@@ -15,6 +15,7 @@ use common\business\CoinBusiness;
...
@@ -15,6 +15,7 @@ use common\business\CoinBusiness;
use
common\business\ExchangeBusiness
;
use
common\business\ExchangeBusiness
;
use
common\models\psources\Coin
;
use
common\models\psources\Coin
;
use
common\models\psources\CoinRecommend
;
use
common\models\psources\CoinRecommend
;
use
common\models\psources\MinerFee
;
use
Yii
;
use
Yii
;
/**
/**
...
@@ -178,10 +179,11 @@ class CoinController extends BaseController
...
@@ -178,10 +179,11 @@ class CoinController extends BaseController
$names
=
Yii
::
$app
->
request
->
post
(
'name'
);
$names
=
Yii
::
$app
->
request
->
post
(
'name'
);
$coin
=
Coin
::
findOne
([
'name'
=>
$names
]);
$coin
=
Coin
::
findOne
([
'name'
=>
$names
]);
if
(
$coin
)
{
if
(
$coin
)
{
$miner_fee
=
$coin
->
minerFee
;
$chain
=
$coin
->
chain
;
if
(
empty
(
$miner_fee
))
{
$miner_fee
=
MinerFee
::
find
()
->
where
([
'platform'
=>
$chain
,
'type'
=>
1
])
->
one
();
return
[];
if
(
!
$miner_fee
){
}
throw
new
Exception
(
'8'
,
'旷工费未设置'
);
}
}
else
{
}
else
{
//如果coin为null,$coin->minerFee会抛出Trying to get property 'minerFee' of non-object",code=>8
//如果coin为null,$coin->minerFee会抛出Trying to get property 'minerFee' of non-object",code=>8
throw
new
Exception
(
'8'
,
'币种不存在'
);
throw
new
Exception
(
'8'
,
'币种不存在'
);
...
...
api/controllers/ServiceController.php
View file @
281e9f71
...
@@ -12,6 +12,7 @@ use api\base\BaseController;
...
@@ -12,6 +12,7 @@ use api\base\BaseController;
use
common\business\ExchangeBusiness
;
use
common\business\ExchangeBusiness
;
use
common\models\psources\Coin
;
use
common\models\psources\Coin
;
use
common\models\psources\CoinRecommend
;
use
common\models\psources\CoinRecommend
;
use
common\models\psources\MinerFee
;
use
common\service\coin\CoinFactory
;
use
common\service\coin\CoinFactory
;
use
Yii
;
use
Yii
;
...
@@ -94,4 +95,22 @@ class ServiceController extends BaseController
...
@@ -94,4 +95,22 @@ class ServiceController extends BaseController
}
}
return
[];
return
[];
}
}
/**
* @return array
* 获取旷工费
*/
public
function
actionFee
()
{
$request
=
Yii
::
$app
->
request
;
$coin
=
$request
->
post
(
'name'
);
if
(
!
$coin
){
return
[
'code'
=>
1
,
'data'
=>
[],
'msg'
=>
'币种不能为空'
];
}
$fee
=
MinerFee
::
find
()
->
where
([
'platform'
=>
$coin
,
'type'
=>
2
])
->
asArray
()
->
one
();
if
(
!
$fee
){
return
[
'code'
=>
1
,
'data'
=>
[],
'msg'
=>
'旷工费未设置'
];
}
return
[
'code'
=>
0
,
'data'
=>
$fee
,
'msg'
=>
'旷工费获取成功'
];
}
}
}
backend/controllers/BaseController.php
View file @
281e9f71
...
@@ -215,7 +215,7 @@ class BaseController extends Controller
...
@@ -215,7 +215,7 @@ class BaseController extends Controller
$this
->
ajaxReturn
(
$data
);
$this
->
ajaxReturn
(
$data
);
}
}
// 成功操作后默认停留1秒
// 成功操作后默认停留1秒
$waitSecond
=
3
;
$waitSecond
=
2
;
if
(
$status
)
{
if
(
$status
)
{
//发送成功信息
//发送成功信息
...
...
backend/controllers/MinerFeeController.php
View file @
281e9f71
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
namespace
backend\controllers
;
namespace
backend\controllers
;
use
common\service\trusteeship\Trusteeship
;
use
Yii
;
use
Yii
;
use
common\models\psources\MinerFee
;
use
common\models\psources\MinerFee
;
use
backend\models\coin\MinerFeeForm
;
use
backend\models\coin\MinerFeeForm
;
...
@@ -21,7 +22,11 @@ class MinerFeeController extends BaseController
...
@@ -21,7 +22,11 @@ class MinerFeeController extends BaseController
public
function
actionCost
()
public
function
actionCost
()
{
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
$data
=
MinerFee
::
getList
(
1
,
999
,
[]);
//数据不多
$request
=
Yii
::
$app
->
request
;
$type
=
$request
->
get
(
'type'
,
1
);
$page
=
$request
->
get
(
'page'
,
1
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$data
=
MinerFee
::
getList
(
$page
,
$limit
,
[[
'type'
=>
$type
]]);
//数据不多
if
(
$data
[
'count'
]
>
0
)
{
if
(
$data
[
'count'
]
>
0
)
{
$data
[
'code'
]
=
0
;
$data
[
'code'
]
=
0
;
}
else
{
}
else
{
...
@@ -42,6 +47,7 @@ class MinerFeeController extends BaseController
...
@@ -42,6 +47,7 @@ class MinerFeeController extends BaseController
{
{
$model
=
new
MinerFeeForm
();
$model
=
new
MinerFeeForm
();
$model
->
scenario
=
'add'
;
$model
->
scenario
=
'add'
;
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
1
);
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
$request
=
Yii
::
$app
->
request
;
$request
=
Yii
::
$app
->
request
;
if
(
$model
->
load
(
$request
->
post
())
&&
$model
->
validate
())
{
if
(
$model
->
load
(
$request
->
post
())
&&
$model
->
validate
())
{
...
@@ -50,6 +56,7 @@ class MinerFeeController extends BaseController
...
@@ -50,6 +56,7 @@ class MinerFeeController extends BaseController
$minerFee
->
min
=
$model
->
min
;
$minerFee
->
min
=
$model
->
min
;
$minerFee
->
max
=
$model
->
max
;
$minerFee
->
max
=
$model
->
max
;
$minerFee
->
level
=
$model
->
level
;
$minerFee
->
level
=
$model
->
level
;
$minerFee
->
type
=
$type
;
$minerFee
->
create_at
=
date
(
'Y-m-d H:i:s'
);
$minerFee
->
create_at
=
date
(
'Y-m-d H:i:s'
);
$minerFee
->
update_at
=
date
(
'Y-m-d H:i:s'
);
$minerFee
->
update_at
=
date
(
'Y-m-d H:i:s'
);
...
@@ -87,7 +94,6 @@ class MinerFeeController extends BaseController
...
@@ -87,7 +94,6 @@ class MinerFeeController extends BaseController
if
(
$minerFee
)
{
if
(
$minerFee
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
validate
())
{
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
validate
())
{
$minerFee
->
platform
=
$model
->
platform
;
$minerFee
->
min
=
$model
->
min
;
$minerFee
->
min
=
$model
->
min
;
$minerFee
->
max
=
$model
->
max
;
$minerFee
->
max
=
$model
->
max
;
$minerFee
->
level
=
$model
->
level
;
$minerFee
->
level
=
$model
->
level
;
...
@@ -133,4 +139,35 @@ class MinerFeeController extends BaseController
...
@@ -133,4 +139,35 @@ class MinerFeeController extends BaseController
}
}
$this
->
error
(
'删除失败'
,
Yii
::
$app
->
request
->
getReferrer
());
$this
->
error
(
'删除失败'
,
Yii
::
$app
->
request
->
getReferrer
());
}
}
public
function
actionUpdateCoin
()
{
Yii
::
$app
->
response
->
format
=
'json'
;
$trusteeship
=
new
Trusteeship
();
$data
=
$trusteeship
->
getSupportCoin
();
if
(
$data
[
'code'
]
!=
0
){
return
[
'code'
=>
-
1
,
'msg'
=>
'获取托管钱包币种失败'
];
}
else
{
$trusteeship_coins
=
array_column
(
$data
[
'data'
],
'currency'
);
$list
=
MinerFee
::
getList
(
1
,
999
,
[[
'type'
=>
2
]]);
if
(
$list
){
$local_coins
=
array_column
(
$list
[
'data'
],
'platform'
);
}
else
{
$local_coins
=
[];
}
$need_add_coins
=
array_diff
(
$trusteeship_coins
,
$local_coins
);
if
(
!
$need_add_coins
){
return
[
'code'
=>
0
,
'msg'
=>
'币种库已经最新'
];
}
foreach
(
$need_add_coins
as
$item
){
$minerFee
=
new
MinerFee
();
$minerFee
->
platform
=
$item
;
$minerFee
->
type
=
2
;
$minerFee
->
create_at
=
date
(
'Y-m-d H:i:s'
);
$minerFee
->
update_at
=
date
(
'Y-m-d H:i:s'
);
$minerFee
->
save
();
}
return
[
'code'
=>
0
,
'msg'
=>
'币种库更新成功'
];
}
}
}
}
\ No newline at end of file
backend/models/coin/MinerFeeForm.php
View file @
281e9f71
...
@@ -17,6 +17,7 @@ class MinerFeeForm extends Model
...
@@ -17,6 +17,7 @@ class MinerFeeForm extends Model
public
$max
;
public
$max
;
public
$min
;
public
$min
;
public
$level
;
public
$level
;
public
$type
;
public
function
formName
()
public
function
formName
()
{
{
...
@@ -26,10 +27,9 @@ class MinerFeeForm extends Model
...
@@ -26,10 +27,9 @@ class MinerFeeForm extends Model
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'id'
,
'
platform'
,
'
min'
,
'max'
,
'level'
],
'required'
,
'on'
=>
'edit'
],
[[
'id'
,
'min'
,
'max'
,
'level'
],
'required'
,
'on'
=>
'edit'
],
[[
'platform'
,
'min'
,
'max'
,
'level'
],
'required'
,
'on'
=>
'add'
],
[[
'platform'
,
'min'
,
'max'
,
'level'
],
'required'
,
'on'
=>
'add'
],
[[
'id'
,
'max'
,
'min'
,
'level'
],
'number'
],
[[
'id'
,
'max'
,
'min'
,
'level'
],
'number'
],
[[
'platform'
],
'string'
,
'max'
=>
255
],
];
];
}
}
...
@@ -37,7 +37,7 @@ class MinerFeeForm extends Model
...
@@ -37,7 +37,7 @@ class MinerFeeForm extends Model
{
{
return
[
return
[
'add'
=>
[
'platform'
,
'min'
,
'max'
,
'level'
],
'add'
=>
[
'platform'
,
'min'
,
'max'
,
'level'
],
'edit'
=>
[
'id'
,
'
platform'
,
'
min'
,
'max'
,
'level'
],
'edit'
=>
[
'id'
,
'min'
,
'max'
,
'level'
],
];
];
}
}
...
...
backend/views/miner-fee/form.php
View file @
281e9f71
...
@@ -24,6 +24,14 @@ $platforms = Coin::getChainList();
...
@@ -24,6 +24,14 @@ $platforms = Coin::getChainList();
<form
class=
"layui-form"
method=
"post"
action=
""
>
<form
class=
"layui-form"
method=
"post"
action=
""
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
name=
"id"
type=
"hidden"
value=
"
<?=
$model
->
id
?>
"
>
<input
name=
"id"
type=
"hidden"
value=
"
<?=
$model
->
id
?>
"
>
<?php
if
(
$model
->
type
==
2
)
:?>
<
div
class
="
layui
-
form
-
item
">
<label class="
layui
-
form
-
label
">币种</label>
<div class="
layui
-
input
-
block
">
<input class="
layui
-
input
" name="
platform
" value="
<?=
$model
->
platform
?>
">
</div>
</div>
<?php
else
:?>
<
div
class
="
layui
-
form
-
item
">
<
div
class
="
layui
-
form
-
item
">
<label class="
layui
-
form
-
label
">平台</label>
<label class="
layui
-
form
-
label
">平台</label>
<div class="
layui
-
input
-
block
">
<div class="
layui
-
input
-
block
">
...
@@ -36,6 +44,7 @@ $platforms = Coin::getChainList();
...
@@ -36,6 +44,7 @@ $platforms = Coin::getChainList();
</select>
</select>
</div>
</div>
</div>
</div>
<?php
endif
;
?>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
最小值
</label>
<label
class=
"layui-form-label"
>
最小值
</label>
...
...
backend/views/miner-fee/index.php
View file @
281e9f71
...
@@ -9,17 +9,30 @@
...
@@ -9,17 +9,30 @@
<h4>
矿工费
</h4>
<h4>
矿工费
</h4>
<div
class=
"layui-row"
>
<div
class=
"layui-row"
>
<div
class=
"layui-col-md1"
>
<div
class=
"layui-tab layui-tab-card"
>
<a
href=
"/admin/miner-fee/add"
>
<ul
class=
"layui-tab-title"
>
<button
class=
"layui-btn"
>
添加矿工费
</button>
<li
class=
"layui-this"
>
币钱包
</li>
</a>
<li>
托管钱包
</li>
</div>
</ul>
<div
class=
"layui-col-md8"
>
<div
class=
"layui-tab-content"
>
<div
class=
"layui-tab-item layui-show"
>
<a
href=
"/admin/miner-fee/add?type=1"
>
<button
class=
"layui-btn"
>
添加矿工费
</button>
</a>
<div
class=
"layui-row"
>
<table
id=
"table1"
class=
"layui-table"
></table>
</div>
</div>
<div
class=
"layui-tab-item"
>
<button
class=
"layui-btn layui-btn-default"
id=
"update-coin"
>
更新币种库
</button>
<table
class=
"layui-table"
id=
"table2"
></table>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"layui-row"
>
<table
id=
"table1"
class=
"layui-table"
></table>
</div>
<script>
<script>
var
table
=
layui
.
table
;
var
table
=
layui
.
table
;
table
.
render
({
table
.
render
({
...
@@ -34,11 +47,40 @@
...
@@ -34,11 +47,40 @@
{
field
:
'update_at'
,
title
:
'更新时间'
},
{
field
:
'update_at'
,
title
:
'更新时间'
},
{
field
:
'id'
,
title
:
'操作'
,
templet
:
"#operatorTpl"
}
{
field
:
'id'
,
title
:
'操作'
,
templet
:
"#operatorTpl"
}
]],
]],
url
:
'/admin/miner-fee/cost'
url
:
'/admin/miner-fee/cost?type=1'
});
table
.
render
({
elem
:
"#table2"
,
page
:
true
,
limit
:
10
,
cols
:
[[
{
field
:
'id'
,
title
:
'ID'
},
{
field
:
'platform'
,
title
:
'币种'
},
{
field
:
'min'
,
title
:
'最小值'
},
{
field
:
'max'
,
title
:
'最大值'
},
{
field
:
'level'
,
title
:
'分档'
},
{
field
:
'create_at'
,
title
:
'创建时间'
},
{
field
:
'update_at'
,
title
:
'更新时间'
},
{
field
:
'id'
,
title
:
'操作'
,
templet
:
"#operatorTpl"
}
]],
url
:
'/admin/miner-fee/cost?type=2'
});
});
$
(
'#update-coin'
).
click
(
function
()
{
$
.
get
(
'/admin/miner-fee/update-coin'
,
{},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
table
.
reload
(
'table2'
,
{
page
:
{
curr
:
1
}
});
}
});
})
</script>
</script>
<script
type=
"text/html"
id=
"operatorTpl"
>
<script
type=
"text/html"
id=
"operatorTpl"
>
<
a
href
=
"/admin/miner-fee/edit?id={{d.id}}"
>
<
a
href
=
"/admin/miner-fee/edit?id={{d.id}}
&type={{d.type}}
"
>
<
button
class
=
"layui-btn layui-btn-sm"
>
编辑
<
/button
>
<
button
class
=
"layui-btn layui-btn-sm"
>
编辑
<
/button
>
<
/a
>
<
/a
>
<
a
href
=
"/admin/miner-fee/del?id={{d.id}}"
>
<
a
href
=
"/admin/miner-fee/del?id={{d.id}}"
>
...
...
common/service/trusteeship/Trusteeship.php
0 → 100644
View file @
281e9f71
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2019/1/10
* Time: 10:53
*/
namespace
common\service\trusteeship
;
use
Yii
;
use
common\helpers\Curl
;
/**
* Lottery平行链 区块链接口
*/
class
Trusteeship
{
/**
* @return string
* 平行链上操作彩票
*/
public
static
function
urlTrusteeshipBuild
()
{
$config
=
Yii
::
$app
->
params
[
'trusteeship'
];
$service
=
$config
[
'service'
];
$scheme
=
$service
[
'scheme'
]
??
'http'
;
$host
=
$service
[
'host'
]
??
'127.0.0.1'
;
$port
=
(
string
)
$service
[
'port'
]
??
''
;
if
(
$port
)
{
return
$scheme
.
'://'
.
$host
.
':'
.
$port
;
}
else
{
return
$scheme
.
'://'
.
$host
;
}
}
/**
* @return array|mixed
* 获取支持的币种
*/
public
function
getSupportCoin
()
{
$ch
=
new
Curl
();
$config
=
Yii
::
$app
->
params
[
'trusteeship'
];
$url
=
self
::
urlTrusteeshipBuild
()
.
$config
[
'coin_getsupport'
];
$result
=
$ch
->
get
(
$url
,
false
);
if
(
!
$result
)
{
return
[
'code'
=>
-
1
,
'msg'
=>
$ch
->
errorText
];
}
if
(
200
==
$result
[
'code'
])
{
$result
[
'code'
]
=
0
;
$result
[
'msg'
]
=
$result
[
'message'
];
unset
(
$result
[
'message'
]);
return
$result
;
}
else
{
return
[
'code'
=>
-
1
,
'msg'
=>
$result
[
'message'
]];
}
}
}
\ 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