Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aic_duty_strategy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
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
yinxiaoling
aic_duty_strategy
Commits
d149b5c3
Commit
d149b5c3
authored
May 13, 2020
by
yinxiaoling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去掉url验证
parent
b4ba53fa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
11 deletions
+67
-11
LoginApiController.php
app/Http/Controllers/LoginApiController.php
+2
-2
StrategySetController.php
app/Http/Controllers/strategy/StrategySetController.php
+1
-1
CheckApiKey.php
app/Http/Middleware/CheckApiKey.php
+6
-4
StrategyService.php
app/Service/StrategyService.php
+58
-4
No files found.
app/Http/Controllers/LoginApiController.php
View file @
d149b5c3
...
@@ -16,11 +16,11 @@ class LoginApiController extends BaseController
...
@@ -16,11 +16,11 @@ class LoginApiController extends BaseController
$url
=
$request
->
url
;
$url
=
$request
->
url
;
Log
::
channel
(
'api'
)
->
info
(
substr
(
md5
(
json_encode
(
$param
)),
1
,
8
));
Log
::
channel
(
'api'
)
->
info
(
substr
(
md5
(
json_encode
(
$param
)),
1
,
8
));
Log
::
channel
(
'api'
)
->
info
(
$url
);
/*
Log::channel('api')->info($url);
if($url != substr(md5(json_encode($param)),1,8)){
if($url != substr(md5(json_encode($param)),1,8)){
return $this->errorWithInfo('url验证不通过', 401);
return $this->errorWithInfo('url验证不通过', 401);
}
}
*/
if
(
empty
(
$param
[
'username'
])
||
empty
(
$param
[
'password'
]
)){
if
(
empty
(
$param
[
'username'
])
||
empty
(
$param
[
'password'
]
)){
return
$this
->
errorWithInfo
(
'参数验证不通过'
,
401
);
return
$this
->
errorWithInfo
(
'参数验证不通过'
,
401
);
}
}
...
...
app/Http/Controllers/strategy/StrategySetController.php
View file @
d149b5c3
...
@@ -39,7 +39,7 @@ class StrategySetController extends Controller
...
@@ -39,7 +39,7 @@ class StrategySetController extends Controller
return
$this
->
errorWithInfo
(
$excelData
[
'msg'
],
401
);
return
$this
->
errorWithInfo
(
$excelData
[
'msg'
],
401
);
}
}
//验证excel数据格式及不合格数据原因
//验证excel数据格式及不合格数据原因
$StrategyService
->
validExcelData
(
$excelData
,
$request
->
day_type
);
$
excelDataValid
=
$
StrategyService
->
validExcelData
(
$excelData
,
$request
->
day_type
);
}
}
dd
(
$excelData
);
dd
(
$excelData
);
dd
(
'策略添加'
);
dd
(
'策略添加'
);
...
...
app/Http/Middleware/CheckApiKey.php
View file @
d149b5c3
...
@@ -25,7 +25,7 @@ class CheckApiKey
...
@@ -25,7 +25,7 @@ class CheckApiKey
$api_key
=
$request
->
api_key
;
$api_key
=
$request
->
api_key
;
$user_sn
=
$request
->
user_sn
;
$user_sn
=
$request
->
user_sn
;
if
(
empty
(
$
url
)
||
empty
(
$
api_key
)
||
empty
(
$user_sn
)){
if
(
empty
(
$api_key
)
||
empty
(
$user_sn
)){
return
$this
->
errorWithInfo
(
'参数验证不通过'
,
401
);
return
$this
->
errorWithInfo
(
'参数验证不通过'
,
401
);
}
}
...
@@ -33,7 +33,7 @@ class CheckApiKey
...
@@ -33,7 +33,7 @@ class CheckApiKey
Log
::
channel
(
'api'
)
->
info
(
'API_PARAM:'
.
json_encode
(
$param
));
Log
::
channel
(
'api'
)
->
info
(
'API_PARAM:'
.
json_encode
(
$param
));
Log
::
channel
(
'api'
)
->
info
(
'API_SERVER_PARAM:'
.
substr
(
md5
(
json_encode
(
$param
)),
1
,
8
));
Log
::
channel
(
'api'
)
->
info
(
'API_SERVER_PARAM:'
.
substr
(
md5
(
json_encode
(
$param
)),
1
,
8
));
Log
::
channel
(
'api'
)
->
info
(
'API_CLIENT_PARAM:'
.
$url
);
/*
Log::channel('api')->info('API_CLIENT_PARAM:'.$url);
$md_url = substr(md5(json_encode($param)),1,8);
$md_url = substr(md5(json_encode($param)),1,8);
...
@@ -41,7 +41,7 @@ class CheckApiKey
...
@@ -41,7 +41,7 @@ class CheckApiKey
if($_SERVER['REQUEST_SCHEME'] == 'http'){
if($_SERVER['REQUEST_SCHEME'] == 'http'){
return $this->errorWithInfo('验证url失败', 401);
return $this->errorWithInfo('验证url失败', 401);
}
}
}
}
*/
$user
=
DB
::
table
(
'users'
)
->
where
(
'user_sn'
,
$param
[
'user_sn'
])
->
first
();
$user
=
DB
::
table
(
'users'
)
->
where
(
'user_sn'
,
$param
[
'user_sn'
])
->
first
();
...
@@ -51,7 +51,9 @@ class CheckApiKey
...
@@ -51,7 +51,9 @@ class CheckApiKey
$puser
=
DB
::
table
(
'users'
)
->
where
(
'user_name'
,
$user
->
parent_sn
)
->
select
(
'expired'
)
->
first
();
$puser
=
DB
::
table
(
'users'
)
->
where
(
'user_name'
,
$user
->
parent_sn
)
->
select
(
'expired'
)
->
first
();
$the_expired
=
$puser
->
expired
;
$the_expired
=
$puser
->
expired
;
}
}
if
(
$api_key
!=
$user
->
api_key
){
return
$this
->
errorWithInfo
(
'key验证失败'
,
401
);
}
$todayDate
=
strtotime
(
date
(
'y-m-d 00:00:00'
,
time
()));
$todayDate
=
strtotime
(
date
(
'y-m-d 00:00:00'
,
time
()));
$expiredDate
=
strtotime
(
$the_expired
.
' 00:00:00'
);
$expiredDate
=
strtotime
(
$the_expired
.
' 00:00:00'
);
...
...
app/Service/StrategyService.php
View file @
d149b5c3
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
App\Service
;
namespace
App\Service
;
use
Maatwebsite\Excel\Facades\Excel
;
use
Maatwebsite\Excel\Facades\Excel
;
use
Illuminate\Support\Facades\Log
;
class
StrategyService
class
StrategyService
{
{
...
@@ -51,8 +52,6 @@ class StrategyService
...
@@ -51,8 +52,6 @@ class StrategyService
}
}
//判断excel数据问题,$day_type//外呼日期类型 0每天 1日期前一天和当天 1需要验证值班日期必填
//判断excel数据问题,$day_type//外呼日期类型 0每天 1日期前一天和当天 1需要验证值班日期必填
public
function
validExcelData
(
$data
,
$day_type
){
public
function
validExcelData
(
$data
,
$day_type
){
//$failDataTitle = ['姓名','*手机号码','值班日期','失败原因'];
//dump($data);
$failData
=
[];
$failData
=
[];
foreach
(
$data
as
$k
=>
$v
){
foreach
(
$data
as
$k
=>
$v
){
$dataLab
=
1
;
$dataLab
=
1
;
...
@@ -88,11 +87,66 @@ class StrategyService
...
@@ -88,11 +87,66 @@ class StrategyService
unset
(
$data
[
$k
]);
unset
(
$data
[
$k
]);
}
}
}
}
dump
(
$failData
,
$data
);
$failTotal
=
count
(
$failData
);
$failTotal
=
count
(
$failData
);
$successTotal
=
count
(
$data
);
$successTotal
=
count
(
$data
);
dd
(
'===================='
);
if
(
$failTotal
>
0
){
//把导出错误数据存入excel表格中供下载
$failDataTitle
=
[
'姓名'
,
'*手机号码'
,
'值班日期'
,
'失败原因'
];
array_unshift
(
$failData
,
$failDataTitle
);
$failExcelName
=
"导入失败数据_"
.
date
(
'YmdHis'
);
$this
->
storeExcelStyle
(
$failExcelName
,
$failData
);
}
return
compact
(
'data'
,
'failData'
,
'failTotal'
,
'successTotal'
);
return
compact
(
'data'
,
'failData'
,
'failTotal'
,
'successTotal'
);
}
}
//保存内容到excel文件并下载
public
function
storeExcelStyle
(
$excelName
,
$datas
,
$endLen
=
''
,
$path
=
''
){
try
{
$arr
=
range
(
'A'
,
'Z'
);
if
(
!
empty
(
$endLen
)){
$endLen
=
$endLen
-
1
;
if
(
isset
(
$arr
[
$endLen
])){
$arr
=
range
(
'A'
,
$arr
[
$endLen
]);
}
}
$e
=
Excel
::
create
(
iconv
(
'UTF-8'
,
'GBK'
,
$excelName
),
function
(
$excel
)
use
(
$datas
,
$arr
){
$excel
->
sheet
(
'score'
,
function
(
$sheet
)
use
(
$datas
,
$arr
){
$col
=
array
();
$sheet
->
rows
(
$datas
);
foreach
(
$arr
as
$v
){
$col
[
$v
]
=
12
;
}
$sheet
->
setWidth
(
$col
);
foreach
(
$arr
as
$k
=>
$v
){
$objRichText
=
new
\PHPExcel_RichText
();
if
(
!
empty
(
$datas
[
0
][
$k
])){
if
(
strpos
(
$datas
[
0
][
$k
],
'*'
)
===
0
){
$objPayable
=
$objRichText
->
createTextRun
(
'*'
);
$objPayable
->
getFont
()
->
setColor
(
new
\PHPExcel_Style_Color
(
\PHPExcel_Style_Color
::
COLOR_RED
)
);
//设置颜色
}
$objRichText
->
createText
(
ltrim
(
$datas
[
0
][
$k
],
'*'
));
$sheet
->
setCellValue
(
$arr
[
$k
]
.
'1'
,
$objRichText
);
}
}
});
});
if
(
empty
(
$path
)){
//默认路径storage/exports
$e
->
store
(
'xlsx'
);
}
else
{
//自定义路径 storage/$path
$e
->
store
(
'xlsx'
,
storage_path
(
$path
));
}
return
true
;
}
catch
(
\Exception
$e
){
Log
::
channel
(
'api'
)
->
error
(
$e
->
getFile
()
.
'-'
.
$e
->
getLine
()
.
'-'
.
$e
->
getMessage
());
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