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
e3005072
Commit
e3005072
authored
Jan 10, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a
parent
4a49d213
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
7 deletions
+97
-7
IssueCoinController.php
api/controllers/IssueCoinController.php
+44
-4
CoinIssueCoin.php
common/models/psources/CoinIssueCoin.php
+27
-3
CoinIssueTemplate.php
common/models/psources/CoinIssueTemplate.php
+26
-0
No files found.
api/controllers/IssueCoinController.php
View file @
e3005072
...
...
@@ -4,6 +4,7 @@ namespace api\controllers;
use
common\components\ErrorMessage
;
use
common\models\psources\CoinIssueRevokeRecord
;
use
common\models\psources\CoinIssueTemplate
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
yii\data\Pagination
;
...
...
@@ -42,7 +43,7 @@ class IssueCoinController extends BaseController
goto
doEnd
;
}
$
result
=
[
$
params
=
[
'name'
=>
isset
(
$result
[
'name'
])
?
$result
[
'name'
]
:
''
,
'symbol'
=>
isset
(
$result
[
'symbol'
])
?
$result
[
'symbol'
]
:
''
,
'total'
=>
isset
(
$result
[
'total'
])
?
$result
[
'total'
]
:
''
,
...
...
@@ -59,12 +60,13 @@ class IssueCoinController extends BaseController
];
$model
=
new
CoinIssueCoin
();
if
(
35
==
$platform_id
)
{
$params
[
'template'
]
=
isset
(
$result
[
'template'
])
?
$result
[
'template'
]
:
[];
$model
->
setScenario
(
CoinIssueCoin
::
SCENARIOS_CREATE_MALL
);
}
else
{
$model
->
setScenario
(
CoinIssueCoin
::
SCENARIOS_CREATE
);
}
$model
->
load
(
$
result
,
''
);
$model
->
load
(
$
params
,
''
);
if
(
!
$model
->
validate
())
{
$msg
=
$model
->
errors
;
$code
=
-
1
;
...
...
@@ -122,7 +124,7 @@ class IssueCoinController extends BaseController
$code
=
-
1
;
goto
doEnd
;
}
$
result
=
[
$
params
=
[
'name'
=>
isset
(
$result
[
'name'
])
?
$result
[
'name'
]
:
''
,
'symbol'
=>
isset
(
$result
[
'symbol'
])
?
strtoupper
(
$result
[
'symbol'
])
:
''
,
'total'
=>
isset
(
$result
[
'total'
])
?
$result
[
'total'
]
:
''
,
...
...
@@ -139,6 +141,7 @@ class IssueCoinController extends BaseController
];
$model
=
new
CoinIssueCoin
();
if
(
35
==
$platform_id
)
{
$params
[
'template'
]
=
isset
(
$result
[
'template'
])
?
$result
[
'template'
]
:
[];
$model
->
setScenario
(
CoinIssueCoin
::
SCENARIOS_CREATE_MALL
);
}
else
{
$model
->
setScenario
(
CoinIssueCoin
::
SCENARIOS_CREATE
);
...
...
@@ -152,6 +155,12 @@ class IssueCoinController extends BaseController
$msg
=
'ok'
;
$code
=
0
;
$data
=
$model
->
getPrimaryKey
();
if
(
35
==
$platform_id
)
{
$template
=
new
CoinIssueTemplate
();
$template
->
issue_coin_id
=
$data
;
$template
->
template
=
isset
(
$result
[
'template'
])
?
$result
[
'template'
]
:
[];
$template
->
save
();
}
$params
=
[
'pre_create_tx'
=>
$pre_create_tx
,
...
...
@@ -245,6 +254,7 @@ class IssueCoinController extends BaseController
$data
->
total
=
(
int
)
$data
->
total
*
1e4
;
$data
->
chain_name
=
$data
->
chain
->
platform
;
$data
->
issue_charge
=
rtrim
(
sprintf
(
'%.3f'
,
floatval
(
$data
->
charge
)),
'0'
);
$data
->
template
=
isset
(
$data
->
templated
->
template
)
?
$data
->
templated
->
template
:
[];
$code
=
0
;
$msg
=
'success'
;
if
(
CoinIssueCoin
::
STATUS_FAILED
==
$data
->
status
)
{
...
...
@@ -262,7 +272,6 @@ class IssueCoinController extends BaseController
$msg
=
'发行失败。失败原因:'
.
$data
->
transfer
->
finish_query_transaction
;
}
if
(
CoinIssueCoin
::
STATUS_CANCEL_FAILED
==
$data
->
status
)
{
$code
=
-
1
;
$msg
=
'撤消失败。失败原因:'
.
ErrorMessage
::
getMessage
(
$data
->
revoke
->
revoke_query_transaction
);
...
...
@@ -472,4 +481,34 @@ class IssueCoinController extends BaseController
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
];
}
public
function
actionSymbolValidate
()
{
$code
=
0
;
$msg
=
'success'
;
$symbol
=
Yii
::
$app
->
request
->
post
(
'symbol'
,
''
);
if
(
false
==
$symbol
)
{
$msg
=
'缺少必要的参数'
;
$code
=
-
1
;
$data
=
null
;
goto
doEnd
;
}
$model
=
CoinIssueCoin
::
find
()
->
where
([
'symbol'
=>
$symbol
,
'platform_id'
=>
35
])
->
asArray
()
->
one
();
if
(
empty
(
$model
))
{
$data
=
$symbol
;
goto
doEnd
;
}
$data
=
$model
[
'symbol'
];
$suffix
=
substr
(
$data
,
-
1
);
if
(
is_numeric
(
$suffix
))
{
$prefix
=
substr
(
$data
,
0
,
-
1
);
$data
=
$prefix
.
(
$suffix
+
1
);
}
else
{
$data
=
$data
.
1
;
}
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
\ No newline at end of file
common/models/psources/CoinIssueCoin.php
View file @
e3005072
...
...
@@ -47,13 +47,14 @@ class CoinIssueCoin extends CommonActiveRecord
public
function
rules
()
{
return
[
[[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'type'
,
'platform_id'
,
'chain_id'
,
'charge_unit'
,
'charge'
],
'required'
],
[[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'type'
,
'platform_id'
,
'chain_id'
,
'charge_unit'
,
'charge'
,
'template'
],
'required'
],
[[
'total'
,
'category'
,
'type'
,
'platform_id'
,
'chain_id'
],
'integer'
],
[[
'introduction'
,
'charge_unit'
],
'string'
,
'length'
=>
[
1
,
20
]],
[
'symbol'
,
'string'
,
'length'
=>
[
6
,
128
]],
[
'name'
,
'string'
,
'length'
=>
[
3
,
50
]],
[
'nickname'
,
'string'
,
'length'
=>
[
0
,
10
]],
[[
'token_type'
,
'nickname'
],
'safe'
],
[
'template'
,
'verfiyTemplate'
],
#['status', 'in', 'range' => [1, 2, 0]],
[
'name'
,
'verfiyName'
],
[
'symbol'
,
'verfiySymbol'
],
...
...
@@ -65,13 +66,29 @@ class CoinIssueCoin extends CommonActiveRecord
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'type'
,
'platform_id'
,
'chain_id'
,
'charge_unit'
,
'charge'
,
'token_type'
,
'nickname'
],
self
::
SCENARIOS_CREATE_MALL
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'type'
,
'platform_id'
,
'chain_id'
,
'token_type'
,
'nickname'
],
self
::
SCENARIOS_CREATE_MALL
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'type'
,
'platform_id'
,
'chain_id'
,
'token_type'
,
'nickname'
,
'template'
],
self
::
SCENARIOS_UPDATE
=>
[
'status'
],
self
::
SCENARIOS_CANCEL
=>
[
'status'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
function
verfiyTemplate
(
$attribute
,
$params
)
{
if
(
3
==
$this
->
token_type
)
{
if
(
empty
(
$this
->
template
))
{
$this
->
addError
(
$attribute
,
'缺少必要的模板参数'
);
return
false
;
}
foreach
(
$this
->
template
as
$key
=>
$val
)
{
if
(
empty
(
$val
))
{
$this
->
addError
(
$attribute
,
$key
.
'不能为空'
);
return
false
;
}
}
}
}
public
function
verfiyName
(
$attribute
,
$params
)
{
//增发
...
...
@@ -159,12 +176,13 @@ class CoinIssueCoin extends CommonActiveRecord
'msg'
=>
'失败原因'
,
'status'
=>
'状态'
,
'charge_unit'
=>
'手续费'
,
'template'
=>
'模板'
,
];
}
public
function
attributes
()
{
return
array_merge
(
parent
::
attributes
(),
[
'issue_charge'
,
'url'
,
'chain_name'
]);
return
array_merge
(
parent
::
attributes
(),
[
'issue_charge'
,
'url'
,
'chain_name'
,
'template'
]);
}
public
function
getChain
()
...
...
@@ -186,4 +204,9 @@ class CoinIssueCoin extends CommonActiveRecord
{
return
$this
->
hasOne
(
CoinIssueRevokeRecord
::
className
(),
[
'issue_coin_id'
=>
'id'
]);
}
public
function
getTemplated
()
{
return
$this
->
hasOne
(
CoinIssueTemplate
::
className
(),
[
'issue_coin_id'
=>
'id'
])
->
select
(
'template'
);
}
}
\ No newline at end of file
common/models/psources/CoinIssueTemplate.php
0 → 100644
View file @
e3005072
<?php
namespace
common\models\psources
;
use
Yii
;
use
yii\db\Expression
;
class
CoinIssueTemplate
extends
CommonActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_issue_template}}'
;
}
public
function
getTransfer
()
{
return
$this
->
hasOne
(
CoinIssueCoin
::
className
(),
[
'issue_coin_id'
=>
'id'
]);
}
}
\ 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