80 lines
2.6 KiB
PHP
80 lines
2.6 KiB
PHP
<?php
|
|
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use app\admin\service\SurveyService;
|
|
use app\common\validate\SurveyValidate;
|
|
use app\model\Survey as SurveyModel;
|
|
|
|
/**
|
|
* 管理部-查勘管理
|
|
*
|
|
* Class AdminSurvey
|
|
* @package app\admin\controller
|
|
*/
|
|
class AdminSurvey extends Base
|
|
{
|
|
|
|
public function index()
|
|
{
|
|
$userId = $this->userId;
|
|
//todo 用户权限检查
|
|
$data = $this->request->get();
|
|
$map = [];
|
|
if (isset($data['user_name']) && !empty($data['user_name'])){
|
|
$map[] = ['s.user_name','like',$data['user_name'].'%'];
|
|
}
|
|
if (isset($data['start_time']) && !empty($data['start_time'])){
|
|
$map[] = ['s.start_time','>',$data['start_time']];
|
|
}
|
|
if (isset($data['end_time']) && !empty($data['end_time'])){
|
|
$map[] = ['s.end_time','<',$data['end_time']];
|
|
}
|
|
if (isset($data['property_full_name']) && !empty($data['property_full_name'])){
|
|
$map[] = ['b.property_full_name','like',$data['property_full_name'].'%'];
|
|
}
|
|
if (isset($data['order_no']) && !empty($data['order_no'])){
|
|
$map[] = ['a.order_no','like',$data['order_no'].'%'];
|
|
}
|
|
if (isset($data['status']) && !empty($data['status'])){
|
|
if (is_array($data['status'])){
|
|
$map[] = ['s.status','in',$data['status']];
|
|
}else{
|
|
$map[] = ['s.status','=',$data['status']];
|
|
}
|
|
}
|
|
$survey = new SurveyModel();
|
|
$surveys = $survey
|
|
->alias('s')
|
|
->join(['pg_property_cert_info' => 'b'],'s.property_cert_info_id = b.id')
|
|
->join(['pg_inquiry' => 'a'],'b.quot_id = a.id')
|
|
->where($map)
|
|
->field([
|
|
'a.order_no','a.is_multiple','a.type','a.user_name',
|
|
'b.property_full_name','b.city','b.area','b.response_username','b.remark',
|
|
's.id','s.status','s.create_time',
|
|
])
|
|
->paginate();
|
|
return $this->buildSuccess($surveys);
|
|
}
|
|
|
|
/**
|
|
* 指派
|
|
*
|
|
* @return \think\Response
|
|
* @throws \app\admin\exception\LogicException
|
|
*/
|
|
public function assign_survey()
|
|
{
|
|
$userId = $this->userId;
|
|
$data = $this->request->post();
|
|
$validate = new SurveyValidate();
|
|
if (!$validate->scene(SurveyValidate::SCENE_ASSIGN)->batch()->check($data)){
|
|
return $this->buildFailed('参数验证失败',$validate->getError());
|
|
}
|
|
$surveyService = new SurveyService();
|
|
$surveyService->assign($userId,$data);
|
|
return $this->buildSuccess();
|
|
}
|
|
} |