Files
pgserver3.0/pgserver/application/admin/controller/Property_cert_info.php
annnj-company 130c1026c4 first commit
2026-04-17 18:29:53 +08:00

137 lines
4.5 KiB
PHP

<?php
namespace app\admin\controller;
use app\admin\service\SurveyService;
use app\common\validate\InquiryDetailValidate;
use app\common\validate\SurveyValidate;
use app\model\Inquiry;
use think\Db;
class Property_cert_info extends Base
{
/**
* 发起查勘
*
* @return \think\Response
* @throws \app\admin\exception\LogicException
*/
public function reqApplySurvey()
{
$order_no = $this->request->post('order_no');
$data = $this->request->post('details/a');
if (!$order_no || !$data) return $this->buildFailed('参数错误');
//验证
$surveyService = new SurveyService();
$verifyResult = $surveyService->checkSurvey($data);
if ($verifyResult['is_success'] !== true) {
return $this->buildFailed('提交信息有误', $verifyResult['errors']);
}
$param['user_id'] = $this->userInfo['user_id'];
$param['user_name'] = $this->userInfo['user_name'];
$param['order_no'] = $order_no;
$param['detail'] = $data;
// $result = $surveyService->askSurvey($param);
if ($this->userInfo['user_id']==1) {
// 超级管理员admin不用检查物业6个月内是否出过报告
$result = $surveyService->askSurveyUnck($param);
} else {
$result = $surveyService->askSurvey($param);
}
if ($result['code'] == -1) {
return $this->buildFailed($result['msg']);
}
return $this->buildSuccess('发起查勘成功');
}
public function searchProperty()
{
// 接收客户端参数
$keyword = $this->request->post('keyword');
$num = $this->request->post('num');// 默认返回10条记录
if (empty($keyword)) {
return $this->buildSuccess('搜索物业名不能为空');
}
// 获取所有物业名称记录
$properties = Db::name('pg_property_cert_info')
->field('id, property_full_name, building_no, unit_no, city_id, city, size, property_cert')
->select();
$result = [];
// 计算相似度并记录
foreach ($properties as $property) {
$similarity = 0;
similar_text($keyword, $property['property_full_name'], $similarity);
$result[] = [
'similarity' => $similarity,
'id' => $property['id'],
'building_name' => $property['property_full_name'],
'building_no' => $property['building_no'],
'unit_no' => $property['unit_no'],
'city_id' => $property['city_id'],
'city' => $property['city'],
'size' => $property['size'],
'property_cert' => $property['property_cert']
];
}
// 按相似度排序
usort($result, function($a, $b) {
return $b['similarity'] <=> $a['similarity'];
});
// 只返回前$num条记录
$result = array_slice($result, 0, $num);
return $this->buildSuccess( $result );
}
// 获取物业详情
public function getPropertyById()
{
$id = $this->request->post('id');
if (empty($id)) {
return $this->buildSuccess( "物业ID不能为空" );
}
$Property_cert_info = new Property_cert_info();
$property = $Property_cert_info->find($id);
if (!$property) {
return $this->buildSuccess( "未找到该物业信息" );
}
// 转换字段名
$result = [
'id' => $property['id'],
'building_name' => $property['property_full_name'],
'building_no' => $property['building_no'],
'unit_no' => $property['unit_no'],
'purchase_date' => $property['purchase_date'] ?? '',
'completion_time' => $property['completion_time'] ?? '',
'is_tran_tax_free' => $property['is_tran_tax_free'] ?? 2, // 默认未满两年
'size' => $property['size'] ?? '',
'reg_price' => $property['reg_price'] ?? '',
'usage' => $property['usage'] ?? '',
'ownership_type' => $property['ownership_type'] ?? 1,
'city_id' => $property['city_id'] ?? '440300',
'property_cert' => $property['property_cert'] ?? '',
'obligee' => $property['obligee'] ?? '',
'land_location' => $property['land_location'] ?? ''
];
return $this->buildSuccess( $result );
}
}