first commit
This commit is contained in:
383
pgserver/application/api/controller/AppInquiry.php
Normal file
383
pgserver/application/api/controller/AppInquiry.php
Normal file
@@ -0,0 +1,383 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\admin\service\SurveyService;
|
||||
use app\admin\service\InquiryService;
|
||||
use app\common\validate\InquiryDetailValidate;
|
||||
use app\common\validate\InquiryValidate;
|
||||
use app\common\validate\SurveyValidate;
|
||||
use app\admin\service\Zcdc;
|
||||
use app\model\Inquiry as InquiryModel;
|
||||
use app\util\ReturnCode;
|
||||
use app\model\Report;
|
||||
use think\Db;
|
||||
|
||||
class AppInquiry extends Base
|
||||
{
|
||||
|
||||
/**
|
||||
* @api {post} api/AppInquiry/save 提交询价
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
|
||||
$validate = new InquiryValidate();
|
||||
if (!$validate->scene(InquiryValidate::APP_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) {
|
||||
return $this->buildFailed('提交信息有误', $verifyResult['errors'], -2);
|
||||
}
|
||||
$inquiryService->createInquiry($data);
|
||||
return $this->buildSuccess('询价成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {post} api/AppInquiry/simpleSave 提交简易询价
|
||||
*/
|
||||
public function simpleSave()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
|
||||
if(!isset($data['user_id']) || !$data['user_id'] || !isset($data['user_name']) || !$data['user_name'] || !isset($data['user_phone']) || !isset($data['department_id']) || !isset($data['department_name'])){
|
||||
return $this->buildFailed('参数有误', ReturnCode::EMPTY_PARAMS);
|
||||
}
|
||||
|
||||
//验证
|
||||
$inquiryService = new InquiryService();
|
||||
$verifyResult = $inquiryService->checkSimpleInquiry($data);
|
||||
if ($verifyResult['is_success'] !== true) {
|
||||
return $this->buildFailed('提交信息有误', $verifyResult['errors'], -2);
|
||||
}
|
||||
|
||||
$res = $inquiryService->createSimpleInquiry($data);
|
||||
if($res['code'] == 1) return $this->buildSuccess();
|
||||
return $this->buildFailed($res['code'], $res['msg']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @api {post} api/AppInquiry/reqApplySurvey 发起查勘
|
||||
*/
|
||||
public function reqApplySurvey()
|
||||
{
|
||||
$order_no = $this->request->post('order_no');
|
||||
$user_id = $this->request->post('user_id');
|
||||
$user_name = $this->request->post('user_name');
|
||||
$data = $this->request->post('details/a');
|
||||
|
||||
if (!$order_no || !$user_id || !$user_name || !$data)
|
||||
return $this->buildFailed('参数错误');
|
||||
//验证
|
||||
$surveyService = new SurveyService();
|
||||
$verifyResult = $surveyService->checkSurvey($data);
|
||||
if ($verifyResult['is_success'] !== true) {
|
||||
return $this->buildFailed($verifyResult['errors']);
|
||||
}
|
||||
|
||||
$result = $surveyService->askSurvey(['order_no'=>$order_no, 'user_id'=>$user_id, 'user_name'=>$user_name, 'detail'=>$data]);
|
||||
if ($result['code'] == -1) {
|
||||
return $this->buildFailed($result['msg']);
|
||||
}
|
||||
return $this->buildSuccess('发起查勘成功');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @api {post} api/AppInquiry/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} api/AppInquiry/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('成功');
|
||||
}
|
||||
|
||||
/**
|
||||
*提交查勘
|
||||
* JA
|
||||
*/
|
||||
public function reqSubmitSurvey()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$validate = new SurveyValidate();
|
||||
if (!$validate->scene(SurveyValidate::SCENE_SUBMIT)->batch()->check($data)) {
|
||||
return $this->buildFailed('数据验证失败', $validate->getError());
|
||||
}
|
||||
try {
|
||||
$surveyService = new SurveyService();
|
||||
if (!$surveyService->survey_detail($data['user_id'], $data, $data['action'])) {
|
||||
return $this->buildFailed('保存失败');
|
||||
}
|
||||
return $this->buildSuccess();
|
||||
} catch (\Exception $e) {
|
||||
// \think\Log::error('错误文件:' . $e->getFile());
|
||||
// \think\Log::error('错误行数:' . $e->getLine());
|
||||
// \think\Log::error('错误代码:' . $e->getCode());
|
||||
// \think\Log::error('错误信息:' . $e->getMessage());
|
||||
return $this->output(-1, $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 退回
|
||||
* JA
|
||||
*/
|
||||
public function reqSubmitSurveyReturn()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$validate = new SurveyValidate();
|
||||
if (!$validate->scene(SurveyValidate::SCENE_RETURN)->batch()->check($data)) {
|
||||
return $this->buildFailed('数据验证失败', $validate->getError());
|
||||
}
|
||||
try {
|
||||
$surveyService = new SurveyService();
|
||||
if (!$surveyService->return_survey($data['user_id'], $data)) {
|
||||
return $this->buildFailed('退回失败');
|
||||
}
|
||||
return $this->buildSuccess();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->output(-1, $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @api {post} api/AppInquiry/createReport 申请生成报告
|
||||
*/
|
||||
public function createReport()
|
||||
{
|
||||
// $user_id = $this->request->post('user_id');
|
||||
// $user_name = $this->request->post('user_name');
|
||||
|
||||
// $quot_id = $this->request->post('quot_id');
|
||||
// $print_cpy_no = $this->request->post('print_cpy_no');
|
||||
// $details = $this->request->post('details/a');
|
||||
// if (!$quot_id || !$details || !$print_cpy_no || !$user_id || !$user_name) return $this->buildFailed('参数错误');
|
||||
|
||||
// //验证
|
||||
// $inquiryService = new InquiryService();
|
||||
// $verifyResult = $inquiryService->checkcreateReport($details);
|
||||
// if ($verifyResult['is_success'] !== true) {
|
||||
// return $this->buildFailed('提交信息有误',$verifyResult['errors']);
|
||||
// }
|
||||
|
||||
// $data['user_id'] = $user_id;
|
||||
// $data['user_name'] = $user_name;
|
||||
// $data['quot_id'] = $quot_id;
|
||||
// $data['print_cpy_no'] = $print_cpy_no;
|
||||
// $data['details'] = $details;
|
||||
$data = $this->request->post();
|
||||
//验证
|
||||
$inquiryService = new InquiryService();
|
||||
if($data['type'] == 1){ //保存操作 - 验证物业信息合法
|
||||
$verifyResult = $inquiryService->checkcreateReportDraft($data);
|
||||
}elseif($data['type'] == 2){ //提交操作 - 验证数据是否合法
|
||||
$verifyResult = $inquiryService->checkcreateReport($data);
|
||||
}
|
||||
if ($verifyResult['is_success'] !== true) {
|
||||
return $this->buildFailed('提交信息有误',$verifyResult['errors']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$isSuccess = (new Report())->createReport($data);
|
||||
if (!$isSuccess) {
|
||||
return $this->buildFailed('申请生成报告失败');
|
||||
}
|
||||
return $this->buildSuccess();
|
||||
}
|
||||
|
||||
// 重复询价的保存
|
||||
public function reqQuotSubmitAgain(){
|
||||
$flag = true;
|
||||
$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['branchCom_id']);
|
||||
$ins_inquiry_data['user_id'] = $request_data['user_id'];
|
||||
$ins_inquiry_data['user_name'] = $request_data['user_name'];
|
||||
$ins_inquiry_data['user_phone'] = $request_data['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'] = $request_data['department_id'];
|
||||
$ins_inquiry_data['department_name'] = $request_data['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']?$request_data['details'][0]['property_cert']:NULL;
|
||||
$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']?$request_data['details'][0]['land_location']:'';
|
||||
$ins_inquiry_detail_data['obligee'] = $request_data['details'][0]['obligee']?$request_data['details'][0]['obligee']:'';
|
||||
$ins_inquiry_detail_data['remark'] = $request_data['details'][0]['remark']?$request_data['details'][0]['remark']:NULL;
|
||||
$ins_inquiry_detail_data['attachments'] = $request_data['details'][0]['attachments']?$request_data['details'][0]['attachments']:NULL;
|
||||
$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('提交询价失败!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
95
pgserver/application/api/controller/AppUpload.php
Normal file
95
pgserver/application/api/controller/AppUpload.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\admin\service\FileService;
|
||||
use app\model\Attachment;
|
||||
use think\Db;
|
||||
use think\File;
|
||||
use think\Log;
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/3/4
|
||||
* Time: 9:37
|
||||
*/
|
||||
class AppUpload extends Base
|
||||
{
|
||||
public function upload(FileService $FileService)
|
||||
{
|
||||
$base64_img = input('image/a');
|
||||
if (empty($base64_img)) return $this->buildFailed(-1, "上传文件不能为空!");
|
||||
//匹配出图片的格式
|
||||
$up_dir = config('uploadFile.img_path') . 'uploads' . DS . date('Ymd');//存放在当前目录的upload文件夹下
|
||||
if (!is_dir($up_dir)) {
|
||||
mkdir($up_dir, 0755, true);
|
||||
}
|
||||
$arr = [];
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
foreach ($base64_img as $k => $v) {
|
||||
//匹配出图片的格式
|
||||
if (!preg_match('/^(data:\s*image\/(\w+);base64,)/', $v, $result)) return $this->buildFailed(-1, "请上传base64文件!");
|
||||
$base64_code = str_replace($result[1], '', $v);
|
||||
if (empty($base64_code)) {
|
||||
return $this->buildFailed(-1, "请上传base64文件!!");
|
||||
}
|
||||
$type = $result[2];
|
||||
//判断库中是否存在
|
||||
$id = Db::name('Attachment')->where([
|
||||
'md5' => md5(base64_decode($base64_code)),
|
||||
'sha1' => sha1(base64_decode($base64_code)),
|
||||
])->value('id');
|
||||
if ($id) {
|
||||
$arr[] = $id;
|
||||
continue;
|
||||
}
|
||||
if (!in_array($type, array('jpeg', 'jpg', 'gif', 'png', 'webp'))) return $this->buildFailed(-1, "请上传图片类型的文件!");
|
||||
$savename = md5(microtime(true)) . '.' . $type;
|
||||
$new_file = $up_dir . DS . $savename;
|
||||
if (!file_put_contents($new_file, base64_decode($base64_code))) return $this->buildFailed(-1, "上传失败!");
|
||||
$info = new File($new_file);
|
||||
$image = \think\Image::open($new_file);
|
||||
$thumPath690 = 'uploads' . DS . 'thumb690' . DS . date('Ymd', time());
|
||||
$thumPath1024 = 'uploads' . DS . 'thumb1024' . DS . date('Ymd', time());
|
||||
$insert_url = DS . 'uploads' . DS . date('Ymd') . DS . $savename;
|
||||
$data = [
|
||||
'name' => $savename, //图片原始名称
|
||||
'savename' => $savename, //新的图片名称
|
||||
'filesize' => $info->getSize(), //文件大小
|
||||
'ext' => $info->getExtension(), //文件后缀
|
||||
'md5' => $info->hash('md5'),
|
||||
'sha1' => $info->hash('sha1'),
|
||||
'mimetype' => $info->getMime(), //mime类型
|
||||
'path' => config('uploadFile.img_path'), //路径
|
||||
'url' => $insert_url,
|
||||
'imagewidth' => $image->width(),
|
||||
'imageheight' => $image->height(),
|
||||
'create_time' => time(),
|
||||
];
|
||||
$thumb1 = $FileService->saveThumbCOS($new_file, $thumPath690, $data['imagewidth'], $data['imageheight'], $data['savename'], 690);
|
||||
$thumb2 = $FileService->saveThumbCOS($new_file, $thumPath1024, $data['imagewidth'], $data['imageheight'], $data['savename'], 1024);
|
||||
$data['thum1'] = $thumb1 != false ? $thumb1 : 'uploads' . DS . date('Ymd') . DS . $savename;
|
||||
$data['thum2'] = $thumb2 != false ? $thumb2 : 'uploads' . DS . date('Ymd') . DS . $savename;
|
||||
$file_path = config('uploadFile.img_path') . trim($insert_url, DS);
|
||||
$res = ossUpload(str_replace("\\", "/", trim($insert_url, DS)), $file_path);
|
||||
unset($info);
|
||||
@unlink($new_file);
|
||||
if ($res['code'] != 1) {
|
||||
Db::rollback();
|
||||
return $this->buildFailed(-1, '移动到阿里云图片服务器有误');
|
||||
}
|
||||
$result = Attachment::create($data);
|
||||
if (empty($result)) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return $this->buildFailed(-1, '添加附件表失败');
|
||||
}
|
||||
$arr[] = $result->id;
|
||||
}
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return $this->buildSuccess(['idstr' => implode(',', $arr)]);
|
||||
}
|
||||
}
|
||||
155
pgserver/application/api/controller/AutomaticInquiry.php
Normal file
155
pgserver/application/api/controller/AutomaticInquiry.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\admin\service\InquiryService;
|
||||
use app\model\Inquiry;
|
||||
use app\model\Property_cert_info;
|
||||
use app\model\Taxation;
|
||||
use app\util\ReturnCode;
|
||||
use app\common\validate\InquiryValidate;
|
||||
use think\Db;
|
||||
|
||||
class AutomaticInquiry extends Base
|
||||
{
|
||||
|
||||
/**
|
||||
* @api {post} api/AutomaticInquiry/save 提交询价
|
||||
*/
|
||||
public function save(){
|
||||
$data = $this->request->post();
|
||||
$validate = new InquiryValidate();
|
||||
if (!$validate->scene(InquiryValidate::Automatic_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) {
|
||||
return $this->buildFailed('提交信息有误', $verifyResult['errors'], -2);
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try{
|
||||
$inquiry = new Inquiry();
|
||||
$inquiry->order_no = $this->generateInquiryNo($data['bank_code']);
|
||||
$inquiry->user_id = $data['user_id'];
|
||||
$inquiry->user_name = $data['user_name'];
|
||||
$inquiry->bank_name = $data['bank_name'];
|
||||
$inquiry->bank_id = $data['bank_id'];
|
||||
if (isset($data['bank_branch_name']) && !empty($data['bank_branch_name']))
|
||||
$inquiry->bank_branch_name = $data['bank_branch_name'];
|
||||
if (isset($data['bank_branch_id']) && !empty($data['bank_branch_id']))
|
||||
$inquiry->bank_branch_id = $data['bank_branch_id'];
|
||||
if (isset($data['bank_sub_name']) && !empty($data['bank_sub_name']))
|
||||
$inquiry->bank_sub_name = $data['bank_sub_name'];
|
||||
if (isset($data['bank_sub_id']) && !empty($data['bank_sub_id']))
|
||||
$inquiry->bank_sub_id = $data['bank_sub_id'];
|
||||
$inquiry->eva_purpose = $data['eva_purpose'];
|
||||
$inquiry->product_id = $data['product_id'];
|
||||
$inquiry->type = $data['type'];
|
||||
$inquiry->is_auto = 1;
|
||||
$inquiry->is_auto_eva = ($data['status'] == 2) ? 1 : 0;
|
||||
$inquiry->is_multiple = count($data['details']) > 1;
|
||||
$inquiry->status = $data['status'];
|
||||
$inquiry->create_time = date('Y-m-d H:i:s');
|
||||
$inquiry->update_time = date('Y-m-d H:i:s');
|
||||
if (!$inquiry->save())
|
||||
return ['code'=>-1, 'msg'=>'inquiry表插入异常'];
|
||||
|
||||
foreach ($data['details'] as $detail) {
|
||||
$property_cert_info = new Property_cert_info();
|
||||
$property_cert_info->quot_id = $inquiry->id;
|
||||
$property_cert_info->city = $detail['city'];
|
||||
$property_cert_info->city_id = $detail['city_id'];
|
||||
$property_cert_info->building_name = trim($detail['building_name']);;
|
||||
$property_cert_info->building_no = trim($detail['building_no']);
|
||||
$property_cert_info->unit_no = trim($detail['unit_no']);
|
||||
$property_cert_info->building_unit_no = (empty($detail['building_no']) || trim($detail['building_no']) == '0') ? $detail['unit_no'] : $detail['building_no'] . $detail['unit_no'];
|
||||
$property_cert_info->property_full_name = $property_cert_info->building_name . $property_cert_info->building_unit_no;
|
||||
$property_cert_info->size = $detail['size'];
|
||||
$property_cert_info->reg_price = $detail['reg_price'];
|
||||
$property_cert_info->usage = $detail['usage'];
|
||||
$property_cert_info->is_tran_tax_free = $detail['is_tran_tax_free'];
|
||||
if (isset($detail['purchase_date']) && !empty($detail['purchase_date']))
|
||||
$property_cert_info->purchase_date = $detail['purchase_date'];
|
||||
if (isset($detail['ownership_type']))
|
||||
$property_cert_info->ownership_type = $detail['ownership_type'];
|
||||
if (isset($detail['remark']))
|
||||
$property_cert_info->remark = $detail['remark'];
|
||||
//todo 附件的处理
|
||||
$property_cert_info->save();
|
||||
}
|
||||
|
||||
if($inquiry->is_auto_eva == 0){
|
||||
//写入消息
|
||||
PublicMessage($inquiry->id,1,1);
|
||||
}
|
||||
|
||||
//查询税费计算
|
||||
$Taxation = new Taxation();
|
||||
|
||||
$map['bank_id'] = $data['bank_id'];
|
||||
$map['product_name'] = $data['eva_purpose'];
|
||||
$map['type'] = $data['type'];
|
||||
$map['state'] = 1;
|
||||
if(isset($data['bank_branch_id']) && !empty($data['bank_branch_id'])){
|
||||
$map['branch_id'] = $data['bank_branch_id'];
|
||||
}
|
||||
$tax_items = $Taxation->where($map)->value("tax_items");
|
||||
Db::commit();
|
||||
return $this->buildSuccess(['id' => $inquiry->id, 'order_no'=>$inquiry->order_no, 'tax_items'=>$tax_items, 'property_cert_info_id' => $property_cert_info->id]);
|
||||
}catch (\Exception $e){
|
||||
Db::rollback();
|
||||
return $this->buildFailed('操作失败', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 产生唯一订单号
|
||||
*
|
||||
* @param $type
|
||||
* @return string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function generateInquiryNo($bank_code)
|
||||
{
|
||||
|
||||
$inquiryNo = $bank_code.date('Ym');
|
||||
$max = Db::name('inquiry')->order('id','desc')->find();
|
||||
if (!$max){
|
||||
$inquiryNo .= '000001';
|
||||
}else{
|
||||
$number = substr($max['order_no'],strlen($max['order_no'])-7, 7);
|
||||
$number += 1;
|
||||
$inquiryNo .= sprintf('%07d',$number);
|
||||
}
|
||||
|
||||
return $inquiryNo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @api {post} api/AutomaticInquiry/getProduct 获取产品名称
|
||||
* @param string $bank 银行名称
|
||||
*/
|
||||
public function getProduct(){
|
||||
$bank = $this->request->post('bank');
|
||||
if(!$bank) return $this->buildFailed('银行名称不能为空', ReturnCode::EMPTY_PARAMS);
|
||||
$where['bank'] = $bank;
|
||||
$where['state'] = 1;
|
||||
$where['type'] = 1;
|
||||
$res = Db::name('product')->field('id,product_name')->where($where)->select();
|
||||
return $this->buildSuccess($res);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
131
pgserver/application/api/controller/Base.php
Normal file
131
pgserver/application/api/controller/Base.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\util\ReturnCode;
|
||||
use think\Controller;
|
||||
use think\facade\Response;
|
||||
|
||||
/**
|
||||
* 接口基础控制器
|
||||
*/
|
||||
class Base extends Controller {
|
||||
|
||||
public function _initialize() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回封装后的API数据到客户端
|
||||
* @access protected
|
||||
* @param mixed $data 要返回的数据
|
||||
* @param mixed $msg 提示信息
|
||||
* @param integer $code 返回的code
|
||||
* @return \think\Response
|
||||
*/
|
||||
protected function buildSuccess($data = [], $msg = '操作成功', $code = 1) {
|
||||
$result = [
|
||||
'code' => $code,
|
||||
'msg' => $msg,
|
||||
'data' => $data,
|
||||
];
|
||||
|
||||
$response = Response::create($result, 'json');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回封装后的API数据到客户端
|
||||
* @access protected
|
||||
* @param mixed $msg 提示信息
|
||||
* @param mixed $data 要返回的数据
|
||||
* @param integer $code 返回的code
|
||||
* @return \think\Response
|
||||
*/
|
||||
protected function buildFailed($msg = '', $data = [], $code = -1) {
|
||||
$result = [
|
||||
'code' => $code,
|
||||
'msg' => $msg,
|
||||
'data' => $data,
|
||||
];
|
||||
|
||||
$response = Response::create($result, 'json');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口调用时参数检查appkey、sign、timestamp
|
||||
*/
|
||||
public function checkParam() {
|
||||
$param = $this->request->post();
|
||||
|
||||
$appkey = $param['appkey'];
|
||||
$sign = $param['sign'];
|
||||
$timestamp = $param['timestamp'];
|
||||
|
||||
//加一个验证ip
|
||||
|
||||
if (empty($appkey) || empty($sign) || empty($timestamp)) {
|
||||
return $this->output(-1, '参数错误');
|
||||
}
|
||||
if (strlen($timestamp) == 10) {
|
||||
$nowtime = date('Ymdhis', time());
|
||||
$oldtime = date('Ymdhis', $timestamp);
|
||||
if ($nowtime - $oldtime > 300) {
|
||||
return $this->output(-1, 'timestamp超时');
|
||||
}
|
||||
} else {
|
||||
return $this->output(-1, 'timestamp参数错误');
|
||||
}
|
||||
$appsecret = $this->account($appkey);
|
||||
if (empty($appsecret)) {
|
||||
return $this->output(-1, '参数错误key');
|
||||
}
|
||||
$newsign = md5($appkey . $appsecret . $timestamp);
|
||||
|
||||
if ($sign !== $newsign) {
|
||||
return $this->output(-1, '签名错误');
|
||||
}
|
||||
|
||||
return true;
|
||||
//查询sign是否已使用
|
||||
//$signCount = M("ApiLog")->where(array('sign' => $sign, 'appkey' => $appkey))->count();
|
||||
// if ($signCount > 1) {
|
||||
// $this->error('', 20022);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据appkey查询信息
|
||||
*/
|
||||
public function account($appkey) {
|
||||
$infos = config('API_USERS');
|
||||
$appsecret = FALSE;
|
||||
foreach ($infos as $k => $v) {
|
||||
if ($v['appkey'] == $appkey) {
|
||||
$appsecret = $v['appsecret'];
|
||||
}
|
||||
}
|
||||
return $appsecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一输出方法
|
||||
* @param int $code
|
||||
* @param string $msg
|
||||
* @param array $data
|
||||
* @return json
|
||||
*/
|
||||
public function output($code = '-1', $msg = '', $data = []) {
|
||||
$result = json([
|
||||
'code' => intval($code),
|
||||
'msg' => strval($msg),
|
||||
'data' => $data ?: (object) $data
|
||||
]);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
60
pgserver/application/api/controller/BizInquiry.php
Normal file
60
pgserver/application/api/controller/BizInquiry.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Db;
|
||||
|
||||
class BizInquiry extends Base
|
||||
{
|
||||
/**
|
||||
* @api {post} api/BizInquiry/search 业务系统估价查询接口
|
||||
*/
|
||||
public function search()
|
||||
{
|
||||
$building_name = request()->param('building_name');
|
||||
$start_time = request()->param('start_time'); //时间戳
|
||||
$end_time = request()->param('end_time'); //时间戳
|
||||
if (empty($building_name)) {
|
||||
return $this->buildFailed('缺少物业名称');
|
||||
}
|
||||
$map = [];
|
||||
$data = [];
|
||||
// foreach ($building_name as $key=>$value) {
|
||||
// unset($map);
|
||||
// if (!empty($start_time)) {
|
||||
// $map[] = ['create_time', '>', $start_time];
|
||||
// }
|
||||
// if (!empty($end_time)) {
|
||||
// $map[] = ['create_time', '<', $end_time];
|
||||
// }
|
||||
// $map[] = ['property_name', 'like', $value.'%'];
|
||||
// $eva_unit_price = $this->getSearch($map);
|
||||
// $data[] = ['building_name'=>$value, 'eva_unit_price'=>$eva_unit_price];
|
||||
// }
|
||||
if (!empty($start_time)) {
|
||||
$map[] = ['create_time', '>', $start_time];
|
||||
}
|
||||
if (!empty($end_time)) {
|
||||
$map[] = ['create_time', '<', $end_time];
|
||||
}
|
||||
$map[] = ['property_name', 'like', $building_name.'%'];
|
||||
$eva_unit_price = $this->getSearch($map);
|
||||
$data[] = ['building_name'=>$building_name, 'eva_unit_price'=>$eva_unit_price];
|
||||
return $this->buildSuccess(['estate_list'=>$data]);
|
||||
}
|
||||
|
||||
public function getSearch($where)
|
||||
{
|
||||
$eva_unit_price = Db::name('return_price')
|
||||
->where($where)
|
||||
->order('create_time', 'desc')
|
||||
->field('eva_unit_price')
|
||||
->find();
|
||||
if ($eva_unit_price) {
|
||||
return $eva_unit_price['eva_unit_price'];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
674
pgserver/application/api/controller/EvaluateInquiry.php
Normal file
674
pgserver/application/api/controller/EvaluateInquiry.php
Normal file
@@ -0,0 +1,674 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\validate\EvaluateInquiryValidate;
|
||||
use app\model\Inquiry as InquiryModel;
|
||||
use app\model\Taxation;
|
||||
use think\Db;
|
||||
use think\facade\Env;
|
||||
|
||||
class EvaluateInquiry extends Base
|
||||
{
|
||||
const CHECK_LOUPAN_URL = 'api/EvaluateInquiry/checkEstate';
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取银行
|
||||
*/
|
||||
public function reqBankList()
|
||||
{
|
||||
$bank_data = Db::name('bank')
|
||||
->where(['type' => 1, 'status' => 1])
|
||||
->field('id,name,bank_code')
|
||||
->select();
|
||||
if ($bank_data) {
|
||||
return $this->buildSuccess($bank_data);
|
||||
} else {
|
||||
return $this->buildFailed('暂无银行数据!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分行
|
||||
*/
|
||||
public function getSubBank()
|
||||
{
|
||||
$bank_id = request()->param('bank_id');
|
||||
if (empty($bank_id)) {
|
||||
return $this->buildFailed('银行id不能为空');
|
||||
}
|
||||
$sub_bank_data = Db::name('bank')
|
||||
->where(['pid' => $bank_id, 'type' => 2, 'status' => 1])
|
||||
->field('id,name')
|
||||
->select();
|
||||
if ($sub_bank_data) {
|
||||
return $this->buildSuccess($sub_bank_data);
|
||||
} else {
|
||||
return $this->buildFailed('暂无分行数据!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支行
|
||||
*/
|
||||
public function getBranchBank()
|
||||
{
|
||||
$bank_branch_id = request()->param('bank_branch_id');
|
||||
if (empty($bank_branch_id)) {
|
||||
return $this->buildFailed('分行id不能为空');
|
||||
}
|
||||
$branch_bank_data = Db::name('bank')
|
||||
->where(['pid' => $bank_branch_id, 'type' => 3, 'status' => 1])
|
||||
->field('id,name')
|
||||
->select();
|
||||
if ($branch_bank_data) {
|
||||
return $this->buildSuccess($branch_bank_data);
|
||||
} else {
|
||||
return $this->buildFailed('暂无支行数据!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取银行贷款类型(评估目的)
|
||||
*/
|
||||
public function getEvaluatePurpose()
|
||||
{
|
||||
$bank_id = request()->param('bank_id');
|
||||
if (empty($bank_id)) {
|
||||
return $this->buildFailed('银行id不能为空');
|
||||
}
|
||||
$purpose_data = Db::name('product')
|
||||
->where(['bank_id' => $bank_id, 'type' => 1, 'state' => 1])
|
||||
->field('id,product_name')
|
||||
->select();
|
||||
if ($purpose_data) {
|
||||
return $this->buildSuccess($purpose_data);
|
||||
} else {
|
||||
return $this->buildFailed('暂无该银行的贷款类型!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 报告防伪查询
|
||||
*/
|
||||
public function reportCheck()
|
||||
{
|
||||
$report_no = request()->param('report_no', '', 'trim'); // 报告编号
|
||||
if (empty($report_no)) {
|
||||
return $this->buildFailed('报告编号不能为空');
|
||||
}
|
||||
$report_data = Db::name('report')
|
||||
->where(['report_no' => $report_no])
|
||||
->where(['status' => 3])
|
||||
->field('id,quot_id,appraisal_time')
|
||||
->find();
|
||||
if ($report_data) {
|
||||
// 询价详情数据
|
||||
$inq_detail_data = Db::name('property_cert_info')
|
||||
->where(['quot_id' => $report_data['quot_id']])
|
||||
->field('id,property_full_name')
|
||||
->select();
|
||||
$result_data = [];
|
||||
foreach ($inq_detail_data as $key => $value) {
|
||||
// 获取回价信息
|
||||
$return_data = Db::name('return_price')
|
||||
->where(['property_cert_info_id' => $value['id']])
|
||||
->field('property_name,area,eva_unit_price,eva_total_value,eva_net_value,eva_net_value2,total_taxes1,total_taxes2')
|
||||
->order('id', 'desc')
|
||||
->find();
|
||||
$result_data[] = $return_data;
|
||||
}
|
||||
$resultData['property_full_name'] = implode(',', array_column($result_data, 'property_name'));
|
||||
$resultData['size'] = implode('/', array_column($result_data, 'area'));
|
||||
$resultData['eva_unit_price'] = implode('/', array_column($result_data, 'eva_unit_price'));
|
||||
$resultData['eva_total_value'] = array_sum(array_column($result_data, 'eva_total_value'));
|
||||
$resultData['eva_net_value'] = array_sum(array_column($result_data, 'eva_net_value'));
|
||||
$resultData['eva_net_value2'] = array_sum(array_column($result_data, 'eva_net_value2'));
|
||||
$resultData['total_taxes1'] = array_sum(array_column($result_data, 'total_taxes1'));
|
||||
$resultData['total_taxes2'] = array_sum(array_column($result_data, 'total_taxes2'));
|
||||
$resultData['appraisal_time'] = $report_data['appraisal_time'];
|
||||
return $this->buildSuccess($resultData);
|
||||
} else {
|
||||
return $this->buildFailed('抱歉,您查询的报告不存在!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 询价匹配查询
|
||||
*/
|
||||
public function inquiryMatch()
|
||||
{
|
||||
$request_data = $this->request->post();
|
||||
|
||||
$loupan_name = $request_data['loupan_name']; // 楼盘名称
|
||||
$building_name = $request_data['building_name']; // 栋号
|
||||
$unit_no = $request_data['unit_no']; // 房号
|
||||
$province_id = $request_data['province_id']; // 省份ID
|
||||
$city_id = $request_data['city_id']; // 城市ID
|
||||
$size = $request_data['size']; // 建筑面积
|
||||
|
||||
/**
|
||||
* 1.先去OA匹配
|
||||
*/
|
||||
|
||||
|
||||
$oa_res = $this->checkFromOa($loupan_name, $building_name, $unit_no);
|
||||
|
||||
if ($oa_res === true) { //OA匹配上了
|
||||
|
||||
if ($request_data['customer_type'] == 1) { //游客,直接返回评估单价、评估总值、二手房参考价
|
||||
$return = [
|
||||
'redirect' => 1, //1.跳转到询价信息详情页 2.游客弹起提示 3.VIP跳转到资料补充页
|
||||
'inquiry_type' => 1, //1.OA匹配的自动询价 2.楼盘字典匹配的自动询价 3.人工询价
|
||||
'eva_unit_price' => round($this->data['eva_unit_price'] / 10) * 10,
|
||||
// 'guide_price' => $request_data['guide_price']!=0 ? $request_data['guide_price'] : $this->data['guide_price'],
|
||||
'guide_price' => $this->data['guide_price'],
|
||||
];
|
||||
} else {
|
||||
$return = [];
|
||||
// VIP,需要在OA插入一条询价记录
|
||||
$request_data['guide_price'] = $request_data['guide_price']!=0 ? $request_data['guide_price'] : $this->data['guide_price'];
|
||||
if ($this->addInquiryRecord($request_data, $this->data['eva_unit_price']) === true) {
|
||||
$return = [
|
||||
'redirect' => 1,
|
||||
'inquiry_type' => 1, //1.OA匹配的自动询价 2.楼盘字典匹配的自动询价 3.人工询价
|
||||
'order_no' => $this->data['order_no'],
|
||||
'eva_unit_price' => $this->data['eva_unit_price'],
|
||||
'eva_net_value' => $this->data['eva_net_value'],
|
||||
'eva_net_value2' => $this->data['eva_net_value2'],
|
||||
'total_taxes1' => $this->data['total_taxes1'],
|
||||
'total_taxes2' => $this->data['total_taxes2'],
|
||||
'gross_value' => $this->data['gross_value'],
|
||||
'guide_price' => $this->data['guide_price'],
|
||||
'estimates_no' => $this->data['estimates_no'],
|
||||
'estimates_url' => $this->data['estimates_url'],
|
||||
];
|
||||
}
|
||||
}
|
||||
return $this->buildSuccess($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2.楼盘字典匹配
|
||||
*/
|
||||
$url = config('serviceConfig.EVALUATE_DICT_API_URL') . self::CHECK_LOUPAN_URL;
|
||||
$param = [
|
||||
'loupan_name' => $loupan_name,
|
||||
'building_name' => $building_name,
|
||||
'unit_no' => $unit_no,
|
||||
'province_id' => $province_id,
|
||||
'city_id' => $city_id,
|
||||
'size' => $size,
|
||||
];
|
||||
trace($url);
|
||||
$loupan_response_data = json_decode($this->sendPost($url, json_encode($param), 30, ['Content-type: application/json']), 1);
|
||||
trace('loupan_response_data');
|
||||
trace($loupan_response_data);
|
||||
|
||||
if ($loupan_response_data['code'] == 1) {
|
||||
if ($request_data['customer_type'] == 1) { //游客
|
||||
$return = [
|
||||
'redirect' => 1,
|
||||
'inquiry_type' => 2,
|
||||
'eva_unit_price' => round($loupan_response_data['data']['price'] / 10) * 10,
|
||||
'guide_price' => $loupan_response_data['data']['guide_price'],
|
||||
];
|
||||
} else {
|
||||
$return = [];
|
||||
// VIP,需要在OA插入一条询价记录
|
||||
$request_data['guide_price'] = $loupan_response_data['data']['guide_price'];
|
||||
if ($this->addInquiryRecord($request_data, $loupan_response_data['data']['price']) === true) {
|
||||
$return = [
|
||||
'redirect' => 1,
|
||||
'inquiry_type' => 2, //1.OA匹配的自动询价 2.楼盘字典匹配的自动询价 3.人工询价
|
||||
'order_no' => $this->data['order_no'],
|
||||
'eva_unit_price' => $this->data['eva_unit_price'],
|
||||
'eva_net_value' => $this->data['eva_net_value'],
|
||||
'eva_net_value2' => $this->data['eva_net_value2'],
|
||||
'total_taxes1' => $this->data['total_taxes1'],
|
||||
'total_taxes2' => $this->data['total_taxes2'],
|
||||
'gross_value' => $this->data['gross_value'],
|
||||
'guide_price' => $this->data['guide_price'],
|
||||
];
|
||||
}
|
||||
}
|
||||
return $this->buildSuccess($return);
|
||||
}
|
||||
trace('OA and Loupan both not match');
|
||||
/**
|
||||
* 3.OA和楼盘都没匹配到
|
||||
*/
|
||||
$return = $request_data['customer_type'] == 1 ? ['redirect' => 2] : ['redirect' => 3];
|
||||
return $this->buildSuccess($return);
|
||||
}
|
||||
|
||||
// 匹配OA
|
||||
private function checkFromOa($loupan_name, $building_name, $unit_no)
|
||||
{
|
||||
$period = getSystemConfig('EVALUATE_INQUIRY_PERIOD'); // 询价时间范围
|
||||
$start_unix_time = time() - $period * 30 * 24 * 3600;
|
||||
|
||||
$start = date('Y-m-d H:i:s', $start_unix_time);
|
||||
$end = date('Y-m-d H:i:s');
|
||||
|
||||
$building_name = ($building_name != '0' && $building_name != '--') ? $building_name : '';
|
||||
$unit_no = ($unit_no != '0' && $unit_no != '--') ? $unit_no : '';
|
||||
|
||||
$where[] = ['i.status', '>', 1];
|
||||
$where[] = ['i.create_time', 'between time', [$start, $end]];
|
||||
$where[] = ['id.property_full_name', '=', trim($loupan_name) . trim($building_name) . trim($unit_no)];
|
||||
$where[] = ['i.is_auto_eva', '=', 0];
|
||||
|
||||
$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) {
|
||||
$this->data = $return_price_data;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// OA添加一条询价记录
|
||||
private function addInquiryRecord($request_data, $eva_unit_price)
|
||||
{
|
||||
try {
|
||||
// 评估单价个位四舍五入
|
||||
$eva_unit_price = round($eva_unit_price/10) * 10;
|
||||
Db::startTrans();
|
||||
// 1.inquiry表
|
||||
$inquiry = new InquiryModel();
|
||||
$ins_inquiry_data = [];
|
||||
$ins_inquiry_data['order_no'] = $inquiry->generateInquiryNo($request_data['branchCom_id']);
|
||||
$ins_inquiry_data['user_id'] = $request_data['user_id'];
|
||||
$ins_inquiry_data['user_name'] = $request_data['user_name'];
|
||||
$ins_inquiry_data['user_phone'] = $request_data['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['eva_purpose'] = $request_data['loan_type'];
|
||||
$ins_inquiry_data['product_id'] = $request_data['loan_type_id'];
|
||||
$ins_inquiry_data['type'] = 1;
|
||||
$ins_inquiry_data['status'] = 2;
|
||||
$ins_inquiry_data['eva_detail_time_long'] = 0;
|
||||
$ins_inquiry_data['is_auto'] = 1;
|
||||
$ins_inquiry_data['is_auto_eva'] = 1;
|
||||
$ins_inquiry_data['source'] = 2;
|
||||
$ins_inquiry_data['create_time'] = date('Y-m-d H:i:s');
|
||||
$ins_inquiry_data['update_time'] = date('Y-m-d H:i:s');
|
||||
$quot_id = Db::name('inquiry')->insertGetId($ins_inquiry_data);
|
||||
// 2.inquiry_detail表
|
||||
$ins_inquiry_detail_data = [];
|
||||
$ins_inquiry_detail_data['quot_id'] = $quot_id;
|
||||
$ins_inquiry_detail_data['city'] = getCity($request_data['city'])['shortname'];
|
||||
$ins_inquiry_detail_data['city_id'] = getCity($request_data['city'])['id'];
|
||||
$ins_inquiry_detail_data['property_full_name'] = trim($request_data['loupan_name']) . trim($request_data['building_name']) . trim($request_data['unit_no']);
|
||||
$ins_inquiry_detail_data['building_name'] = trim($request_data['loupan_name']);
|
||||
$ins_inquiry_detail_data['building_unit_no'] = trim($request_data['building_name']) . trim($request_data['unit_no']);
|
||||
$ins_inquiry_detail_data['building_no'] = trim($request_data['building_name']);
|
||||
$ins_inquiry_detail_data['unit_no'] = trim($request_data['unit_no']);
|
||||
$ins_inquiry_detail_data['size'] = $request_data['size'];
|
||||
$ins_inquiry_detail_data['reg_price'] = $request_data['reg_price'];
|
||||
$ins_inquiry_detail_data['is_tran_tax_free'] = $request_data['is_over5year'];
|
||||
$ins_inquiry_detail_data['ownership_type'] = $request_data['ownership_type'];
|
||||
$ins_inquiry_detail_data['usage'] = getDictionaryCode('HOUSE_USAGE', '住宅')['code'];
|
||||
$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');
|
||||
$property_cert_info = Db::name('property_cert_info')->insertGetId($ins_inquiry_detail_data);
|
||||
// 判断结果
|
||||
if (!$quot_id || !$property_cert_info) {
|
||||
Db::rollback();
|
||||
return false;
|
||||
}
|
||||
Db::commit();
|
||||
|
||||
// 3.查询税费计算
|
||||
$Taxation = new Taxation();
|
||||
$map['bank_id'] = $request_data['bank_id'];
|
||||
$map['product_name'] = $request_data['loan_type'];
|
||||
$map['type'] = 1;
|
||||
$map['state'] = 1;
|
||||
if (isset($request_data['bank_branch_id']) && !empty($request_data['bank_branch_id'])) {
|
||||
$map['branch_id'] = $request_data['bank_branch_id'];
|
||||
}
|
||||
$tax_items = $Taxation->where($map)->value("tax_items");
|
||||
$post_data = [
|
||||
'eva_unit_price' => $eva_unit_price,
|
||||
'id' => $property_cert_info,
|
||||
'is_tran_tax_free' => $request_data['is_over5year'],
|
||||
'loan_ratio' => "0.70",
|
||||
'reg_price' => $request_data['reg_price'],
|
||||
'size' => $request_data['size'],
|
||||
'tax_items' => explode(',', $tax_items),
|
||||
'ownership_type' => $request_data['ownership_type']
|
||||
];
|
||||
$url = env('uploadFile.host_url') . '/admin/Pending/AutomaticCalculation';
|
||||
$return_price_data = json_decode($this->sendPost($url, json_encode($post_data), 30, ['Content-type: application/json']), true);
|
||||
if ($return_price_data['code'] != 1) {
|
||||
trace('税费计算出错:');
|
||||
trace($return_price_data);
|
||||
return false;
|
||||
}
|
||||
|
||||
$ins_return_price_data = [
|
||||
'property_cert_info_id' => $property_cert_info,
|
||||
'property_name' => trim($request_data['loupan_name']) . trim($request_data['building_name']) . trim($request_data['unit_no']),
|
||||
'area' => $request_data['size'],
|
||||
// 'floor' => $request_data['floor'],
|
||||
'building_unit_no' => trim($request_data['building_name']) . trim($request_data['unit_no']),
|
||||
'building_no' => trim($request_data['building_name']),
|
||||
'unit_no' => trim($request_data['unit_no']),
|
||||
'eva_unit_price' => $eva_unit_price,
|
||||
'guide_price' => $request_data['guide_price'] ?? 0,
|
||||
'eva_total_value' => $return_price_data['data']['eva_total_value'],
|
||||
'eva_net_value' => $return_price_data['data']['eva_net_value'],
|
||||
'eva_net_value2' => $return_price_data['data']['eva_net_value2'],
|
||||
'corporate_income_tax' => $return_price_data['data']['corporate_income_tax'],
|
||||
'tran_service_fee' => $return_price_data['data']['tran_service_fee'],
|
||||
'edu_surcharge' => $return_price_data['data']['edu_surcharge'],
|
||||
'urban_construction_tax' => $return_price_data['data']['urban_construction_tax'],
|
||||
'deed_tax' => $return_price_data['data']['deed_tax'],
|
||||
'stamp_duty' => $return_price_data['data']['stamp_duty'],
|
||||
'added_tax' => $return_price_data['data']['added_tax'],
|
||||
'land_value_added_tax' => $return_price_data['data']['land_value_added_tax'],
|
||||
'land_value_added_tax_copy' => $return_price_data['data']['land_value_added_tax_copy'],
|
||||
'personal_income_tax' => $return_price_data['data']['personal_income_tax'],
|
||||
'personal_income_tax_copy' => $return_price_data['data']['personal_income_tax_copy'],
|
||||
'auction_fee' => $return_price_data['data']['auction_fee'],
|
||||
'total_taxes1' => $return_price_data['data']['total_taxes1'],
|
||||
'total_taxes2' => $return_price_data['data']['total_taxes2'],
|
||||
'loan_ratio' => 0.70,
|
||||
'gross_value' => $return_price_data['data']['gross_value'],
|
||||
'eva_net_value' => $return_price_data['data']['eva_net_value'],
|
||||
'eva_net_value2' => $return_price_data['data']['eva_net_value2'],
|
||||
'tax_items' => $tax_items,
|
||||
'tips' => $return_price_data['data']['tips'],
|
||||
'appraiser_id' => 0,
|
||||
'appraiser_name' => '自动估价',
|
||||
'create_time' => time()
|
||||
];
|
||||
|
||||
Db::name('return_price')->insert($ins_return_price_data);
|
||||
|
||||
// 匹配OA生成盖章的预估单(取消自动签章2021-06-30)
|
||||
// $post_estimate_data = [
|
||||
// 'id' => $quot_id,
|
||||
// 'appraiser_ids' => env('evaluate.valuer_id')
|
||||
// ];
|
||||
// $estimate_url = env('uploadFile.host_url') . '/admin/Pending/SignatureSave';
|
||||
// $estimate = json_decode($this->sendPost($estimate_url, json_encode($post_estimate_data), 30, ['Content-type: application/json']), true);
|
||||
|
||||
// PublicMessage($quot_id, 2, 2);
|
||||
$this->data = [
|
||||
'order_no' => $ins_inquiry_data['order_no'],
|
||||
'eva_unit_price' => $eva_unit_price,
|
||||
'eva_total_value' => $return_price_data['data']['eva_total_value'],
|
||||
'eva_net_value' => $return_price_data['data']['eva_net_value'],
|
||||
'eva_net_value2' => $return_price_data['data']['eva_net_value2'],
|
||||
'total_taxes1' => $return_price_data['data']['total_taxes1'],
|
||||
'total_taxes2' => $return_price_data['data']['total_taxes2'],
|
||||
'gross_value' => $return_price_data['data']['gross_value'],
|
||||
'guide_price' => $request_data['guide_price'],
|
||||
// 'estimates_no' => !empty($estimate['data']) ? $estimate['data'] : '',
|
||||
// 'estimates_url' => !empty($estimate['data']) ? env('uploadFile.host_url') . '/admin/Pending/EstimateSheetTemplate?estimated_no=' . $estimate['data'] : '',
|
||||
'estimates_no' => '',
|
||||
'estimates_url' => '',
|
||||
];
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
trace('错误接口:' . request()->path());
|
||||
trace('操作参数:' . json_encode(input(), 256));
|
||||
trace('错误文件:' . $e->getFile());
|
||||
trace('错误行数:' . $e->getLine());
|
||||
trace('错误代码:' . $e->getCode());
|
||||
trace('错误信息:' . $e->getMessage());
|
||||
return '系统开小差,请稍后重试!';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* POST 请求(支持文件上传)
|
||||
* @param string $url HTTP请求URL地址
|
||||
* @param array|string $data POST提交的数据
|
||||
* @param int $second 请求超时时间
|
||||
* @param array $header 请求Header信息
|
||||
* @return bool|string
|
||||
*/
|
||||
static public function sendPost($url, $data = [], $second = 30, $header = [])
|
||||
{
|
||||
$curl = curl_init();
|
||||
self::applyData($data);
|
||||
self::applyHttp($curl, $url);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, $second);
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
if (!empty($header)) {
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
|
||||
}
|
||||
list($content, $status) = [curl_exec($curl), curl_getinfo($curl), curl_close($curl)];
|
||||
return (intval($status["http_code"]) === 200) ? $content : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post 数据过滤处理
|
||||
* @param array $data
|
||||
* @param bool $isBuild
|
||||
* @return string
|
||||
*/
|
||||
private static function applyData(&$data, $isBuild = true)
|
||||
{
|
||||
if (!is_array($data)) {
|
||||
return null;
|
||||
}
|
||||
foreach ($data as &$value) {
|
||||
is_array($value) && $isBuild = true;
|
||||
if (!(is_string($value) && strlen($value) > 0 && $value[0] === '@')) {
|
||||
continue;
|
||||
}
|
||||
if (!file_exists(($file = realpath(trim($value, '@'))))) {
|
||||
continue;
|
||||
}
|
||||
list($isBuild, $mime) = [false, FileService::getFileMine(pathinfo($file, 4))];
|
||||
if (class_exists('CURLFile', false)) {
|
||||
$value = new CURLFile($file, $mime);
|
||||
} else {
|
||||
$value = "{$value};type={$mime}";
|
||||
}
|
||||
}
|
||||
$isBuild && $data = http_build_query($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置SSL参数
|
||||
* @param $curl
|
||||
* @param string $url
|
||||
*/
|
||||
private static function applyHttp(&$curl, $url)
|
||||
{
|
||||
if (stripos($url, "https") === 0) {
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_SSLVERSION, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// 估价系统补充资料时,询价记录需要改状态到待回价
|
||||
public function modifyInquiryStatus()
|
||||
{
|
||||
// $order_no = input('order_no');
|
||||
$input = input('');
|
||||
if (!$input['order_no']) return $this->buildFailed('询价单号不能为空');
|
||||
$attachments = '';
|
||||
if (!empty($input['property_pic_info'])) {
|
||||
$input['property_pic_info']['url'] = $input['oss_base_url'] . $input['property_pic_info']['url'];
|
||||
$input['property_pic_info']['thum1'] = $input['property_pic_info']['url'];
|
||||
unset($input['property_pic_info']['id']);
|
||||
unset($input['property_pic_info']['fs_attachment_id']);
|
||||
unset($input['property_pic_info']['thum2']);
|
||||
unset($input['property_pic_info']['thum3']);
|
||||
unset($input['property_pic_info']['category']);
|
||||
$attachments = Db::name('attachment')->insertGetId($input['property_pic_info']);
|
||||
}
|
||||
|
||||
$remark = '';
|
||||
if (!empty($input['house_structure'])) $remark .= '户型结构:' . $input['house_structure'] . '|';
|
||||
if (!empty($input['is_double_str'])) $remark .= '是否双拼:' . $input['is_double_str'] . '|';
|
||||
if (!empty($input['is_double_plus_str'])) $remark .= '是否多拼:' . $input['is_double_plus_str'] . '|';
|
||||
if (!empty($input['unit_type'])) $remark .= '户型:' . $input['unit_type'] . '|';
|
||||
if (!empty($input['house_toward'])) $remark .= '朝向:' . $input['house_toward'] . '|';
|
||||
if (!empty($input['landspace'])) $remark .= '景观:' . $input['landspace'] . '|';
|
||||
if (!empty($input['decoration'])) $remark .= '装修情况:' . $input['decoration'] . '|';
|
||||
if (!empty($input['remark'])) $remark .= '其他说明:' . $input['remark'];
|
||||
|
||||
try {
|
||||
$inquiry_info = Db::name('inquiry')->where(['order_no' => $input['order_no']])->find();
|
||||
if (!$inquiry_info) return $this->buildFailed('询价记录不存在');
|
||||
if (!in_array($inquiry_info['status'], [1, 2])) return $this->buildFailed('估计师正在加急处理此询价,请勿重复操作');
|
||||
// 补充资料更新到询价详情表
|
||||
$property_cert_info['attachments'] = $attachments;
|
||||
$property_cert_info['remark'] = trim($remark, '|');
|
||||
if ($inquiry_info['status'] == 2) {
|
||||
$property_cert_info['adjust_status'] = 1;
|
||||
$property_cert_info['adjust_reason'] = '城市云估价格复核';
|
||||
$property_cert_info['variance_ratio'] = 0.05;
|
||||
}
|
||||
Db::name('property_cert_info')->where(['quot_id' => $inquiry_info['id']])->update($property_cert_info);
|
||||
// 已回价的估价系统询价,价格复核不用修改status为1,流转到自动估价调价项目2021-07-02
|
||||
// Db::name('inquiry')->where(['id' => $inquiry_info['id']])->update(['status' => 1, 'update_time' => date('Y-m-d H:i:s')]); // 2021-07-02 注释
|
||||
return $this->buildSuccess();
|
||||
} catch (\Exception $e) {
|
||||
trace('错误接口:' . request()->path());
|
||||
trace('操作参数:' . json_encode(input(), 256));
|
||||
trace('错误文件:' . $e->getFile());
|
||||
trace('错误行数:' . $e->getLine());
|
||||
trace('错误代码:' . $e->getCode());
|
||||
trace('错误信息:' . $e->getMessage());
|
||||
return $this->buildFailed('系统开小差,请稍后重试!');
|
||||
}
|
||||
}
|
||||
|
||||
// 估价系统补充资料时,如果之前没匹配OA或者后台的,需在OA系统新增一条询价记录
|
||||
public function addInquiry()
|
||||
{
|
||||
$request_data = input('');
|
||||
|
||||
$validate = new EvaluateInquiryValidate();
|
||||
if (!$validate->check($request_data)) return $this->buildFailed($validate->getError());
|
||||
|
||||
$attachments = '';
|
||||
if (!empty($request_data['property_pic_info'])) {
|
||||
$request_data['property_pic_info']['url'] = $request_data['oss_base_url'] . $request_data['property_pic_info']['url'];
|
||||
$request_data['property_pic_info']['thum1'] = $request_data['property_pic_info']['url'];
|
||||
unset($request_data['property_pic_info']['id']);
|
||||
unset($request_data['property_pic_info']['fs_attachment_id']);
|
||||
unset($request_data['property_pic_info']['thum2']);
|
||||
unset($request_data['property_pic_info']['thum3']);
|
||||
unset($request_data['property_pic_info']['category']);
|
||||
$attachments = Db::name('attachment')->insertGetId($request_data['property_pic_info']);
|
||||
}
|
||||
|
||||
$remark = '';
|
||||
if (!empty($request_data['house_structure'])) $remark .= '户型结构:' . $request_data['house_structure'] . '|';
|
||||
if (!empty($request_data['is_double_str'])) $remark .= '是否双拼:' . $request_data['is_double_str'] . '|';
|
||||
if (!empty($request_data['is_double_plus_str'])) $remark .= '是否多拼:' . $request_data['is_double_plus_str'] . '|';
|
||||
if (!empty($request_data['unit_type'])) $remark .= '户型:' . $request_data['unit_type'] . '|';
|
||||
if (!empty($request_data['house_toward'])) $remark .= '朝向:' . $request_data['house_toward'] . '|';
|
||||
if (!empty($request_data['landspace'])) $remark .= '景观:' . $request_data['landspace'] . '|';
|
||||
if (!empty($request_data['decoration'])) $remark .= '装修情况:' . $request_data['decoration'] . '|';
|
||||
if (!empty($request_data['remark'])) $remark .= '其他说明:' . $request_data['remark'];
|
||||
|
||||
try {
|
||||
Db::startTrans();
|
||||
// 1.inquiry表
|
||||
$inquiry = new InquiryModel();
|
||||
$order_no = $inquiry->generateInquiryNo($request_data['type']);
|
||||
$ins_inquiry_data = [];
|
||||
$ins_inquiry_data['order_no'] = $order_no;
|
||||
$ins_inquiry_data['user_id'] = $request_data['user_id'];
|
||||
$ins_inquiry_data['user_name'] = $request_data['user_name'];
|
||||
$ins_inquiry_data['user_phone'] = $request_data['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['eva_purpose'] = $request_data['loan_type'];
|
||||
$ins_inquiry_data['product_id'] = $request_data['loan_type_id'];
|
||||
$ins_inquiry_data['type'] = 1;
|
||||
$ins_inquiry_data['status'] = 1;
|
||||
$ins_inquiry_data['eva_detail_time_long'] = 0;
|
||||
$ins_inquiry_data['is_auto'] = 1;
|
||||
$ins_inquiry_data['is_auto_eva'] = 0;
|
||||
$ins_inquiry_data['source'] = 2;
|
||||
$ins_inquiry_data['create_time'] = date('Y-m-d H:i:s');
|
||||
$ins_inquiry_data['update_time'] = date('Y-m-d H:i:s');
|
||||
$quot_id = Db::name('inquiry')->insertGetId($ins_inquiry_data);
|
||||
// 2.inquiry_detail表
|
||||
$ins_inquiry_detail_data = [];
|
||||
$ins_inquiry_detail_data['quot_id'] = $quot_id;
|
||||
$ins_inquiry_detail_data['city'] = getCity($request_data['city'])['shortname'];
|
||||
$ins_inquiry_detail_data['city_id'] = getCity($request_data['city'])['id'];
|
||||
$ins_inquiry_detail_data['property_full_name'] = trim($request_data['loupan_name']) . trim($request_data['building_name']) . trim($request_data['unit_no']);
|
||||
$ins_inquiry_detail_data['building_name'] = trim($request_data['loupan_name']);
|
||||
$ins_inquiry_detail_data['building_unit_no'] = trim($request_data['building_name']) . trim($request_data['unit_no']);
|
||||
$ins_inquiry_detail_data['building_no'] = trim($request_data['building_name']);
|
||||
$ins_inquiry_detail_data['unit_no'] = trim($request_data['unit_no']);
|
||||
$ins_inquiry_detail_data['size'] = $request_data['size'];
|
||||
$ins_inquiry_detail_data['reg_price'] = $request_data['reg_price'];
|
||||
$ins_inquiry_detail_data['is_tran_tax_free'] = $request_data['is_over5year'];
|
||||
$ins_inquiry_detail_data['ownership_type'] = $request_data['ownership_type'];
|
||||
$ins_inquiry_detail_data['usage'] = getDictionaryCode('HOUSE_USAGE', '住宅')['code'];
|
||||
$ins_inquiry_detail_data['attachments'] = $attachments;
|
||||
$ins_inquiry_detail_data['remark'] = trim($remark, '|');
|
||||
$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');
|
||||
$property_cert_info = Db::name('property_cert_info')->insertGetId($ins_inquiry_detail_data);
|
||||
// 判断结果
|
||||
if (!$quot_id || !$property_cert_info) {
|
||||
Db::rollback();
|
||||
return false;
|
||||
}
|
||||
Db::commit();
|
||||
return $this->buildSuccess(['order_no' => $order_no]);
|
||||
} catch (\Exception $e) {
|
||||
trace('错误接口:' . request()->path());
|
||||
trace('操作参数:' . json_encode(input(), 256));
|
||||
trace('错误文件:' . $e->getFile());
|
||||
trace('错误行数:' . $e->getLine());
|
||||
trace('错误代码:' . $e->getCode());
|
||||
trace('错误信息:' . $e->getMessage());
|
||||
return $this->buildFailed('系统开小差,请稍后重试!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user