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
2af4d47a
Commit
2af4d47a
authored
Oct 22, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
后台配置
parent
04404eee
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
141 additions
and
54 deletions
+141
-54
SupportedSymbolController.php
api/controllers/SupportedSymbolController.php
+64
-6
CoinSupportedSymbolController.php
backend/controllers/CoinSupportedSymbolController.php
+15
-17
CoinSupportedSymbolForm.php
backend/models/coin/CoinSupportedSymbolForm.php
+16
-23
add.php
backend/views/coin-supported-symbol/add.php
+6
-2
index.js
backend/web/js/coin-supported-symbol/index.js
+22
-4
CoinSupportedSymbol.php
common/models/psources/CoinSupportedSymbol.php
+18
-2
No files found.
api/controllers/SupportedSymbolController.php
View file @
2af4d47a
...
@@ -6,27 +6,84 @@ use api\base\BaseController;
...
@@ -6,27 +6,84 @@ use api\base\BaseController;
use
common\models\psources\CoinAirDropTrade
;
use
common\models\psources\CoinAirDropTrade
;
use
common\models\psources\CoinSupportedSymbol
;
use
common\models\psources\CoinSupportedSymbol
;
use
common\service\chain33\Chain33Service
;
use
common\service\chain33\Chain33Service
;
use
linslin\yii2\curl\Curl
;
use
Yii
;
use
Yii
;
use
yii\helpers\ArrayHelper
;
class
SupportedSymbolController
extends
BaseController
class
SupportedSymbolController
extends
BaseController
{
{
public
function
action
Search
()
public
function
action
Index
()
{
{
$platform_
withhold_id
=
Yii
::
$app
->
request
->
get
(
'
id'
,
''
);
$platform_
id
=
Yii
::
$app
->
request
->
get
(
'platform_
id'
,
''
);
if
(
empty
(
$platform_
withhold_
id
))
{
if
(
empty
(
$platform_id
))
{
$msg
=
'参数不能为空'
;
$msg
=
'参数不能为空'
;
$code
=
-
1
;
$code
=
-
1
;
$data
=
null
;
$data
=
null
;
goto
doEnd
;
goto
doEnd
;
}
}
$coinSupportedSymbol
=
CoinSupportedSymbol
::
find
()
->
select
(
'symbol'
)
->
where
([
'platform_withhold_id'
=>
$platform_withhold_id
])
->
asArray
()
->
all
();
$parentSupportedSymbol
=
CoinSupportedSymbol
::
find
()
->
where
([
'platform_id'
=>
$platform_id
])
->
groupBy
(
'currency'
)
->
all
();
$data
=
array_column
(
$coinSupportedSymbol
,
'symbol'
);
$market
=
[];
foreach
(
$parentSupportedSymbol
as
$val
)
{
$coin_name
[]
=
$val
->
coinInfo
->
name
;
}
$curl
=
new
Curl
();
$data
=
[
"names"
=>
$coin_name
];
$params
=
json_encode
(
$data
);
$curl
->
setHeader
(
'Content-Type'
,
'application/json'
);
$curl
->
setRawPostData
(
$params
);
$res
=
$curl
->
post
(
\Yii
::
$app
->
params
[
'biqianbao'
]
.
'/interface/coin/coin-index'
,
true
);
$res
=
json_decode
(
$res
,
true
);
$res
=
array_column
(
$res
[
'data'
],
NULL
,
'id'
);;
foreach
(
$parentSupportedSymbol
as
&
$val
)
{
$temp
=
[];
$temp
[
'id'
]
=
(
int
)
$val
->
currency
;
$temp
[
'name'
]
=
$val
->
coinInfo
->
name
;
$temp
[
'icon'
]
=
$val
->
coinInfo
->
icon
;
$temp
[
'isToken'
]
=
(
1
==
$val
->
coinInfo
->
treaty
)
?
true
:
false
;
$temp
[
'isParacross'
]
=
(
'BTY'
==
strtoupper
(
$val
->
coinInfo
->
platform
))
?
false
:
true
;
$temp
[
'url'
]
=
'http://www.huifen.com'
;
$temp
[
'platfrom'
]
=
$val
->
coinInfo
->
platform
;
$temp
[
'rmb'
]
=
isset
(
$res
[
$val
->
currency
][
'rmb'
])
?
$res
[
$val
->
currency
][
'rmb'
]
:
0.00
;
$temp
[
'usd'
]
=
isset
(
$res
[
$val
->
currency
][
'usd'
])
?
$res
[
$val
->
currency
][
'usd'
]
:
0.00
;
array_push
(
$market
,
$temp
);
$coin_name
[]
=
$val
->
coinInfo
->
name
;
}
foreach
(
$market
as
&
$val
)
{
$childSupportedSymbol
=
CoinSupportedSymbol
::
find
()
->
where
([
'platform_id'
=>
$platform_id
,
'currency'
=>
$val
[
'id'
]])
->
all
();
$tokens
=
[];
foreach
(
$childSupportedSymbol
as
$child
)
{
$curl
=
new
Curl
();
$data
=
[
"names"
=>
[
$child
->
baseCurrencyInfo
->
name
]
];
$params
=
json_encode
(
$data
);
$curl
->
setHeader
(
'Content-Type'
,
'application/json'
);
$curl
->
setRawPostData
(
$params
);
$res
=
$curl
->
post
(
\Yii
::
$app
->
params
[
'biqianbao'
]
.
'/interface/coin/coin-index'
,
true
);
$res
=
json_decode
(
$res
,
true
);
$temp
=
[];
$temp
[
'id'
]
=
(
int
)
$child
->
base_currency
;
$temp
[
'name'
]
=
$child
->
baseCurrencyInfo
->
name
;
$temp
[
'icon'
]
=
$child
->
baseCurrencyInfo
->
icon
;
$temp
[
'isToken'
]
=
(
1
==
$child
->
baseCurrencyInfo
->
treaty
)
?
true
:
false
;
$temp
[
'isParacross'
]
=
(
'BTY'
==
strtoupper
(
$child
->
baseCurrencyInfo
->
platform
))
?
false
:
true
;
$temp
[
'url'
]
=
'http://www.huifen.com'
;
$temp
[
'platfrom'
]
=
$child
->
baseCurrencyInfo
->
platform
;
$temp
[
'rmb'
]
=
isset
(
$res
[
'data'
][
0
][
'rmb'
])
?
$res
[
'data'
][
0
][
'rmb'
]
:
0.00
;
$temp
[
'usd'
]
=
isset
(
$res
[
'data'
][
0
][
'usd'
])
?
$res
[
'data'
][
0
][
'usd'
]
:
0.00
;
array_push
(
$tokens
,
$temp
);
}
$val
[
'tokens'
]
=
$tokens
;
}
$code
=
0
;
$code
=
0
;
$msg
=
'success'
;
$msg
=
'success'
;
doEnd
:
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$
data
];
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$
market
];
}
}
}
}
\ No newline at end of file
backend/controllers/CoinSupportedSymbolController.php
View file @
2af4d47a
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
backend\controllers
;
namespace
backend\controllers
;
use
backend\models\coin\CoinSupportedSymbolForm
;
use
backend\models\coin\CoinSupportedSymbolForm
;
use
common\models\psources\Coin
;
use
common\models\psources\CoinSupportedSymbol
;
use
common\models\psources\CoinSupportedSymbol
;
use
Yii
;
use
Yii
;
...
@@ -23,7 +24,11 @@ class CoinSupportedSymbolController extends BaseController
...
@@ -23,7 +24,11 @@ class CoinSupportedSymbolController extends BaseController
$where
[]
=
[
'platform_id'
=>
$id
];
$where
[]
=
[
'platform_id'
=>
$id
];
}
}
$data
=
CoinSupportedSymbol
::
getList
(
$page
,
$limit
,
$where
);
$data
=
CoinSupportedSymbol
::
getList
(
$page
,
$limit
,
$where
);
$data
[
'code'
]
=
0
;
foreach
(
$data
[
'data'
]
as
&
$val
)
{
$val
->
currency
=
$val
->
coinInfo
->
name
;
$val
->
base_currency
=
$val
->
baseCurrencyInfo
->
name
;
}
Yii
::
$app
->
response
->
format
=
'json'
;
Yii
::
$app
->
response
->
format
=
'json'
;
return
$data
;
return
$data
;
}
}
...
@@ -33,32 +38,25 @@ class CoinSupportedSymbolController extends BaseController
...
@@ -33,32 +38,25 @@ class CoinSupportedSymbolController extends BaseController
public
function
actionAdd
()
public
function
actionAdd
()
{
{
$this
->
layout
=
false
;
$model
=
new
CoinSupportedSymbolForm
();
$model
=
new
CoinSupportedSymbolForm
();
$model
->
scenario
=
'add'
;
$model
->
scenario
=
'add'
;
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$data
=
Yii
::
$app
->
request
->
post
();
$data
=
Yii
::
$app
->
request
->
post
();
if
(
$model
->
load
(
$data
,
''
)
&&
$model
->
validate
())
{
if
(
$model
->
load
(
$data
,
''
)
&&
$model
->
validate
())
{
$currency
=
Coin
::
find
()
->
select
(
'id'
)
->
where
([
'name'
=>
$data
[
'currency'
]])
->
asArray
()
->
one
();
$base_currency
=
Coin
::
find
()
->
select
(
'id'
)
->
where
([
'name'
=>
$data
[
'base_currency'
]])
->
asArray
()
->
one
();
$coinSupportedSymbol
=
new
CoinSupportedSymbol
();
$coinSupportedSymbol
=
new
CoinSupportedSymbol
();
$coinSupportedSymbol
->
platform_id
=
$data
[
'platform_id'
];
$coinSupportedSymbol
->
platform_id
=
$data
[
'platform_id'
];
$coinSupportedSymbol
->
currency
=
$
data
[
'currency
'
];
$coinSupportedSymbol
->
currency
=
$
currency
[
'id
'
];
$coinSupportedSymbol
->
base_currency
=
$
data
[
'base_currency
'
];
$coinSupportedSymbol
->
base_currency
=
$
base_currency
[
'id
'
];
$result
=
$coinSupportedSymbol
->
save
();
$result
=
$coinSupportedSymbol
->
save
();
if
(
$result
===
true
)
{
if
(
$result
!=
true
)
{
$this
->
success
(
'添加成功'
,
'/admin/coin-supported-symbol/list?id='
.
$data
[
'platform_id'
]);
return
[
'code'
=>
-
1
,
'msg'
=>
current
(
$model
->
firstErrors
)];
}
}
//表单验证失败
$errors
=
$model
->
errors
;
if
(
$errors
)
{
foreach
(
$errors
as
$key
=>
$item
)
{
$errors
=
$item
[
0
];
break
;
}
}
}
elseif
(
isset
(
$result
)
&&
$result
[
'code'
]
!=
0
)
{
$errors
=
$result
[
'message'
];
}
}
$this
->
error
(
$errors
,
Yii
::
$app
->
request
->
getReferrer
())
;
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
]
;
}
}
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
);
return
$this
->
render
(
'add'
,
[
'model'
=>
$model
,
'platform_id'
=>
$platform_id
]);
return
$this
->
render
(
'add'
,
[
'model'
=>
$model
,
'platform_id'
=>
$platform_id
]);
...
...
backend/models/coin/CoinSupportedSymbolForm.php
View file @
2af4d47a
...
@@ -2,13 +2,15 @@
...
@@ -2,13 +2,15 @@
namespace
backend\models\coin
;
namespace
backend\models\coin
;
use
common\models\psources\Coin
;
use
yii\base\Model
;
use
yii\base\Model
;
class
CoinSupportedSymbolForm
extends
Model
class
CoinSupportedSymbolForm
extends
Model
{
{
public
$id
;
public
$id
;
public
$platform_withhold_id
;
public
$platform_id
;
public
$symbol
;
public
$currency
;
public
$base_currency
;
public
function
formName
()
public
function
formName
()
{
{
...
@@ -18,34 +20,26 @@ class CoinSupportedSymbolForm extends Model
...
@@ -18,34 +20,26 @@ class CoinSupportedSymbolForm extends Model
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'platform_withhold_id'
,
'symbol'
],
'required'
,
'on'
=>
'add'
],
[[
'platform_id'
,
'currency'
,
'base_currency'
],
'required'
,
'on'
=>
'add'
],
[[
'id'
,
'platform_withhold_id'
,
'symbol'
],
'required'
,
'on'
=>
'update'
],
[[
'id'
,
'platform_id'
,
'currency'
,
'base_currency'
],
'required'
,
'on'
=>
'update'
],
[[
'currency'
,
'base_currency'
],
'isExist'
]
];
];
}
}
public
function
attributeLabel
s
()
public
function
scenario
s
()
{
{
return
[
return
[
'id'
=>
'ID'
,
'add'
=>
[
'platform_id'
,
'currency'
,
'base_currency'
],
'platform_withhold_id'
=>
'对应链'
,
'update'
=>
[
'id'
,
'platform_id'
,
'currency'
,
'base_currency'
],
'symbol'
=>
'货币对'
,
];
];
}
}
public
function
scenarios
(
)
public
function
isExist
(
$attribute
,
$params
)
{
{
return
[
$coin_model
=
Coin
::
find
()
->
where
([
'name'
=>
$this
->
currency
])
->
one
();
'add'
=>
[
if
(
false
==
$coin_model
)
{
'platform_withhold_id'
,
$this
->
addError
(
$attribute
,
'币种不存在'
);
'symbol'
return
false
;
],
}
'update'
=>
[
'id'
,
'platform_withhold_id'
,
'symbol'
],
];
}
}
}
}
\ No newline at end of file
backend/views/coin-supported-symbol/add.php
View file @
2af4d47a
...
@@ -3,8 +3,12 @@
...
@@ -3,8 +3,12 @@
<form
id=
"addData"
>
<form
id=
"addData"
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<div
class=
"input-group my-group"
>
<div
class=
"input-group my-group"
>
<span
class=
"input-group-addon"
>
币种名称
</span>
<span
class=
"input-group-addon"
>
交易货币
</span>
<input
name=
"coin_name"
type=
"text"
class=
"form-control"
lay-verify=
"required"
>
<input
name=
"currency"
type=
"text"
class=
"form-control"
lay-verify=
"required"
>
</div>
<div
class=
"input-group my-group"
>
<span
class=
"input-group-addon"
>
基础货币
</span>
<input
name=
"base_currency"
type=
"text"
class=
"form-control"
lay-verify=
"required"
>
</div>
</div>
<input
class=
"layui-input"
name=
"platform_id"
type=
"hidden"
value=
"
<?=
$platform_id
?>
"
<input
class=
"layui-input"
name=
"platform_id"
type=
"hidden"
value=
"
<?=
$platform_id
?>
"
lay-verify=
"required"
>
lay-verify=
"required"
>
...
...
backend/web/js/coin-supported-symbol/index.js
View file @
2af4d47a
...
@@ -14,8 +14,24 @@ var tableIns = table.render({
...
@@ -14,8 +14,24 @@ var tableIns = table.render({
loading
:
true
,
loading
:
true
,
cols
:
[[
cols
:
[[
{
field
:
'id'
,
title
:
'ID'
},
{
field
:
'id'
,
title
:
'ID'
},
{
field
:
'currency'
,
title
:
'交易货币'
},
{
{
field
:
'base_currency'
,
title
:
'基础货币'
},
field
:
'currency'
,
title
:
'交易货币'
,
//templet: function (data) {
//var name = JSON.parse(data.name);
//console.log(typeof (data.name), name.zh);
//return name.zh
//}
},
{
field
:
'base_currency'
,
title
:
'基础货币'
,
//templet: function (data) {
//var name = JSON.parse(data.name);
//console.log(typeof (data.name), name.zh);
//return name.zh
//}
},
{
field
:
'create_time'
,
title
:
'创建时间'
},
{
field
:
'create_time'
,
title
:
'创建时间'
},
{
field
:
'id'
,
title
:
'操作'
,
templet
:
'#operationTpl'
}
{
field
:
'id'
,
title
:
'操作'
,
templet
:
'#operationTpl'
}
]],
]],
...
@@ -58,10 +74,10 @@ $('#add').click(function () {
...
@@ -58,10 +74,10 @@ $('#add').click(function () {
btn1
:
function
()
{
btn1
:
function
()
{
$
.
post
(
'/admin/coin-supported-symbol/add'
,
$
(
"#addData"
).
serialize
(),
function
(
rev
)
{
$
.
post
(
'/admin/coin-supported-symbol/add'
,
$
(
"#addData"
).
serialize
(),
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
layer
.
msg
(
rev
.
msg
);
if
(
rev
.
code
==
0
)
{
//
if (rev.code == 0) {
layer
.
close
(
index
);
layer
.
close
(
index
);
table
.
reload
(
"table1"
,
{});
table
.
reload
(
"table1"
,
{});
}
//
}
});
});
}
}
});
});
...
@@ -69,4 +85,5 @@ $('#add').click(function () {
...
@@ -69,4 +85,5 @@ $('#add').click(function () {
});
});
return
false
;
return
false
;
});
});
\ No newline at end of file
common/models/psources/CoinSupportedSymbol.php
View file @
2af4d47a
...
@@ -16,9 +16,9 @@ class CoinSupportedSymbol extends BaseActiveRecord
...
@@ -16,9 +16,9 @@ class CoinSupportedSymbol extends BaseActiveRecord
$query
=
$query
->
andWhere
(
$item
);
$query
=
$query
->
andWhere
(
$item
);
}
}
$count
=
$query
->
count
();
$count
=
$query
->
count
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
a
sArray
()
->
a
ll
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
all
();
return
[
'count'
=>
$count
,
'data'
=>
$data
];
return
[
'count'
=>
$count
,
'data'
=>
$data
,
'code'
=>
0
];
}
}
public
function
addOne
(
$params
)
public
function
addOne
(
$params
)
...
@@ -36,4 +36,20 @@ class CoinSupportedSymbol extends BaseActiveRecord
...
@@ -36,4 +36,20 @@ class CoinSupportedSymbol extends BaseActiveRecord
return
[
'code'
=>
$exception
->
getCode
(),
'message'
=>
$exception
->
getMessage
()];
return
[
'code'
=>
$exception
->
getCode
(),
'message'
=>
$exception
->
getMessage
()];
}
}
}
}
// public function attributes()
// {
// return array_merge(parent::attributes(), ['code']);
// }
public
function
getCoinInfo
()
{
return
$this
->
hasOne
(
Coin
::
class
,
[
'id'
=>
'currency'
]);
}
public
function
getBaseCurrencyInfo
()
{
return
$this
->
hasOne
(
Coin
::
class
,
[
'id'
=>
'base_currency'
]);
}
}
}
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