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
ef8eea58
Commit
ef8eea58
authored
Apr 28, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
钱包导入
parent
9c0b22c2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
0 deletions
+105
-0
PlatformCoinsController.php
api/controllers/PlatformCoinsController.php
+49
-0
CoinPlatformCoins.php
common/models/psources/CoinPlatformCoins.php
+56
-0
No files found.
api/controllers/PlatformCoinsController.php
0 → 100644
View file @
ef8eea58
<?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'
=>
[],
'msg'
=>
'缺少必要的参数'
];
}
$item_array
=
[];
foreach
(
$coins_address
as
$item
){
$isExistModel
=
CoinPlatformCoins
::
find
()
->
where
([
'coins_address'
=>
$item
[
'coinAddress'
],
'platform_id'
=>
$platform_id
])
->
one
();
if
(
$isExistModel
)
continue
;
$item_array
[]
=
[
$item
[
'coinName'
],
$item
[
'coinAddress'
],
$type
,
$platform_id
,
]
;
}
$result
=
CoinPlatformCoins
::
batchImport
(
$item_array
);
if
(
!
$result
){
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
'数据导入失败'
];
}
return
[
'code'
=>
0
,
'data'
=>
[],
'msg'
=>
'数据导入成功'
];
}
}
\ No newline at end of file
common/models/psources/CoinPlatformCoins.php
0 → 100644
View file @
ef8eea58
<?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
;
}
}
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