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
4d16a46b
Commit
4d16a46b
authored
Sep 07, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
be33e855
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
15 deletions
+89
-15
BaseController.php
api/base/BaseController.php
+16
-1
PlatformCoinsController.php
api/controllers/PlatformCoinsController.php
+73
-14
No files found.
api/base/BaseController.php
View file @
4d16a46b
...
...
@@ -49,7 +49,7 @@ class BaseController extends Controller
$this
->
currency_id
=
\Yii
::
$app
->
request
->
headers
->
get
(
'FZM-CURRENCY-ID'
);
}
$allow_list
=
array_unique
(
\Yii
::
$app
->
params
[
'allow_options_domain'
][
'allow_options_domain'
]);
$allow_list
=
array_unique
(
\Yii
::
$app
->
params
[
'allow_options_domain'
][
'allow_options_domain'
]);
$origin
=
\Yii
::
$app
->
request
->
headers
->
get
(
'Origin'
);
if
(
!
in_array
(
$origin
,
$allow_list
))
{
...
...
@@ -63,6 +63,21 @@ class BaseController extends Controller
public
function
beforeAction
(
$action
)
{
$request_controller
=
Yii
::
$app
->
controller
->
id
;
$request_action
=
Yii
::
$app
->
controller
->
action
->
id
;
if
(
'platform-coins'
==
$request_controller
&&
'air-drop'
==
$request_action
)
{
$rawParams
=
Yii
::
$app
->
request
->
post
();
if
(
isset
(
$rawParams
[
'key'
]))
{
$DES
=
Yii
::
$app
->
des
;
$params
=
$DES
->
decrypt
(
$rawParams
[
'key'
]);
if
(
$params
==
false
)
{
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数'
];
}
$rawBodyParams
=
json_decode
(
$params
,
true
);
Yii
::
$app
->
request
->
setBodyParams
(
$rawBodyParams
);
}
}
$this
->
start
=
microtime
(
true
);
return
parent
::
beforeAction
(
$action
);
// TODO: Change the autogenerated stub
}
...
...
api/controllers/PlatformCoinsController.php
View file @
4d16a46b
...
...
@@ -9,15 +9,7 @@ use Yii;
class
PlatformCoinsController
extends
BaseController
{
/**
* 新增空投钱包
*
* @param string $platform_id
* @param string $platform_coins
* @return array
*/
public
function
actionIndex
()
public
function
actionAirDrop
()
{
$platform_id
=
Yii
::
$app
->
request
->
post
(
'platform_id'
,
''
);
$coins_address
=
Yii
::
$app
->
request
->
post
(
'platform_coins'
,
''
);
...
...
@@ -56,11 +48,7 @@ class PlatformCoinsController extends BaseController
$isExistModel
->
save
();
continue
;
}
// if (!empty($isExistModel) && strlen($isExistModel->deviceCode) > 0 && $isExistModel->deviceCode !== $deviceCode) {
// $isExistModel->deviceCode = $deviceCode;
// $isExistModel->save();
// continue;
// };
if
(
!
empty
(
$isExistModel
)
&&
$isExistModel
->
deviceCode
==
$deviceCode
)
{
continue
;
};
...
...
@@ -99,4 +87,74 @@ class PlatformCoinsController extends BaseController
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
}
/**
* 新增空投钱包
*
* @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'
,
''
);
$header
=
Yii
::
$app
->
request
->
headers
;
$deviceCode
=
$header
[
'FZM-REQUEST-UUID'
]
??
null
;
if
(
empty
(
$platform_id
)
||
empty
(
$coins_address
)
||
empty
(
$type
))
{
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数'
];
}
if
(
41
==
$platform_id
)
{
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数'
];
}
if
(
empty
(
$deviceCode
))
{
return
[
'code'
=>
0
,
'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_name'
=>
$coin_name
,
'coins_address'
=>
$coins_address
,
'platform_id'
=>
$platform_id
])
->
one
();
if
(
!
empty
(
$isExistModel
)
&&
empty
(
$isExistModel
->
deviceCode
))
{
$isExistModel
->
deviceCode
=
$deviceCode
;
$isExistModel
->
save
();
continue
;
}
// if (!empty($isExistModel) && strlen($isExistModel->deviceCode) > 0 && $isExistModel->deviceCode !== $deviceCode) {
// $isExistModel->deviceCode = $deviceCode;
// $isExistModel->save();
// continue;
// };
if
(
!
empty
(
$isExistModel
)
&&
$isExistModel
->
deviceCode
==
$deviceCode
)
{
continue
;
};
$item_array
[]
=
[
$coin_name
,
$coins_address
,
$type
,
$deviceCode
,
$platform_id
,
];
}
if
(
empty
(
$item_array
))
{
return
[
'code'
=>
0
,
'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
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