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
bbd14bd7
Commit
bbd14bd7
authored
Feb 05, 2020
by
shajiaming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
h5平行链
parent
818a227d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
207 additions
and
0 deletions
+207
-0
WalletChainController.php
api/controllers/WalletChainController.php
+145
-0
WalletChain.php
common/models/psources/WalletChain.php
+62
-0
No files found.
api/controllers/WalletChainController.php
0 → 100644
View file @
bbd14bd7
<?php
namespace
api\controllers
;
use
Yii
;
use
api\base\BaseController
;
use
common\models\psources\WalletChain
;
use
yii\data\Pagination
;
class
WalletChainController
extends
BaseController
{
/**
* h5发行链列表
* @param string wallet_address
* @return array
*/
public
function
actionChains
()
{
if
(
!
Yii
::
$app
->
request
->
isGet
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'请求方式错误!'
;
goto
doEnd
;
}
$params
=
Yii
::
$app
->
request
->
get
();
$wallet_address
=
isset
(
$params
[
'wallet_address'
])
?
$params
[
'wallet_address'
]
:
''
;
if
(
false
==
$wallet_address
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'参数错误'
;
goto
doEnd
;
}
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$size
=
Yii
::
$app
->
request
->
get
(
'size'
,
10
);
$query
=
WalletChain
::
find
()
->
select
(
'id, token, platform'
)
->
where
([
'wallet_address'
=>
$wallet_address
])
->
orderBy
(
'id'
);
$model
=
$query
->
offset
((
$page
-
1
)
*
$size
)
->
orderBy
(
'create_time desc'
)
->
limit
(
$size
)
->
asArray
()
->
all
();
$countQuery
=
clone
$query
;
$pages
=
new
Pagination
([
'totalCount'
=>
$countQuery
->
count
(),
'pageSize'
=>
$size
]);
$this
->
data
=
[
'list'
=>
$model
,
'page'
=>
[
'pageCount'
=>
$pages
->
pageCount
,
'pageSize'
=>
$size
,
'currentPage'
=>
$page
,
]
];
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
}
/**
* h5发行链
* @param string platform
* @param string address
* @param string private_key
* @param string fee
* @param string token
* @param string host
* @param string port
* @param string wallet_address
* @param string hash
* @return array
*/
public
function
actionChain
()
{
$request
=
Yii
::
$app
->
request
;
if
(
!
$request
->
isPost
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'请求方式错误!'
;
goto
doEnd
;
}
$post
=
$request
->
post
();
$model
=
new
WalletChain
();
$model
->
setScenario
(
WalletChain
::
SCENARIOS_CREATE
);
$params
=
[
'platform'
=>
isset
(
$post
[
'platform'
])
?
$post
[
'platform'
]
:
''
,
'address'
=>
isset
(
$post
[
'address'
])
?
$post
[
'address'
]
:
''
,
'private_key'
=>
isset
(
$post
[
'private_key'
])
?
$post
[
'private_key'
]
:
''
,
'token'
=>
isset
(
$post
[
'token'
])
?
strtoupper
(
$post
[
'token'
])
:
''
,
'host'
=>
isset
(
$post
[
'host'
])
?
$post
[
'host'
]
:
''
,
'port'
=>
isset
(
$post
[
'port'
])
?
$post
[
'port'
]
:
''
,
'wallet_address'
=>
isset
(
$post
[
'wallet_address'
])
?
$post
[
'wallet_address'
]
:
''
,
'hash'
=>
isset
(
$post
[
'hash'
])
?
$post
[
'hash'
]
:
''
,
'fee'
=>
isset
(
$post
[
'fee'
])
?
$post
[
'fee'
]
:
''
];
if
(
$model
->
load
(
$params
,
''
)
&&
$model
->
save
())
{
goto
doEnd
;
}
$this
->
msg
=
$model
->
errors
;
$this
->
code
=
-
1
;
goto
doEnd
;
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
}
/**
* h5发行链
* @param string wallet_address
* @return array
*/
public
function
actionDetail
()
{
if
(
!
Yii
::
$app
->
request
->
isGet
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'请求方式错误!'
;
goto
doEnd
;
}
$params
=
Yii
::
$app
->
request
->
get
();
$id
=
isset
(
$params
[
'id'
])
?
$params
[
'id'
]
:
''
;
if
(
false
==
$id
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'参数错误'
;
goto
doEnd
;
}
$model
=
WalletChain
::
find
()
->
select
(
'platform, token, address, private_key, fee, host, port, hash'
)
->
where
([
'id'
=>
(
int
)
$id
])
->
asArray
()
->
one
();
if
(
empty
(
$model
))
{
goto
doEnd
;
}
$model
[
'fee'
]
=
$model
[
'fee'
]
.
$model
[
'token'
];
$model
[
'charge'
]
=
'10BTY'
;
$this
->
data
=
$model
;
goto
doEnd
;
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
}
}
\ No newline at end of file
common/models/psources/WalletChain.php
0 → 100644
View file @
bbd14bd7
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
WalletChain
extends
BaseActiveRecord
{
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{wallet_chain}}'
;
}
public
function
attributeLabels
()
{
return
[
'id'
=>
'ID'
,
'platform'
=>
'平行链名称'
,
'address'
=>
'代扣地址'
,
'private_key'
=>
'代扣私钥'
,
'execer'
=>
'执行器'
,
'fee'
=>
'手续费'
,
'brower_url'
=>
'浏览器链接'
,
'token'
=>
'手续费(基础代币)'
,
'host'
=>
'钱包服务IP'
,
'port'
=>
'钱包服务端口'
,
'wallet_address'
=>
'钱包地址'
,
'hash'
=>
'申请费用hash'
];
}
public
function
rules
()
{
return
[
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
,
'hash'
,
'port'
,
'fee'
],
'required'
],
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
,
'hash'
],
'string'
],
[[
'platform'
],
'string'
,
'length'
=>
[
1
,
30
]],
[[
'token'
],
'string'
,
'length'
=>
[
1
,
10
]],
[[
'port'
],
'integer'
]
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'platform'
,
'token'
,
'address'
,
'private_key'
,
'fee'
,
'host'
,
'port'
,
'wallet_address'
,
'hash'
],
self
::
SCENARIOS_UPDATE
=>
[
'platform'
,
'token'
,
'address'
,
'private_key'
,
'fee'
,
'host'
,
'port'
,
'wallet_address'
,
'hash'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
\ 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