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
9e5fda4e
Commit
9e5fda4e
authored
Sep 07, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into 'master'
Feature/optimize See merge request
!376
parents
e01a8a8f
4d16a46b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
158 additions
and
14 deletions
+158
-14
BaseController.php
api/base/BaseController.php
+37
-0
PlatformCoinsController.php
api/controllers/PlatformCoinsController.php
+73
-14
WarnController.php
console/controllers/WarnController.php
+48
-0
No files found.
api/base/BaseController.php
View file @
9e5fda4e
...
...
@@ -48,10 +48,36 @@ class BaseController extends Controller
if
(
\Yii
::
$app
->
request
->
headers
->
get
(
'FZM-CURRENCY-ID'
))
{
$this
->
currency_id
=
\Yii
::
$app
->
request
->
headers
->
get
(
'FZM-CURRENCY-ID'
);
}
$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
))
{
$origin
=
implode
(
','
,
$allow_list
);
}
$this
->
header
(
'Access-Control-Allow-Origin'
,
$origin
);
$this
->
header
(
'Access-Control-Allow-Methods'
,
'POST,GET,OPTIONS,PUT,DELETE'
);
$this
->
header
(
'Access-Control-Allow-Credentials'
,
'true'
);
$this
->
header
(
'Access-Control-Allow-Headers'
,
'Authorization,FZM-REQUEST-OS,FZM-USER-IP,FZM-REQUEST-UUID,FZM-PLATFORM-ID,Content-Type,Content-Length'
);
}
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
}
...
...
@@ -148,4 +174,14 @@ class BaseController extends Controller
return
$models
;
}
public
function
header
(
$key
,
$value
)
{
$this
->
header_list
[
$key
]
=
$value
;
}
public
function
getHeaders
()
{
return
$this
->
header_list
;
}
}
\ No newline at end of file
api/controllers/PlatformCoinsController.php
View file @
9e5fda4e
...
...
@@ -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
console/controllers/WarnController.php
0 → 100644
View file @
9e5fda4e
<?php
namespace
console\controllers
;
use
linslin\yii2\curl\Curl
;
use
voku\helper\HtmlDomParser
;
use
yii\console\Controller
;
class
WarnController
extends
Controller
{
public
function
actionAuto
()
{
$redis
=
\Yii
::
$app
->
redis_user
;
if
(
!
$redis
->
EXISTS
(
"status"
))
{
$curl
=
new
Curl
();
$url
=
'http://www.offcn.com/sydw/2020/0813/571289.html?www.offcn.com-hengtong'
;
$response
=
$curl
->
get
(
$url
);
$html
=
HtmlDomParser
::
str_get_html
(
$response
);
$tbody
=
(
$html
->
find
(
'tbody'
));
if
(
$tbody
->
find
(
'tr'
))
{
foreach
(
$tbody
->
find
(
'tr'
)
as
$key
=>
$e
)
{
if
(
$key
==
2
)
{
$string
=
HtmlDomParser
::
str_get_html
(
$e
->
innertext
);
if
(
$string
->
find
(
'td'
))
{
if
(
strpos
(
$string
->
find
(
'td'
)[
2
]
->
innertext
,
'暂未公布'
)
!==
false
)
{
return
0
;
}
else
{
$redis
->
set
(
'status'
,
date
(
'Y-m-d H:i:s'
));
try
{
$mail
=
\Yii
::
$app
->
mailer
->
compose
();
$mail
->
setFrom
(
'sjm@33.cn'
);
$mail
->
setTo
(
'sjm@33.cn'
);
$mail
->
setSubject
(
"2020浙江事业单位统考笔试成绩"
);
$mail
->
setHtmlBody
(
"<h1>笔试成绩已发布!,进面最高分:"
.
$string
->
find
(
'td'
)[
3
]
->
innertext
.
";进面最低分:"
.
$string
->
find
(
'td'
)[
4
]
->
innertext
.
"</h1>"
);
$mail
->
send
();
}
catch
(
\ErrorException
$e
)
{
return
0
;
}
}
}
}
}
}
}
}
}
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