1621 lines
65 KiB
PHP
1621 lines
65 KiB
PHP
<?php
|
||
|
||
|
||
namespace app\admin\controller;
|
||
|
||
use app\admin\service\OcrService;
|
||
use app\admin\service\OssService;
|
||
use app\common\validate\ReportValidate;
|
||
use app\model\Charge;
|
||
use app\model\Taxation;
|
||
use think\Db;
|
||
use app\admin\service\InquiryService;
|
||
use app\common\validate\InquiryValidate;
|
||
use app\model\Inquiry as InquiryModel;
|
||
use app\model\InquiryOldData as InquiryOldDataModel;
|
||
use app\admin\service\CommonService;
|
||
use app\model\Attachment;
|
||
use app\util\ReturnCode;
|
||
use app\model\Report;
|
||
use app\util\Tools;
|
||
use app\admin\controller\Charge as ChargeController;
|
||
use think\facade\Log;
|
||
|
||
class Bussiness extends Base
|
||
{
|
||
|
||
/**
|
||
* 询价列表
|
||
*/
|
||
public function index()
|
||
{
|
||
$data = $this->request->post();
|
||
$inquiry = new InquiryModel();
|
||
if(empty($this->userInfo)){
|
||
return $this->buildFailed("提交询价单失败,因用户信息为空,请重新登录","",ReturnCode::AUTH_ERROR);
|
||
}
|
||
if (!$this->isAdmin() && !$this->isAppraiser() && !$this->isBusinessTeamLeader() ) {
|
||
//$data['user_id'] = $this->userInfo['user_ids'] ? implode(',', $this->userInfo['user_ids']) : ''; //权限
|
||
$data['user_id'] = array($this->userInfo['user_id']);
|
||
|
||
}
|
||
|
||
|
||
$inquiries = $inquiry->getInquiryPaginate($this->getPage(),$data);
|
||
|
||
// for test coding 测试代码
|
||
//$inquiries['data']['userInfo_srv'] = $this->userInfo;
|
||
|
||
return $this->buildSuccess(['data' => $inquiries['data'], 'count' => $inquiries['total']],false);
|
||
}
|
||
|
||
/**
|
||
* 询价列表(旧数据)
|
||
*/
|
||
public function old_index()
|
||
{
|
||
$data = $this->request->post();
|
||
$inquiry = new InquiryOldDataModel();
|
||
if(empty($this->userInfo)){
|
||
return $this->buildFailed("提交询价单失败,因用户信息为空,请重新登录","",ReturnCode::AUTH_ERROR);
|
||
}
|
||
// if (!$this->isAdmin() && !$this->isAppraiser() && !$this->isBusinessTeamLeader() ) {
|
||
// //$data['user_id'] = $this->userInfo['user_ids'] ? implode(',', $this->userInfo['user_ids']) : ''; //权限
|
||
// $data['user_id'] = array($this->userInfo['user_id']);
|
||
// }
|
||
|
||
|
||
$inquiries = $inquiry->getOldInquiryPaginate($this->getPage(),$data);
|
||
|
||
// for test coding 测试代码
|
||
//$inquiries['data']['userInfo_srv'] = $this->userInfo;
|
||
|
||
return $this->buildSuccess(['data' => $inquiries['data'], 'count' => $inquiries['total']],false);
|
||
}
|
||
|
||
/**
|
||
* @api {post} admin/Inquiry/property_cert_info 询价详情
|
||
*/
|
||
public function property_cert_info(){
|
||
$quot_id = $this->request->post('quot_id');
|
||
$property_cert_info_id = $this->request->post('property_cert_info_id');
|
||
if(!$quot_id || !$property_cert_info_id)
|
||
return $this->buildFailed('参数不能为空!');
|
||
|
||
$subsql = Db::table('pg_return_price')->field('appraiser_name,total_guide_tax,property_cert_info_id,eva_unit_price,guide_price,eva_total_value,eva_net_value,eva_net_value2,gross_value,loan_ratio,internal_remarks,external_remarks,tips')->group('property_cert_info_id')->order('property_cert_info_id', 'desc')->buildSql();
|
||
$result = Db::name('inquiry')->alias('a')
|
||
->join(['pg_property_cert_info' => 'b'], 'b.quot_id = a.id')
|
||
->join([$subsql => 'd'], 'b.id = d.property_cert_info_id', 'left')
|
||
->field('a.id,a.order_no,a.bank_name,a.bank_id,a.bank_branch_name,a.bank_branch_id,a.bank_sub_name,a.product_id,a.bank_customer_mgr_name,a.type,a.user_name,a.buss_username,a.eva_purpose,d.appraiser_name')
|
||
->where(['a.id' => $quot_id])
|
||
->find();
|
||
|
||
$estate_info = Db::table('pg_property_cert_info')->field('id,property_full_name as building_name')->where(['quot_id' => $quot_id])->select();
|
||
$result['estata_number'] = count($estate_info);//物业数量
|
||
$result['estate_info'] = $estate_info; //物业信息
|
||
//回价信息
|
||
$returnPrices = Db::name('property_cert_info')->alias('d')
|
||
->join([$subsql => 'p'], 'd.id = p.property_cert_info_id')
|
||
->field('d.property_full_name,d.size,d.usage,p.eva_unit_price,p.total_guide_tax,p.guide_price,p.eva_total_value,p.eva_net_value,p.eva_net_value2,p.gross_value,p.loan_ratio,p.internal_remarks,p.external_remarks,p.tips,p.appraiser_name')
|
||
->where('d.quot_id', $quot_id)
|
||
->select();
|
||
$result['returnPrices'] = $returnPrices;
|
||
|
||
|
||
//基本信息
|
||
$common = new CommonService();
|
||
$res = $common->getDetatil($quot_id,$property_cert_info_id);
|
||
$result['basic_info'] = $res ? $res : [];
|
||
return $this->buildSuccess($result);
|
||
}
|
||
|
||
|
||
/**
|
||
* @api {post} admin/Inquiry/save 提交询价
|
||
*/
|
||
public function save()
|
||
{
|
||
$data = $this->request->post();
|
||
|
||
$validate = new InquiryValidate();
|
||
// 如果有批量物业数据上传
|
||
$batchfile = $this->request->file("file");
|
||
if (!$validate->scene(InquiryValidate::SCENE_CREATE)->batch()->check($data)) {
|
||
return $this->buildFailed('提交信息有误', $validate->getError());
|
||
}
|
||
|
||
$inquiryService = new InquiryService();
|
||
$verifyResult = $inquiryService->checkInquiryDetails($data['type'], $data['details']);
|
||
if ($verifyResult['is_success'] !== true) {
|
||
Log::error("提交信息有误:".json_encode($verifyResult['errors'], 256));
|
||
return $this->buildFailed('提交信息有误', $verifyResult['errors'], -2);
|
||
}
|
||
$data['user_id'] = $this->userInfo['user_id'];
|
||
$data['user_name'] = $this->userInfo['user_name'];
|
||
$data['user_phone'] = $this->userInfo['user_phone'];
|
||
$data['department_id'] = $this->userInfo['department_id'];
|
||
$data['department_name'] = $this->userInfo['department_name'];
|
||
|
||
$res = $inquiryService->createInquiry($data);
|
||
if($res['code'] == 1){
|
||
return $this->buildSuccess();
|
||
}
|
||
return $this->buildFailed($res['code'], $res['msg']);
|
||
}
|
||
|
||
public function batchSave()
|
||
{
|
||
// 如果有批量物业数据上传
|
||
$batchfile = $this->request->file("file");
|
||
if( !$batchfile->isValid())
|
||
{
|
||
return $this->buildFailed('上传的文件有误', '请检查文件的可用性!');
|
||
}
|
||
|
||
$data = $this->request->post();
|
||
|
||
$inquiryService = new InquiryService();
|
||
|
||
if( isset( $data['op'] ) && 'update' == $data['op'] )
|
||
{
|
||
$res = $inquiryService->updateInquirybyBatch( $data['quot_id'] , $batchfile, $data, $this->getUserId(), $this->getUserName());
|
||
if( 1 != $res['code'])
|
||
{
|
||
return $this->buildFailed( $res['msg'] ) ;
|
||
}
|
||
else
|
||
{
|
||
return $this->buildSuccess();
|
||
}
|
||
}
|
||
|
||
$validate = new InquiryValidate();
|
||
if( !isset($batchfile) )
|
||
{
|
||
return $this->buildFailed('请提交物业信息','物业Excel为空!');
|
||
}
|
||
|
||
if (!$validate->scene(InquiryValidate::SCENE_BATCH_SAVE)->batch()->check($data))
|
||
{
|
||
return $this->buildFailed('提交信息有误', $validate->getError());
|
||
}
|
||
|
||
$inquiryService = new InquiryService();
|
||
$data['user_id'] = $this->userInfo['user_id'];
|
||
$data['user_name'] = $this->userInfo['user_name'];
|
||
$data['user_phone'] = $this->userInfo['user_phone'];
|
||
$data['department_id'] = $this->userInfo['department_id'];
|
||
$data['department_name'] = $this->userInfo['department_name'];
|
||
|
||
$res = $inquiryService->createInquirybyBatch($data, $batchfile, $this->getUserId(), $this->getUserName());
|
||
if($res['code'] == 1){
|
||
return $this->buildSuccess();
|
||
}
|
||
return $this->buildFailed($res['code'], $res['msg']);
|
||
}
|
||
|
||
|
||
// 判断物业是否在指定时间内重复询价
|
||
public function reqIsQuotDuplicated(){
|
||
$repeat_type = 3; // 默认设置正常询价
|
||
$period = getSystemConfig('INQUIRY_PERIOD'); // 询价时间范围
|
||
// $start_time_unix = time() - $period * 30 * 24 * 3600;
|
||
$start_time_unix = time() - $period * 24 * 3600; // 单位由月修改为天
|
||
$return_data = [];
|
||
$return_data['repeat_type'] = $repeat_type;
|
||
$return_data['inquiry_period'] = $period;
|
||
|
||
if (empty($this->userInfo)) {
|
||
return $this->buildFailed("检查询价单是否存在失败,因用户信息为空,请重新登录","",ReturnCode::AUTH_ERROR);
|
||
}
|
||
|
||
$request_data = $this->request->post();
|
||
|
||
if ($request_data['type'] == 2) {
|
||
return $this->buildSuccess($return_data);
|
||
}
|
||
|
||
$validate = new InquiryValidate();
|
||
if (!$validate->scene(InquiryValidate::SCENE_CREATE)->batch()->check($request_data)) {
|
||
return $this->buildFailed('提交信息有误', $validate->getError());
|
||
}
|
||
$inquiryService = new InquiryService();
|
||
$verifyResult = $inquiryService->checkInquiryDetails($request_data['type'], $request_data['details']);
|
||
if ($verifyResult['is_success'] !== true) {
|
||
return $this->buildFailed('提交信息有误', $verifyResult['errors'], -2);
|
||
}
|
||
|
||
$user_id = $this->userInfo['user_id'];
|
||
$bank_id = $request_data['bank_id']; // 银行
|
||
$product_id = $request_data['product_id']; // 评估目的
|
||
$building_name = $request_data['details'][0]['building_name']; // 楼盘名称
|
||
$building_no = $request_data['details'][0]['building_no']; // 栋号
|
||
$unit_no = $request_data['details'][0]['unit_no']; // 房号
|
||
$is_tran_tax_free = $request_data['details'][0]['is_tran_tax_free']; // 是否满两年,1:是,2:否
|
||
$size = $request_data['details'][0]['size']; // 建筑面积
|
||
$reg_price = $request_data['details'][0]['reg_price']; // 登记价
|
||
$bank_sub_name = $request_data['bank_sub_name']; // 支行名
|
||
$start_time = date('Y-m-d H:i:s', $start_time_unix);
|
||
$end_time = date('Y-m-d H:i:s');
|
||
|
||
$building_no = $building_no!='0'?$building_no:'';
|
||
$unit_no = $unit_no!='0'?$unit_no:'';
|
||
|
||
if (strpos($reg_price, ".")===false) {
|
||
$reg_price = sprintf("%.2f", $reg_price);
|
||
}
|
||
|
||
$where[] = ['i.user_id', '=', $user_id];
|
||
$where[] = ['i.status', '>', 1];
|
||
$where[] = ['i.create_time', 'between time', [$start_time, $end_time]];
|
||
$where[] = ['i.bank_id', '=', $bank_id];
|
||
$where[] = ['i.product_id', '=', $product_id];
|
||
$where[] = ['id.property_full_name', '=', trim($building_name).trim($building_no).trim($unit_no)];
|
||
$where[] = ['id.is_tran_tax_free', '=', $is_tran_tax_free];
|
||
$where[] = ['id.size', '=', $size];
|
||
$where[] = ['id.reg_price', '=', $reg_price];
|
||
|
||
$result = Db::name('inquiry')
|
||
->alias('i')
|
||
->Join('property_cert_info id', 'i.id=id.quot_id')
|
||
->field('id.id as property_cert_info_id,i.user_id,i.status,i.bank_name,i.bank_sub_name')
|
||
->where($where)
|
||
->order('i.create_time desc')
|
||
->find();
|
||
|
||
if ($result) {
|
||
$return_data['repeat_type'] = 1; // 是否匹配到业务员自己已询价的历史记录,1:是,2:否
|
||
$return_data['report_finished'] = $result['status']==8?1:2; // 是否已出具报告,1:是,2:否
|
||
// 获取回价信息
|
||
$return_price_data = Db::name('return_price')
|
||
->where(['property_cert_info_id'=>$result['property_cert_info_id']])
|
||
->order('id desc')
|
||
->find();
|
||
$return_data['property_name'] = $return_price_data['property_name']; // 物业名称
|
||
$return_data['area'] = $return_price_data['area']; // 物业建筑面积
|
||
$return_data['eva_unit_price'] = $return_price_data['eva_unit_price']; // 评估单价
|
||
$return_data['eva_total_value'] = $return_price_data['eva_total_value']; // 评估总值
|
||
$return_data['eva_net_value'] = $return_price_data['eva_net_value']; // 净值1
|
||
$return_data['eva_net_value2'] = $return_price_data['eva_net_value2']; // 净值2
|
||
$return_data['gross_value'] = $return_price_data['gross_value']; // 贷款金额
|
||
$return_data['guide_price'] = $return_price_data['guide_price']; // 指导价
|
||
$return_data['tips'] = $return_price_data['tips']; // 贷款成数提示
|
||
$return_data['bank_name'] = $result['bank_name'].$bank_sub_name; // 银行+支行
|
||
$return_data['appraiser_name'] = $return_price_data['appraiser_name']; // 回价员
|
||
$return_data['remark'] = $return_price_data['external_remarks']; // 备注
|
||
$return_data['property_cert_info_id'] = $result['property_cert_info_id'];
|
||
} else {
|
||
$map[] = ['i.status', '>', 1];
|
||
$map[] = ['i.create_time', 'between time', [$start_time, $end_time]];
|
||
$map[] = ['i.bank_id', '=', $bank_id];
|
||
$map[] = ['i.product_id', '=', $product_id];
|
||
$map[] = ['id.property_full_name', '=', trim($building_name).trim($building_no).trim($unit_no)];
|
||
$map[] = ['id.is_tran_tax_free', '=', $is_tran_tax_free];
|
||
$map[] = ['id.size', '=', $size];
|
||
$map[] = ['id.reg_price', '=', $reg_price];
|
||
|
||
$result = Db::name('inquiry')
|
||
->alias('i')
|
||
->Join('property_cert_info id', 'i.id=id.quot_id')
|
||
->field('id.id as property_cert_info_id,i.user_id,i.status,i.bank_name,i.bank_sub_name')
|
||
->where($map)
|
||
->order('i.create_time desc')
|
||
->find();
|
||
|
||
if ($result) {
|
||
$return_data['repeat_type'] = 2; // 是否匹配到业务员自己已询价的历史记录,1:是,2:否
|
||
$return_data['report_finished'] = $result['status']==8?1:2; // 是否已出具报告,1:是,2:否
|
||
// 获取回价信息
|
||
$return_price_data = Db::name('return_price')
|
||
->where(['property_cert_info_id'=>$result['property_cert_info_id']])
|
||
->order('id desc')
|
||
->find();
|
||
$return_data['property_name'] = $return_price_data['property_name']; // 物业名称
|
||
$return_data['area'] = $return_price_data['area']; // 物业建筑面积
|
||
$return_data['eva_unit_price'] = $return_price_data['eva_unit_price']; // 评估单价
|
||
$return_data['eva_total_value'] = $return_price_data['eva_total_value']; // 评估总值
|
||
$return_data['eva_net_value'] = $return_price_data['eva_net_value']; // 净值1
|
||
$return_data['eva_net_value2'] = $return_price_data['eva_net_value2']; // 净值2
|
||
$return_data['gross_value'] = $return_price_data['gross_value']; // 贷款金额
|
||
$return_data['guide_price'] = $return_price_data['guide_price']; // 指导价
|
||
$return_data['tips'] = $return_price_data['tips']; // 贷款成数提示
|
||
$return_data['bank_name'] = $result['bank_name'].$bank_sub_name; // 银行+支行
|
||
$return_data['appraiser_name'] = $return_price_data['appraiser_name']; // 回价员
|
||
$return_data['remark'] = $return_price_data['external_remarks']; // 备注
|
||
$return_data['property_cert_info_id'] = $result['property_cert_info_id'];
|
||
}
|
||
}
|
||
return $this->buildSuccess($return_data);
|
||
}
|
||
|
||
// 重复询价的保存
|
||
public function reqQuotSubmitAgain(){
|
||
$flag = true;
|
||
if (empty($this->userInfo)) {
|
||
return $this->buildFailed("重复询价保存失败,因用户信息为空,请重新登录","",ReturnCode::AUTH_ERROR);
|
||
}
|
||
|
||
$request_data = $this->request->post();
|
||
|
||
$validate = new InquiryValidate();
|
||
if (!$validate->scene(InquiryValidate::SCENE_CREATE)->batch()->check($request_data)) {
|
||
return $this->buildFailed('提交信息有误', $validate->getError());
|
||
}
|
||
$inquiryService = new InquiryService();
|
||
$verifyResult = $inquiryService->checkInquiryDetails($request_data['type'], $request_data['details']);
|
||
if ($verifyResult['is_success'] !== true) {
|
||
return $this->buildFailed('提交信息有误', $verifyResult['errors'], -2);
|
||
}
|
||
|
||
$period = getSystemConfig('INQUIRY_PERIOD'); // 询价时间范围
|
||
// $start_time_unix = time() - $period * 30 * 24 * 3600;
|
||
$start_time_unix = time() - $period * 24 * 3600; // 单位由月修改为天
|
||
|
||
$bank_id = $request_data['bank_id']; // 银行
|
||
$product_id = $request_data['product_id']; // 评估目的
|
||
$building_name = $request_data['details'][0]['building_name']; // 楼盘名称
|
||
$building_no = $request_data['details'][0]['building_no']; // 栋号
|
||
$unit_no = $request_data['details'][0]['unit_no']; // 房号
|
||
$is_tran_tax_free = $request_data['details'][0]['is_tran_tax_free']; // 是否满两年,1:是,2:否
|
||
$size = $request_data['details'][0]['size']; // 建筑面积
|
||
$reg_price = $request_data['details'][0]['reg_price']; // 登记价
|
||
$start_time = date('Y-m-d H:i:s', $start_time_unix);
|
||
$end_time = date('Y-m-d H:i:s');
|
||
|
||
$building_no = $building_no!='0'?$building_no:'';
|
||
$unit_no = $unit_no!='0'?$unit_no:'';
|
||
|
||
if (strpos($reg_price, ".")===false) {
|
||
$reg_price = sprintf("%.2f", $reg_price);
|
||
}
|
||
|
||
$where[] = ['i.status', '>', 1];
|
||
$where[] = ['i.create_time', 'between time', [$start_time, $end_time]];
|
||
$where[] = ['i.bank_id', '=', $bank_id];
|
||
$where[] = ['i.product_id', '=', $product_id];
|
||
$where[] = ['id.property_full_name', '=', trim($building_name).trim($building_no).trim($unit_no)];
|
||
$where[] = ['id.is_tran_tax_free', '=', $is_tran_tax_free];
|
||
$where[] = ['id.size', '=', $size];
|
||
$where[] = ['id.reg_price', '=', $reg_price];
|
||
|
||
Db::startTrans();
|
||
$result = Db::name('inquiry')
|
||
->alias('i')
|
||
->Join('property_cert_info id', 'i.id=id.quot_id')
|
||
->field('id.*')
|
||
->where($where)
|
||
->order('i.create_time desc')
|
||
->find();
|
||
|
||
$return_price_data = Db::name('return_price')
|
||
->where(['property_cert_info_id'=>$result['id']])
|
||
->order('id desc')
|
||
->find();
|
||
if ($result && $return_price_data) {
|
||
$inquiry = new InquiryModel();
|
||
$ins_inquiry_data = [];
|
||
$ins_inquiry_data['order_no'] = $inquiry->generateInquiryNo($request_data['type']);
|
||
$ins_inquiry_data['user_id'] = $this->userInfo['user_id'];
|
||
$ins_inquiry_data['user_name'] = $this->userInfo['user_name'];
|
||
$ins_inquiry_data['buss_user_id'] = $request_data['buss_user_id'];
|
||
$ins_inquiry_data['buss_username'] = $request_data['buss_username'];
|
||
$ins_inquiry_data['business_no'] = $request_data['business_no'];
|
||
$ins_inquiry_data['user_phone'] = $this->userInfo['user_phone'];
|
||
$ins_inquiry_data['bank_id'] = $request_data['bank_id'];
|
||
$ins_inquiry_data['bank_name'] = $request_data['bank_name'];
|
||
$ins_inquiry_data['bank_branch_id'] = $request_data['bank_branch_id'];
|
||
$ins_inquiry_data['bank_branch_name'] = $request_data['bank_branch_name'];
|
||
$ins_inquiry_data['bank_sub_id'] = $request_data['bank_sub_id'];
|
||
$ins_inquiry_data['bank_sub_name'] = $request_data['bank_sub_name'];
|
||
$ins_inquiry_data['bank_customer_mgr_id'] = $request_data['bank_customer_mgr_id'];
|
||
$ins_inquiry_data['bank_customer_mgr_name'] = $request_data['bank_customer_mgr_name'];
|
||
$ins_inquiry_data['bank_customer_mgr_phone'] = $request_data['bank_customer_mgr_phone'];
|
||
$ins_inquiry_data['eva_purpose'] = $request_data['eva_purpose'];
|
||
$ins_inquiry_data['product_id'] = $request_data['product_id'];
|
||
$ins_inquiry_data['type'] = $request_data['type'];
|
||
$ins_inquiry_data['status'] = 2;
|
||
$ins_inquiry_data['department_id'] = $this->userInfo['department_id'];
|
||
$ins_inquiry_data['department_name'] = $this->userInfo['department_name'];
|
||
$ins_inquiry_data['eva_detail_time_long'] = 0;
|
||
$ins_inquiry_data['create_time'] = date('Y-m-d H:i:s');
|
||
$ins_inquiry_data['update_time'] = date('Y-m-d H:i:s');
|
||
$ins_inquiry_result = Db::name('inquiry')->insert($ins_inquiry_data);
|
||
$quot_id = Db::name('inquiry')->getLastInsID();
|
||
|
||
$ins_inquiry_detail_data = [];
|
||
$ins_inquiry_detail_data['quot_id'] = $quot_id;
|
||
$ins_inquiry_detail_data['city'] = $result['city'];
|
||
$ins_inquiry_detail_data['city_id'] = $result['city_id'];
|
||
$ins_inquiry_detail_data['property_full_name'] = $result['property_full_name'];
|
||
$ins_inquiry_detail_data['building_name'] = $result['building_name'];
|
||
$ins_inquiry_detail_data['building_unit_no'] = $result['building_unit_no'];
|
||
$ins_inquiry_detail_data['building_no'] = $result['building_no'];
|
||
$ins_inquiry_detail_data['unit_no'] = $result['unit_no'];
|
||
$ins_inquiry_detail_data['size'] = $result['size'];
|
||
$ins_inquiry_detail_data['reg_price'] = $result['reg_price'];
|
||
$ins_inquiry_detail_data['is_tran_tax_free'] = $result['is_tran_tax_free'];
|
||
$ins_inquiry_detail_data['ownership_type'] = $request_data['details'][0]['ownership_type'];
|
||
$ins_inquiry_detail_data['usage'] = $request_data['details'][0]['usage'];
|
||
$ins_inquiry_detail_data['property_cert'] = $request_data['details'][0]['property_cert'];
|
||
$ins_inquiry_detail_data['purchase_date'] = $request_data['details'][0]['purchase_date']?$request_data['details'][0]['purchase_date']:NULL;
|
||
$ins_inquiry_detail_data['completion_time'] = $request_data['details'][0]['completion_time']?$request_data['details'][0]['completion_time']:NULL;
|
||
$ins_inquiry_detail_data['land_location'] = $request_data['details'][0]['land_location'];
|
||
$ins_inquiry_detail_data['obligee'] = $request_data['details'][0]['obligee'];
|
||
$ins_inquiry_detail_data['year'] = $request_data['details'][0]['year'];
|
||
$ins_inquiry_detail_data['remark'] = $request_data['details'][0]['remark'];
|
||
$ins_inquiry_detail_data['attachments'] = $request_data['details'][0]['attachments'];
|
||
$ins_inquiry_detail_data['create_time'] = date('Y-m-d H:i:s');
|
||
$ins_inquiry_detail_data['update_time'] = date('Y-m-d H:i:s');
|
||
$ins_inquiry_detail_result = Db::name('property_cert_info')->insert($ins_inquiry_detail_data);
|
||
$property_cert_info = Db::name('property_cert_info')->getLastInsID();
|
||
|
||
$ins_return_price_data = $return_price_data;
|
||
$ins_return_price_data['id'] = '';
|
||
$ins_return_price_data['property_cert_info_id'] = $property_cert_info;
|
||
$ins_return_price_data['create_time'] = time();
|
||
$ins_return_price_result = Db::name('return_price')->insert($ins_return_price_data);
|
||
|
||
if ($ins_inquiry_result && $ins_inquiry_detail_result && $ins_return_price_result) {
|
||
Db::commit();
|
||
PublicMessage($quot_id,2,2);
|
||
} else {
|
||
$flag = false;
|
||
Db::rollback();
|
||
}
|
||
} else {
|
||
$flag = false;
|
||
Db::rollback();
|
||
}
|
||
|
||
if ($flag) {
|
||
return $this->buildSuccess('', '提交询价成功!');
|
||
} else {
|
||
return $this->buildFailed('提交询价失败!');
|
||
}
|
||
}
|
||
|
||
//判断物业是否近三个月出过报告
|
||
public function checkExistReport(){
|
||
$data = $this->request->post('data/a');
|
||
if(!$data) return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '参数错误');
|
||
$where[] = ['d.property_full_name', 'in', $data];
|
||
$where[] = ['r.status', '=', 3];
|
||
$where[] = ['r.appraisal_time', 'between', [date('Y-m-d H:i:s', strtotime('-3 month')), date('Y-m-d H:i:s', time())]];
|
||
$res = Db::name('report')->alias('r')
|
||
->field('d.property_full_name,i.bank_name,i.bank_branch_name,i.eva_purpose,r.appraisal_time,p.eva_unit_price,p.eva_net_value,p.eva_net_value2,p.gross_value')
|
||
->join('inquiry i', 'i.id = r.quot_id')
|
||
->join('property_cert_info d', 'i.id=d.quot_id')
|
||
->join('return_price p', 'd.id = p.property_cert_info_id')
|
||
->group('d.id')
|
||
->where($where)
|
||
->select();
|
||
foreach ($res as &$val){
|
||
$val['appraisal_time'] = date('Y年m月d日', strtotime($val['appraisal_time']));
|
||
}
|
||
return $this->buildSuccess($res);
|
||
}
|
||
|
||
|
||
/**
|
||
* @api {post} admin/Inquiry/reqPropertCertInfo 上传房产信息
|
||
*/
|
||
public function reqPropertCertInfo()
|
||
{
|
||
$data = $this->request->post();
|
||
$validate = new InquiryValidate();
|
||
if (!$validate->scene(InquiryValidate::SCENE_UPLOADATTACHMENTS)->batch()->check($data)) {
|
||
return $this->buildFailed($validate->getError());
|
||
}
|
||
|
||
$inquiryService = new InquiryService();
|
||
$isSuccess = $inquiryService->reqPropertCertInfo($data);
|
||
if (!$isSuccess) {
|
||
return $this->buildFailed('上传产证信息失败');
|
||
}
|
||
return $this->buildSuccess('上传产证信息成功');
|
||
}
|
||
|
||
|
||
/**
|
||
* @api {post} admin/Inquiry/reqNormalAdjustApprisePrice 正常调价
|
||
*/
|
||
public function reqNormalAdjustApprisePrice(){
|
||
$data = $this->request->post();
|
||
$validate = new InquiryValidate();
|
||
if (!$validate->scene(InquiryValidate::SCENE_MODIFYPRICE)->batch()->check($data)) {
|
||
return $this->buildFailed($validate->getError());
|
||
}
|
||
$inquiryService = new InquiryService();
|
||
$result = $inquiryService->reqNormalAdjustApprisePrice($data);
|
||
if ($result['code'] == -1) {
|
||
return $this->buildFailed($result['msg']);
|
||
}
|
||
return $this->buildSuccess('正常调价成功');
|
||
}
|
||
|
||
/**
|
||
* 撤单
|
||
*/
|
||
public function cancel()
|
||
{
|
||
$data = $this->request->post();
|
||
$validate = new InquiryValidate();
|
||
if (!$validate->scene(InquiryValidate::SCENE_CANCEL)->batch()->check($data)) {
|
||
return $this->buildFailed($validate->getError());
|
||
}
|
||
$inquiryService = new InquiryService();
|
||
$isSuccess = $inquiryService->cancelInquiry($data['quot_id']);
|
||
if (!$isSuccess) {
|
||
return $this->buildFailed('撤单失败');
|
||
}
|
||
return $this->buildSuccess();
|
||
}
|
||
|
||
|
||
/**
|
||
* @api {post} admin/Inquiry/createReport 申请生成报告
|
||
*
|
||
* @parameter property_cert_info_id 询价详情id
|
||
*/
|
||
public function createReport(){
|
||
$data = $this->request->post();
|
||
$type = $data['type'];
|
||
//验证
|
||
$inquiryService = new InquiryService();
|
||
if($type == 1){ //保存操作 - 验证物业信息合法
|
||
$verifyResult = $inquiryService->checkcreateReportDraft($data);
|
||
}elseif($type == 2){ //提交操作 - 验证数据是否合法
|
||
$verifyResult = $inquiryService->checkcreateReport($data);
|
||
}
|
||
|
||
if ($verifyResult['is_success'] !== true) {
|
||
return $this->buildFailed('提交信息有误');
|
||
}
|
||
|
||
$data['user_id'] = $this->userInfo['user_id'];
|
||
$data['user_name'] = $this->userInfo['user_name'];
|
||
|
||
/*$serverIP = env("uploadFile.qrcode_url");
|
||
|
||
// 生成二维码值(腾讯云登记域名)
|
||
$qrvalue = $serverIP."/index.php/admin/ReportManage/getAnticounterfeitPage?quot_id=".$data['quot_id'];
|
||
|
||
// 创建二维码
|
||
$url = Tools::createQRCode($qrvalue);
|
||
if(!empty($url))
|
||
{
|
||
$data['qrvalue'] = $qrvalue;
|
||
$data['qrurl'] = $url;
|
||
}*/
|
||
|
||
$isSuccess = (new Report())->createReport($data);
|
||
|
||
if (!$isSuccess) {
|
||
return $this->buildFailed('申请生成报告失败');
|
||
}
|
||
return $this->buildSuccess();
|
||
}
|
||
|
||
/**
|
||
* 获取一个报告流水号
|
||
*
|
||
* @return void
|
||
*/
|
||
public function getReportQRCode()
|
||
{
|
||
$res = ['reportNo'=>'','url'=>''];
|
||
|
||
$data = $this->request->post();
|
||
//var_dump($data);
|
||
$data['user_id'] = $this->userInfo['user_id'];
|
||
$data['user_name'] = $this->userInfo['user_name'];
|
||
|
||
$reportSrv = new Report();
|
||
$reports = $reportSrv->getReportByInquiryID($data['quot_id']);
|
||
|
||
if( count($reports) > 0 )
|
||
{
|
||
$reportInfo = $reports[0];
|
||
$res['reportNo'] = $reportInfo['report_no'];
|
||
$res['url'] = $reportInfo['qrurl'];
|
||
|
||
$this->buildChargeWithCheck( $reportInfo['id'],$res['reportNo'] );
|
||
}
|
||
else{
|
||
|
||
$serverIP = env("uploadFile.qrcode_url");
|
||
|
||
// 生成二维码值
|
||
$report_qrcode_unique_key = md5(uniqid());
|
||
$qrvalue = $serverIP.'/index.php/admin/ReportManage/getAnticounterfeitPage?quot_id='.$data['quot_id'] . '&key=' .$report_qrcode_unique_key;
|
||
$data['report_qrcode_unique_key'] = $report_qrcode_unique_key;
|
||
|
||
|
||
// 创建二维码
|
||
$url = Tools::createQRCode($qrvalue);
|
||
|
||
if($url != null )
|
||
{
|
||
$data['qrvalue'] = $qrvalue;
|
||
$data['qrurl'] = $url;
|
||
}
|
||
|
||
$resCreate = $reportSrv->createOffLineReport($data);
|
||
if (!$resCreate['isSucess']) {
|
||
return $this->buildFailed('申请生成报告失败:'.$resCreate['reason']);
|
||
}
|
||
$report_no = $resCreate['report_no'];
|
||
|
||
$this->buildChargeWithCheck( $reportSrv['id'] , $report_no );
|
||
|
||
//var_dump($report_no);
|
||
$res['reportNo'] = $report_no;
|
||
|
||
$res['url'] = $url;
|
||
|
||
}
|
||
return $this->buildSuccess($res);
|
||
}
|
||
|
||
/**
|
||
* 创建一条报告订单(如有报告号重复,就不创建)
|
||
* @param report_id
|
||
* @param report_no
|
||
*
|
||
**/
|
||
private function buildChargeWithCheck( $report_id, $report_no )
|
||
{
|
||
// 生成离线报告
|
||
$modelCharge = new Charge();
|
||
// 如果此报告的订单不存在,插入一条订单
|
||
$chargeInfo = $modelCharge->getInfoByReportNo($report_no);
|
||
//var_dump($chargeInfo);
|
||
if( $chargeInfo )
|
||
{
|
||
return ['result'=>true , 'msg'=>'已有订单数据' ];
|
||
}
|
||
else
|
||
{
|
||
$ChargeController = new ChargeController();
|
||
$chargeRes = $ChargeController->insReportData( $report_id );
|
||
//var_dump( $ChargeController);
|
||
if(!$chargeRes['result'])
|
||
{
|
||
['result'=>false, 'msg'=>$chargeRes['msg'] ];
|
||
}
|
||
}
|
||
|
||
return ['result'=>true ,'msg'=>'成功插入' ];
|
||
}
|
||
|
||
public function cqr()
|
||
{
|
||
$data = $this->request->post();
|
||
$res['url'] = $this->createQRCode($data['qrid']);
|
||
return $this->buildSuccess($res);
|
||
}
|
||
|
||
/**
|
||
* 创建二维码
|
||
* @var int inquriy_id 询价ID
|
||
* @return [ sti'qrvalue','qrurl'] . string qrvalue 二维码的值; string qrurl 二维码下载链接
|
||
*/
|
||
public function createQRCode( $quot_id )
|
||
{
|
||
$serverIP = env("uploadFile.qrcode_url");
|
||
|
||
// 生成二维码值
|
||
$qrvalue = $serverIP.'/index.php/admin/ReportManage/getAnticounterfeitPage?quot_id='. $quot_id;
|
||
|
||
// 创建二维码
|
||
$url = Tools::createQRCode($qrvalue);
|
||
$res = null;
|
||
if($url != null )
|
||
{
|
||
$res = ['qrvalue'=>$qrvalue,'qrurl'=>$url];
|
||
}
|
||
|
||
return $res;
|
||
}
|
||
|
||
//获取报告详情
|
||
public function getReportDetail(){
|
||
$quot_id = $this->request->post('quot_id');
|
||
if(!$quot_id) return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '参数错误');
|
||
$res = Db::name('report')
|
||
->field('id,print_cpy_no,pay_type,is_housing_fund,borrower_name,borrower_idcard,business_type,order_src')
|
||
->where(['quot_id'=>$quot_id])
|
||
->find();
|
||
|
||
|
||
if($res){
|
||
$res['order_src'] = (string)$res['order_src'];
|
||
$reportDetail = Db::name('report_detail')->alias('x')
|
||
->join('property_cert_info y', 'x.property_cert_info_id = y.id')
|
||
->field('x.id,x.property_cert_info_id,y.year,x.property_cert,x.obligee,x.cert_type,x.cert_no,x.client,x.parcel_no,x.parcel_area,x.parcel_usage,x.use_right_source,x.completion_date,
|
||
x.purchase_date,x.reg_date,x.max_land_use_years,x.land_use_start_time,x.land_use_end_time,x.area_id,x.area,x.building_area,x.land_location,x.house_cert_img_ids')
|
||
->where(['x.report_id'=>$res['id']])
|
||
->select();
|
||
foreach ($reportDetail as $k => &$v){
|
||
$v['house_img_details'] = ($v['house_cert_img_ids']) ? (new Attachment())->getUrls(explode(',', $v['house_cert_img_ids'])) : [];
|
||
$v['house_cert_img_ids'] = ($v['house_cert_img_ids']) ? explode(',', $v['house_cert_img_ids']) : '';
|
||
$v['area_id'] = (string)$v['area_id'];
|
||
}
|
||
$res['details'] = $reportDetail;
|
||
}
|
||
|
||
return $this->buildSuccess($res);
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* @api {get} admin/Inquiry/reqNormalAdjustApprisePriceList 正常调价列表
|
||
*/
|
||
public function reqNormalAdjustApprisePriceList(InquiryModel $inquiry)
|
||
{
|
||
$userId = $this->userInfo['user_id'];
|
||
$data = $this->request->post();
|
||
|
||
//2020年5月24日14:03:28 cavan
|
||
if(empty($this->userInfo)){
|
||
return $this->buildFailed("获取正常调价列表失败,因用户信息为空,请重新登录","",ReturnCode::AUTH_ERROR);
|
||
}
|
||
|
||
if (!in_array("ROLE_ADMIN", $this->userInfo['roleCode'])) {
|
||
//$data['user_id'] = $this->userInfo['user_ids'] ? implode(',', $this->userInfo['user_ids']) : '';
|
||
$data['user_id'] = array($this->userInfo['user_id']);
|
||
}
|
||
$res = $inquiry->getNormalModifyList($userId, $this->getPage(), $data);
|
||
return $this->buildSuccess($res);
|
||
}
|
||
|
||
|
||
/**
|
||
* @api {post} admin/Inquiry/normalModifyDetail 正常调价详情
|
||
*/
|
||
public function normalModifyDetail(InquiryModel $inquiry)
|
||
{
|
||
$data = $this->request->post();
|
||
if (empty($data['id']) || empty($data['property_cert_info_id'])) return $this->buildFailed('参数不能为空!');
|
||
$res = $inquiry->getNormalModifyDetail($data);
|
||
return $this->buildSuccess($res);
|
||
}
|
||
|
||
|
||
/**
|
||
* @api {post} admin/Inquiry/reqPropertyInfo 上传房产信息-获取房产详情
|
||
*/
|
||
public function reqPropertyInfo(){
|
||
$quot_id = $this->request->post('quot_id');
|
||
if(!$quot_id) return $this->buildFailed('inquiry_id询价id不能为空');
|
||
|
||
$field = 'x.id,x.property_full_name as building_name,x.city_id,x.owner_name,x.property_cert,x.attachments,x.ownership_type,x.size,x.year,y.eva_unit_price';
|
||
|
||
$subsql = Db::table('pg_return_price')
|
||
->field('property_cert_info_id,eva_unit_price')
|
||
->group('property_cert_info_id')
|
||
->order('property_cert_info_id', 'desc')->buildSql();
|
||
|
||
$data = Db::name('property_cert_info')->alias('x')
|
||
->join([$subsql => 'y'], 'x.id = y.property_cert_info_id', 'left')
|
||
->where('x.quot_id', $quot_id)
|
||
->field($field)
|
||
->group('x.id')
|
||
->select();
|
||
|
||
foreach ($data as &$value) {
|
||
$attachments = [];
|
||
if ($value['attachments']){
|
||
$ids = explode(',', $value['attachments']);
|
||
$attachments = (new Attachment())->getUrls($ids);
|
||
}
|
||
$value['attachments'] = $attachments;
|
||
}
|
||
return $this->buildSuccess($data);
|
||
}
|
||
|
||
|
||
/**
|
||
* @api {post} admin/Inquiry/getProduct 获取评估目的
|
||
*
|
||
* @param bank_id 银行id
|
||
*/
|
||
public function getProduct(){
|
||
$bank_id = $this->request->post('bank_id');
|
||
$type = $this->request->post('type');
|
||
if(!$bank_id) return $this->buildFailed('参数不能为空');
|
||
$where['bank_id'] = $bank_id;
|
||
$where['state'] = 1;
|
||
$where['type'] = !empty($type) ? $type : 1;
|
||
$res = Db::name('product')->field('id,product_name')->where($where)->select();
|
||
return $this->buildSuccess($res);
|
||
}
|
||
|
||
// 房产证OCR识别
|
||
public function ocrRecogniseHouseCert()
|
||
{
|
||
$image_arr = ['image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/bmp', 'image/webp'];
|
||
$pdf_arr = ['application/pdf'];
|
||
$file_ids = $this->request->post('file_ids');
|
||
if (!$file_ids) return $this->buildFailed('参数不能为空');
|
||
|
||
try {
|
||
$all_data = [];
|
||
foreach ($file_ids as $file_id) {
|
||
$attachment = (new Attachment())->where('id', $file_id)->find();
|
||
if (!$attachment) return $this->buildFailed('附件不存在');
|
||
|
||
$file_url = str_replace('\\', '/', config('uploadFile.url') . $attachment['url']);
|
||
|
||
$tmpPath = str_replace('\\', '/', ROOT_PATH . 'runtime/temp/');
|
||
if (!is_dir($tmpPath)) {
|
||
mkdir($tmpPath, 0777, true);
|
||
}
|
||
if (!in_array($attachment['mimetype'], $image_arr) && !in_array($attachment['mimetype'], $pdf_arr)) {
|
||
continue;
|
||
}
|
||
|
||
// 保存为临时图片文件
|
||
$tempFilePath = $tmpPath . md5(uniqid()). '.'. $attachment['ext'];
|
||
|
||
$oss_service = new OssService();
|
||
$res = $oss_service->getOSSFile($file_url, $tempFilePath);
|
||
sleep(3);
|
||
|
||
$curl_res = curlRequest(
|
||
env('ocr_service.url'),
|
||
'POST',
|
||
null,
|
||
[],
|
||
['file' => $tempFilePath]
|
||
);
|
||
|
||
if($curl_res['code'] == 200) {
|
||
$all_data[] = json_decode($curl_res['data'], true);
|
||
}
|
||
@unlink($tempFilePath);
|
||
}
|
||
$data = !empty($all_data) ? array_merge(...$all_data) : [];
|
||
// return $this->buildSuccess($data);
|
||
|
||
// try {
|
||
|
||
|
||
//第一种
|
||
$data1 = [
|
||
'不动产权第',
|
||
'粤',
|
||
'附',
|
||
'2025',
|
||
'深圳市',
|
||
'0106364号',
|
||
'1',
|
||
'市场商品房。取得方式:购买。买卖合同签订日期:2025年3月20日',
|
||
'权利人',
|
||
'郭佩萍',
|
||
'说明:本不动产上的其他权利事项,以不动产登记薄记载为准',
|
||
'共有情况',
|
||
'单独所有',
|
||
'中',
|
||
'坐落',
|
||
'福田区福田街道福华路京海花园塔楼15B',
|
||
'不动产单元号',
|
||
'440304008002GB00091F00010072',
|
||
'广权市求',
|
||
'权利类型',
|
||
'国有建设用地使用权/房屋所有权',
|
||
'权利性质',
|
||
'出让/商品房',
|
||
'用途',
|
||
'商业、住宅/住宅',
|
||
'面积',
|
||
'建筑面积:100.12平方米',
|
||
'使用期限',
|
||
'70年,从1996年8月28日至2066年8月27日上',
|
||
'产教证事',
|
||
'1.宗地号:B121-0034宗地面积:4789.4平方米',
|
||
'2.套内建筑面积:81.76平方米',
|
||
'3.竣工日期:1998年7月24日',
|
||
'4.登记价:人民币3430000元',
|
||
'权利其他状况',
|
||
'单不动产卖',
|
||
'5.权利人:郭佩萍(440514199805131840)',
|
||
'#工作',
|
||
'#不动产租证'
|
||
];
|
||
|
||
//第二种
|
||
$data2 = [
|
||
"权利人",
|
||
"建筑物及其附着物",
|
||
")[100%]************",
|
||
"房地产名称",
|
||
"晨晖家园2座10K",
|
||
"*****************",
|
||
"土",
|
||
"地",
|
||
"建筑面积",
|
||
"35.85m",
|
||
"套内建筑面积",
|
||
"24.72m²",
|
||
"",
|
||
"",
|
||
"用途",
|
||
"单身公寓",
|
||
"竣工日期",
|
||
"2004年10月29日",
|
||
"宗地号",
|
||
"B114-0066",
|
||
"宗地面积",
|
||
"3001.9m",
|
||
"登记价",
|
||
"人民币241537.00元",
|
||
"土地用途",
|
||
"单身公寓、肉菜市场",
|
||
"所在区",
|
||
"福田",
|
||
"他项权利摘要及附记",
|
||
"土地位置",
|
||
"深圳市福田区皇岗公园一街",
|
||
"市场商品房。于2009-12-23购买。",
|
||
"使用年限",
|
||
"70年,从1999年03月29日至2069年03月28日止。",
|
||
"程",
|
||
"",
|
||
"",
|
||
"29:2669星12月站销抵押络中域工银特股有限公司深圳福田支行,编号2D09047764",
|
||
"中国印花税票国",
|
||
"深房地字第 3000595892 号",
|
||
"(正本)",
|
||
"深圳市房地产权登记中心(印章)",
|
||
"登记日期2009年12月25日"
|
||
];
|
||
|
||
//第三种
|
||
$data3 = [
|
||
"估",
|
||
"4.",
|
||
"规",
|
||
"2.",
|
||
"知",
|
||
"土",
|
||
"地",
|
||
"权利人名称",
|
||
"张美",
|
||
"宗",
|
||
"地",
|
||
"号",
|
||
"B215-0016",
|
||
"权利人性质",
|
||
"份额",
|
||
"个人",
|
||
"100%",
|
||
"百花二路",
|
||
"土",
|
||
"地",
|
||
"位",
|
||
"置",
|
||
"法定代表人姓名",
|
||
"认",
|
||
"所有权性质",
|
||
"身份证类型",
|
||
"标准",
|
||
"转让",
|
||
"使用权来源",
|
||
"身份证所在地",
|
||
"吉林省吉林市",
|
||
"等",
|
||
"级",
|
||
"身份证号码",
|
||
"222401197202291624",
|
||
"中高层住宅用地",
|
||
"用",
|
||
"途",
|
||
"权利人名称",
|
||
"份额",
|
||
"10.9",
|
||
"用地",
|
||
"平方米",
|
||
"共",
|
||
"面",
|
||
"",
|
||
"积",
|
||
"有",
|
||
"录",
|
||
"12929.2平方米",
|
||
"共有使用权面积",
|
||
"支术",
|
||
"权",
|
||
"人",
|
||
"使用年限",
|
||
"70年从1993-06-29至2063-06-28止",
|
||
"签名",
|
||
"日共",
|
||
"用",
|
||
"地价款",
|
||
"档",
|
||
"登",
|
||
"出让金",
|
||
"记",
|
||
"其",
|
||
"签",
|
||
"机",
|
||
"市政配套",
|
||
"日",
|
||
"关",
|
||
"设施费",
|
||
"中",
|
||
"N",
|
||
"土地开发费",
|
||
"乙",
|
||
"2",
|
||
"3",
|
||
"OFF",
|
||
"房",
|
||
"屋",
|
||
"及其它附着物",
|
||
"使用面积",
|
||
"建购价款",
|
||
"分摊用地",
|
||
"GT",
|
||
"建筑面积",
|
||
"结构装修",
|
||
"竣工日期",
|
||
"(M2)",
|
||
"(M2)",
|
||
"(元)",
|
||
"面积(M²)",
|
||
"宗地支号",
|
||
"名称及栋号",
|
||
"山",
|
||
"88.11",
|
||
"¥500000",
|
||
"0093",
|
||
"百花公寓1栋",
|
||
"13E",
|
||
"框剪结构初级装修",
|
||
"1995-01-31",
|
||
"以下至白",
|
||
"",
|
||
"心",
|
||
"业",
|
||
"绿",
|
||
"支术",
|
||
"",
|
||
"面",
|
||
"签名",
|
||
"日共",
|
||
"”",
|
||
"档",
|
||
"1",
|
||
"签",
|
||
"日",
|
||
"2",
|
||
"C",
|
||
"L",
|
||
"5"
|
||
];
|
||
|
||
// 住宅
|
||
// 第一种
|
||
$data11 = [
|
||
"粤",
|
||
"(2022)",
|
||
"深圳市不动产权第0208755",
|
||
"号",
|
||
"市场商品房。该权利人于2022-06-18购买该商品房。根据深府办规",
|
||
"权利人",
|
||
"颜湘之(H60260884)",
|
||
"【2018】9号,自登记之日起,该房产3年内禁止转让。",
|
||
"说明:本不动产上的其他权利事项,以不动产登记薄记载为准。",
|
||
"共有情况单独所有",
|
||
"莲花街道景田西路与商报路交汇处东北侧天健天骄北庐1栋E座",
|
||
"坐",
|
||
"落",
|
||
"4301",
|
||
"不动产单元号440304003001GB00307F00010851",
|
||
"权利类型",
|
||
"国有建设用地使用权/房屋所有权",
|
||
"权利性质",
|
||
"出让/商品房",
|
||
"用",
|
||
"途",
|
||
"二类居住用地/住宅",
|
||
"面",
|
||
"积",
|
||
"建筑面积:209.64平方米",
|
||
"使用期限",
|
||
"70年,从2017年4月10日至2087年4月9日止",
|
||
"1.宗地号:B202-0088,宗地面积:19918.68平方米",
|
||
"2.套内建筑面积:163.57平方米",
|
||
"3.竣工日期:2020年12月31日",
|
||
"4.登记价人民币31186726元",
|
||
"权利其他状况",
|
||
"5.共有情况:无"
|
||
];
|
||
|
||
// 第二种
|
||
$data12 = [
|
||
"人",
|
||
"建筑物及其附着物",
|
||
"权利",
|
||
"房地产名称",
|
||
"鹏兴花园41栋611",
|
||
"******************",
|
||
"杨福荣(650203195909200068)[100%]*********",
|
||
"85.15m",
|
||
"套内建筑面积**m",
|
||
"地",
|
||
"建筑面积",
|
||
"土",
|
||
"竣工日期",
|
||
"2000年06月30日",
|
||
"用",
|
||
"途",
|
||
"住宅",
|
||
"宗地面积",
|
||
"28466.1m",
|
||
"宗地号",
|
||
"H227-0034",
|
||
"登记价",
|
||
"人民币393989.00元",
|
||
"所在区",
|
||
"罗湖",
|
||
"土地用途",
|
||
"中高层住宅用地",
|
||
"他喷权利",
|
||
"",
|
||
"摘要及附记",
|
||
"土地位置",
|
||
"罗湖区莲塘鹏兴路",
|
||
"市场商品房:该权利人子2007-0829申请办理转移登记。",
|
||
"01",
|
||
"热",
|
||
"70年,从1992年02月25日至2062年02月24日止。",
|
||
"1).2007年09月11日抵押给招商银行股份有限公司深圳东门支行,编号1D07030563(18",
|
||
"使用年限",
|
||
"322):",
|
||
"个人年",
|
||
"",
|
||
"合同专用章",
|
||
"TO童NTPI",
|
||
"2(x05年银行业纳税六名",
|
||
"南银行股份有限公司",
|
||
"原件抵押在民生銀行",
|
||
"深房地字第2000388496号",
|
||
"(正本)",
|
||
"二",
|
||
"",
|
||
"深圳市国土资源和房产管理局(印章)",
|
||
"1",
|
||
"登记日期2007年09月04日"
|
||
];
|
||
|
||
// 第三种
|
||
$data13 = [
|
||
"0上10",
|
||
"权利人名称",
|
||
"土",
|
||
"地",
|
||
"",
|
||
"李耀先",
|
||
"宗",
|
||
"地号",
|
||
"权利人性质",
|
||
"份额",
|
||
"G06311-25",
|
||
"个人",
|
||
"1/2",
|
||
"土地位置",
|
||
"布吉镇大芬村",
|
||
"法定代表人姓名",
|
||
"无注",
|
||
"所有权性质",
|
||
"身份证类型",
|
||
"标准",
|
||
"自空平",
|
||
"使用权来源",
|
||
"购商品房",
|
||
"身份证所在地",
|
||
"黑龙江省",
|
||
"等",
|
||
"级",
|
||
"身份证号码",
|
||
"231005631211101",
|
||
"用",
|
||
"途",
|
||
"往宅用地",
|
||
"权利人名称",
|
||
"份额",
|
||
"共",
|
||
"张丽萍",
|
||
"1/2",
|
||
"用地面积",
|
||
"15.1",
|
||
"平方米",
|
||
"有权人",
|
||
"共有使用权面积",
|
||
"2554.4平方米",
|
||
"使用年限",
|
||
"70年从1991-06-28至2061-06-28止",
|
||
"用地价款",
|
||
"登记机关",
|
||
"出让金",
|
||
"其",
|
||
"市政配套",
|
||
"设施费",
|
||
"登记日期001年02月19田)",
|
||
"中",
|
||
"土地开发费",
|
||
"5",
|
||
"2",
|
||
"3",
|
||
"房屋",
|
||
"及",
|
||
"其它",
|
||
"附",
|
||
"着物",
|
||
"fe!",
|
||
"建筑面积使用面积",
|
||
"建购价款",
|
||
"分提用地",
|
||
"房号",
|
||
"结构装修",
|
||
"竣工日期",
|
||
"(M²)",
|
||
"(M²)",
|
||
"(元)",
|
||
"宗地支号",
|
||
"名称及栋号",
|
||
"1993-12-31",
|
||
"66.55",
|
||
"¥123800",
|
||
"电联大厦",
|
||
"3F2-2",
|
||
"框架结初级装修",
|
||
"以下空白",
|
||
"86",
|
||
"人",
|
||
"人衣",
|
||
"心中气市",
|
||
"5",
|
||
"2"
|
||
];
|
||
|
||
// 非住宅
|
||
// 第一种
|
||
$data21 = [
|
||
"粤(",
|
||
"2015",
|
||
"",
|
||
")",
|
||
"深圳市不动产权第",
|
||
"",
|
||
"0065978",
|
||
"附",
|
||
"记",
|
||
"深圳市宝盛实业有限公司[100%]",
|
||
"市场商品房。",
|
||
"权利人",
|
||
"本不动产上的其他权利和事项,以不动产登记簿记载为准。",
|
||
"共有情况",
|
||
"单独所有",
|
||
"坐",
|
||
"落",
|
||
"南山区学苑大道南科大雅苑135",
|
||
"不动产单元号",
|
||
"权利类型",
|
||
"国有建设用地使用权/房屋(构筑物)所有权",
|
||
"商品房",
|
||
"权利性质",
|
||
"用",
|
||
"途",
|
||
"商业",
|
||
"面",
|
||
"积",
|
||
"188.84平方米",
|
||
"使用期限",
|
||
"70年,从2011年10月14日至2081年10月13日止",
|
||
"宗地号:1506-0004:宗地面积:22669.97平方米",
|
||
"套内建筑面积:185.16平方米",
|
||
"竣工日期:2015年09月10日",
|
||
"登记价:人民币1669503.00元",
|
||
"权利其他状况"
|
||
];
|
||
|
||
// 第二种
|
||
$data22 = [
|
||
"权利人",
|
||
"建筑物及其附着物",
|
||
"住宅楼1栋17-601",
|
||
"深圳市富乐金电子科技有限公司[100%]********",
|
||
"房地产名称",
|
||
"土",
|
||
"地",
|
||
"984.78m",
|
||
"套内建筑面积**",
|
||
"建筑面积",
|
||
"宗地面积6166.7m",
|
||
"商业",
|
||
"竣工日期",
|
||
"宗地号",
|
||
"H214-0062",
|
||
"用途",
|
||
"1983年06月01日",
|
||
"所在区",
|
||
"罗湖",
|
||
"人民币10460000.00元",
|
||
"土地用途",
|
||
"商业、住宅",
|
||
"登记价",
|
||
"土地位置",
|
||
"罗湖区东门中路城东街",
|
||
"使用年限",
|
||
"50年,从1981年10月23日至2031年10月22日止。",
|
||
"。",
|
||
"复印件与原舒核对相行",
|
||
"八",
|
||
"u",
|
||
"找",
|
||
"",
|
||
"深房地字第2000548680号",
|
||
"(正本)",
|
||
"本",
|
||
"深圳市房地产权登记中心(印章)",
|
||
"登记日期2011年12月21日"
|
||
];
|
||
|
||
$data31 = [
|
||
"权",
|
||
"利",
|
||
"人",
|
||
"建筑物及其附着物",
|
||
"深圳市新天际广告有限公司[100%]****************************",
|
||
"房地产名称",
|
||
"中国经贸大厦10C",
|
||
"土",
|
||
"地",
|
||
"建筑面积",
|
||
"125.13m",
|
||
"套内建筑面积",
|
||
"90.48m²",
|
||
"用",
|
||
"途",
|
||
"办公",
|
||
"宗地号",
|
||
"B301-0058",
|
||
"宗地面积",
|
||
"竣工日期",
|
||
"2007年04月24日",
|
||
"4647.9m²",
|
||
"登记价",
|
||
"人民币1932453.00元",
|
||
"土地用途",
|
||
"商业、办公",
|
||
"所在区",
|
||
"福田",
|
||
"他项权利摘要及附记",
|
||
"土地位置",
|
||
"福田区竹子林紫竹七路",
|
||
"市场商品房。于2009-12-22购买。",
|
||
"使用年限",
|
||
"50年,从2005年03月29日至2055年03月28日止。",
|
||
"5",
|
||
"團",
|
||
"",
|
||
"B",
|
||
"",
|
||
"中国印花税票理",
|
||
"深房地字第3000596103号",
|
||
"(正本)",
|
||
"深圳市房地产权登记中心(印章)",
|
||
"登记日期2009年12月28日"
|
||
];
|
||
|
||
$data32 = [
|
||
"图",
|
||
"2019",
|
||
"不动产权第",
|
||
"0047625号",
|
||
"深圳市",
|
||
"附记",
|
||
"广程证书",
|
||
"权利人",
|
||
"市场商品房。合同签订日期:2019-03-14。根据深府办规[2018]9号,自",
|
||
"熊刚(360102197406025315)",
|
||
"登记之日起3年内禁止转让。",
|
||
"说明:本不动产上的其他权利事项,以不动产登记簿记载为准。",
|
||
"共有情况",
|
||
"单独所有",
|
||
"坐落",
|
||
"子不动产权证书",
|
||
"华华不动产权证书",
|
||
"南山月亮湾月亮湾山庄B区低层住宅B34",
|
||
"M",
|
||
"不动产单元号",
|
||
"440305004006GB00012F00350070",
|
||
"权利类型",
|
||
"不动产林证龙平不动产权证书",
|
||
"国有建设用地使用权/房屋所有权",
|
||
"华食",
|
||
"权利性质",
|
||
"出让/商品房",
|
||
"用",
|
||
"途",
|
||
"居住用地/住宅",
|
||
"不动产权证书",
|
||
"不动产权证书",
|
||
"门",
|
||
"",
|
||
"金",
|
||
"面",
|
||
"积",
|
||
"建筑面积:259.34平方米",
|
||
"使用期限",
|
||
"70年,从1992年12月20日至2062年12月19日止",
|
||
"权证书",
|
||
"平务不动产权证书",
|
||
"动",
|
||
"1.宗地号:T101-0035,宗地面积:137443.3平方米",
|
||
"2.套内建筑面积:平方米",
|
||
"3.竣工日期:1998年11月18日",
|
||
"4.登记价人民币10000000元",
|
||
"权利其他状况",
|
||
"5.共有情况:无",
|
||
"不动产权证",
|
||
"不动产权证书",
|
||
"不动产权证书",
|
||
"不动产权证书名",
|
||
"不动产机证#",
|
||
"保动产权证书#",
|
||
"会",
|
||
""
|
||
];
|
||
|
||
$data = array_values(array_filter($data));
|
||
|
||
$property_cert_info = OcrService::getPropertyCert($data);
|
||
$obligee_and_cert_no = OcrService::getObligeeAndCertNo($data);
|
||
$size_and_reg_price_and_completion_time = OcrService::getSizeAndRegPriceAndCompletionTime($data);
|
||
$purchase_date_and_use_right_source = OcrService::getPurchaseDateAndUseRightSource($data);
|
||
$property_full_name = OcrService::getPropertyFullName($data);
|
||
$ownership_type_and_usage = OcrService::getOwnershipTypeAndUsage($data);
|
||
|
||
// 组合结果
|
||
$result = [
|
||
'property_cert' => $property_cert_info['property_cert'],
|
||
'city' => $property_cert_info['city'],
|
||
'city_id' => $property_cert_info['city_id'],
|
||
'obligee' => $obligee_and_cert_no['obligee'],
|
||
'cert_no' => $obligee_and_cert_no['cert_no'],
|
||
'size' => $size_and_reg_price_and_completion_time['size'],
|
||
'reg_price' => $size_and_reg_price_and_completion_time['reg_price'],
|
||
'completion_time' => $size_and_reg_price_and_completion_time['completion_time'],
|
||
'purchase_date' => $purchase_date_and_use_right_source['purchase_date'],
|
||
'use_right_source' => $purchase_date_and_use_right_source['use_right_source'],
|
||
'property_full_name' => $property_full_name['property_full_name'],
|
||
'ownership_type' => $ownership_type_and_usage['ownership_type'],
|
||
'usage' => $ownership_type_and_usage['usage'],
|
||
];
|
||
|
||
|
||
return $this->buildSuccess($result);
|
||
/*
|
||
京津冀晋蒙辽吉黑沪苏浙皖闽赣鲁豫澳台鄂湘粤桂琼渝川贵云藏陕甘青宁新港
|
||
*
|
||
*/
|
||
|
||
} catch(\Exception $e) {
|
||
Log::error('错误文件:'.$e->getFile());
|
||
Log::error('错误行数:'.$e->getLine());
|
||
Log::error('错误编码:'.$e->getCode());
|
||
Log::error('错误信息:'.$e->getMessage());
|
||
return $this->buildFailed('系统错误');
|
||
}
|
||
}
|
||
|
||
public function copyPropertyCertInfo()
|
||
{
|
||
$id = $this->request->post('id');
|
||
if (empty($id)) return $this->buildFailed('参数错误');
|
||
|
||
$list = Db::name('property_cert_info')->where('quot_id', $id)->select();
|
||
if (empty($list)) return $this->buildFailed('未找到相关数据');
|
||
|
||
return $this->buildSuccess($list);
|
||
}
|
||
|
||
public function autoInquiry()
|
||
{
|
||
$building_name = $this->request->post('building_name');
|
||
$building_no = $this->request->post('building_no');
|
||
$unit_no = $this->request->post('unit_no');
|
||
$size = $this->request->post('size');
|
||
|
||
if (empty($building_name)) return $this->buildFailed('请输入物业名称');
|
||
if (empty($building_no)) return $this->buildFailed('请输入栋号');
|
||
if (empty($unit_no)) return $this->buildFailed('请输入房号');
|
||
if (empty($size)) return $this->buildFailed('请输入建筑面积');
|
||
|
||
$returnData = [
|
||
'user_id' => $this->userInfo['user_id'],
|
||
'building_name' => $building_name,
|
||
'building_no' => $building_no,
|
||
'unit_no' => $unit_no,
|
||
'size' => $size,
|
||
'is_exist' => 2, //1.存在 2.不存在
|
||
'eva_total_value' => 0,
|
||
'eva_unit_price' => 0,
|
||
'eva_submit_datetime' => date('Y-m-d H:i:s'),
|
||
];
|
||
|
||
$latestPropertyCertInfo = Db::name('property_cert_info')
|
||
->where([
|
||
'building_name' => $building_name,
|
||
'building_no' => $building_no,
|
||
'unit_no' => $unit_no,
|
||
])
|
||
->whereNotNull('eva_unit_price')
|
||
->where('r_create_time >= UNIX_TIMESTAMP(DATE_SUB(FROM_UNIXTIME(UNIX_TIMESTAMP(NOW()), "%Y-%m-%d 00:00:00"), INTERVAL 3 MONTH))')
|
||
->order('r_create_time desc')
|
||
->find();
|
||
if (!empty($latestPropertyCertInfo)) {
|
||
$returnData['is_exist'] = 1;
|
||
$returnData['eva_total_value'] = $latestPropertyCertInfo['eva_unit_price'] * $size;
|
||
$returnData['eva_unit_price'] = $latestPropertyCertInfo['eva_unit_price'];
|
||
}
|
||
|
||
$res = Db::name('auto_inquiry_record')->insert($returnData);
|
||
if (!$res) {
|
||
return $this->buildFailed('系统错误');
|
||
}
|
||
|
||
return $this->buildSuccess($returnData);
|
||
}
|
||
|
||
public function autoInquiryList()
|
||
{
|
||
$list = Db::name('auto_inquiry_record')
|
||
->field('id, building_name, building_no, unit_no, size, is_exist, eva_total_value, eva_unit_price, eva_submit_datetime')
|
||
->where('user_id', $this->userInfo['user_id'])
|
||
->order('create_time desc')
|
||
->paginate($this->getPage())
|
||
->toArray();
|
||
return $this->buildSuccess($list);
|
||
}
|
||
|
||
public function checkBusinessNoIsValid()
|
||
{
|
||
$data = $this->request->post();
|
||
if(empty($data['business_no'])) return $this->buildFailed('业务编号不能为空');
|
||
if(empty($data['bank_name'])) return $this->buildFailed('机构不能为空');
|
||
if(empty($data['loan_type'])) return $this->buildFailed('贷款种类不能为空');
|
||
|
||
if($data['bank_name'] == '中国银行' && in_array($data['loan_type'], ['二手按揭', '普惠'])) {
|
||
$boc_common_main = Db::name('boc_common_main')
|
||
->where('bankPreEstimateNo', $data['business_no'])
|
||
->whereOr('bankEstimateNo', $data['business_no'])
|
||
->find();
|
||
if (empty($boc_common_main)) {
|
||
return $this->buildFailed('中行业务编号不存在');
|
||
}
|
||
if ($boc_common_main['is_related'] == 2) {
|
||
return $this->buildFailed('中行业务编号已被关联,请勿重复关联');
|
||
}
|
||
} elseif ($data['bank_name'] == '中国工商银行' && $data['loan_type'] == '普惠') {
|
||
$icbcph_pre_estimate_info = Db::name('icbc_ph_pre_estimate_biz_content')
|
||
->where('bankPreEstimateNo', $data['business_no'])
|
||
->find();
|
||
if (empty($icbcph_pre_estimate_info)) {
|
||
return $this->buildFailed('工行业务编号不存在');
|
||
}
|
||
if ($icbcph_pre_estimate_info['is_related'] == 1) {
|
||
return $this->buildFailed('工行业务编号已被关联,请勿重复关联');
|
||
}
|
||
}
|
||
return $this->buildSuccess();
|
||
}
|
||
|
||
|
||
} |