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
3a260f2c
Commit
3a260f2c
authored
Apr 30, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into 'master'
Develop See merge request
!3
parents
270071b7
bcaeeb80
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
480 additions
and
28 deletions
+480
-28
PlatformCoinsController.php
api/controllers/PlatformCoinsController.php
+56
-0
TradeController.php
api/controllers/TradeController.php
+79
-0
VisitStatisticsController.php
api/controllers/VisitStatisticsController.php
+113
-9
CoinTransferController.php
backend/controllers/CoinTransferController.php
+14
-2
CoinAppVersion.php
common/models/psources/CoinAppVersion.php
+2
-2
CoinDailyNumbers.php
common/models/psources/CoinDailyNumbers.php
+39
-0
CoinDailyStatistics.php
common/models/psources/CoinDailyStatistics.php
+2
-15
CoinDailyTimes.php
common/models/psources/CoinDailyTimes.php
+39
-0
CoinPlatformCoins.php
common/models/psources/CoinPlatformCoins.php
+56
-0
CoinTokenTransfer.php
common/models/psources/CoinTokenTransfer.php
+39
-0
Chain33Service.php
common/service/chain33/Chain33Service.php
+41
-0
No files found.
api/controllers/PlatformCoinsController.php
0 → 100644
View file @
3a260f2c
<?php
namespace
api\controllers
;
use
api\base\BaseController
;
use
common\models\psources\CoinPlatformCoins
;
use
Yii
;
class
PlatformCoinsController
extends
BaseController
{
/**
* 新增空投钱包
*
* @param string $platform_id
* @param string $platform_coins
* @return array
*/
public
function
actionIndex
()
{
$platform_id
=
Yii
::
$app
->
request
->
post
(
'platform_id'
,
''
);
$coins_address
=
Yii
::
$app
->
request
->
post
(
'platform_coins'
,
''
);
$type
=
Yii
::
$app
->
request
->
post
(
'type'
,
''
);
if
(
empty
(
$platform_id
)
||
empty
(
$coins_address
)
||
empty
(
$type
)){
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数'
];
}
$item_array
=
[];
foreach
(
$coins_address
as
$item
){
$platform_coins_arr
=
explode
(
','
,
$item
);
$coin_name
=
$platform_coins_arr
[
0
];
$coins_address
=
$platform_coins_arr
[
1
];
if
(
empty
(
$coin_name
)
||
empty
(
$coins_address
))
continue
;
$isExistModel
=
CoinPlatformCoins
::
find
()
->
where
([
'coins_address'
=>
$coins_address
,
'platform_id'
=>
$platform_id
])
->
one
();
if
(
$isExistModel
)
continue
;
$item_array
[]
=
[
$coin_name
,
$coins_address
,
$type
,
$platform_id
,
]
;
}
if
(
empty
(
$item_array
)){
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'数据重复插入'
];
}
$result
=
CoinPlatformCoins
::
batchImport
(
$item_array
);
if
(
!
$result
){
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'数据导入失败'
];
}
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
}
}
\ No newline at end of file
api/controllers/TradeController.php
View file @
3a260f2c
...
@@ -8,6 +8,8 @@
...
@@ -8,6 +8,8 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
api\base\BaseController
;
use
api\base\BaseController
;
use
common\models\psources\CoinTokenTransfer
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
Yii
;
...
@@ -45,4 +47,80 @@ class TradeController extends BaseController
...
@@ -45,4 +47,80 @@ class TradeController extends BaseController
}
}
public
function
actionAddressIsExist
()
{
$get
=
Yii
::
$app
->
request
->
get
();
$to
=
$get
[
'coin_address'
]
??
''
;
if
(
empty
(
$to
)){
return
[
'code'
=>
-
1
,
'msg'
=>
'参数不能为空'
];
}
$coinTokenTransfer
=
CoinTokenTransfer
::
find
()
->
where
([
'coin_address'
=>
$to
,
'code'
=>
1
])
->
one
();
if
(
!
$coinTokenTransfer
){
return
[
'code'
=>
0
,
'msg'
=>
'record does not exist'
];
}
return
[
'code'
=>
1
,
'msg'
=>
'record already exists'
];
}
public
function
actionTokenTransfer
()
{
$get
=
Yii
::
$app
->
request
->
get
();
$to
=
$get
[
'coin_address'
]
??
''
;
if
(
empty
(
$to
)){
return
[
'code'
=>
-
1
,
'msg'
=>
'参数不能为空'
];
}
$coinTokenTransfer
=
CoinTokenTransfer
::
find
()
->
where
([
'coin_address'
=>
$to
,
'code'
=>
1
])
->
one
();
if
(
$coinTokenTransfer
){
return
[
'code'
=>
-
1
,
'msg'
=>
'record already exists'
];
}
$fee
=
100000
;
$amount
=
1
*
1e8
;
$note
=
'2050糖果'
;
$execer
=
'user.p.youngplus.token'
;
$isToken
=
true
;
$tokenSymbol
=
'YPLUS'
;
$service
=
new
Chain33Service
();
$createRawTransaction
=
$service
->
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
);
if
(
0
!=
$createRawTransaction
[
'code'
]){
$msg
=
$createRawTransaction
[
'msg'
];
$code
=
-
1
;
goto
doEnd
;
}
$txHex
=
$createRawTransaction
[
'result'
];
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2'
;
$expire
=
'1m'
;
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
if
(
0
!=
$signRawTx
[
'code'
]){
$msg
=
$signRawTx
[
'msg'
];
$code
=
-
1
;
goto
doEnd
;
}
$sign_str
=
$signRawTx
[
'result'
];
$result
=
$service
->
sendTransaction
(
$sign_str
);
if
(
0
!=
$result
[
'code'
]){
$msg
=
$result
[
'msg'
];
$code
=
-
1
;
goto
doEnd
;
}
$code
=
1
;
$msg
=
$result
[
'result'
];
doEnd
:
$coinTokenTransfer
=
new
CoinTokenTransfer
();
$coinTokenTransfer
->
coin_address
=
$to
;
$coinTokenTransfer
->
msg
=
$msg
;
$coinTokenTransfer
->
code
=
$code
;
$coinTokenTransfer
->
save
();
return
[
'code'
=>
$code
,
'msg'
=>
$msg
];
}
}
}
\ No newline at end of file
api/controllers/VisitStatisticsController.php
View file @
3a260f2c
...
@@ -9,30 +9,48 @@
...
@@ -9,30 +9,48 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
api\base\BaseController
;
use
api\base\BaseController
;
use
common\models\psources\CoinAppVisitStatistics
;
use
common\models\psources\CoinDailyStatistics
;
use
common\models\psources\CoinDailyNumbers
;
use
common\models\psources\CoinDailyTimes
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
Yii
;
class
VisitStatisticsController
extends
BaseController
class
VisitStatisticsController
extends
BaseController
{
{
/**
* 单个DAPP停留时长
*
* @param string $dapp_name
* @param string $identify
* @param string $duration
* @param string $dapp_address
* @param string $coins_address
* @param string $platform_id
* @return array
*/
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$dapp_name
=
Yii
::
$app
->
request
->
get
(
'dapp_name'
,
''
);
$dapp
=
Yii
::
$app
->
request
->
get
(
'dapp'
,
''
);
$identify
=
Yii
::
$app
->
request
->
get
(
'identify'
,
''
);
$identify
=
Yii
::
$app
->
request
->
get
(
'identify'
,
''
);
$duration
=
Yii
::
$app
->
request
->
get
(
'duration'
,
''
);
$duration
=
Yii
::
$app
->
request
->
get
(
'duration'
,
''
);
$address
=
Yii
::
$app
->
request
->
get
(
'address'
,
''
);
$dapp_address
=
Yii
::
$app
->
request
->
get
(
'dapp_address'
,
''
);
$coins_address
=
Yii
::
$app
->
request
->
get
(
'coins_address'
,
''
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
''
);
if
(
empty
(
$dapp
)
||
empty
(
$identify
)
||
empty
(
$duration
)
||
empty
(
$address
)){
if
(
empty
(
$dapp
_name
)
||
empty
(
$identify
)
||
empty
(
$duration
)
||
empty
(
$dapp_address
)
||
empty
(
$coins_address
)
||
empty
(
$platform_id
)){
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
'缺少必要的参数'
];
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
'缺少必要的参数'
];
}
}
$isExistModel
=
Coin
AppVisitStatistics
::
find
()
->
where
([
'identify'
=>
$identify
])
->
one
();
$isExistModel
=
Coin
DailyStatistics
::
find
()
->
where
([
'identify'
=>
$identify
,
'platform_id'
=>
$platform_id
])
->
one
();
if
(
!
$isExistModel
)
{
if
(
!
$isExistModel
)
{
$model
=
new
CoinAppVisitStatistics
();
$model
=
new
CoinDailyStatistics
();
$model
->
dapp
=
$dapp
;
$model
->
dapp_name
=
$dapp_name
;
$model
->
dapp_address
=
$dapp_address
;
$model
->
duration
=
$duration
;
$model
->
duration
=
$duration
;
$model
->
address
=
$address
;
$model
->
identify
=
$identify
;
$model
->
identify
=
$identify
;
$model
->
coins_address
=
$coins_address
;
$model
->
platform_id
=
$platform_id
;
$model
->
save
();
$model
->
save
();
return
[
'code'
=>
0
,
'data'
=>
[],
'msg'
=>
'数据记录插入成功'
];
return
[
'code'
=>
0
,
'data'
=>
[],
'msg'
=>
'数据记录插入成功'
];
}
}
...
@@ -43,4 +61,89 @@ class VisitStatisticsController extends BaseController
...
@@ -43,4 +61,89 @@ class VisitStatisticsController extends BaseController
return
[
'code'
=>
0
,
'data'
=>
[],
'msg'
=>
'数据记录更新成功'
];
return
[
'code'
=>
0
,
'data'
=>
[],
'msg'
=>
'数据记录更新成功'
];
}
}
}
}
/**
* 日打开/进入DAPP的个数/次数
*
* @param string $dapp_name
* @param string $dapp_address
* @param string $coins_address
* @param string $platform_id
* @return array
*/
public
function
actionDailyTimes
()
{
$dapp_name
=
Yii
::
$app
->
request
->
get
(
'dapp_name'
,
''
);
$dapp_address
=
Yii
::
$app
->
request
->
get
(
'dapp_address'
,
''
);
$coins_address
=
Yii
::
$app
->
request
->
get
(
'coins_address'
,
''
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
''
);
if
(
empty
(
$dapp_name
)
||
empty
(
$dapp_address
)
||
empty
(
$coins_address
)
||
empty
(
$platform_id
)){
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
'缺少必要的参数'
];
}
$begin
=
date
(
"Y-m-d"
,
time
())
.
" 00:00:00"
;
$end
=
date
(
"Y-m-d"
,
time
())
.
" 23:59:59"
;
$isExist_coinDailyNumbers
=
CoinDailyNumbers
::
find
()
->
where
([
'dapp_name'
=>
$dapp_name
,
'dapp_address'
=>
$dapp_address
,
'coins_address'
=>
$coins_address
,
'platform_id'
=>
$platform_id
])
->
andWhere
([
'between'
,
'create_time'
,
$begin
,
$end
])
->
one
();
if
(
!
$isExist_coinDailyNumbers
){
$model_coinDailyNumbers
=
new
CoinDailyNumbers
();
$model_coinDailyNumbers
->
setScenario
(
CoinDailyNumbers
::
SCENARIOS_CREATE
);
$model_coinDailyNumbers
->
load
(
Yii
::
$app
->
request
->
get
(),
''
);
$model_coinDailyNumbers
->
save
();
}
$model_coinDailyTimes
=
new
CoinDailyTimes
();
$model_coinDailyTimes
->
setScenario
(
CoinDailyTimes
::
SCENARIOS_CREATE
);
if
(
$model_coinDailyTimes
->
load
(
Yii
::
$app
->
request
->
get
(),
''
)
&&
$model_coinDailyTimes
->
save
())
{
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据记录插入成功'
];
}
else
{
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
current
(
$model_coinDailyTimes
->
firstErrors
)];
}
}
/**
* 获取coin地址下DAPP交易信息
*
* @param string $coins_address
* @return array
*/
public
function
actionDappResult
()
{
$coins_address
=
Yii
::
$app
->
request
->
get
(
'coins_address'
,
''
);
if
(
empty
(
$coins_address
)){
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
'缺少必要的参数'
];
}
$service
=
new
Chain33Service
();
$result
=
$service
->
getDappTradeResult
(
$coins_address
);
if
(
0
!==
$result
[
'code'
]){
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
$result
[
'msg'
]];
}
$queryResultItems
=
$result
[
'result'
]
??
[];
if
(
empty
(
$queryResultItems
)){
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
'error'
];
}
$resultJSON
=
json_decode
(
$queryResultItems
[
'queryResultItems'
][
0
][
'resultJSON'
],
true
);
$betting_times
=
$resultJSON
[
'betting_times'
]
??
0
;
$betting_amount
=
$resultJSON
[
'betting_amount'
]
??
0
;
$earnings
=
$resultJSON
[
'earnings'
]
??
0
;
$data
=
[
'betting_times'
=>
$betting_times
,
'betting_amount'
=>
$betting_amount
,
'earnings'
=>
$earnings
];
return
[
'code'
=>
0
,
'data'
=>
$data
,
'msg'
=>
'ok'
];
}
}
}
\ No newline at end of file
backend/controllers/CoinTransferController.php
View file @
3a260f2c
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
namespace
backend\controllers
;
namespace
backend\controllers
;
use
backend\models\Coin
;
use
common\service\chain33\Chain33Service
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
Yii
;
use
common\models\psources\CoinTransfer
;
use
common\models\psources\CoinTransfer
;
...
@@ -66,17 +67,27 @@ class CoinTransferController extends BaseController
...
@@ -66,17 +67,27 @@ class CoinTransferController extends BaseController
public
function
actionBatchTransfer
()
public
function
actionBatchTransfer
()
{
{
$model
=
CoinTransfer
::
find
()
->
where
([
'
status'
=>
0
])
->
limit
(
30
)
->
all
();
$model
=
CoinTransfer
::
find
()
->
where
([
'
hash'
=>
'-----------------'
])
->
limit
(
30
)
->
all
();
foreach
(
$model
as
$val
){
foreach
(
$model
as
$val
){
echo
$val
->
address
.
"<br/>"
;
echo
$val
->
address
.
"<br/>"
;
$id
=
$val
->
id
;
$id
=
$val
->
id
;
$to
=
$val
->
address
;
$to
=
$val
->
address
;
$amount
=
str_replace
(
" TSC"
,
""
,
$val
->
amount
)
*
1e8
;
#$amount = str_replace(" TSC", "", $val->amount) * 1e8;
$amount
=
$val
->
amount
*
1e8
;
$fee
=
100000
;
$fee
=
100000
;
$note
=
''
;
$note
=
''
;
$execer
=
'user.p.tschain.coins'
;
$execer
=
'user.p.tschain.coins'
;
// $isExist = CoinTransfer::find()->where(['address' => $val->address, 'status' => 1])->one();
// if($isExist){
// $updateModel = CoinTransfer::findOne($val->id);
// $updateModel->hash = '-----------------';
// $updateModel->status = 1;
// $updateModel->save();
// continue;
// }
$service
=
new
Chain33Service
();
$service
=
new
Chain33Service
();
$createRawTransaction
=
$service
->
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
);
$createRawTransaction
=
$service
->
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
);
...
@@ -89,6 +100,7 @@ class CoinTransferController extends BaseController
...
@@ -89,6 +100,7 @@ class CoinTransferController extends BaseController
$expire
=
'1m'
;
$expire
=
'1m'
;
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
if
(
0
!=
$signRawTx
[
'code'
]){
if
(
0
!=
$signRawTx
[
'code'
]){
continue
;
continue
;
}
}
...
...
common/models/psources/CoinAppVersion.php
View file @
3a260f2c
...
@@ -45,8 +45,8 @@ class CoinAppVersion extends BaseActiveRecord
...
@@ -45,8 +45,8 @@ class CoinAppVersion extends BaseActiveRecord
*/
*/
public
static
function
getLastStable
(
$type
=
1
,
$platform_id
=
1
)
public
static
function
getLastStable
(
$type
=
1
,
$platform_id
=
1
)
{
{
$max_version
=
self
::
find
()
->
where
([
'type'
=>
$type
,
'platform_id'
=>
$platform_id
])
->
max
(
'version
'
);
$max_version
_code
=
self
::
find
()
->
where
([
'type'
=>
$type
,
'platform_id'
=>
$platform_id
])
->
max
(
'version_code
'
);
$data
=
self
::
find
()
->
where
([
'type'
=>
$type
,
'platform_id'
=>
$platform_id
,
'version
'
=>
$max_version
])
->
asArray
()
->
one
();
$data
=
self
::
find
()
->
where
([
'type'
=>
$type
,
'platform_id'
=>
$platform_id
,
'version
_code'
=>
$max_version_code
])
->
asArray
()
->
one
();
return
$data
;
return
$data
;
}
}
...
...
common/models/psources/CoinDailyNumbers.php
0 → 100644
View file @
3a260f2c
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
CoinDailyNumbers
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_daily_numbers}}'
;
}
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
function
rules
()
{
return
[
[[
'dapp_name'
,
'dapp_address'
,
'coins_address'
,
'platform_id'
],
'required'
],
[[
'platform_id'
],
'match'
,
'pattern'
=>
'/^[0-9]+$/'
,
'message'
=>
'{attribute} 必须为数字'
],
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'dapp_name'
,
'dapp_address'
,
'coins_address'
,
'platform_id'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
common/models/psources/Coin
AppVisit
Statistics.php
→
common/models/psources/Coin
Daily
Statistics.php
View file @
3a260f2c
...
@@ -3,23 +3,10 @@
...
@@ -3,23 +3,10 @@
namespace
common\models\psources
;
namespace
common\models\psources
;
use
common\core\BaseActiveRecord
;
use
common\core\BaseActiveRecord
;
use
yii\behaviors\TimestampBehavior
;
use
yii\db\Expression
;
use
Yii
;
use
Yii
;
class
Coin
AppVisit
Statistics
extends
BaseActiveRecord
class
Coin
Daily
Statistics
extends
BaseActiveRecord
{
{
// public function behaviors()
// {
// return [
// [
// 'class' => TimestampBehavior::className(),
// 'createdAtAttribute' => 'created_at', // 自己根据数据库字段修改
// 'updatedAtAttribute' => 'updated_at', // 自己根据数据库字段修改
// 'value' => new Expression('NOW()'), // 自己根据数据库字段修改
// ]
// ];
// }
public
static
function
getDb
()
public
static
function
getDb
()
{
{
...
@@ -28,7 +15,7 @@ class CoinAppVisitStatistics extends BaseActiveRecord
...
@@ -28,7 +15,7 @@ class CoinAppVisitStatistics extends BaseActiveRecord
public
static
function
tableName
()
public
static
function
tableName
()
{
{
return
'{{%coin_
app_visit
_statistics}}'
;
return
'{{%coin_
daily
_statistics}}'
;
}
}
}
}
common/models/psources/CoinDailyTimes.php
0 → 100644
View file @
3a260f2c
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
CoinDailyTimes
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_daily_times}}'
;
}
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
function
rules
()
{
return
[
[[
'dapp_name'
,
'dapp_address'
,
'coins_address'
,
'platform_id'
],
'required'
],
[[
'platform_id'
],
'match'
,
'pattern'
=>
'/^[0-9]+$/'
,
'message'
=>
'{attribute} 必须为数字'
],
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'dapp_name'
,
'dapp_address'
,
'coins_address'
,
'platform_id'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
common/models/psources/CoinPlatformCoins.php
0 → 100644
View file @
3a260f2c
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
CoinPlatformCoins
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
'{{%coin_platform_coins}}'
;
}
public
function
rules
()
{
return
[
[[
'coins_name'
,
'coins_address'
,
'type'
,
'platform_id'
],
'required'
],
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'coins_name'
,
'coins_address'
,
'type'
,
'platform_id'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
/**
* 导入数据
*
* @param array $datas
* @return boolean
*/
public
static
function
batchImport
(
array
$datas
)
{
if
(
!
is_array
(
$datas
))
{
return
false
;
}
try
{
$result
=
self
::
getDb
()
->
createCommand
()
->
batchInsert
(
self
::
tableName
(),
[
'coins_name'
,
'coins_address'
,
'type'
,
'platform_id'
],
$datas
)
->
execute
();
return
$result
;
}
catch
(
\Exception
$e
)
{
}
return
false
;
}
}
common/models/psources/CoinTokenTransfer.php
0 → 100644
View file @
3a260f2c
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
CoinTokenTransfer
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_token_transfer}}'
;
}
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
function
rules
()
{
return
[
[[
'coin_address'
,
'msg'
,
'code'
],
'required'
],
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'coin_address'
,
'msg'
,
'code'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
\ No newline at end of file
common/service/chain33/Chain33Service.php
View file @
3a260f2c
...
@@ -63,6 +63,32 @@ class Chain33Service
...
@@ -63,6 +63,32 @@ class Chain33Service
}
}
/**
/**
* 获取coin地址下DAPP交易信息
*
* @param string|array $address
* @return array
*/
public
function
getDappTradeResult
(
$address
)
{
$params
=
[
'execer'
=>
'wasm'
,
'funcName'
=>
'WasmGetContractTable'
,
'payload'
=>
[
'contractName'
=>
'user.p.tschain.user.wasm.dice'
,
'items'
=>
[
[
'tableName'
=>
'addrinfo'
,
'key'
=>
'addrinfo-'
.
$address
]
]
]
];
return
$this
->
send
(
$params
);
}
/**
* 获取地址下的所有token资产
* 获取地址下的所有token资产
*
*
* @param string|array $address
* @param string|array $address
...
@@ -130,6 +156,21 @@ class Chain33Service
...
@@ -130,6 +156,21 @@ class Chain33Service
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
}
}
public
function
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
)
{
$params
=
[
"to"
=>
$to
,
"amount"
=>
$amount
,
"isToken"
=>
$isToken
,
"tokenSymbol"
=>
$tokenSymbol
,
"fee"
=>
$fee
,
"note"
=>
$note
,
"execer"
=>
$execer
,
];
return
$this
->
send
(
$params
,
'Chain33.CreateRawTransaction'
);
}
public
function
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
)
public
function
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
)
{
{
$params
=
[
$params
=
[
...
...
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