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
706bb055
Commit
706bb055
authored
Sep 17, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
钱包所支持可发行货币
parent
accc1a5c
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
287 additions
and
165 deletions
+287
-165
IssueChainController.php
api/controllers/IssueChainController.php
+0
-26
IndexAsset.php
backend/assets/coinSupportedCoin/IndexAsset.php
+17
-0
CoinSupportedCoinController.php
backend/controllers/CoinSupportedCoinController.php
+71
-0
add.php
backend/views/coin-supported-coin/add.php
+12
-0
index.php
backend/views/coin-supported-coin/index.php
+34
-0
index.php
backend/views/wallet/index.php
+3
-6
index.js
backend/web/js/coin-supported-coin/index.js
+72
-0
CoinIssueCoinForm_.php
common/models/psources/CoinIssueCoinForm_.php
+0
-133
CoinSupportedCoin.php
common/models/psources/CoinSupportedCoin.php
+78
-0
No files found.
api/controllers/IssueChainController.php
View file @
706bb055
...
...
@@ -48,29 +48,4 @@ class IssueChainController extends BaseController
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionGetBalance
()
{
$data
=
null
;
$address
[]
=
\Yii
::
$app
->
request
->
get
(
'address'
,
''
);
$execer
=
\Yii
::
$app
->
request
->
get
(
'execer'
,
''
);
if
(
empty
(
$address
)
||
empty
(
$execer
))
{
$msg
=
'缺少必要的参数'
;
$code
=
-
1
;
goto
doEnd
;
}
$service
=
new
Chain33Service
();
$result
=
$service
->
getBalance
(
$address
,
$execer
);
if
(
0
!==
$result
[
'code'
]
||
null
!==
$result
[
'error'
])
{
$msg
=
$result
[
'error'
];
$code
=
-
1
;
goto
doEnd
;
}
$code
=
0
;
$msg
=
'ok'
;
$data
=
$result
[
'result'
][
0
][
'balance'
];
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
\ No newline at end of file
backend/assets/coinSupportedCoin/IndexAsset.php
0 → 100644
View file @
706bb055
<?php
namespace
backend\assets\coinSupportedCoin
;
use
yii\web\AssetBundle
;
use
yii\web\View
;
class
IndexAsset
extends
AssetBundle
{
public
$sourcePath
=
'@backend/web/js/coin-supported-coin'
;
public
$js
=
[
'index.js'
,
];
public
$jsOptions
=
[
'position'
=>
View
::
POS_END
,
];
}
backend/controllers/CoinSupportedCoinController.php
0 → 100644
View file @
706bb055
<?php
namespace
backend\controllers
;
use
common\models\psources\CoinSupportedCoin
;
use
Yii
;
class
CoinSupportedCoinController
extends
BaseController
{
public
function
actionList
()
{
$platform_id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$page
=
$request
->
get
(
'page'
,
1
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$id
=
$request
->
get
(
'id'
,
''
);
$where
=
[];
if
(
$id
)
{
$where
[]
=
[
'platform_id'
=>
$id
];
}
$data
=
CoinSupportedCoin
::
getList
(
$page
,
$limit
,
$where
);
$data
[
'code'
]
=
0
;
Yii
::
$app
->
response
->
format
=
'json'
;
return
$data
;
}
return
$this
->
render
(
'index'
,
[
'platform_id'
=>
$platform_id
]);
}
public
function
actionAdd
()
{
$this
->
layout
=
false
;
$model
=
new
CoinSupportedCoin
();
$model
->
setScenario
(
CoinSupportedCoin
::
SCENARIOS_CREATE
);
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$data
=
Yii
::
$app
->
request
->
post
();
if
(
$model
->
load
(
$data
,
''
)
&&
$model
->
save
())
{
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
$error
=
$model
->
errors
;
if
(
$error
)
{
return
[
'code'
=>
-
1
,
'msg'
=>
current
(
$model
->
firstErrors
)];
}
}
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
);
return
$this
->
render
(
'add'
,
[
'model'
=>
$model
,
'platform_id'
=>
$platform_id
]);
}
public
function
actionDelete
()
{
Yii
::
$app
->
response
->
format
=
'json'
;
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
0
);
if
(
$id
)
{
$model
=
CoinSupportedCoin
::
findOne
([
'id'
=>
$id
]);
if
(
$model
)
{
try
{
$model
->
delete
();
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
catch
(
\Throwable
$t
)
{
return
[
'code'
=>
$t
->
getCode
(),
'msg'
=>
$t
->
getMessage
()];
}
}
}
return
[
'code'
=>
-
1
,
'msg'
=>
'删除失败'
];
}
}
\ No newline at end of file
backend/views/coin-supported-coin/add.php
0 → 100644
View file @
706bb055
<div
style=
"padding: 5px 20px;"
>
<br>
<form
id=
"addData"
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<div
class=
"input-group my-group"
>
<span
class=
"input-group-addon"
>
币种名称
</span>
<input
name=
"coin_name"
type=
"text"
class=
"form-control"
lay-verify=
"required"
>
</div>
<input
class=
"layui-input"
name=
"platform_id"
type=
"hidden"
value=
"
<?=
$platform_id
?>
"
lay-verify=
"required"
>
</form>
</div>
backend/views/coin-supported-coin/index.php
0 → 100644
View file @
706bb055
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 上午9:59
*/
use
backend\assets\coinSupportedCoin\IndexAsset
;
IndexAsset
::
register
(
$this
);
?>
<style>
.layui-table-tips-c
{
padding
:
0px
;
}
</style>
<h4>
货币列表
</h4>
<div
class=
"layui-row"
>
<div
class=
"layui-col-md1"
>
<button
class=
"layui-btn layui-btn-sm"
lay-event=
"add"
id=
"add"
>
单笔添加
</button>
</div>
</div>
<input
id=
"platform_id"
type=
"hidden"
value=
"
<?=
$platform_id
?>
"
>
<div
class=
"layui-row"
>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
<script
type=
"text/html"
id=
"operationTpl"
>
<
a
lay
-
event
=
"delete"
>
<
button
class
=
"layui-btn layui-btn-sm layui-btn-danger"
><
i
class
=
"layui-icon"
>&
#
xe640
;
<
/i></
button
>
<
/a
>
</script>
backend/views/wallet/index.php
View file @
706bb055
...
...
@@ -42,10 +42,7 @@ IndexAsset::register($this);
</div>
<script
type=
"text/html"
id=
"operationTpl"
>
<
a
lay
-
event
=
"edit"
>
<
button
class
=
"layui-btn layui-btn-sm"
><
i
class
=
"layui-icon"
>&
#
xe642
;
<
/i></
button
>
<
/a
>
<
a
lay
-
event
=
"delete"
>
<
button
class
=
"layui-btn layui-btn-sm layui-btn-danger"
><
i
class
=
"layui-icon"
>&
#
xe640
;
<
/i></
button
>
<
/a
>
<
a
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"edit"
>
编辑
<
/a
>
<
a
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"delete"
>
删除
<
/a
>
<
a
class
=
"layui-btn layui-btn-primary layui-btn-xs"
href
=
"/admin/coin-supported-coin/list?id={{d.id}}"
>
支持发行货币种类
<
/a
>
</script>
backend/web/js/coin-supported-coin/index.js
0 → 100644
View file @
706bb055
/**
* @author rlgyzhcn@qq.com
*/
var
table
=
layui
.
table
;
var
form
=
layui
.
form
;
var
layer
=
layui
.
layer
;
form
.
render
();
var
platform_id
=
$
(
"#platform_id"
).
val
();
var
tableIns
=
table
.
render
({
elem
:
"#table1"
,
url
:
'/admin/coin-supported-coin/list?id='
+
platform_id
,
limit
:
10
,
page
:
1
,
loading
:
true
,
cols
:
[[
{
field
:
'id'
,
title
:
'ID'
},
{
field
:
'coin_name'
,
title
:
'货币对'
},
{
field
:
'create_time'
,
title
:
'创建时间'
},
{
field
:
'id'
,
title
:
'操作'
,
templet
:
'#operationTpl'
}
]],
});
form
.
on
(
'submit(form1)'
,
function
(
data
)
{
table
.
reload
(
"table1"
,
{
where
:
data
.
field
,
page
:
{
curr
:
1
},
});
return
false
;
});
//监听单元格事件
table
.
on
(
'tool(table1)'
,
function
(
obj
)
{
var
data
=
obj
.
data
;
if
(
obj
.
event
==
'delete'
)
{
layer
.
confirm
(
'真的要删除'
+
data
.
coin_name
+
'吗?'
,
{
icon
:
3
,
title
:
'删除'
},
function
(
index
)
{
layer
.
close
(
index
);
//向服务端发送删除指令
$
.
get
(
'/admin/coin-supported-coin/delete?id='
+
obj
.
data
.
id
,
function
(
data
,
status
)
{
if
(
data
.
code
==
0
)
{
obj
.
del
();
//删除对应行(tr)的DOM结构
}
layer
.
msg
(
data
.
msg
);
});
});
}
});
$
(
'#add'
).
click
(
function
()
{
//打开弹窗
$
.
get
(
'/admin/coin-supported-coin/add?platform_id='
+
platform_id
,
{},
function
(
str
)
{
var
index
=
layer
.
open
({
type
:
1
,
title
:
'添加数据'
,
id
:
'add-one'
,
skin
:
'layui-layer-lan'
,
area
:
[
'320px'
,
'auto'
],
content
:
str
,
btn
:
[
'确认'
,
'取消'
],
btn1
:
function
()
{
$
.
post
(
'/admin/coin-supported-coin/add'
,
$
(
"#addData"
).
serialize
(),
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
rev
.
code
==
0
)
{
layer
.
close
(
index
);
table
.
reload
(
"table1"
,
{});
}
});
}
});
layui
.
form
.
render
();
});
return
false
;
});
\ No newline at end of file
common/models/psources/CoinIssueCoinForm_.php
deleted
100644 → 0
View file @
accc1a5c
<?php
namespace
common\models\psources
;
use
yii\base\Model
;
class
CoinIssueCoinForm
extends
Model
{
public
$name
;
public
$symbol
;
public
$total
;
public
$owner
;
public
$introduction
;
public
$category
;
public
$platform_id
;
public
$chain_id
;
private
$_issue_coin_list
;
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
static
function
getDb
()
{
return
\Yii
::
$app
->
get
(
'p_sources'
);
}
public
function
rules
()
{
return
[
[[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
],
'required'
],
[[
'total'
,
'category'
,
'platform_id'
,
'chain_id'
],
'integer'
],
[
'introduction'
,
'string'
,
'length'
=>
[
1
,
20
]],
[
'symbol'
,
'string'
,
'length'
=>
[
1
,
20
]],
[
'name'
,
'string'
,
'length'
=>
[
1
,
6
]],
[
'symbol'
,
'unique'
],
[[
'total'
],
'issuableAmout'
]
];
}
public
function
isExist
(
$attribute
,
$params
)
{
var_dump
(
$attribute
,
$params
);
exit
;
}
public
function
issuableAmout
(
$attribute
,
$params
)
{
return
true
;
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
],
self
::
SCENARIOS_UPDATE
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
function
attributeLabels
()
{
return
[
'name'
=>
'Token简称'
,
'symbol'
=>
'Token全称'
,
'total'
=>
'发行数量'
,
'owner'
=>
'接收地址'
,
'introduction'
=>
'Token简介'
,
'category'
=>
'是否增加发'
,
'chain_id'
=>
'平行链名称'
];
}
public
function
getIsNewRecord
()
{
return
$this
->
_issue_coin_list
===
null
;
}
public
function
getIssueList
(
$id
)
{
$this
->
_issue_coin_list
=
CoinIssueCoin
::
find
()
->
where
(
'agent_id = :agent_id'
,
[
':agent_id'
=>
$id
])
->
one
();
if
(
$this
->
_issue_coin_list
)
{
$this
->
agent_id
=
$this
->
_issue_coin_list
->
agent_id
;
$this
->
title
=
$this
->
_issue_coin_list
->
title
;
$this
->
etitle
=
$this
->
_issue_coin_list
->
etitle
;
$this
->
description
=
$this
->
_issue_coin_list
->
description
;
$this
->
requirement
=
$this
->
_issue_coin_list
->
requirement
;
$this
->
status
=
$this
->
_issue_coin_list
->
status
;
}
return
$this
->
_issue_coin_list
;
}
/**
* 保存代理人
* @return boolean
*/
public
function
save
()
{
if
(
$this
->
validate
())
{
if
(
$this
->
getIsNewRecord
())
{
$this
->
_issue_coin_list
=
new
CoinIssueCoin
();
}
$this
->
_issue_coin_list
->
name
=
$this
->
name
;
$this
->
_issue_coin_list
->
symbol
=
$this
->
symbol
;
$this
->
_issue_coin_list
->
total
=
$this
->
total
;
$this
->
_issue_coin_list
->
owner
=
$this
->
owner
;
$this
->
_issue_coin_list
->
introduction
=
$this
->
introduction
;
$this
->
_issue_coin_list
->
category
=
$this
->
category
;
$this
->
_issue_coin_list
->
platform_id
=
$this
->
platform_id
;
$this
->
_issue_coin_list
->
chain_id
=
$this
->
chain_id
;
return
$this
->
_issue_coin_list
->
save
();
}
else
{
return
false
;
}
}
}
\ No newline at end of file
common/models/psources/CoinSupportedCoin.php
0 → 100644
View file @
706bb055
<?php
namespace
common\models\psources
;
use
Yii
;
use
yii\db\Expression
;
class
CoinSupportedCoin
extends
CommonActiveRecord
{
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_supported_coin}}'
;
}
public
function
rules
()
{
return
[
[[
'platform_id'
,
'coin_name'
],
'required'
],
[[
'platform_id'
],
'integer'
],
[
'coin_name'
,
'string'
,
'length'
=>
[
1
,
50
]],
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'platform_id'
,
'coin_name'
],
self
::
SCENARIOS_UPDATE
=>
[
'platform_id'
,
'coin_name'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
function
attributeLabels
()
{
return
[
'platform_id'
=>
'所属钱包'
,
'coin_name'
=>
'币种名称'
,
];
}
public
static
function
getList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[])
{
$query
=
self
::
find
();
foreach
(
$condition
as
$item
)
{
$query
=
$query
->
andWhere
(
$item
);
}
$count
=
$query
->
count
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
return
[
'count'
=>
$count
,
'data'
=>
$data
];
}
public
function
addOne
(
$params
)
{
$params
=
array_filter
(
$params
,
function
(
$value
)
{
if
(
null
==
$value
)
{
return
false
;
}
return
true
;
});
$this
->
setAttributes
(
$params
,
false
);
try
{
return
(
bool
)
$this
->
save
();
}
catch
(
\Exception
$exception
)
{
return
[
'code'
=>
$exception
->
getCode
(),
'message'
=>
$exception
->
getMessage
()];
}
}
}
\ 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