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
7c5aa62a
Commit
7c5aa62a
authored
5 years ago
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一键发币
parent
ed4df541
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
207 additions
and
15 deletions
+207
-15
IssueChainController.php
api/controllers/IssueChainController.php
+2
-0
IssueCoinController.php
api/controllers/IssueCoinController.php
+54
-5
CoinIssueCoin.php
common/models/psources/CoinIssueCoin.php
+27
-6
CoinIssueRecord.php
common/models/psources/CoinIssueRecord.php
+42
-0
CoinPlatform.php
common/models/psources/CoinPlatform.php
+6
-1
IssueChainController.php
wallet/controllers/IssueChainController.php
+68
-0
IssueCoinController.php
wallet/controllers/IssueCoinController.php
+8
-3
No files found.
api/controllers/IssueChainController.php
View file @
7c5aa62a
...
...
@@ -40,6 +40,8 @@ class IssueChainController extends BaseController
foreach
(
$chain_model
as
&
$val
)
{
$val
->
chain_name
=
isset
(
$val
->
chain
->
platform
)
?
$val
->
chain
->
platform
:
''
;
$val
->
issue_charge
=
(
int
)
$val
->
issue_charge
;
$val
->
charge_unit
=
$val
->
gas
->
coin_name
;
unset
(
$val
->
download_url
);
unset
(
$val
->
introduce
);
unset
(
$val
->
create_time
);
...
...
This diff is collapsed.
Click to expand it.
api/controllers/IssueCoinController.php
View file @
7c5aa62a
...
...
@@ -2,10 +2,10 @@
namespace
api\controllers
;
use
common\models\psources\CoinIssueRecord
;
use
Yii
;
use
yii\data\Pagination
;
use
api\base\BaseController
;
use
common\models\psources\CoinPlatform
;
use
common\models\psources\CoinIssueCoin
;
class
IssueCoinController
extends
BaseController
...
...
@@ -37,7 +37,6 @@ class IssueCoinController extends BaseController
}
$result
=
Yii
::
$app
->
request
->
post
();
$chain_id
=
isset
(
$result
[
'chain_id'
])
?
$result
[
'chain_id'
]
:
0
;
$issue_charge
=
CoinPlatform
::
find
()
->
where
([
'id'
=>
$platform_id
])
->
asArray
()
->
one
();
if
(
false
==
$chain_id
)
{
$msg
=
'不存在的链'
;
$code
=
-
1
;
...
...
@@ -48,11 +47,12 @@ class IssueCoinController extends BaseController
'symbol'
=>
isset
(
$result
[
'symbol'
])
?
strtoupper
(
$result
[
'symbol'
])
:
''
,
'total'
=>
isset
(
$result
[
'total'
])
?
$result
[
'total'
]
:
''
,
'owner'
=>
isset
(
$result
[
'owner'
])
?
$result
[
'owner'
]
:
''
,
'url'
=>
isset
(
$result
[
'url'
])
?
$result
[
'url'
]
:
''
,
'introduction'
=>
isset
(
$result
[
'introduction'
])
?
$result
[
'introduction'
]
:
''
,
'category'
=>
isset
(
$result
[
'category'
])
?
$result
[
'category'
]
:
0
,
'platform_id'
=>
$platform_id
,
'chain_id'
=>
$chain_id
,
'charge
'
=>
$issue_charge
[
'issue_charge'
]
'charge
_unit_id'
=>
isset
(
$result
[
'charge_unit_id'
])
?
$result
[
'charge_unit_id'
]
:
''
];
$model
->
load
(
$result
,
''
);
if
(
!
$model
->
save
())
{
...
...
@@ -63,7 +63,10 @@ class IssueCoinController extends BaseController
$msg
=
'ok'
;
$code
=
0
;
$data
=
$model
->
getPrimaryKey
();
$coin_issue_record
=
new
CoinIssueRecord
();
$coin_issue_record
->
platform_id
=
$platform_id
;
$coin_issue_record
->
total
=
$result
[
'total'
];
$coin_issue_record
->
save
();
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
...
...
@@ -98,6 +101,7 @@ class IssueCoinController extends BaseController
$pages
=
new
Pagination
([
'totalCount'
=>
$countQuery
->
count
(),
'pageSize'
=>
$size
]);
foreach
(
$models
as
&
$val
)
{
$val
->
chain_id
=
$val
->
chain
->
platform
;
$val
->
total
=
(
int
)
$val
->
total
*
1e8
;
}
$data
=
[
'list'
=>
$models
,
...
...
@@ -124,11 +128,55 @@ class IssueCoinController extends BaseController
goto
doEnd
;
}
$data
=
CoinIssueCoin
::
find
()
->
where
([
'id'
=>
$id
])
->
asArray
()
->
one
();
$data
=
CoinIssueCoin
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
$data
->
total
=
(
int
)
$data
->
total
*
1e8
;
$data
->
chain_id
=
$data
->
chain
->
platform
;
$data
->
charge
=
isset
(
$data
->
platform
->
issue_charge
)
?
(
int
)
$data
->
platform
->
issue_charge
:
0
;
$data
->
charge_unit
=
isset
(
$data
->
gas
->
coin_name
)
?
$data
->
gas
->
coin_name
:
''
;
$code
=
0
;
$msg
=
'success'
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionVerify
()
{
$id
=
Yii
::
$app
->
request
->
post
(
'id'
,
''
);
if
(
false
==
$id
)
{
$msg
=
'缺少必要的参数'
;
$code
=
-
1
;
goto
doEnd
;
}
$model
=
CoinIssueCoin
::
findOne
(
$id
);
if
(
false
==
$model
)
{
$msg
=
'不存在的记录'
;
$code
=
-
1
;
goto
doEnd
;
}
if
(
$model
->
status
>
CoinIssueCoin
::
UN_AUDIT
)
{
$msg
=
'不允许取消的发行'
;
$code
=
-
1
;
goto
doEnd
;
}
$data
=
[
'status'
=>
CoinIssueCoin
::
CANCEL_ISSUE
,
];
$model
->
setScenario
(
CoinIssueCoin
::
SCENARIOS_CANCEL
);
$model
->
load
(
$data
,
''
);
if
(
!
$model
->
save
())
{
$msg
=
current
(
$model
->
firstErrors
);
$code
=
-
1
;
goto
doEnd
;
}
$code
=
0
;
$msg
=
'success'
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
];
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
common/models/psources/CoinIssueCoin.php
View file @
7c5aa62a
...
...
@@ -20,6 +20,7 @@ class CoinIssueCoin extends CommonActiveRecord
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
const
SCENARIOS_CANCEL
=
'cancel'
;
public
static
function
getDb
()
{
...
...
@@ -34,22 +35,34 @@ class CoinIssueCoin extends CommonActiveRecord
public
function
rules
()
{
return
[
[[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'
introduction'
,
'category'
,
'platform_id'
,
'chain
_id'
],
'required'
],
[[
'total'
,
'category'
,
'platform_id'
,
'chain_id'
],
'integer'
],
[[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'
url'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
,
'charge_unit
_id'
],
'required'
],
[[
'total'
,
'category'
,
'platform_id'
,
'chain_id'
,
'charge_unit_id'
],
'integer'
],
[
'introduction'
,
'string'
,
'length'
=>
[
1
,
20
]],
[
'symbol'
,
'string'
,
'length'
=>
[
1
,
20
]],
[
'msg'
,
'string'
,
'length'
=>
[
1
,
10
]],
[
'name'
,
'string'
,
'length'
=>
[
1
,
6
]],
[
'status'
,
'in'
,
'range'
=>
[
1
,
2
,
0
]],
#
['status', 'in', 'range' => [1, 2, 0]],
[
'symbol'
,
'unique'
],
[
'url'
,
'url'
],
[
'total'
,
'verfiyAmount'
]
];
}
public
function
verfiyAmount
(
$attribute
,
$params
)
{
$issue_record
=
CoinIssueRecord
::
find
()
->
where
([
'platform_id'
=>
$this
->
platform_id
])
->
sum
(
'total'
);
$issue_record
=
empty
(
$issue_record
)
?
0
:
$issue_record
;
if
(
$issue_record
+
$this
->
$attribute
>=
900
)
{
$this
->
addError
(
$this
->
$attribute
,
'最大发行量900亿,目前已发行'
.
$issue_record
.
'亿'
);
}
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
],
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
,
'url'
,
'charge_unit_id'
],
self
::
SCENARIOS_UPDATE
=>
[
'status'
,
'msg'
],
self
::
SCENARIOS_CANCEL
=>
[
'status'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
...
...
@@ -65,13 +78,15 @@ class CoinIssueCoin extends CommonActiveRecord
'category'
=>
'是否增发'
,
'chain_id'
=>
'平行链名称'
,
'msg'
=>
'失败原因'
,
'status'
=>
'状态'
'status'
=>
'状态'
,
'charge_unit_id'
=>
'手续费'
,
'url'
=>
'浏览器地址'
];
}
public
function
attributes
()
{
return
array_merge
(
parent
::
attributes
(),
[
'charge'
]);
return
array_merge
(
parent
::
attributes
(),
[
'charge'
,
'charge_unit'
]);
}
/**
...
...
@@ -95,4 +110,9 @@ class CoinIssueCoin extends CommonActiveRecord
{
return
$this
->
hasOne
(
CoinPlatform
::
className
(),
[
'id'
=>
'platform_id'
]);
}
public
function
getGas
()
{
return
$this
->
hasOne
(
CoinSupportedCoin
::
className
(),
[
'id'
=>
'charge_unit_id'
]);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
common/models/psources/CoinIssueRecord.php
0 → 100644
View file @
7c5aa62a
<?php
namespace
common\models\psources
;
use
Yii
;
class
CoinIssueRecord
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_issue_record}}'
;
}
public
function
rules
()
{
return
[
[[
'platform_id'
,
'total'
],
'required'
],
[[
'total'
,
'platform_id'
],
'integer'
],
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'platform_id'
,
'total'
],
self
::
SCENARIOS_UPDATE
=>
[
'platform_id'
,
'total'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
common/models/psources/CoinPlatform.php
View file @
7c5aa62a
...
...
@@ -77,11 +77,16 @@ class CoinPlatform extends BaseActiveRecord
public
function
attributes
()
{
return
array_merge
(
parent
::
attributes
(),
[
'chain_name'
]);
return
array_merge
(
parent
::
attributes
(),
[
'chain_name'
,
'charge_unit'
]);
}
public
function
getChain
()
{
return
$this
->
hasOne
(
CoinPlatformWithHold
::
className
(),
[
'id'
=>
'chain_id'
]);
}
public
function
getGas
()
{
return
$this
->
hasOne
(
CoinSupportedCoin
::
className
(),
[
'id'
=>
'charge_unit_id'
]);
}
}
This diff is collapsed.
Click to expand it.
wallet/controllers/IssueChainController.php
View file @
7c5aa62a
...
...
@@ -3,6 +3,7 @@
namespace
wallet\controllers
;
use
common\models\psources\CoinPlatform
;
use
common\models\psources\CoinSupportedCoin
;
use
Yii
;
use
wallet\base\BaseController
;
...
...
@@ -48,9 +49,76 @@ class IssueChainController extends BaseController
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionChainInfo
()
{
$data
=
null
;
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
if
(
empty
(
$platform_id
))
{
$msg
=
'缺少必要的参数'
;
$code
=
-
1
;
goto
doEnd
;
}
if
(
1
==
$platform_id
)
{
$chain_model
=
CoinPlatform
::
find
()
->
select
(
'id, chain_id'
)
->
all
();
}
else
{
$chain_model
=
CoinPlatform
::
find
()
->
select
(
'id, chain_id'
)
->
where
([
'id'
=>
$platform_id
])
->
all
();
}
if
(
false
==
$chain_model
)
{
$msg
=
'不存在的链'
;
$code
=
-
1
;
goto
doEnd
;
}
foreach
(
$chain_model
as
&
$val
)
{
$val
->
chain_name
=
isset
(
$val
->
chain
->
platform
)
?
$val
->
chain
->
platform
:
''
;
$coin_supported_coin
=
CoinSupportedCoin
::
find
()
->
select
(
'id, coin_name'
)
->
where
([
'platform_id'
=>
$val
->
id
])
->
asArray
()
->
all
();
$val
->
charge_unit
=
$coin_supported_coin
;
}
$msg
=
'ok'
;
$code
=
0
;
$data
=
is_array
(
$chain_model
)
?
$chain_model
:
[
$chain_model
];
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionSetCharge
()
{
$data
=
null
;
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$result
=
Yii
::
$app
->
request
->
post
();
$issue_charge
=
isset
(
$result
[
'issue_charge'
])
?
$result
[
'issue_charge'
]
:
''
;
$charge_unit_id
=
isset
(
$result
[
'charge_unit_id'
])
?
strtoupper
(
$result
[
'charge_unit_id'
])
:
''
;
if
(
false
==
$issue_charge
||
false
==
$charge_unit_id
)
{
$msg
=
'提交数据有误'
;
$code
=
-
1
;
goto
doEnd
;
}
$chain_model
=
CoinPlatform
::
find
()
->
where
([
'id'
=>
$platform_id
])
->
one
();
if
(
false
==
$chain_model
)
{
$msg
=
'不存在的链'
;
$code
=
-
1
;
goto
doEnd
;
}
$chain_model
->
issue_charge
=
$issue_charge
;
$chain_model
->
charge_unit_id
=
$charge_unit_id
;
if
(
false
==
$chain_model
->
save
())
{
$msg
=
'手续费设置失败'
;
$code
=
-
1
;
goto
doEnd
;
}
$msg
=
'ok'
;
$code
=
0
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
];
}
public
function
actionManageReview
()
...
...
This diff is collapsed.
Click to expand it.
wallet/controllers/IssueCoinController.php
View file @
7c5aa62a
...
...
@@ -19,11 +19,11 @@ class IssueCoinController extends BaseController
$chain_id
=
\Yii
::
$app
->
request
->
get
(
'chain_id'
,
''
);
if
(
1
==
$platform_id
)
{
$query
=
CoinIssueCoin
::
find
()
->
select
(
'id, name, total, status, chain_id, platform_id, owner, category, symbol, introduction, create_time'
)
->
select
(
'id, name, total, status, chain_id,
url, charge_unit_id,
platform_id, owner, category, symbol, introduction, create_time'
)
->
orderBy
(
'create_time desc'
);
}
else
{
$query
=
CoinIssueCoin
::
find
()
->
select
(
'id, name, total, status, chain_id, platform_id, owner, category, symbol, introduction, create_time'
)
->
select
(
'id, name, total, status, chain_id,
url, charge_unit_id,
platform_id, owner, category, symbol, introduction, create_time'
)
->
where
([
'platform_id'
=>
$platform_id
])
->
orderBy
(
'create_time desc'
);
}
...
...
@@ -48,6 +48,8 @@ class IssueCoinController extends BaseController
foreach
(
$models
as
&
$val
)
{
$val
->
chain_id
=
$val
->
chain
->
platform
;
$val
->
charge
=
isset
(
$val
->
platform
->
issue_charge
)
?
(
int
)
$val
->
platform
->
issue_charge
:
0
;
$val
->
charge_unit
=
isset
(
$val
->
gas
->
coin_name
)
?
$val
->
gas
->
coin_name
:
''
;
$val
->
total
=
(
int
)
$val
->
total
*
1e8
;
}
$data
=
[
'list'
=>
$models
,
...
...
@@ -74,7 +76,10 @@ class IssueCoinController extends BaseController
goto
doEnd
;
}
$data
=
CoinIssueCoin
::
find
()
->
where
([
'id'
=>
$id
])
->
asArray
()
->
one
();
$data
=
CoinIssueCoin
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
$data
->
total
=
(
int
)
$data
->
total
*
1e8
;
$data
->
charge
=
isset
(
$data
->
platform
->
issue_charge
)
?
(
int
)
$data
->
platform
->
issue_charge
:
0
;
$data
->
charge_unit
=
isset
(
$data
->
gas
->
coin_name
)
?
$data
->
gas
->
coin_name
:
''
;
$code
=
0
;
$msg
=
'success'
;
...
...
This diff is collapsed.
Click to expand it.
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