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
f91cc4e8
Commit
f91cc4e8
authored
May 19, 2020
by
yinxiaoling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异常捕获
parent
aa44aef9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
219 additions
and
193 deletions
+219
-193
Tool.php
app/Http/Controllers/Tool.php
+1
-1
StrategySetController.php
app/Http/Controllers/strategy/StrategySetController.php
+136
-116
StrategyTaskController.php
app/Http/Controllers/strategy/StrategyTaskController.php
+82
-76
No files found.
app/Http/Controllers/Tool.php
View file @
f91cc4e8
...
...
@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Route; */
trait
Tool
{
public
function
getAllowLoginUser
(){
return
[
'user_name'
=>
'yxl00
1
'
,
'user_sn'
=>
'SYSUSER|9da548a2e392a679eb274a0b2abeb627'
,
'parent_sn'
=>
'ljs'
];
return
[
'user_name'
=>
'yxl00
2
'
,
'user_sn'
=>
'SYSUSER|9da548a2e392a679eb274a0b2abeb627'
,
'parent_sn'
=>
'ljs'
];
}
public
function
getAllowProjects
(
$style
=
0
){
$projectInfo
=
[[
'sn'
=>
'projects|a3a4259352c8e964ad6ea6c5ee8a7208'
,
'name'
=>
'liuy-转人工测试'
],[
'sn'
=>
'projects|17a71649f886bce050d637e86a3c85e8'
,
'name'
=>
'小贷-测试林俊生'
]];
...
...
app/Http/Controllers/strategy/StrategySetController.php
View file @
f91cc4e8
...
...
@@ -21,95 +21,110 @@ class StrategySetController extends Controller
use
Tool
;
public
function
index
(){
$projectArr
=
$this
->
getAllowProjects
(
1
);
$strategyInfo
=
StrategySet
::
all
()
->
toArray
();
$listInfo
=
[];
foreach
(
$strategyInfo
as
$k
=>
$v
){
$projectSnTemp
=
explode
(
"#"
,
$v
[
'project_sn'
]);
$v
[
'project_name'
]
=
isset
(
$projectArr
[
$projectSnTemp
[
0
]])
?
$projectArr
[
$projectSnTemp
[
0
]]
:
''
;
if
(
isset
(
$projectSnTemp
[
1
])
&&
isset
(
$projectArr
[
$projectSnTemp
[
1
]])){
$v
[
'project_name'
]
.=
$projectArr
[
$projectSnTemp
[
1
]];
try
{
$projectArr
=
$this
->
getAllowProjects
(
1
);
$strategyInfo
=
StrategySet
::
all
()
->
toArray
();
$listInfo
=
[];
foreach
(
$strategyInfo
as
$k
=>
$v
){
$projectSnTemp
=
explode
(
"#"
,
$v
[
'project_sn'
]);
$v
[
'project_name'
]
=
isset
(
$projectArr
[
$projectSnTemp
[
0
]])
?
$projectArr
[
$projectSnTemp
[
0
]]
:
''
;
if
(
isset
(
$projectSnTemp
[
1
])
&&
isset
(
$projectArr
[
$projectSnTemp
[
1
]])){
$v
[
'project_name'
]
.=
$projectArr
[
$projectSnTemp
[
1
]];
}
$v
[
'disabled_name'
]
=
$v
[
'disabled'
]
==
0
?
'启用'
:
'停用'
;
$v
[
'day_type_name'
]
=
$v
[
'day_type'
]
==
0
?
'每天'
:
'日期前一天和当天'
;
$v
[
'frequency_type_name'
]
=
$v
[
'frequency_type'
]
==
1
?
'一天一次'
:
'一天两次'
;
$listInfo
[]
=
$v
;
}
$v
[
'disabled_name'
]
=
$v
[
'disabled'
]
==
0
?
'启用'
:
'停用'
;
$v
[
'day_type_name'
]
=
$v
[
'day_type'
]
==
0
?
'每天'
:
'日期前一天和当天'
;
$v
[
'frequency_type_name'
]
=
$v
[
'frequency_type'
]
==
1
?
'一天一次'
:
'一天两次'
;
$listInfo
[]
=
$v
;
}
return
$this
->
successWithInfo
(
$listInfo
);
return
$this
->
successWithInfo
(
$listInfo
);
}
catch
(
\Exception
$e
){
Log
::
channel
(
'api'
)
->
error
(
$e
->
getFile
()
.
'-'
.
$e
->
getLine
()
.
'-'
.
$e
->
getMessage
());
return
$this
->
errorWithInfo
(
'操作异常'
,
500
);
}
}
public
function
store
(
Request
$request
,
StrategyService
$StrategyService
){
$allowLoginUser
=
$this
->
getAllowLoginUser
();
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'strategy_name'
=>
'required|max:30'
,
'user_sn'
=>
'required'
,
'call_number'
=>
'required'
,
'day_type'
=>
'required'
,
'frequency_type'
=>
'required'
,
'call_time_set'
=>
'required'
,
'project_sn'
=>
'required'
]);
if
(
$validator
->
fails
())
{
return
$this
->
errorWithInfo
(
'表单验证失败'
,
401
);
}
$params
=
$request
->
all
();
if
(
$params
[
'day_type'
]
==
0
){
//每天、一天两次,两个时间点、一个话术或者两个话术
$checkCallTimeSet
=
explode
(
"#"
,
$params
[
'call_time_set'
]);
if
(
!
isset
(
$checkCallTimeSet
[
1
])
||
empty
(
$checkCallTimeSet
[
1
])){
return
$this
->
errorWithInfo
(
'呼叫设置验证失败'
,
401
);
}
}
else
{
//日期前一天和当天、一天一次, 一个时间点两个话术
$checkProjectSn
=
explode
(
"#"
,
$params
[
'project_sn'
]);
if
(
!
isset
(
$checkProjectSn
[
1
])
||
empty
(
$checkProjectSn
[
1
])){
return
$this
->
errorWithInfo
(
'呼叫设置验证失败'
,
401
);
try
{
$allowLoginUser
=
$this
->
getAllowLoginUser
();
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'strategy_name'
=>
'required|max:30'
,
'user_sn'
=>
'required'
,
'call_number'
=>
'required'
,
'day_type'
=>
'required'
,
'frequency_type'
=>
'required'
,
'call_time_set'
=>
'required'
,
'project_sn'
=>
'required'
]);
if
(
$validator
->
fails
())
{
return
$this
->
errorWithInfo
(
'表单验证失败'
,
401
);
}
$params
=
$request
->
all
();
if
(
$params
[
'day_type'
]
==
0
){
//每天、一天两次,两个时间点、一个话术或者两个话术
$checkCallTimeSet
=
explode
(
"#"
,
$params
[
'call_time_set'
]);
if
(
!
isset
(
$checkCallTimeSet
[
1
])
||
empty
(
$checkCallTimeSet
[
1
])){
return
$this
->
errorWithInfo
(
'呼叫设置验证失败'
,
401
);
}
}
else
{
//日期前一天和当天、一天一次, 一个时间点两个话术
$checkProjectSn
=
explode
(
"#"
,
$params
[
'project_sn'
]);
if
(
!
isset
(
$checkProjectSn
[
1
])
||
empty
(
$checkProjectSn
[
1
])){
return
$this
->
errorWithInfo
(
'呼叫设置验证失败'
,
401
);
}
}
}
$successTotal
=
$failTotal
=
0
;
$failDataFile
=
''
;
if
(
isset
(
$params
[
'upload'
])){
//excel文件上传
$excelData
=
$StrategyService
->
validUploadExcel
(
$request
,
'upload'
,
8388608
);
//限制最大上传文件8M
if
(
isset
(
$excelData
[
'code'
])){
return
$this
->
errorWithInfo
(
$excelData
[
'msg'
],
401
);
$successTotal
=
$failTotal
=
0
;
$failDataFile
=
''
;
if
(
isset
(
$params
[
'upload'
])){
//excel文件上传
$excelData
=
$StrategyService
->
validUploadExcel
(
$request
,
'upload'
,
8388608
);
//限制最大上传文件8M
if
(
isset
(
$excelData
[
'code'
])){
return
$this
->
errorWithInfo
(
$excelData
[
'msg'
],
401
);
}
//验证excel数据格式及不合格数据原因
$excelDataValid
=
$StrategyService
->
validExcelData
(
$excelData
,
$params
[
'day_type'
]);
extract
(
$excelDataValid
);
unset
(
$params
[
'upload'
]);
}
//验证excel数据格式及不合格数据原因
$excelDataValid
=
$StrategyService
->
validExcelData
(
$excelData
,
$params
[
'day_type'
]);
extract
(
$excelDataValid
);
unset
(
$params
[
'upload'
]);
}
if
(
isset
(
$successTotal
)
&&
$successTotal
>
0
){
$params
[
'latest_total'
]
=
$successTotal
;
$params
[
'total'
]
=
$successTotal
;
}
$strategySn
=
$this
->
uidd
();
$params
[
'strategy_sn'
]
=
$strategySn
;
$params
[
'user_name'
]
=
$allowLoginUser
[
'user_name'
];
$params
[
'parent_sn'
]
=
$allowLoginUser
[
'parent_sn'
];
$StrategySet
=
new
StrategySet
(
$params
);
$setReturn
=
$StrategySet
->
save
();
if
(
$setReturn
){
//策略保存成功,处理excel数据
if
(
isset
(
$successTotal
)
&&
$successTotal
>
0
){
$insertExcelReturn
=
$StrategyService
->
insertStrategyExcel
(
$strategySn
,
$successData
);
$params
[
'latest_total'
]
=
$successTotal
;
$params
[
'total'
]
=
$successTotal
;
}
}
//返回成功数、失败数、失败导出文件
$returnArr
=
compact
(
'total'
,
'successTotal'
,
'failTotal'
,
'failDataFile'
);
return
$this
->
successWithInfo
(
$returnArr
);
$strategySn
=
$this
->
uidd
();
$params
[
'strategy_sn'
]
=
$strategySn
;
$params
[
'user_name'
]
=
$allowLoginUser
[
'user_name'
];
$params
[
'parent_sn'
]
=
$allowLoginUser
[
'parent_sn'
];
$StrategySet
=
new
StrategySet
(
$params
);
$setReturn
=
$StrategySet
->
save
();
if
(
$setReturn
){
//策略保存成功,处理excel数据
if
(
isset
(
$successTotal
)
&&
$successTotal
>
0
){
$insertExcelReturn
=
$StrategyService
->
insertStrategyExcel
(
$strategySn
,
$successData
);
}
}
//返回成功数、失败数、失败导出文件
$returnArr
=
compact
(
'total'
,
'successTotal'
,
'failTotal'
,
'failDataFile'
);
return
$this
->
successWithInfo
(
$returnArr
);
}
catch
(
\Exception
$e
){
Log
::
channel
(
'api'
)
->
error
(
$e
->
getFile
()
.
'-'
.
$e
->
getLine
()
.
'-'
.
$e
->
getMessage
());
return
$this
->
errorWithInfo
(
'操作异常'
,
500
);
}
}
//删除策略
public
function
destroy
(
$strategySn
){
DB
::
transaction
(
function
()
use
(
$strategySn
)
{
// 删除逻辑 注意多表关联的情况
StrategySet
::
where
(
'strategy_sn'
,
$strategySn
)
->
delete
();
StrategyExcel
::
where
(
'strategy_sn'
,
$strategySn
)
->
delete
();
//StrategyTask::where('strategy_sn', $strategySn)->delete();
StrategyTask
::
where
([[
'strategy_sn'
,
$strategySn
],[
'is_created'
,
0
]])
->
delete
();
//删除未新建的任务数据
});
return
$this
->
successWithInfo
(
'操作完成'
);
try
{
DB
::
transaction
(
function
()
use
(
$strategySn
)
{
// 删除逻辑 注意多表关联的情况
StrategySet
::
where
(
'strategy_sn'
,
$strategySn
)
->
delete
();
StrategyExcel
::
where
(
'strategy_sn'
,
$strategySn
)
->
delete
();
//StrategyTask::where('strategy_sn', $strategySn)->delete();
StrategyTask
::
where
([[
'strategy_sn'
,
$strategySn
],[
'is_created'
,
0
]])
->
delete
();
//删除未新建的任务数据
});
return
$this
->
successWithInfo
(
'操作完成'
);
}
catch
(
\Exception
$e
){
Log
::
channel
(
'api'
)
->
error
(
$e
->
getFile
()
.
'-'
.
$e
->
getLine
()
.
'-'
.
$e
->
getMessage
());
return
$this
->
errorWithInfo
(
'操作异常'
,
500
);
}
}
//子账号列表
public
function
getUsersList
(){
...
...
@@ -165,45 +180,50 @@ class StrategySetController extends Controller
//导入excel数据
public
function
importExcelData
(
Request
$request
,
StrategyService
$StrategyService
){
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'strategy_sn'
=>
'required'
,
'upload'
=>
'required'
]);
if
(
$validator
->
fails
())
{
return
$this
->
errorWithInfo
(
'表单验证失败'
,
401
);
}
$strategySn
=
$request
->
strategy_sn
;
$strategyInfo
=
StrategySet
::
where
(
'strategy_sn'
,
$strategySn
)
->
first
();
if
(
empty
(
$strategyInfo
)){
return
$this
->
errorWithInfo
(
'策略不存在'
,
401
);
}
$day_type
=
$strategyInfo
->
day_type
;
if
(
isset
(
$request
->
upload
)
&&
!
empty
(
$request
->
upload
)){
//excel文件上传
$total
=
$successTotal
=
$failTotal
=
0
;
$failDataFile
=
''
;
$excelData
=
$StrategyService
->
validUploadExcel
(
$request
,
'upload'
,
8388608
);
//限制最大上传文件8M
if
(
isset
(
$excelData
[
'code'
])){
return
$this
->
errorWithInfo
(
$excelData
[
'msg'
],
401
);
}
//验证excel数据格式及不合格数据原因
$excelDataValid
=
$StrategyService
->
validExcelData
(
$excelData
,
$day_type
);
extract
(
$excelDataValid
);
try
{
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'strategy_sn'
=>
'required'
,
'upload'
=>
'required'
]);
if
(
isset
(
$successTotal
)
&&
$successTotal
>
0
){
$insertExcelReturn
=
$StrategyService
->
insertStrategyExcel
(
$strategySn
,
$successData
);
//添加最新导入数及总数
$updateArr
[
'latest_total'
]
=
$successTotal
;
$updateArr
[
'total'
]
=
$strategyInfo
->
total
+
$successTotal
;
StrategySet
::
where
(
'strategy_sn'
,
$strategySn
)
->
update
(
$updateArr
);
}
if
(
$validator
->
fails
())
{
return
$this
->
errorWithInfo
(
'表单验证失败'
,
401
);
}
//返回成功数、失败数、失败导出文件
$returnArr
=
compact
(
'total'
,
'successTotal'
,
'failTotal'
,
'failDataFile'
);
return
$this
->
successWithInfo
(
$returnArr
);
}
else
{
return
$this
->
errorWithInfo
(
'请选择导入文件'
,
401
);
}
$strategySn
=
$request
->
strategy_sn
;
$strategyInfo
=
StrategySet
::
where
(
'strategy_sn'
,
$strategySn
)
->
first
();
if
(
empty
(
$strategyInfo
)){
return
$this
->
errorWithInfo
(
'策略不存在'
,
401
);
}
$day_type
=
$strategyInfo
->
day_type
;
if
(
isset
(
$request
->
upload
)
&&
!
empty
(
$request
->
upload
)){
//excel文件上传
$total
=
$successTotal
=
$failTotal
=
0
;
$failDataFile
=
''
;
$excelData
=
$StrategyService
->
validUploadExcel
(
$request
,
'upload'
,
8388608
);
//限制最大上传文件8M
if
(
isset
(
$excelData
[
'code'
])){
return
$this
->
errorWithInfo
(
$excelData
[
'msg'
],
401
);
}
//验证excel数据格式及不合格数据原因
$excelDataValid
=
$StrategyService
->
validExcelData
(
$excelData
,
$day_type
);
extract
(
$excelDataValid
);
if
(
isset
(
$successTotal
)
&&
$successTotal
>
0
){
$insertExcelReturn
=
$StrategyService
->
insertStrategyExcel
(
$strategySn
,
$successData
);
//添加最新导入数及总数
$updateArr
[
'latest_total'
]
=
$successTotal
;
$updateArr
[
'total'
]
=
$strategyInfo
->
total
+
$successTotal
;
StrategySet
::
where
(
'strategy_sn'
,
$strategySn
)
->
update
(
$updateArr
);
}
//返回成功数、失败数、失败导出文件
$returnArr
=
compact
(
'total'
,
'successTotal'
,
'failTotal'
,
'failDataFile'
);
return
$this
->
successWithInfo
(
$returnArr
);
}
else
{
return
$this
->
errorWithInfo
(
'请选择导入文件'
,
401
);
}
}
catch
(
\Exception
$e
){
Log
::
channel
(
'api'
)
->
error
(
$e
->
getFile
()
.
'-'
.
$e
->
getLine
()
.
'-'
.
$e
->
getMessage
());
return
$this
->
errorWithInfo
(
'操作异常'
,
500
);
}
}
}
app/Http/Controllers/strategy/StrategyTaskController.php
View file @
f91cc4e8
...
...
@@ -16,91 +16,97 @@ class StrategyTaskController extends Controller
use
Tool
;
public
function
index
(
Request
$request
){
//搜索分页?
$pageSize
=
request
()
->
pageSize
;
$projectArr
=
$this
->
getAllowProjects
(
1
);
//$strategyInfo = StrategyTask::all()->toArray();
$searchArr
=
[];
/* $searchArr['phone'] = request()->phone;
$searchArr['is_created'] = request()->is_created;
$searchArr['callTimeStart'] = request()->started_at;
$searchArr['callTimeStop'] = request()->stoped_at; */
$searchArr
[
'phone'
]
=
$request
->
phone
;
$searchArr
[
'is_created'
]
=
$request
->
is_created
;
$searchArr
[
'callTimeStart'
]
=
$request
->
started_at
;
$searchArr
[
'callTimeStop'
]
=
$request
->
stoped_at
;
Log
::
channel
(
'api'
)
->
info
(
var_export
(
$searchArr
,
true
));
$strategyInfo
=
StrategyTask
::
where
(
function
(
$query
)
use
(
$searchArr
){
if
(
isset
(
$searchArr
[
'phone'
])
&&
!
empty
(
$searchArr
[
'phone'
])){
$query
->
where
(
'phone'
,
'like'
,
"%
{
$searchArr
[
'phone'
]
}
%"
);
}
if
(
isset
(
$searchArr
[
'is_created'
])
&&
is_numeric
(
$searchArr
[
'is_created'
])){
$query
->
where
(
'is_created'
,
"
{
$searchArr
[
'is_created'
]
}
"
);
}
try
{
$pageSize
=
request
()
->
pageSize
;
$projectArr
=
$this
->
getAllowProjects
(
1
);
//$strategyInfo = StrategyTask::all()->toArray();
if
(
isset
(
$searchArr
[
'callTimeStart'
])
&&
!
empty
(
$searchArr
[
'callTimeStart'
])){
$query
->
whereRaw
(
" call_date || ' ' || call_time >= '
{
$searchArr
[
'callTimeStart'
]
}
'"
);
}
$searchArr
=
[];
/* $searchArr['phone'] = request()->phone;
$searchArr['is_created'] = request()->is_created;
$searchArr['callTimeStart'] = request()->started_at;
$searchArr['callTimeStop'] = request()->stoped_at; */
$searchArr
[
'phone'
]
=
$request
->
phone
;
$searchArr
[
'is_created'
]
=
$request
->
is_created
;
$searchArr
[
'callTimeStart'
]
=
$request
->
started_at
;
$searchArr
[
'callTimeStop'
]
=
$request
->
stoped_at
;
Log
::
channel
(
'api'
)
->
info
(
var_export
(
$searchArr
,
true
));
if
(
isset
(
$searchArr
[
'callTimeStop'
])
&&
!
empty
(
$searchArr
[
'callTimeStop'
])){
$query
->
whereRaw
(
" call_date || ' ' || call_time <= '
{
$searchArr
[
'callTimeStop'
]
}
'"
);
}
});
if
(
empty
(
$pageSize
)){
$strategyInfo
=
$strategyInfo
->
orderBy
(
'call_date'
,
'desc'
)
->
orderBy
(
'call_time'
,
'desc'
)
->
get
()
->
toArray
();
}
else
{
$strategyInfo
=
$strategyInfo
->
orderBy
(
'call_date'
,
'desc'
)
->
orderBy
(
'call_time'
,
'desc'
)
->
paginate
(
$pageSize
)
->
toArray
();
}
$listInfo
=
[];
if
(
isset
(
$strategyInfo
[
'data'
])
&&
!
empty
(
$strategyInfo
[
'data'
])){
foreach
(
$strategyInfo
[
'data'
]
as
$k
=>
$v
){
$strategyInfo
[
'data'
][
$k
][
'project_name'
]
=
isset
(
$projectArr
[
$v
[
'project_sn'
]])
?
$projectArr
[
$v
[
'project_sn'
]]
:
''
;
$strategyInfo
[
'data'
][
$k
][
'is_created_name'
]
=
$v
[
'is_created'
]
==
0
?
'未建'
:
'已建'
;
$strategyInfo
=
StrategyTask
::
where
(
function
(
$query
)
use
(
$searchArr
){
if
(
isset
(
$searchArr
[
'phone'
])
&&
!
empty
(
$searchArr
[
'phone'
])){
$query
->
where
(
'phone'
,
'like'
,
"%
{
$searchArr
[
'phone'
]
}
%"
);
}
if
(
isset
(
$searchArr
[
'is_created'
])
&&
is_numeric
(
$searchArr
[
'is_created'
])){
$query
->
where
(
'is_created'
,
"
{
$searchArr
[
'is_created'
]
}
"
);
}
if
(
isset
(
$searchArr
[
'callTimeStart'
])
&&
!
empty
(
$searchArr
[
'callTimeStart'
])){
$query
->
whereRaw
(
" call_date || ' ' || call_time >= '
{
$searchArr
[
'callTimeStart'
]
}
'"
);
}
if
(
isset
(
$searchArr
[
'callTimeStop'
])
&&
!
empty
(
$searchArr
[
'callTimeStop'
])){
$query
->
whereRaw
(
" call_date || ' ' || call_time <= '
{
$searchArr
[
'callTimeStop'
]
}
'"
);
}
});
if
(
empty
(
$pageSize
)){
$strategyInfo
=
$strategyInfo
->
orderBy
(
'call_date'
,
'desc'
)
->
orderBy
(
'call_time'
,
'desc'
)
->
get
()
->
toArray
();
}
else
{
$strategyInfo
=
$strategyInfo
->
orderBy
(
'call_date'
,
'desc'
)
->
orderBy
(
'call_time'
,
'desc'
)
->
paginate
(
$pageSize
)
->
toArray
();
}
}
return
$this
->
successWithInfo
(
$strategyInfo
);
$listInfo
=
[];
if
(
isset
(
$strategyInfo
[
'data'
])
&&
!
empty
(
$strategyInfo
[
'data'
])){
foreach
(
$strategyInfo
[
'data'
]
as
$k
=>
$v
){
$strategyInfo
[
'data'
][
$k
][
'project_name'
]
=
isset
(
$projectArr
[
$v
[
'project_sn'
]])
?
$projectArr
[
$v
[
'project_sn'
]]
:
''
;
$strategyInfo
[
'data'
][
$k
][
'is_created_name'
]
=
$v
[
'is_created'
]
==
0
?
'未建'
:
'已建'
;
}
}
return
$this
->
successWithInfo
(
$strategyInfo
);
}
catch
(
\Exception
$e
){
Log
::
channel
(
'api'
)
->
error
(
$e
->
getFile
()
.
'-'
.
$e
->
getLine
()
.
'-'
.
$e
->
getMessage
());
return
$this
->
errorWithInfo
(
'操作异常'
,
500
);
}
}
public
function
update
(
Request
$request
,
$id
)
{
$phone
=
$request
->
phone
;
$name
=
$request
->
name
;
$callTime
=
$request
->
call_time
;
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'phone'
=>
'required|regex:/^1[3-8]{1}[0-9]{9}$/'
,
'user_sn'
=>
'required'
,
'call_time'
=>
'required'
,
'name'
=>
'max:20'
]);
if
(
$validator
->
fails
())
{
return
$this
->
errorWithInfo
(
'表单验证失败'
,
401
);
}
$taskInfo
=
StrategyTask
::
find
(
$id
);
if
(
empty
(
$taskInfo
)){
return
$this
->
errorWithInfo
(
'任务数据不存在'
,
401
);
}
if
(
$taskInfo
->
is_created
==
1
){
return
$this
->
errorWithInfo
(
'任务已经创建不能编辑'
,
401
);
}
$taskInfo
->
phone
=
$phone
;
$taskInfo
->
name
=
$name
;
$taskInfo
->
call_time
=
$callTime
;
$taskInfo
->
save
();
return
$this
->
successWithInfo
(
'更新成功'
);
try
{
$phone
=
$request
->
phone
;
$name
=
$request
->
name
;
$callTime
=
$request
->
call_time
;
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'phone'
=>
'required|regex:/^1[3-8]{1}[0-9]{9}$/'
,
'user_sn'
=>
'required'
,
'call_time'
=>
'required'
,
'name'
=>
'max:20'
]);
if
(
$validator
->
fails
())
{
return
$this
->
errorWithInfo
(
'表单验证失败'
,
401
);
}
$taskInfo
=
StrategyTask
::
find
(
$id
);
if
(
empty
(
$taskInfo
)){
return
$this
->
errorWithInfo
(
'任务数据不存在'
,
401
);
}
if
(
$taskInfo
->
is_created
==
1
){
return
$this
->
errorWithInfo
(
'任务已经创建不能编辑'
,
401
);
}
$taskInfo
->
phone
=
$phone
;
$taskInfo
->
name
=
$name
;
$taskInfo
->
call_time
=
$callTime
;
$taskInfo
->
save
();
return
$this
->
successWithInfo
(
'更新成功'
);
}
catch
(
\Exception
$e
){
Log
::
channel
(
'api'
)
->
error
(
$e
->
getFile
()
.
'-'
.
$e
->
getLine
()
.
'-'
.
$e
->
getMessage
());
return
$this
->
errorWithInfo
(
'操作异常'
,
500
);
}
}
...
...
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