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
11f9ce15
Commit
11f9ce15
authored
Oct 31, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发币
parent
8e5e1f52
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
149 additions
and
7 deletions
+149
-7
IssueCoinController.php
api/controllers/IssueCoinController.php
+20
-4
CoinIssueChainRecord.php
common/models/psources/CoinIssueChainRecord.php
+39
-0
CoinIssueCoin.php
common/models/psources/CoinIssueCoin.php
+8
-3
IssueChainTransferController.php
console/controllers/IssueChainTransferController.php
+82
-0
No files found.
api/controllers/IssueCoinController.php
View file @
11f9ce15
...
...
@@ -2,12 +2,12 @@
namespace
api\controllers
;
use
common\models\psources\CoinIssueRecord
;
use
common\models\psources\CoinPlatform
;
use
Yii
;
use
yii\data\Pagination
;
use
api\base\BaseController
;
use
common\models\psources\CoinPlatform
;
use
common\models\psources\CoinIssueCoin
;
use
common\models\psources\CoinIssueChainRecord
;
class
IssueCoinController
extends
BaseController
{
...
...
@@ -49,6 +49,14 @@ class IssueCoinController extends BaseController
$code
=
-
1
;
goto
doEnd
;
}
$pre_create_tx
=
isset
(
$result
[
'pre_create_tx'
])
?
$result
[
'pre_create_tx'
]
:
''
;
if
(
false
==
$pre_create_tx
)
{
$msg
=
'预签名错误'
;
$code
=
-
1
;
goto
doEnd
;
}
$result
=
[
'name'
=>
isset
(
$result
[
'name'
])
?
$result
[
'name'
]
:
''
,
'symbol'
=>
isset
(
$result
[
'symbol'
])
?
strtoupper
(
$result
[
'symbol'
])
:
''
,
...
...
@@ -60,8 +68,6 @@ class IssueCoinController extends BaseController
'chain_id'
=>
$chain_id
,
'charge_unit_id'
=>
isset
(
$result
[
'charge_unit_id'
])
?
$result
[
'charge_unit_id'
]
:
''
,
'charge'
=>
$coin_platform
->
issue_charge
,
'step_one_tx'
=>
isset
(
$result
[
'step_one_tx'
])
?
$result
[
'step_one_tx'
]
:
''
,
'step_one_result'
=>
0
];
$model
->
load
(
$result
,
''
);
if
(
!
$model
->
save
())
{
...
...
@@ -73,6 +79,16 @@ class IssueCoinController extends BaseController
$code
=
0
;
$data
=
$model
->
getPrimaryKey
();
$params
=
[
'pre_create_tx'
=>
$pre_create_tx
,
'finish_tx'
=>
'0'
,
'issue_coin_id'
=>
$data
,
];
$transfer_model
=
new
CoinIssueChainRecord
();
$transfer_model
->
setScenario
(
CoinIssueChainRecord
::
SCENARIOS_PRE_CREATE
);
$transfer_model
->
load
(
$params
,
''
);
$transfer_model
->
save
();
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
...
...
common/models/psources/CoinIssueChainRecord.php
0 → 100644
View file @
11f9ce15
<?php
namespace
common\models\psources
;
use
Yii
;
class
CoinIssueChainRecord
extends
CommonActiveRecord
{
//定义场景
const
SCENARIOS_PRE_CREATE
=
'create'
;
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_issue_chain_record}}'
;
}
public
function
rules
()
{
return
[
[[
'pre_create_tx'
,
'pre_send_transaction'
,
'pre_query_transaction'
,
'finish_tx'
,
'finish_send_transaction'
,
'finish_query_transaction'
,
'issue_coin_id'
],
'required'
],
[[
'issue_coin_id'
],
'integer'
],
[[
'finish_tx'
],
'safe'
]
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_PRE_CREATE
=>
[
'pre_create_tx'
,
'issue_coin_id'
,
'finish_tx'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
\ No newline at end of file
common/models/psources/CoinIssueCoin.php
View file @
11f9ce15
...
...
@@ -39,7 +39,7 @@ class CoinIssueCoin extends CommonActiveRecord
public
function
rules
()
{
return
[
[[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
,
'charge_unit_id'
,
'charge'
,
'step_one_tx'
],
'required'
],
[[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
,
'charge_unit_id'
,
'charge'
],
'required'
],
[[
'total'
,
'category'
,
'platform_id'
,
'chain_id'
,
'charge_unit_id'
],
'integer'
],
[
'introduction'
,
'string'
,
'length'
=>
[
1
,
20
]],
[
'symbol'
,
'string'
,
'length'
=>
[
1
,
6
]],
...
...
@@ -89,7 +89,7 @@ class CoinIssueCoin extends CommonActiveRecord
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
,
'charge_unit_id'
,
'charge'
,
'step_one_tx'
,
'step_one_result'
],
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
,
'charge_unit_id'
,
'charge'
],
self
::
SCENARIOS_UPDATE
=>
[
'status'
,
'msg'
],
self
::
SCENARIOS_CANCEL
=>
[
'status'
],
];
...
...
@@ -109,7 +109,6 @@ class CoinIssueCoin extends CommonActiveRecord
'msg'
=>
'失败原因'
,
'status'
=>
'状态'
,
'charge_unit_id'
=>
'手续费'
,
'step_one_tx'
=>
'签名'
,
];
}
...
...
@@ -144,4 +143,9 @@ class CoinIssueCoin extends CommonActiveRecord
{
return
$this
->
hasOne
(
CoinSupportedCoin
::
className
(),
[
'id'
=>
'charge_unit_id'
]);
}
public
function
getTransfer
()
{
return
$this
->
hasOne
(
CoinIssueChainTransfer
::
className
(),
[
'issue_coin_id'
=>
'id'
]);
}
}
\ No newline at end of file
console/controllers/IssueChainTransferController.php
0 → 100644
View file @
11f9ce15
<?php
namespace
console\controllers
;
use
common\models\psources\CoinIssueChainRecord
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
yii\console\Controller
;
class
IssueChainTransferController
extends
Controller
{
public
function
actionSendTransaction
(
$step
)
{
if
(
1
==
$step
)
{
$columns
=
[
'id'
,
'pre_create_tx'
,
'issue_coin_id'
];
$condition
=
[
'pre_send_transaction'
=>
'0'
,
'pre_query_transaction'
=>
'0'
];
}
if
(
2
==
$step
)
{
$columns
=
[
'id'
,
'finish_tx'
,
'issue_coin_id'
];
$condition
=
[
'pre_query_transaction'
=>
'success'
,
'finish_send_transaction'
=>
'0'
,
'finish_query_transaction'
=>
'0'
];
}
$model
=
CoinIssueChainRecord
::
find
()
->
select
(
$columns
)
->
where
(
$condition
)
->
all
();
if
(
false
==
$model
)
{
echo
date
(
'Y-m-d H:i:s'
)
.
' STEP: '
.
$step
.
'暂无交易计划'
.
PHP_EOL
;
return
0
;
}
$node
=
Yii
::
$app
->
params
[
'chain_nodes'
][
'STO'
];
$chain_service
=
new
Chain33Service
(
$node
);
foreach
(
$model
as
$val
)
{
$result
=
$chain_service
->
sendTransaction
(
$val
->
pre_create_tx
);
if
(
0
!=
$result
[
'code'
])
{
$params
=
[
'pre_query_transaction'
=>
$result
[
'msg'
]
];
goto
doEnd
;
}
$params
=
[
'pre_send_transaction'
=>
$result
[
'result'
]
];
doEnd
:
$current_record
=
CoinIssueChainRecord
::
findOne
(
$val
->
id
);
$current_record
->
load
(
$params
,
''
);
$current_record
->
update
();
echo
json_encode
(
$current_record
->
errors
);
exit
;
}
}
public
function
actionQueryTransaction
(
$step
)
{
if
(
1
==
$step
)
{
$model
=
CoinIssueChainRecord
::
find
()
->
where
([
'<>'
,
'pre_send_transaction'
,
'0'
])
->
all
();
}
if
(
2
==
$step
)
{
$model
=
CoinIssueChainRecord
::
find
()
->
where
([
'<>'
,
'pre_send_transaction'
,
'0'
])
->
andWhere
([
'<>'
,
'finish_send_transaction'
,
'0'
])
->
all
();
}
if
(
false
==
$model
)
{
echo
date
(
'Y-m-d H:i:s'
)
.
' STEP: '
.
$step
.
'暂无完成的发送交易'
.
PHP_EOL
;
return
0
;
}
foreach
(
$model
as
$val
)
{
}
}
}
\ 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