Files
annnj-company 130c1026c4 first commit
2026-04-17 18:29:53 +08:00

82 lines
3.1 KiB
PHP

<?php
namespace app\admin\controller;
use app\admin\service\InquiryService;
use app\model\Inquiry as InquiryModel;
use think\Db;
class SimpleInquiry extends Base{
/**
* 简易询价列表
*/
public function index(InquiryModel $inquiry)
{
$search_text = $this->request->post('search_text'); //物业名称
$status = $this->request->post('status'); //订单状态
$user_name = $this->request->post('user_name'); //业务员
$response_username = $this->request->post('response_username'); //询价员
$start_time = $this->request->post('start_time'); //询价开始时间
$end_time = $this->request->post('end_time'); //询价结束时间
$map = [];
if(empty($this->userInfo)){
return $this->buildFailed("获取简易询价列表失败,因用户信息为空,请重新登录","",ReturnCode::AUTH_ERROR);
}
//权限
if (!in_array("ROLE_ADMIN", $this->userInfo['roleCode'])) {
$user_ids = array($this->userInfo['user_id']); //$this->userInfo['user_ids'] ? implode(',', $this->userInfo['user_ids']) : '';
$map[] = ['i.user_id' ,'in', $user_ids]; //权限
}
$search_text && $map[] = ['d.property_full_name','like','%'.$search_text.'%'];
$user_name && $map[] = ['i.user_name','like','%'.$user_name.'%'];
$response_username && $map[] = ['p.appraiser_name','like','%'.$response_username.'%'];
if ($start_time || $end_time) $map[] = getQueryDate('i.create_time', $start_time, $end_time);
if($status){
$map[] = ['i.status', '=', $status];
}else{
$map[] = ['i.status', 'in', '1,5,8'];
}
$map[] = ['i.is_simple', '=', 1];
$res = $inquiry->simpleInquiryList($this->getPage(),$map);
return $this->buildSuccess(['list' => $res['data'], 'count' => $res['total']]);
}
//获取订单状态
public function getOrderStatus(){
$map[] = ['code', 'in', '1,5,8'];
$res = Db::name('dictionary')->field('code,valname')->where(['type'=>'ORDER_STATUS', 'status'=>1])->where($map)->select();
return $this->buildSuccess($res);
}
/**
* 提交简易询价
*/
public function save()
{
$data = $this->request->post();
//验证
$inquiryService = new InquiryService();
$verifyResult = $inquiryService->checkSimpleInquiry($data);
if ($verifyResult['is_success'] !== true) {
return $this->buildFailed('提交信息有误', $verifyResult['errors'], -2);
}
$userInfo = ['user_id'=>$this->userInfo['user_id'], 'user_name'=>$this->userInfo['user_name'], 'user_phone'=>$this->userInfo['user_phone'], 'department_id'=>$this->userInfo['department_id'], 'department_name'=> $this->userInfo['department_name']];
$data = array_merge($userInfo, $data);
$res = $inquiryService->createSimpleInquiry($data);
if($res['code'] == 1) {
return $this->buildSuccess();
}
return $this->buildFailed($res['code'], $res['msg']);
}
}