Files
pgserver3.0/pgserver/application/util/OffsiteOneTemplate.php
2026-04-23 14:52:18 +08:00

1473 lines
86 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
//单套物业模板参数
namespace app\util;
use app\admin\service\CommonService;
use app\admin\exception\LogicException;
use app\model\Inquiry;
use app\model\Property_cert_info;
use app\model\ReturnPrice;
use app\model\Survey;
use app\model\SurveyDetail;
use app\model\Report;
use app\model\ReportDetail;
use app\model\Attachment;
use app\model\Region;
use think\Db;
use app\admin\controller\Survey as SurveyC;
use app\model\MethodFormal;
use app\model\MethodProfit;
use think\facade\Env;
use think\facade\Log;
class OffsiteOneTemplate
{
public function getValue($reportid) {
$reportInfo = Report::where('id', $reportid)->find();
$reportDetailInfo = ReportDetail::where('report_id', $reportid)->find();
$inquiryInfo = Inquiry::where('id', $reportInfo['quot_id'])->find();
$inquiryDetailInfo = Property_cert_info::where('quot_id', $reportInfo['quot_id'])->find();
$survey = new Survey();
// 房产证号文字处理
$property_cert = '';
// $consult = Db::name('consult_record')->where(['property_cert_info_id'=>$inquiryDetailInfo['id']])->find();
// $deed_number_str = Db::name('consult_record_det')->where(['id'=>$consult['consult_record_det_id']])->find();
// $deed_number_str = $deed_number_str['data_printResult'];
// if (!$consult) {
// // pg_report_detail.new_online_info
// $deed_number_str = $reportDetailInfo['new_online_info'];
// }
$parcel_no = $reportDetailInfo['parcel_no'];
// 更新宗地信息
if (empty($reportDetailInfo['adjacent_property']) &&
empty($reportDetailInfo['bus_lines']) &&
empty($reportDetailInfo['boundaries']) &&
empty($reportDetailInfo['pub_serv']) &&
empty($reportDetailInfo['property_intro']) &&
!empty($parcel_no))
{
//CommonService::UpdateZongDiInfo( $parcel_no,$reportDetailInfo);
$zd_info = CommonService::UpdateZongDiInfo( $parcel_no);
$reportDetailInfo['adjacent_property'] = $zd_info['adjacent_property'];
$reportDetailInfo['bus_lines'] = $zd_info['bus_lines'];
$reportDetailInfo['boundaries'] = $zd_info['boundaries'];
$reportDetailInfo['pub_serv'] = $zd_info['pub_serv'];
$reportDetailInfo['property_intro'] = $zd_info['property_intro'];
}
$deed_number_str = $reportDetailInfo['new_online_info'];
// if (strpos($deed_number_str, '') !== false) {
// $deed_number_str_array = explode('', $deed_number_str);
//// if (strpos($deed_number_str_array[1], '证号') !== false) {
//// $deed_number_array = explode('证号', $deed_number_str_array[1]);
//// if (strpos($deed_number_array[1], '不动产权') !== false) {
//// $property_cert = $deed_number_array[1];
//// } else {
//// $property_cert = '深房地字第'.$deed_number_array[1].'号';
//// }
//// }
// foreach ($deed_number_str_array as $deed_k=>$deed_v)
// if (strpos($deed_v, '证号') !== false) {
// $deed_number_array = explode('证号', $deed_v);
// if (strpos($deed_v, '不动产权') !== false) {
//// $property_cert = $deed_number_array[1];
// $property_cert = str_replace('', '(', $deed_number_array[1]);
// $property_cert = str_replace('', ')', $property_cert);
// } else {
// $property_cert = '深房地字第'.$deed_number_array[1].'号';
// }
// }
// } else {
// // 根据城市查找省份简称
// $province_tag = '';
// $city = $inquiryDetailInfo['city'] ?? '';
// if (!empty($city)) {
// $provinceCityArray = Region::PROVINCE_CITY;
// foreach ($provinceCityArray as $province => $cities) {
// if (in_array($city, $cities)) {
// $province_tag = $province;
// break;
// }
// }
// }
//
// // 拼接不动产权证号
// if (!empty($reportDetailInfo['year']) && !empty($province_tag)) {
// $property_cert = $province_tag . '' . $reportDetailInfo['year'] . '' . $city . '市不动产权第' . $reportDetailInfo['property_cert'] . '号';
// } else {
// $property_cert = '深房地字第' . $reportDetailInfo['property_cert'] . '号';
// }
// }
// 根据城市查找省份简称
$province_tag = '';
$city = $inquiryDetailInfo['city'] ?? '';
if (!empty($city)) {
$provinceCityArray = Region::PROVINCE_CITY;
foreach ($provinceCityArray as $province => $cities) {
if (in_array($city, $cities)) {
$province_tag = $province;
break;
}
}
}
// 拼接不动产权证号
if (!empty($reportDetailInfo['year']) && !empty($province_tag)) {
$property_cert = $province_tag . '' . $reportDetailInfo['year'] . '' . $city . '市不动产权第' . $reportDetailInfo['property_cert'] . '号';
} else {
$property_cert = '深房地字第' . $reportDetailInfo['property_cert'] . '号';
}
$valuerInfo = Db::name('valuer')->field('name,mobile,certificate_number,mark,certificate,autograph')->whereIn('id', [$reportInfo['appraiser_id'], $reportInfo['appraiser2_id']])->select();
$attachmnet = new Attachment();
$valuerName = '';
$valuerimg = [];
if (!empty($valuerInfo)) {
$name_len = 0;
foreach ($valuerInfo as $kkk=>$vvv) {
if (mb_strlen($vvv['name'])>$name_len) {
$name_len = mb_strlen($vvv['name']);
}
}
$i = 1;
foreach ($valuerInfo as &$vvalue) {
// 报告pdf封面多个估价师姓名字数不同对字数少的的中间加空格排版版面处理
$name_arr = preg_split('/(?<!^)(?!$)/u', $vvalue['name']);
if ($name_len ==3 && mb_strlen($vvalue['name'])==2) {
// $vname = $name_arr[0].'&nbsp;&nbsp;'.$name_arr[1];
$vname = $name_arr[0].''.$name_arr[1];
} elseif ($name_len ==4 && mb_strlen($vvalue['name'])==2) {
// $vname = $name_arr[0].'&nbsp;&nbsp;&nbsp;&nbsp;'.$name_arr[1];
$vname = $name_arr[0].''.$name_arr[1];
} elseif ($name_len ==4 && mb_strlen($vvalue['name'])==3) {
$vname = $name_arr[0].'&nbsp;&nbsp;'.$name_arr[1].'&nbsp;&nbsp;'.$name_arr[2];
} else {
$vname = $vvalue['name'];
}
$valuerName .= $vname . '(注册号:' . $vvalue['certificate_number'] . '<br/>';
$vvalue['nod'] = $i++;
if (!empty($vvalue['certificate'])) {
$valuerimg[] = $vvalue['certificate'];
}
if (!empty($vvalue['autograph'])) {
$vvalue['autograph'] = $attachmnet->getUrl($vvalue['autograph'])['url'];
}
}
}
$code = '';
//根据首套物业所在城市获取报告code
if (empty($code)) {
if ($inquiryDetailInfo['city'] == '北京') {
$code = 'B';
} elseif ($inquiryDetailInfo['city'] == '武汉') {
$code = 'C';
} else {
$code = 'A';
}
}
// $attachmnet = new Attachment();
$report_summary_img_ids = [];
if (!empty($reportDetailInfo['report_summary_img_ids'])) {
$summaryIds = explode(',', $reportDetailInfo['report_summary_img_ids']);
$report_summary_img_ids = $attachmnet->getUrls($summaryIds);
}
$year = mb_substr($reportInfo['report_no'], 0, 4);
$report_no = explode('-', $reportInfo['report_no']);
$pos_f = mb_strpos($reportInfo['report_no'], '-');
$numberings = mb_substr($reportInfo['report_no'], 4, $pos_f+4);
$suffix = mb_substr($reportInfo['report_no'], $pos_f+8);
$gross_value = $eva_net_value = $eva_net_value2 = 0;
$appraiserData = $resultData = [];$owner_name = '';
$type_str = getDictionaryName('ORDER_TYPE', $inquiryInfo['type']);
$priceInfo = Db::name('return_price')->where('property_cert_info_id', $inquiryDetailInfo['id'])->order('id', 'desc')->find();
$gross_value = $gross_value + $priceInfo['eva_total_value'];
$eva_net_value = $eva_net_value + $priceInfo['eva_net_value'];
$eva_net_value2 = $eva_net_value2 + $priceInfo['eva_net_value2'];
$surveyInfo = Survey::where('property_cert_info_id', $inquiryDetailInfo['id'])->find();
$surveyDetailInfo = SurveyDetail::where('survey_id', $surveyInfo['id'])->find();
// $property_cert = !empty($inquiryDetailInfo['year']) ? $inquiryDetailInfo['year'] . $inquiryDetailInfo['property_cert'] : $inquiryDetailInfo['property_cert'];//产证号
if (strpos($inquiryDetailInfo['property_complex'], '㎡') !== false) {
$property_complex = str_replace('㎡', '<span style="font-family: sun-exta;">㎡</span>', $inquiryDetailInfo['property_complex']);
} else {
$property_complex = $inquiryDetailInfo['property_complex'];
}
//估 价 结 果 明 细 表 (住宅)
$data = [];
$data['nod'] = 1;
$data['full_estate_name'] = $inquiryDetailInfo['property_full_name'];
$data['usage_str'] = getDictionaryName('HOUSE_USAGE', $inquiryDetailInfo['usage']);
$data['size'] = $inquiryDetailInfo['size'];
$data['assessment_all_value'] = number_format($priceInfo['eva_total_value']);
$data['gross_value'] = number_format($priceInfo['eva_total_value']);
$data['net_worth'] = number_format($priceInfo['eva_net_value']);
$data['net_worth_tow'] = number_format($priceInfo['eva_net_value2']);
$data['estate_name'] = $inquiryDetailInfo['property_complex'];//所在楼盘
$data['area'] = $reportDetailInfo['small_district_name'];//所在片区
$data['market_price']=number_format($priceInfo['market_price']);//市场参考单价
$data['guide_price']=number_format($priceInfo['guide_price']);//二手房成交参考单价
// 添加错误处理,确保数值计算安全
$guide_price = is_numeric($priceInfo['guide_price']) ? $priceInfo['guide_price'] : 0;
$size = is_numeric($inquiryDetailInfo['size']) ? $inquiryDetailInfo['size'] : 0;
$data['guide_total']=number_format($guide_price * $size);//参考价总值
$data['guide_price_building'] = $reportDetailInfo['ref_unit_price_building'];//参考单价所属楼盘
$data['unit_price']=number_format($priceInfo['eva_unit_price']);//评估单价
$data['total_price']=number_format($priceInfo['eva_total_value']);//评估总价
$data['estimated_taxes']=number_format($priceInfo['total_taxes1']);//预计税费
$data['gross_worth']=number_format($eva_net_value);//抵押净值
$data['register_price']=number_format($inquiryDetailInfo['reg_price'], 2);//登记价
$data['deed_number'] = $property_cert;//房产证
$data['land_location'] = $reportDetailInfo['land_location'];//坐落位置
$data['obligee_percent'] = $reportDetailInfo['obligee_percent'];//权利人
$data['statutory_payment'] = number_format($inquiryDetailInfo['statutory_payment'], 2);//法定优先受偿款
//中信银行-快速变现价值
if ($inquiryInfo['type'] == 1) {
$rapid_roi_citic = round($priceInfo['eva_total_value']*0.7);
} else {
$rapid_roi_citic = round($priceInfo['eva_total_value']*0.6);
}
$data['rapid_roi_citic'] = number_format($rapid_roi_citic,0,'.',',');
//$data['qrurl'] = $inquiryInfo['qrurl'];//二维码地址
// 收益法的估价结果明细备注内容新增租金数据 2022-02-11 16:00:00
$data9 = MethodProfit::where('property_cert_info_id', $inquiryDetailInfo['id'])->find();
$data['month_profit'] = !empty($data9['month_profit']) ? $data9['month_profit'] : 0;
$appraiserData[] = $data;
//估价结果明细
$reDetail = Db::name('report_detail')->where('property_cert_info_id', $inquiryDetailInfo['id'])->find();
//竣工时间
$completion = strtotime($reDetail['completion_date']);//竣工时间戳
$restrict = strtotime('1970-01-01');//限制时间戳
$completion_date = !empty($reDetail['completion_date']) && $completion > $restrict ? date('Y年m月d日', $completion) : '****年**月**日';
//购买日期
$buy_date_unix = strtotime($reDetail['purchase_date']);
$buy_restrict = strtotime('1899-11-30');
$purchase_date = !empty($reDetail['purchase_date']) && $buy_date_unix > $buy_restrict ? date('Y年m月d日', $buy_date_unix) : '——';
$data1 = [];
$data1['full_estate_name'] = $inquiryDetailInfo['property_full_name'];
$data1['deed_number'] = $property_cert;
$data1['usage_str'] = getDictionaryName('HOUSE_USAGE', $inquiryDetailInfo['usage']);
$data1['size'] = $priceInfo['area'];
$data1['market_price'] = number_format($priceInfo['market_price']);
$data1['guide_price'] = number_format($priceInfo['guide_price']);
// 添加错误处理,确保数值计算安全
$guide_price = is_numeric($priceInfo['guide_price']) ? $priceInfo['guide_price'] : 0;
$area = is_numeric($priceInfo['area']) ? $priceInfo['area'] : 0;
$data1['guide_price_total'] = number_format($guide_price * $area);
$data1['assessment_price'] = number_format($priceInfo['eva_unit_price']);
$data1['gross_value'] = number_format($priceInfo['eva_total_value']);
$data1['net_worth'] = number_format($priceInfo['eva_net_value']);
$data1['net_worth_tow'] = number_format($priceInfo['eva_net_value2']);
$data1['estate_name'] = $inquiryDetailInfo['property_complex'];//所在楼盘
$data1['area'] = $reportDetailInfo['small_district_name'];//所在片区
//$data1['buy_date'] = !empty($inquiryDetailInfo['purchase_date']) ? date('Y年m月d日', strtotime($inquiryDetailInfo['purchase_date'])) : date('Y年m月d日', strtotime($reDetail['purchase_date']));
// $data1['buy_date'] = date('Y年m月d日', strtotime($reDetail['reg_date']));
$data1['buy_date'] = !empty($reDetail['purchase_date']) && $buy_date_unix > $buy_restrict ? date('Y年m月d日', $buy_date_unix) : date('Y年m月d日', strtotime($reDetail['reg_date']));
$data1['completion_date'] = $completion_date;
$data1['is_vacant'] = $reDetail['is_vacant'] == 1 ? '是' : '否';
$data1['vacant_months'] = $reDetail['vacant_months'];
$data1['is_through'] = $reDetail['is_connect_with_other'] == 2 ? '是' : '否';
$data1['is_self_built'] = $reDetail['is_self_built'] == 2 ? '是' : '否';
$data1['is_violation'] = $reDetail['is_illegal_building'] == 2 ? '是' : '否';
$data1['is_auction'] = $reDetail['is_arbitration'] == 2 ? '是' : '否';
$data1['is_consistent'] = $reDetail['is_consistent'] == 2 ? '是' : '否';
$data1['is_double'] = $reDetail['is_double_unit'] == 2 ? '是' : '否';
$data1['is_old_change'] = $reDetail['is_renovation'];
$data1['is_old_change_citic'] = $reDetail['is_renovation'] == 2 ? '是' : '否';
$data1['is_verify_mb'] = $reDetail['is_impl_subject'];
$data1['announcement_link'] = $reDetail['announce_link'];
$data1['is_residence'] = $reDetail['is_residential'];
$data1['is_double_plus'] = $reDetail['is_multi_unit'] == 2 ? '是' : '否';
$data1['is_darkroom'] = $reDetail['has_hidden_room'] == 2 ? '是' : '否';
$data1['is_rent'] = $surveyDetailInfo['parking_lot_usage'] == 3 ? '是' : '否';
$data1['is_rent_citic'] = Survey::getDictionaryName1('residence_parking_garage_status',$surveyDetailInfo['parking_lot_usage']);
$data1['is_inconsit_cond'] = $reDetail['is_inconsit_cond'];
$data1['inconsistent_reason'] = $reDetail['inconsistent_reason'];
$data1['register_price'] = number_format($inquiryDetailInfo['reg_price'], 2);
$data1['city'] = $inquiryDetailInfo['city'];
$data1['assessment_time'] = date('Y年m月d日', strtotime($reportInfo['appraisal_time'])); // 评估报告出具日期
$resultData[] = $data1;
$usage_name = getDictionaryName('HOUSE_USAGE', $inquiryDetailInfo['usage']);
$structure = !empty($surveyDetailInfo) ? $surveyDetailInfo['structure'] : '';
$newness_rate = !empty($surveyDetailInfo) ? $surveyDetailInfo['newness_rate'] : '';
$decoration = !empty($surveyDetailInfo) ? $surveyDetailInfo['decoration'] : '';
$survey_time = !empty($inquiryDetailInfo['survey_time']) ? date('Y年m月d日', strtotime($inquiryDetailInfo['survey_time'])) : '';
$returnDateInfo = Db::name('return_price')->field('MIN(create_time) as min_time,MAX(create_time) as max_time')->where('property_cert_info_id', $inquiryDetailInfo['id'])->find();
$gross_value_str = convertAmountToCn($gross_value, $type = 1);
$gross_value = number_format($gross_value);
$net_worth_str = convertAmountToCn($eva_net_value, $type = 1);
$eva_net_value = number_format($eva_net_value);
$net_worth_tow_str = convertAmountToCn($eva_net_value2, $type = 1);
$eva_net_value2 = number_format($eva_net_value2);
$appraisal_time = !empty($reportInfo['appraisal_time']) ? explode('-', $reportInfo['appraisal_time']) : '';
$surveyc=new SurveyC();
$options=$surveyc->surveyOptionsList();
$simpleInfo = Db::name('method_simple')->field('id,property_cert_info_id,item,trade_date,building_name as estate_name,size,floor_number1,unit_type,floor_number2,price,transactions')->where('property_cert_info_id', $inquiryDetailInfo['id'])->order('id', 'asc')->select();
$formalInfo = Db::name('method_formal')->field('transaction_instance,transaction_situation,transaction_date,area_situation,equity_situation,matter_situation,total_situation')->where('property_cert_info_id', $inquiryDetailInfo['id'])->order('id', 'asc')->find();
$gzFormalInfo = Db::name('method_formal_gz')->where('property_cert_info_id', $inquiryDetailInfo['id'])->value('comparative_price_calculation');
$land_use_enddate = new \DateTime($reportDetailInfo['land_use_end_time']);
$max_land_use_years = empty($reportDetailInfo['max_land_use_years']) ? '不动产权证上未记载' : $reportDetailInfo['max_land_use_years'] . '年,从' .date('Y年m月d日', strtotime($reportDetailInfo['land_use_start_time'])) . '到' . $land_use_enddate->format('Y年m月d日') . '止';
$info = [];
if (!empty($gzFormalInfo)) {
$info['gzFormalInfo'] = json_decode($gzFormalInfo, 1);
// 添加错误处理,确保数值转换安全
if (isset($info['gzFormalInfo']['price']['two'])) {
$info['gzFormalInfo']['price']['two'] = is_numeric($info['gzFormalInfo']['price']['two']) ? (int)$info['gzFormalInfo']['price']['two'] : 0;
}
if (isset($info['gzFormalInfo']['price']['three'])) {
$info['gzFormalInfo']['price']['three'] = is_numeric($info['gzFormalInfo']['price']['three']) ? (int)$info['gzFormalInfo']['price']['three'] : 0;
}
if (isset($info['gzFormalInfo']['price']['four'])) {
$info['gzFormalInfo']['price']['four'] = is_numeric($info['gzFormalInfo']['price']['four']) ? (int)$info['gzFormalInfo']['price']['four'] : 0;
}
if (isset($info['gzFormalInfo']['comparing_prices']) && is_numeric($info['gzFormalInfo']['comparing_prices'])) {
$info['gzFormalInfo']['price_revision_avg'] = number_format($info['gzFormalInfo']['comparing_prices']);
$info['gzFormalInfo']['price_revision_avg_total'] = number_format($info['gzFormalInfo']['comparing_prices'] * $inquiryDetailInfo['size']);
} else {
$info['gzFormalInfo']['price_revision_avg'] = 0;
$info['gzFormalInfo']['price_revision_avg_total'] = 0;
}
}
//第一页
$info['extract'] = $reportInfo['e_case_code'];//电子报告提取码
// dump($year);
// dump($code);
// dump($numberings);
// dump($suffix);
// die;
$info['report_no'] = $reportInfo['report_no'];//估价报告编号
$info['item_name'] = $reportDetailInfo['land_location'] . $inquiryDetailInfo['property_full_name'];//估价项目名称
$info['item_name_index'] = $reportDetailInfo['land_location'] . $inquiryDetailInfo['property_full_name'] . '一套' . $usage_name . '用途';//估价项目名称(首页)
$info['client_name'] = $reportDetailInfo['client'];//估价委托人
$info['employee_name'] = $valuerName;//注册房地产估价师
$info['finish_date'] = !empty($reportInfo['appraisal_time']) ? date('Y年m月d日', strtotime($reportInfo['appraisal_time'])) : '';//估价报告出具日期
$info['order_type'] = getDictionaryName('ORDER_TYPE', $inquiryInfo['type']);//订单类型
$info['estate_name'] = $inquiryDetailInfo['property_full_name'];
$info['land_location'] = $reportDetailInfo['land_location'];
$info['report_QR_code'] = $reportInfo['report_qrcode'];//防伪二维码
$info['property_name'] = !empty($inquiryDetailInfo) ? $inquiryDetailInfo['property_full_name'] : '';
$info['estate_info'] = $inquiryDetailInfo['property_full_name'];
$info['isNewCert'] = !empty($reportDetailInfo['year'] );// 是否新证。此项为空为老证,反之是新不动产证。
// $info['otherrights_type'] = $this->getOtherRightsType($reportInfo['otherrights_type']);//他项权利说明
// $info['DFFA_desc'] = $this->getDFFADesc( $reportInfo['otherrights_type']); // 背离事实假设描述
$info['buss_username'] = $inquiryInfo['buss_username'];
$info['buss_userphone'] = $inquiryInfo['buss_userphone'];
//第二页
$info['report_summary_img'] = $report_summary_img_ids;//摘要
$info['orderType'] = $inquiryInfo['type'];//订单类型 住宅 商业
//第三页
$info['cost_date'] = $reportInfo['valuation_time'];//价值时点
// 判断物业楼龄是否超过30年以出具报告的价值时点为截止日期
$is_thirty = (strtotime($reportInfo['valuation_time']) - $completion) / (365*24*60*60);
$info['is_thirty'] = intval($is_thirty);
$info['cost_date_cn'] = !empty($reportInfo['valuation_time']) ? date('Y年m月d日', strtotime($reportInfo['valuation_time'])):'';//价值时点
$info['gross_value_str'] = $gross_value_str;//市场价值文本
$info['net_worth_str'] = $net_worth_str;//抵押净值1文本
$info['net_worth_tow_str'] = $net_worth_tow_str;//抵押净值2文本
$info['gross_value'] = $gross_value;//市场价值
$info['net_worth'] = $eva_net_value;//抵押净值1
$info['net_worth_tow'] = $eva_net_value2;//抵押净值2
$info['cost_time'] = !empty($reportInfo['valuation_time']) ? date('Y/m/d', strtotime($reportInfo['valuation_time'])) : '';//价值时点
$info['appraiserData'] = $appraiserData;//估 价 结 果 明 细 表
$info['finish_date_cn'] = !empty($appraisal_time) ? numToWordone($appraisal_time[0]) .'年'. numToWordone(intval($appraisal_time[1])) .'月'. numToWordone(intval($appraisal_time[2])) . '日' : '';//二〇二〇年五月九日
// 简易报告有效期
// $info['simple_valid'] = date('Y-m-d', strtotime("$appraisal_time +3 months"));
$info['simple_valid'] = date('Y-m-d', strtotime("+3 months", strtotime($reportInfo['appraisal_time'])));
// TODO:市场价值中文
$info['total_price_cn']=convertAmountToCn($reportDetailInfo['eva_total_value']);
$info['total_price']=number_format($reportDetailInfo['eva_total_value']);
//预计税费 建行云取税费2
if ($inquiryInfo['bank_name'] == '中国建设银行' && $inquiryInfo['eva_purpose'] == '抵押贷款(云)') {
$anticiated_taxes = $priceInfo['total_taxes2'];
} else {
$anticiated_taxes = $priceInfo['total_taxes1'];
}
$info['estimated_taxes_cn']=convertAmountToCn($anticiated_taxes);
$info['estimated_taxes']=number_format($anticiated_taxes);
// TODO:抵押价值中文
$info['gross_value_cn']=convertAmountToCn($gross_value);
// TODO:抵押净值中文
$info['gross_worth_cn']=convertAmountToCn($priceInfo['eva_net_value']);
$info['gross_worth']=number_format($priceInfo['eva_net_value']);
$info['entrust_explain']=$reportInfo['commission_note'];//委托说明
// 添加错误处理,确保数值计算安全
$guide_price = is_numeric($priceInfo['guide_price']) ? $priceInfo['guide_price'] : 0;
$area = is_numeric($priceInfo['area']) ? $priceInfo['area'] : 0;
$total_guide_tax = is_numeric($priceInfo['total_guide_tax']) ? $priceInfo['total_guide_tax'] : 0;
$info['guide_net']=number_format($guide_price * $area - $total_guide_tax);
$info['gujia_result_remark'] = $reportInfo['appraisal_result_remark'];
$info['rapid_roi_citic'] = number_format($rapid_roi_citic);
$info['rapid_roi_citic_str'] = convertAmountToCn($rapid_roi_citic);
// $info['income_period'] = $data9['income_period'];
// 计算收益期限,添加错误处理
$land_use_end_time = strtotime($reportDetailInfo['land_use_end_time']);
$valuation_time = strtotime($reportInfo['valuation_time']);
if ($land_use_end_time && $valuation_time) {
$info['income_period'] = round(($land_use_end_time - $valuation_time)/(365.25*24*3600), 2);
} else {
$info['income_period'] = 0;
}
$info['citic_pm'] = number_format(round($priceInfo['eva_total_value']*5/100,2));
// 中行法定优先受偿款
$info['statutory_payment'] = number_format($inquiryDetailInfo['statutory_payment']);
$info['statutory_payment_cn']=convertAmountToCn(round($inquiryDetailInfo['statutory_payment']));
$boc_gross_value = round($priceInfo['eva_total_value']-$inquiryDetailInfo['statutory_payment']); // 中行抵押价值
$info['boc_gross_value'] = number_format($boc_gross_value);
$info['boc_gross_value_cn']=convertAmountToCn($boc_gross_value);
$boc_gross_worth = $boc_gross_value-$anticiated_taxes; // 中行抵押净值
$info['boc_gross_worth'] = number_format($boc_gross_worth);
$info['boc_gross_worth_cn']=convertAmountToCn($boc_gross_worth);
//第四页
$info['resultData'] = $resultData;//估价结果明细
$info['report_time'] = date('Y年m月d日', strtotime($reportInfo['valuation_time'])) . '到' . date('Y年m月d日', strtotime($reportInfo['appraisal_time']));
$cost_time = !empty($reportInfo['valuation_time']) ? explode('-', $reportInfo['valuation_time']) : '';
$info['cost_date_str'] = !empty($cost_time) ? numToWordone($cost_time[0]) .'年'. numToWordone(intval($cost_time[1])) .'月'. numToWordone(intval($cost_time[2])) . '日' : '';//二〇二〇年五月九日
//第五页
$info['is_court'] = $reportDetailInfo['is_court'];
$info['deviate_explain'] = $reportDetailInfo['deviation_desc'];
//第六页
$info['valuerInfo'] = $valuerInfo;//估计师信息
$info['otherrights_type'] = $this->getOtherRightsType($reportDetailInfo['otherrights_type']);//他项权利说明
$info['otherrights_type_int'] = $reportDetailInfo['otherrights_type'];
$info['DFFA_desc'] = $this->getDFFADesc( $reportInfo['otherrights_type']); // 背离事实假设描述
//第七页
//权益状况描述与分析(商铺)
$data8 = [];
$data8['name'] = '一';
$data8['estate_name'] = $inquiryDetailInfo['property_full_name'];
$data8['zdbh'] = $reportDetailInfo['parcel_no'];
$data8['land_use'] = $reportDetailInfo['parcel_usage'];
$data8['land_use_year'] = $max_land_use_years;
$data8['deed_number'] = $property_cert;
$data8['usage_str'] = getDictionaryName('HOUSE_USAGE', $inquiryDetailInfo['usage']);
$data8['obligee'] = $reportDetailInfo['obligee'];
$usage_condition = Survey::getArrayField($surveyDetailInfo, ['usage_condition'],$options['shop']['shop_usage_status']);
$data8['shop_usage_status'] = !empty($usage_condition['shop_usage_status']) ? $usage_condition['shop_usage_status'] : '——';
$equityData[] = $data8;
$info['equityData'] = $equityData;
//第八页
//有效期
$evaluation_date = $reportInfo['appraisal_time'];
$info['valid_date'] = date('Y年m月d日', strtotime($reportInfo['appraisal_time'])) . '至' . date('Y年m月d日', strtotime("$evaluation_date +1 year -1 day"));
//第九页
//$info['owner_name'] = $reportDetailInfo['obligee'];//权利人
$info['owner_name'] = $reportDetailInfo['obligee_percent'];//2023-4-12新增字段权利人份额
$info['type_str'] = $type_str;//
$info['usage_name'] = $usage_name;//权利人
$info['structure'] = $structure;//建筑结构
$info['new_rate'] = Survey::getDictionaryName1('residence_new_rate',$newness_rate);//成新率
$info['decoration'] = Survey::getDictionaryName1('residence_decoration_grade',$decoration);//装修档次
$info['deed_number'] = $property_cert;//房权证号
$info['usage_str'] = getDictionaryName('HOUSE_USAGE', $inquiryDetailInfo['usage']);//房屋用途
$info['practical_usage_str'] = getDictionaryName_opa('residence_practical_application', $surveyDetailInfo['usage']);// 查勘表-查勘后的实际房屋用途
$info['size'] = $inquiryDetailInfo['size'];//建筑面积:
$info['zdbh'] = $reportDetailInfo['parcel_no'];//宗地号
$info['zd_area'] = is_numeric($reportDetailInfo['parcel_area']) ? number_format($reportDetailInfo['parcel_area'],2) : $reportDetailInfo['parcel_area'];//宗地面积
$info['land_use'] = $reportDetailInfo['parcel_usage'];//土地用途
$info['land_use_begin'] = $reportDetailInfo['land_use_start_time'];//土地使用开始时间
$info['land_use_end'] = $reportDetailInfo['land_use_end_time'];//土地使用结束时间
$info['land_use_begin_cn'] = date('Y年m月d日',strtotime($reportDetailInfo['land_use_start_time']));//土地使用开始时间
$info['land_use_end_cn'] = date('Y年m月d日',strtotime($reportDetailInfo['land_use_end_time']));//土地使用结束时间
//$info['buy_date'] = date('Y年m月d日',strtotime($inquiryDetailInfo['purchase_date']));//登记/购买日期
//$info['buy_date'] = date('Y年m月d日',strtotime($reportDetailInfo['purchase_date']));//购买日期
//$info['register_time'] = date('Y年m月d日',strtotime($reportDetailInfo['reg_date']));//登记日期
$info['city'] = $inquiryDetailInfo['city'];//所在城市
//第十页
//第十一页
$info['start_survey_time'] = date('Y年m月d日', strtotime($surveyInfo['create_time']));
$info['survey_time'] = $survey_time;//查勘时间
//回价时间段
$info['return_date'] = !empty($returnDateInfo) ? date('Y年m月d日', $returnDateInfo['min_time']) . '至' . date('Y年m月d日', $returnDateInfo['max_time']) : '';
// 民生银行拍卖费
$info['ms_pm'] = number_format(round($priceInfo['eva_total_value']*6/100));
// 民生银行公证费
$info['ms_gz'] = number_format(round($priceInfo['eva_total_value']*3/1000));
// 民生银行转移登记费
$info['ms_transfer'] = number_format(round($priceInfo['eva_total_value']*1/1000));
// 民生银行拍卖费+公证费+转移登记费
$ms_total = round($priceInfo['eva_total_value']*6/100) + round($priceInfo['eva_total_value']*3/1000) + round($priceInfo['eva_total_value']*1/1000);
$info['ms_total'] = number_format($ms_total);
//第十二页
//估 价 结 果 明 细 表
$data = [];
$data['full_estate_name'] = $inquiryDetailInfo['property_full_name'];
$data['deed_number'] = $property_cert;
$data['usage_str'] = getDictionaryName('HOUSE_USAGE', $inquiryDetailInfo['usage']);
$data['size'] = $inquiryDetailInfo['size'];
$data['assessment_price'] = number_format($priceInfo['eva_unit_price']);
$data['assessment_all_value'] = number_format($priceInfo['eva_total_value']);
$data['gross_value'] = number_format($priceInfo['eva_total_value']);
$data['net_worth'] = number_format($priceInfo['eva_net_value']);
$data['net_worth_tow'] = number_format($priceInfo['eva_net_value2']);
$data['area'] = $surveyInfo['area'];
$data['estate_name'] = $inquiryDetailInfo['building_name'];
$data['obligee_percent'] = $reportDetailInfo['obligee_percent'];//权利人
// 估价结果明细表
$data['full_estate_name'] = $inquiryDetailInfo['property_full_name'];
$data['obligee'] = $reportDetailInfo['obligee'];
$data['usage_str'] = getDictionaryName('HOUSE_USAGE', $inquiryDetailInfo['usage']);
$data['size'] = $inquiryDetailInfo['size'];
$data['eva_purpose'] = $inquiryInfo['eva_purpose'];
$data['is_over2year_name'] = ($inquiryDetailInfo['is_tran_tax_free'] == 1) ? "" : "";
$data['tenure_type_name'] = ($inquiryDetailInfo['ownership_type'] == 1) ? "个人" : (($inquiryDetailInfo['ownership_type'] == 2) ? "企业" : "");
$data['usage_name'] = Db::name("dictionary")->where(["type" => "HOUSE_USAGE", "code" => $inquiryDetailInfo['usage']])->value("valname");
$data['market_price'] = ($priceInfo['market_price'] > 0) ? number_format($priceInfo['market_price'], 0) : 0;
$data['guide_price'] = ($priceInfo['guide_price'] > 0) ? number_format($priceInfo['guide_price'], 0) : 0;
$data['assessment_price'] = ($priceInfo['eva_unit_price'] > 0) ? number_format($priceInfo['eva_unit_price'], 0) : 0;
// 添加错误处理,确保数值计算安全
$guide_price = is_numeric($priceInfo['guide_price']) ? $priceInfo['guide_price'] : 0;
$size = is_numeric($inquiryDetailInfo['size']) ? $inquiryDetailInfo['size'] : 0;
$data['total_guide_assessment_price'] = $guide_price ? number_format($guide_price * $size) : 0;
// 添加错误处理,确保数值计算安全
$guide_price = is_numeric($priceInfo['guide_price']) ? $priceInfo['guide_price'] : 0;
$size = is_numeric($inquiryDetailInfo['size']) ? $inquiryDetailInfo['size'] : 0;
$total_guide_tax = is_numeric($priceInfo['total_guide_tax']) ? $priceInfo['total_guide_tax'] : 0;
$data['total_guide_assessment_net_worth'] = number_format($guide_price * $size - $total_guide_tax);
$data['assessment_all_value'] = ($priceInfo['eva_total_value'] > 0) ? number_format($priceInfo['eva_total_value'], 0) : 0;
$data['assessment_net_worth'] = ($priceInfo['eva_net_value'] > 0) ? number_format($priceInfo['eva_net_value'], 0) : 0;
$data['assessment_net_worth_tow'] = ($priceInfo['eva_net_value2'] > 0) ? number_format($priceInfo['eva_net_value2'], 0) : 0;
$data['sales_tax'] = ($priceInfo['corporate_income_tax'] > 0) ? number_format($priceInfo['corporate_income_tax'], 0) : 0;
$data['service_charge'] = ($priceInfo['tran_service_fee'] > 0) ? number_format($priceInfo['tran_service_fee'], 0) : 0;
$data['education_surcharges'] = ($priceInfo['edu_surcharge'] > 0) ? number_format($priceInfo['edu_surcharge'], 0) : 0;
$data['urban_construction_tax'] = ($priceInfo['urban_construction_tax'] > 0) ? number_format($priceInfo['urban_construction_tax'], 0) : 0;
$data['deed_tax'] = ($priceInfo['deed_tax'] > 0) ? number_format($priceInfo['deed_tax'], 0) : 0;
$data['stamp_duty'] = ($priceInfo['stamp_duty'] > 0) ? number_format($priceInfo['stamp_duty'], 0) : 0;
$data['added_tax'] = ($priceInfo['added_tax'] > 0) ? number_format($priceInfo['added_tax'], 0) : 0;
$data['land_value_added_tax'] = ($priceInfo['land_value_added_tax'] > 0) ? number_format($priceInfo['land_value_added_tax'], 0) : 0;
$data['individual_income_tax'] = ($priceInfo['personal_income_tax'] > 0) ? number_format($priceInfo['personal_income_tax'], 0) : 0;
$data['individual_income_tax_copy'] = ($priceInfo['personal_income_tax_copy'] > 0) ? number_format($priceInfo['personal_income_tax_copy'], 0) : 0;
$data['auction_fee'] = ($priceInfo['auction_fee'] > 0) ? number_format($priceInfo['auction_fee'], 0) : 0;
$data['total_tax1'] = ($priceInfo['total_taxes1'] > 0) ? number_format($priceInfo['total_taxes1'], 0) : 0;
$data['total_tax2'] = ($priceInfo['total_taxes2'] > 0) ? number_format($priceInfo['total_taxes2'], 0) : 0;
$data['total_guide_tax'] = ($priceInfo['total_guide_tax'] > 0) ? number_format($priceInfo['total_guide_tax'], 0) : 0;
$data['total_tax_ceb'] = $data['total_tax1'];
$data['register_price'] = $inquiryDetailInfo['reg_price'];
// 添加错误处理,确保数值计算安全
$eva_total_value = is_numeric($priceInfo['eva_total_value']) ? $priceInfo['eva_total_value'] : 0;
$data['rapid_roi_citic'] = $inquiryInfo['type'] == 1 ? $eva_total_value * 0.7 : $eva_total_value * 0.5;
// 添加错误处理,确保数值计算安全
$corporate_income_tax = is_numeric($priceInfo['corporate_income_tax']) ? $priceInfo['corporate_income_tax'] : 0;
$tran_service_fee = is_numeric($priceInfo['tran_service_fee']) ? $priceInfo['tran_service_fee'] : 0;
$edu_surcharge = is_numeric($priceInfo['edu_surcharge']) ? $priceInfo['edu_surcharge'] : 0;
$urban_construction_tax = is_numeric($priceInfo['urban_construction_tax']) ? $priceInfo['urban_construction_tax'] : 0;
$deed_tax = is_numeric($priceInfo['deed_tax']) ? $priceInfo['deed_tax'] : 0;
$stamp_duty = is_numeric($priceInfo['stamp_duty']) ? $priceInfo['stamp_duty'] : 0;
$added_tax = is_numeric($priceInfo['added_tax']) ? $priceInfo['added_tax'] : 0;
$land_value_added_tax = is_numeric($priceInfo['land_value_added_tax']) ? $priceInfo['land_value_added_tax'] : 0;
$personal_income_tax = is_numeric($priceInfo['personal_income_tax']) ? $priceInfo['personal_income_tax'] : 0;
$auction_fee = is_numeric($priceInfo['auction_fee']) ? $priceInfo['auction_fee'] : 0;
$data['total_tax'] = $corporate_income_tax + $tran_service_fee + $edu_surcharge + $urban_construction_tax +
$deed_tax + $stamp_duty + $added_tax + $land_value_added_tax + $personal_income_tax +
$auction_fee;
// 添加错误处理,确保数值计算安全
$education_surcharges = is_numeric($data['education_surcharges']) ? $data['education_surcharges'] : 0;
$urban_construction_tax = is_numeric($data['urban_construction_tax']) ? $data['urban_construction_tax'] : 0;
$data['urban_construction_education'] = $education_surcharges + $urban_construction_tax;
//中行净值扣除法定优先受偿款
// 添加错误处理,确保数值计算安全
$eva_total_value = is_numeric($inquiryDetailInfo['eva_total_value']) ? $inquiryDetailInfo['eva_total_value'] : 0;
$statutory_payment = is_numeric($inquiryDetailInfo['statutory_payment']) ? $inquiryDetailInfo['statutory_payment'] : 0;
$data['boc_net'] = $eva_total_value - $statutory_payment;
$appraiserDataTow[] = $data;
//估 价 结 果 明 细 表合计
$totalAppraiserDataTwo['full_estate_name'] = '合计';
$totalAppraiserDataTwo['deed_number'] = '——';
$totalAppraiserDataTwo['usage_str'] = '——';
$totalAppraiserDataTwo['size'] = !empty($totalAppraiserData['size']) ? $totalAppraiserData['size'] + $inquiryDetailInfo['size'] : $inquiryDetailInfo['size'];
$totalAppraiserDataTwo['assessment_price'] = '——';
$totalAppraiserDataTwo['assessment_all_value'] = !empty($totalAppraiserData['eva_total_value']) ? $totalAppraiserData['eva_total_value']+ $priceInfo['eva_total_value'] : $priceInfo['eva_total_value'];
$totalAppraiserDataTwo['gross_value'] = !empty($totalAppraiserData['gross_value']) ? $totalAppraiserData['gross_value'] + $priceInfo['eva_total_value'] : $priceInfo['eva_total_value'];
$totalAppraiserDataTwo['net_worth'] = !empty($totalAppraiserData['net_worth']) ? $totalAppraiserData['net_worth'] + $priceInfo['eva_net_value'] : $priceInfo['eva_net_value'];
$totalAppraiserDataTwo['net_worth_tow'] = !empty($totalAppraiserData['net_worth_tow']) ? $totalAppraiserData['net_worth_tow'] + $priceInfo['eva_net_value2'] : $priceInfo['eva_net_value2'];
$totalAppraiserDataTwo['area'] = '——';
$totalAppraiserDataTwo['estate_name'] = '——';
$totalAppraiserDataTwo['obligee_percent'] = '——';
$info['appraiserDataTwo'] = array_merge($appraiserDataTow, [$totalAppraiserDataTwo]);
//第十三页
$info['land_use_year'] = !empty($reportDetailInfo['max_land_use_years']) ? $reportDetailInfo['max_land_use_years'].'年' : '不动产权证上未记载';//土地使用年限
$info['land_use_year_cn'] = $max_land_use_years;
//$info['buy_date'] = date('Y年m月d日',strtotime($inquiryDetailInfo['purchase_date']));//登记/购买日期
//$info['buy_date'] = date('Y年m月d日',strtotime($reportDetailInfo['purchase_date']));//购买日期
$info['buy_date'] = $purchase_date;
$info['postscript_remarks'] = $reportDetailInfo['cert_remark'];//附记备注
$info['register_time'] = date('Y年m月d日',strtotime($reportDetailInfo['reg_date']));//登记日期
$info['completion_date'] = $completion_date;//竣工日期
$info['completion_date_cn'] = $completion_date;//竣工日期
$info['use_source'] = $reportDetailInfo['use_right_source'];//使用权来源
$info['louceng'] = $reportDetailInfo['floor_no'];//楼层
$info['towards'] = Survey::getDictionaryName1('residence_towards',$surveyDetailInfo['towards']);//朝向
$info['parking_garage_status'] = Survey::getDictionaryName1('residence_parking_garage_status',$surveyDetailInfo['parking_lot_usage']);//使用现状
$info['floor_number'] = $surveyDetailInfo['floor_no'];//评估楼层
$info['size'] = $inquiryDetailInfo['size'];//
$info['house_type'] = $this->getHouseStatus($surveyDetailInfo['unit_type']);//户型
$info['is_old_chang_desc'] = $this->__getIsOldChangeDesc($reportDetailInfo['is_renovation']);//是否被政府批准列入棚改或旧改 1否2是
$info['address'] = $surveyDetailInfo['address'];//物业地址
$info['house_status'] = getDictionaryName('HOUSE_status', $reportDetailInfo['house_condition']);//房屋状况
$info['rapid_realization_value_rate'] = ($inquiryInfo['type']==1)?'70':'60';
$info['area'] = $surveyInfo['area'];
//$returnDateInfo = Db::name('users')->field('user_name')->where('user_id', $surveyInfo['assignee_id'])->find();
//$info['suvery_assigner_name'] = $returnDateInfo['user_name'];//查勘人姓名
$info['suvery_assigner_name'] = preg_replace("/\(.*\)/u", "", $surveyInfo['user_name']);//查勘人姓名
//判断商业或住宅
if ($surveyInfo['survey_type'] == 1) {
//外墙
$exterior_wall = Survey::getOptionField($surveyDetailInfo, ['exterior_view'],$options['residence']['residence_outdoor_scene']);
$info['outside_wall'] = !empty($exterior_wall['value'][0]) ? implode('、', $exterior_wall['value']) : '——';
$living_room = $this->getFacilityName(Survey::getOptionField1($surveyDetailInfo, ['living_room', 'living_room_img_ids'],$options['residence']));
//内墙
$info['inside_wall'] = !empty($living_room['interior_wall']) ? $living_room['interior_wall'] : '——';
//天花板
$info['ceiling'] = !empty($living_room['ceiling']) ? $living_room['ceiling'] : '——';
//地面
$info['ground'] = !empty($living_room['ground']) ? $living_room['ground'] : '——';
//门窗
$door_window = Survey::getOptionField($surveyDetailInfo, ['doorplate'],$options['residence']['residence_doorplate']);
$info['door_window'] = !empty($door_window['value'][0]) ? implode('、', $door_window['value']) : '——';
//厨房
$kitchen = Survey::getOptionField1($surveyDetailInfo, ['kitchen'], $options['residence']);
$flag=0;
if (!empty($kitchen['value'])) {
foreach ($kitchen['value'] as $kk => $kv) {
if(!empty($kv['value'])){
$flag=1;
}
}
}
$kitchen = $this->getAllName($kitchen);
$info['kitchen'] = !empty($flag) ? implode('', $kitchen) : '——';
//卫生间
$bathroom = Survey::getOptionField1($surveyDetailInfo, ['bathroom'], $options['residence']);
$bathroomValue = $this->getAllName($bathroom);
$info['bathroom'] = !empty($bathroomValue) ? implode('', $bathroomValue) : '——';
//空调
$facility = $this->getFacilityName(Survey::getOptionField1($surveyDetailInfo, ['facility'], $options['residence']));
$info['conditioner'] = !empty($facility['conditioner']) ? $facility['conditioner'] : '——';
//水电
$info['hydropower'] = !empty($facility['hydropower']) ? $facility['hydropower'] : '——';
//通讯
$info['communication'] = !empty($facility['communication']) ? $facility['communication'] : '——';
//电梯
$info['lift'] = !empty($surveyDetailInfo['elevator']) ? $surveyDetailInfo['elevator'] : '——';
// $info['remark'] = !empty($surveyDetailInfo['remarks']) ? $surveyDetailInfo['remarks'] : '——';//备注
// if ($inquiryInfo['bank_name'] == '中国光大银行') {
// $info['remark'] = $surveyDetailInfo['remarks'];
// } else {
// $info['remark'] = !empty($surveyDetailInfo['remarks']) ? $surveyDetailInfo['remarks'] : '——';;
// }
$info['remark'] = $surveyDetailInfo['remarks'];
$info['special_remarks'] = !empty($surveyDetailInfo['special_remarks']) ? $surveyDetailInfo['special_remarks'] : '0';//特殊户型备注
} else {
//外墙
$exterior_wall = Survey::getOptionField($surveyDetailInfo, ['exterior_wall'], $options['shop']['shop_outdoor_scene']);
$info['outside_wall'] = !empty($exterior_wall['value'][0]) ? implode('、', $exterior_wall['value']) : '——';
//内墙
$interior_wall = Survey::getOptionField($surveyDetailInfo, ['interior_wall'], $options['shop']['shop_parlour']);
$info['inside_wall'] = !empty($interior_wall['value'][0]) ? implode('、', $interior_wall['value']) : '——';
//天花板
$ceiling = Survey::getOptionField($surveyDetailInfo, ['ceiling'], $options['shop']['shop_balcony']);
$info['ceiling'] = !empty($ceiling['value'][0]) ? implode('、', $ceiling['value']) : '——';
//地面
$ground = Survey::getOptionField($surveyDetailInfo, ['ground'], $options['shop']['shop_kitchen']);
$info['ground'] = !empty($ground['value'][0]) ? implode('、', $ground['value']) : '——';
//门窗
$door_window = Survey::getOptionField($surveyDetailInfo, ['door_window'], $options['shop']['shop_door_window']);
$info['door_window'] = !empty($door_window['value'][0]) ? implode('、', $door_window['value']) : '——';
//厨房
$kitchen = Survey::getOptionField1($surveyDetailInfo, ['kitchen'], $options['shop']['shop_kitchen2']);
$flag=0;
if (!empty($kitchen['value'])) {
foreach ($kitchen['value'] as $kk => $kv) {
if(!empty($kv['value'])){
$flag=1;
}
}
}
$kitchen = $this->getAllName($kitchen);
$info['kitchen'] = !empty($flag) ? implode('', $kitchen) : '——';
// 商铺状况
$survey=new Survey();
$shopstatus=$survey->getShopStatus($surveyDetailInfo, ['shop_condition'],$options['shop']['shop_situation']);
$info['shop_situation'] = '';
foreach ($shopstatus as $key => $statusvalue) {
if($statusvalue['name']=='商铺形状'){
$info['shop_situation']=$statusvalue['value'];
}
}
//卫生间
$bathroom = Survey::getOptionField1($surveyDetailInfo, ['bathroom'], $options['shop']['shop_toilet']);
$bathroomValue = $this->getAllName($bathroom);
$info['bathroom'] = !empty($bathroomValue) ? implode('', $bathroomValue) : '——';
//空调
$facility = $this->getFacilityName($survey->getFacility($surveyDetailInfo, ['facility'], $options['shop']['shop_facilities']));
$info['conditioner'] = !empty($facility['conditioner']) ? $facility['conditioner'] : '——';
//水电
$info['hydropower'] = !empty($facility['hydropower']) ? $facility['hydropower'] : '——';
//通讯
$info['communication'] = !empty($facility['communication']) ? $facility['communication'] : '——';
//电梯
$info['lift'] = !empty($facility['lift']) ? $this->getLift($facility['lift']) : '无';
//备注(商业,单套 取报告委托说明)
// $info['remark'] = $reportInfo['commission_note'] ?: '——';
if ($inquiryInfo['bank_name'] == '中国光大银行') {
$info['remark'] = $reportInfo['commission_note'];
} else {
$info['remark'] = $reportInfo['commission_note'] ?: '——';
}
}
//其他
$other = Survey::getOptionField1($surveyDetailInfo, ['other'], $options['residence']);
$other = $this->getFacilityName($other);
$info['other'] = !empty($other) ? implode('、', $other) : '——';
//取报告详情
$info['nearby_estate'] = str_replace(' ', '', $reportDetailInfo['adjacent_property']);//毗邻物业
$info['bus_route'] = str_replace(' ', '', $reportDetailInfo['bus_lines']);//公交线路
$info['environment_landscape'] = str_replace(' ', '', $surveyDetailInfo['scenery']);//环境和景观
$info['estate_introduction'] = str_replace(' ', '', $reportDetailInfo['property_intro']);//物业介绍
//四至
//$directional = $this->getDirectional($surveyDetailInfo['boundaries']);
$info['directional_position'] = str_replace(' ', '', $reportDetailInfo['boundaries']);
//$info['directional_position2'] = $directional;
//公共服务设施
//$info['public_facility'] = $this->getPublicFacility(json_decode($surveyDetailInfo['pub_serv'], true));
$info['public_facility'] = str_replace(' ', '', $reportDetailInfo['pub_serv']);
$info['register_price_m'] = $inquiryDetailInfo['reg_price'];
$info['register_price'] = number_format($inquiryDetailInfo['reg_price'], 2);//登记价
$info['floor_total'] = $surveyDetailInfo['total_floors'];//总楼层
$usage_condition = Survey::getArrayField($surveyDetailInfo, ['usage_condition'],$options['shop']['shop_usage_status']);
$info['usage_status']=!empty($usage_condition['shop_usage_status']) ? $usage_condition['shop_usage_status'] : '——';
//第十四页
//物业概述
$estateInfo=[];
if(!empty($reportDetailInfo['risk_remark'])){
$estateInfo[] = $reportDetailInfo['risk_remark'];
}
$info['estateInfo'] = $estateInfo;//物业概况
//市场背景
$market = Db::name('market_background')->where('status', 1)->whereIn('type', $reportInfo['market_background'])->group('type')->order('id', 'desc')->select();
foreach ($market as $mKey => $mValue) {
$market[$mKey]['num'] = numToWordone($mKey + 1);
}
$info['backgroundData'] = $market;
$info['backgroundData_type'] = $market[0]['type'];
//估价对象基本状况一览表(商铺)
$data7 = [];
$data7['estate_name'] = $inquiryDetailInfo['property_full_name'];
$data7['property_addr'] = $reportDetailInfo['land_location'];
$data7['deed_number'] = $property_cert;
$data7['obligee'] = $reportDetailInfo['obligee'];
$data7['register_price'] = number_format($inquiryDetailInfo['reg_price'], 2);
$data7['zdbh'] = $reportDetailInfo['parcel_no'];
// $data7['zd_area'] = number_format($reportDetailInfo['parcel_area'],2);
$data7['zd_area'] = is_numeric($reportDetailInfo['parcel_area']) ? number_format($reportDetailInfo['parcel_area'],2) : $reportDetailInfo['parcel_area'];//宗地面积
$data7['land_use'] = $reportDetailInfo['parcel_usage'];
$data7['directional_position'] = $reportDetailInfo['boundaries'];
$data7['shop_situation'] = '规则多边形';//$survey->getShopStatus($surveyDetailInfo, ['shop_condition'], $options['shop']['shop_situation']);
$data7['land_use_year'] = $max_land_use_years;
$data7['condition'] = '已按规划建成,并已发证';
$data7['develop'] = '五通一平,地上建有建筑物';
$subjectProperty[] = $data7;
$info['subjectProperty'] = $subjectProperty;
$data10 = [];
$data10['full_estate_name'] = $inquiryDetailInfo['property_full_name'];//项目名称
$data10['usage_str'] = $usage_name;//房屋用途
$assessResult[] = $data10;
$info['assessResult'] = $assessResult;
//第十五页
if (!empty($simpleInfo)) {
foreach ($simpleInfo as &$svalue) {
// $svalue['size'] = intval($svalue['size']);
$svalue['size'] = $svalue['size'];
$svalue['price'] = number_format(intval($svalue['price']));
}
}
$info['simpleData'] = $simpleInfo;
if(!empty($formalInfo)){
foreach ($formalInfo as &$formalC) {
$formalC=json_decode($formalC,true);
}
}
$info['formalData'] = $formalInfo;//测算方法-比较法
$formalInfoGz = Db::name('method_formal_gz')
->where('property_cert_info_id', $inquiryDetailInfo['id'])
->order('id', 'asc')
->find();
if(!empty($formalInfoGz)){
foreach ($formalInfoGz as &$formalG) {
$formalG=json_decode($formalG,true);
}
}
$info['formalDataGz'] = $formalInfoGz;//测算方法-GZ比较法
// 估价测算过程备注估价对象周边案例参考成交价格
$info['guide_price'] = $priceInfo['guide_price'];
$guide_case_data = Db::name('guide_case')->where(['property_cert_info_id'=>$inquiryDetailInfo['id']])->select();
$info['guide_case_data'] = $guide_case_data;
//第十六页
//收益法
$profitData = [];
// $data9 = MethodProfit::where('property_cert_info_id', $inquiryDetailInfo['id'])->find();
$contract_rent = 0;
if ($data9) {
$market_research = $data9['market_research'];
$list = [];
foreach ($market_research as $key => $v) {
$list = [];
if (!empty($v['house_imgs'])) {
//获取图片信息
$list = $attachmnet->getUrl($v['house_imgs']);
}
if (!empty($v['islimit'])) {
$contract_rent = $v['islimit'];
}
$market_research[$key]['house_imgs_url'] = !empty($list) ? $list['url'] : '';
}
$data9['market_research'] = $market_research;
$data9['estate_name'] = $inquiryDetailInfo['property_full_name'];
$data9['size'] = $surveyDetailInfo['size'];
$data9['land_use_year'] = $max_land_use_years;
$data9['num'] = '一';
$data9['isNewCert'] = !empty($inquiryDetailInfo['year'] );// 是否新证。此项为空为老证,反之是新不动产证。
$data9['new_rate_cn'] = Survey::getDictionaryName1('residence_new_rate', $surveyDetailInfo['newness_rate']);//成新率
$data9['deed_number'] = $property_cert;
$data9['test_func'] = $reDetail['test_method'];
$data9['contract_rent'] = $contract_rent;
$profitData[] = $data9;
}
$gyprofitData = [];
$data11 = Db::name('method_gyprofit')->where('property_cert_info_id='.$inquiryDetailInfo['id'])->find();
if ($data11) {
$market_research = $data9['market_research'];
$list = [];
foreach ($market_research as $key => $v) {
$list = [];
if (!empty($v['house_imgs'])) {
//获取图片信息
$list = $attachmnet->getUrl($v['house_imgs']);
}
if (!empty($v['islimit'])) {
$contract_rent = $v['islimit'];
}
$market_research[$key]['house_imgs_url'] = !empty($list) ? $list['url'] : '';
}
$data11['market_research'] = $market_research;
$data11['appraisal_object'] = $data9['appraisal_object'];
$data11['estate_name'] = $inquiryDetailInfo['property_full_name'];
$data11['size'] = $surveyDetailInfo['size'];
$data11['test_func'] = $reDetail['test_method'];
$data11['contract_rent'] = $contract_rent;
$gyprofitData[] = $data11;
}
$info['profitData'] = $profitData;
$info['gyprofitData'] = $gyprofitData;
$current_date = $reportInfo['create_time'];
$info['one_year'] = date('Y年', strtotime("$current_date -1 year")) . '平均月租金(元/平方米/月)';
$info['two_year'] = date('Y年', strtotime("$current_date -2 year")) . '平均月租金(元/平方米/月)';
$info['three_year'] = date('Y年', strtotime("$current_date -3 year")) . '平均月租金(元/平方米/月)';
//第十七页
//回价信息 税费
$info['p_item_name'] = $inquiryDetailInfo['property_full_name'];//
$info['p_size'] = $priceInfo['area'];//
$info['p_assessment_price'] = number_format(intval($priceInfo['eva_unit_price']));//
$info['p_assessment_price_str'] = convertAmountToCn($priceInfo['eva_unit_price']);
$info['p_assessment_all_value'] = number_format(intval($priceInfo['eva_total_value']));//
$info['p_added_tax'] = number_format(intval($priceInfo['added_tax']));//增值税
$info['p_urban_construction_tax'] = number_format(intval($priceInfo['urban_construction_tax']));//城市维护建设税
$info['p_education_surcharges'] = number_format(intval($priceInfo['edu_surcharge']));//教育费附加
$education_surcharges_s = round($priceInfo['edu_surcharge']*0.6);
$education_surcharges_df = $priceInfo['edu_surcharge']-$education_surcharges_s;
$info['p_education_surcharges_s'] = number_format(intval($education_surcharges_s));
$info['p_education_surcharges_df'] = number_format(intval($education_surcharges_df));
$info['p_stamp_duty'] = number_format(intval($priceInfo['stamp_duty']));//印花税
$info['p_auction_fee'] = number_format(intval($priceInfo['auction_fee']));//拍卖费
$info['p_land_value_added_tax'] = number_format(intval($priceInfo['land_value_added_tax']));//土地增值税
$info['p_land_value_added_tax_copy'] = number_format(intval($priceInfo['land_value_added_tax_copy']));//土地增值税
$info['p_individual_income_tax'] = number_format(intval($priceInfo['personal_income_tax']));//个人所得税
$info['p_individual_income_tax_copy'] = number_format(intval($priceInfo['personal_income_tax_copy']));//个人所得税
$info['p_deed_tax'] = number_format(intval($priceInfo['deed_tax']));//契税
$ms_total_tax = intval($priceInfo['added_tax'])+intval($priceInfo['urban_construction_tax'])+intval($priceInfo['edu_surcharge'])+intval($priceInfo['personal_income_tax_copy'])+intval($priceInfo['total_taxes1']); // 民生银行二手税费备注说明
$info['ms_total_tax'] = number_format($ms_total_tax); // 民生银行二手税费备注说明
$ms_total_net = intval($priceInfo['eva_total_value'])-$ms_total_tax;
$info['ms_total_net'] = number_format($ms_total_net); // 民生银行二手税费备注说明
$ms_dy_total_tax = intval($priceInfo['personal_income_tax_copy'])+intval($priceInfo['total_taxes1']); // 民生银行抵押税费备注说明
$info['ms_dy_total_tax'] = number_format($ms_dy_total_tax); // 民生银行抵押税费备注说明
$ms_dy_total_net = intval($priceInfo['eva_total_value'])-$ms_dy_total_tax;
$info['ms_dy_total_net'] = number_format($ms_dy_total_net); // 民生银行抵押税费备注说明
$info['gd_total_tax'] = number_format(intval($priceInfo['total_taxes1']+$priceInfo['personal_income_tax_copy']+$priceInfo['added_tax'])); // 光大银行住宅税费备注说明
$info['gd_total_net'] = number_format(intval($priceInfo['eva_total_value']-$priceInfo['total_taxes1']-$priceInfo['personal_income_tax_copy']-$priceInfo['added_tax'])); // 光大银行住宅税费备注说明
$info['bank_name'] = $inquiryInfo['bank_name'];
$info['evaluate_purpose'] = $inquiryInfo['eva_purpose'];
//工商二手 5+6+7+8+9+10+11+12 特殊处理
$total_taxes1 = 0;
if ($inquiryInfo['bank_name'] == '中国工商银行' && $inquiryInfo['eva_purpose'] == '二手房按揭贷款') {
if ($inquiryInfo['type'] == 2) {
$info['p_added_tax'] = 0;
$total_taxes1 = intval($priceInfo['deed_tax']);
} else {
$total_taxes1 = intval($priceInfo['added_tax']) + intval($priceInfo['urban_construction_tax']) + intval($priceInfo['edu_surcharge']) + intval($priceInfo['stamp_duty']) + intval($priceInfo['land_value_added_tax']) + intval($priceInfo['personal_income_tax']) + intval($priceInfo['tran_service_fee']) + intval($priceInfo['deed_tax']);
}
} else {
$total_taxes1 = $priceInfo['total_taxes1'];
}
$info['p_total_tax1'] = number_format(intval($total_taxes1));//税费合计1
$info['p_total_tax1_cn'] = convertAmountToCn($total_taxes1);
//建行二手 5+6+7+8+9+10 特殊处理
$total_taxes2 = 0;
if ($inquiryInfo['bank_name'] == '中国建设银行' && ($inquiryInfo['eva_purpose'] == '二手房按揭贷款' || $inquiryInfo['eva_purpose'] == '二手房按揭贷款(旧政策)')) {
$total_taxes2 = intval($priceInfo['added_tax']) + intval($priceInfo['urban_construction_tax']) + intval($priceInfo['edu_surcharge']) + intval($priceInfo['stamp_duty']) + intval($priceInfo['land_value_added_tax']) + intval($priceInfo['personal_income_tax']);
} else {
$total_taxes2 = $priceInfo['total_taxes2'];
}
$info['p_total_tax2'] = number_format(intval($total_taxes2));//税费合计2
$info['p_total_tax2_cn'] = convertAmountToCn($total_taxes2);
$info['p_service_charge'] = number_format(intval($priceInfo['tran_service_fee']));//交易服务费
$info['p_estate_name'] = $priceInfo['property_name'];//物业名称
$info['p_register_price'] = number_format($inquiryDetailInfo['reg_price'], 2);//登记价
//第十八页
//物业位置图
$loc_img_ids = [];
if (!empty($surveyDetailInfo['loc_img_ids'])) {
$locationIds = explode(',', $surveyDetailInfo['loc_img_ids']);
$loc_img_ids = $attachmnet->getUrls($locationIds);
}
$info['location_imgs'] = $loc_img_ids;
//第十九页
//查勘图库
$appraisal_img_ids = [];
if (!empty($surveyDetailInfo['appraisal_img_ids'])) {
$allIds = explode(',', $surveyDetailInfo['appraisal_img_ids']);
// if (count($allIds) >= 12) {//大于等于12时取12张图片
// $allIds = array_slice($allIds, 0, 12);
// } elseif (count($allIds) >= 8 && count($allIds) < 12) {//大于等于8且小于12时取8张图片
// $allIds = array_slice($allIds, 0, 8);
// } else {//否则取6张图片
// $allIds = array_slice($allIds, 0, 6);
// }
$appraisal_img_ids = $attachmnet->getUrls(array_filter($allIds));
}
$info['survey_gallery_imgs'] = $appraisal_img_ids;
//第二十页
//房产证照
$house_cert_img_ids = [];
if (!empty($reportDetailInfo['house_cert_img_ids'])) {
$houseIds = explode(',', $reportDetailInfo['house_cert_img_ids']);
$house_cert_img_ids = $attachmnet->getUrls($houseIds);
}
$info['house_img'] = $house_cert_img_ids;
//公司资质
$company_img = [
// array('url' => 'https://test-cspg.oss-cn-shenzhen.aliyuncs.com/uploads/20200902/d77a31b4e8cbee20c4b310df77cf125c.png'), // 营业执照
// array('url' => Env::get('uploadFile.host_url') . DS . 'image' . DS .'business_license2.jpg'), // 变更(备案)通知书
array('url' => Env::get('uploadFile.host_url') . DS . 'image' . DS .'business_license1.jpg'), // 营业执照
// 2022-06-28
// array('url' => 'https://test-cspg.oss-cn-shenzhen.aliyuncs.com/uploads/20200902/change_notification.jpeg'), // 变更(备案)通知书 2022-06-28
//array('url' => 'https://test-cspg.oss-cn-shenzhen.aliyuncs.com/uploads/company2.png')
array('url' => Env::get('uploadFile.host_url') . DS . 'image' . DS .'business_license3.jpg')
];
$info['company_img'] = $company_img;
//估价师证件
$valuer_img = [];
if (!empty($valuerimg)) {
$valuer_img = $attachmnet->getUrls($valuerimg);
}
$info['valuer_img'] = $valuer_img;
$reportDetailData = ReportDetail::where('property_cert_info_id', $inquiryDetailInfo['id'])->find();
//估价对象实物状况描述与分析
$data5 = [];
// $data5['name'] = '表' . numToWordone($key + 1);
$data5['estate_name'] = $inquiryDetailInfo['property_full_name'];//估价对象
$data5['zdbh'] = $reportDetailData['parcel_no'];//
// $data5['zd_area'] = number_format($reportDetailData['parcel_area'],2);//
$data5['zd_area'] = is_numeric($reportDetailData['parcel_area']) ? number_format($reportDetailData['parcel_area'],2) : $reportDetailData['parcel_area'];//宗地面积
$data5['land_use'] = $reportDetailData['parcel_usage'];//
$data5['shop_situation'] = '';//商铺状态
$data5['land_location'] = $reportDetailData['land_location'];//估价对象位置
$data5['house_str'] = $this->getHouseStatus($surveyDetailInfo['unit_type']);//户型
$data5['outdoor_scene'] = $surveyDetailInfo['exterior_view'];//外观
$data5['floor_total'] = $surveyDetailInfo['total_floors'];//总楼层
$data5['floor_number'] = $surveyDetailInfo['floor_no'];//估价对象楼层
$data5['use_source'] = Survey::getDictionaryName1('residence_parking_garage_status',$surveyDetailInfo['parking_lot_usage']);//现状使用状况
$data5['towards'] = Survey::getDictionaryName1('residence_towards',$surveyDetailInfo['towards']) ?: '——';//朝向
$data5['decoration'] = Survey::getDictionaryName1('residence_decoration_grade',$surveyDetailInfo['decoration']) ?: '——';//装修档次
$data5['size'] = $inquiryDetailInfo['size'];//
$data5['usage_str'] = getDictionaryName('HOUSE_USAGE', $inquiryDetailInfo['usage']);//
$data5['structure'] = $structure ?: '——';//结构
$data5['completion_date'] = $completion_date;
$data5['directional_position'] = $reportDetailData['boundaries'];//四至
$data5['new_rate'] = $surveyDetailInfo['newness_rate'];//成新率
$info['bedroom_desc_str'] = '--';
//判断商业或住宅
if ($surveyInfo['survey_type'] == 1) {
//外墙
$exterior_wall = Survey::getOptionField($surveyDetailInfo, ['exterior_view'],$options['residence']['residence_outdoor_scene']);
$data5['outside_wall'] = !empty($exterior_wall['value'][0]) ? implode('、', $exterior_wall['value']) : '——';
$living_room = $this->getFacilityName(Survey::getOptionField1($surveyDetailInfo, ['living_room', 'living_room_img_ids'],$options['residence']));
//内墙
$data5['inside_wall'] = !empty($living_room['interior_wall']) ? $living_room['interior_wall'] : '——';
//天花板
$data5['ceiling'] = !empty($living_room['ceiling']) ? $living_room['ceiling'] : '——';
//地面
$data5['ground'] = !empty($living_room['ground']) ? $living_room['ground'] : '——';
//门窗
$door_window = Survey::getOptionField($surveyDetailInfo, ['doorplate'],$options['residence']['residence_doorplate']);
$data5['door_window'] = !empty($door_window['value'][0]) ? implode('、', $door_window['value']) : '——';
//卫生间
$bathroom = Survey::getOptionField1($surveyDetailInfo, ['bathroom'], $options['residence']);
$bathroomValue = $this->getAllName($bathroom);
$data5['bathroom'] = !empty($bathroomValue) ? implode('', $bathroomValue) : '——';
//卧室
$bedroom = $this->getAllName(Survey::getOptionField1($surveyDetailInfo, ['bedroom'], $options['residence']));
$data5['bedroom_ceiling'] = !empty($bedroom['ceiling']) ? $bedroom['ceiling'] : '——';//天花板
$data5['bedroom_ground'] = !empty($bedroom['ground']) ? $bedroom['ground'] : '——';//地面
$data5['bedroom_inside_wall'] = !empty($bedroom['interior_wall']) ? $bedroom['interior_wall'] : '——';//内墙
$info['bedroom_desc_str'] = !empty($bedroom) ? implode('',$bedroom) : '——'; // 卧室的描述
//厨房
$kitchen = Survey::getOptionField1($surveyDetailInfo, ['kitchen'], $options['residence']);
$kitchen = $this->getAllName($kitchen);
$data5['kitchen'] = !empty($kitchen) ? implode('', $kitchen) : '——';
//空调
$facility = $this->getFacilityName(Survey::getOptionField1($surveyDetailInfo, ['facility'], $options['residence']));
$data5['conditioner'] = !empty($facility['conditioner']) ? $facility['conditioner'] : '——';
//水电
$data5['hydropower'] = !empty($facility['hydropower']) ? $facility['hydropower'] : '——';
//通讯
$data5['communication'] = !empty($facility['communication']) ? $facility['communication'] : '——';
//电梯
$data5['lift'] = !empty($surveyDetailInfo['elevator']) ? $surveyDetailInfo['elevator'] : '无';
// dump($surveyDetailInfo);
if(empty($facility['conditioner'])&&empty($facility['hydropower'])&&empty($facility['communication'])&&empty($surveyDetailInfo['elevator'])){
$data5['total']='——';
}else{
$temp='';
foreach ($facility as $key => $value) {
$temp.=$value.';';
}
$data5['total']=$temp;
}
//备注
$data5['remark'] = $surveyDetailInfo['remarks'] ?: '——';
} else {
//外墙
$exterior_wall = Survey::getOptionField($surveyDetailInfo, ['exterior_wall'], $options['shop']['shop_outdoor_scene']);
$data5['outside_wall'] = !empty($exterior_wall['value'][0]) ? implode('、', $exterior_wall['value']) : '——';
//内墙
$interior_wall = Survey::getOptionField($surveyDetailInfo, ['interior_wall'], $options['shop']['shop_parlour']);
$data5['inside_wall'] = !empty($interior_wall['value'][0]) ? implode('、', $interior_wall['value']) : '——';
//天花板
$ceiling = Survey::getOptionField($surveyDetailInfo, ['ceiling'], $options['shop']['shop_balcony']);
$data5['ceiling'] = !empty($ceiling['value'][0]) ? implode('、', $ceiling['value']) : '——';
//地面
$ground = Survey::getOptionField($surveyDetailInfo, ['ground'], $options['shop']['shop_kitchen']);
$data5['ground'] = !empty($ground['value'][0]) ? implode('、', $ground['value']) : '——';
//门窗
$door_window = Survey::getOptionField($surveyDetailInfo, ['door_window'], $options['shop']['shop_door_window']);
$data5['door_window'] = !empty($door_window['value'][0]) ? implode('、', $door_window['value']) : '——';
//卫生间
$bathroom = Survey::getOptionField1($surveyDetailInfo, ['bathroom'], $options['shop']['shop_toilet']);
$bathroomValue = $this->getAllName($bathroom);
$data5['bathroom'] = !empty($bathroomValue) ? implode('', $bathroomValue) : '——';
//卧室
$bedroom = !empty($surveyDetailInfo['bedroom']) && $surveyDetailInfo['bedroom'] != "[]" ? $this->getDataName(Survey::getOptionField1($surveyDetailInfo, ['bedroom'], $options['residence'])) : [];
$data5['bedroom_ceiling'] = !empty($bedroom['ceiling']) ? $bedroom['ceiling'] : '——';//天花板
$data5['bedroom_ground'] = !empty($bedroom['ground']) ? $bedroom['ground'] : '——';//地面
$data5['bedroom_inside_wall'] = !empty($bedroom['interior_wall']) ? $bedroom['interior_wall'] : '——';//内墙
//厨房
$kitchen = Survey::getOptionField1($surveyDetailInfo, ['kitchen'], $options['shop']['shop_kitchen2']);
$kitchen = $this->getAllName($kitchen);
$data5['kitchen'] = !empty($kitchen) ? implode('', $kitchen) : '——';
//空调
$facility = $this->getFacilityName($survey->getFacility($surveyDetailInfo, ['facility'], $options['shop']['shop_facilities']));
$data5['conditioner'] = !empty($facility['conditioner']) ? $facility['conditioner'] : '——';
//水电
$data5['hydropower'] = !empty($facility['hydropower']) ? $facility['hydropower'] : '——';
//通讯
$data5['communication'] = !empty($facility['communication']) ? $facility['communication'] : '——';
//电梯
$data5['lift'] = !empty($facility['lift']) ? $this->getLift($facility['lift']) : '无';
// dump($surveyDetailInfo);
if(empty($facility['conditioner'])&&empty($facility['hydropower'])&&empty($facility['communication'])&&empty($facility['lift'])){
$data5['total']='——';
}else{
$temp='';
foreach ($facility as $key => $value) {
if ($key != 'lift') {
$temp.=$value.';';
}
}
$data5['total']= empty($facility['lift']) ? $temp : $temp . $facility['lift'] . ';';
}
//备注(商业,单套 取报告委托说明)
$data5['remark'] = $reportInfo['commission_note'] ?: '——';
}
//客厅
$living_room = $this->getAllName(Survey::getOptionField1($surveyDetailInfo, ['living_room'], $options['residence']));
$data5['living_ceiling'] = !empty($living_room['ceiling']) ? $living_room['ceiling'] : '——';//天花板
$data5['living_ground'] = !empty($living_room['ground']) ? $living_room['ground'] : '——';//地面
$data5['living_inside_wall'] = !empty($living_room['interior_wall']) ? $living_room['interior_wall'] : '——';//内墙
$info['living_desc_str'] = !empty($living_room) ? implode('',$living_room) : '——'; //客厅的字符描述
//厨房
// $kitchen = Survey::getOptionField1($surveyDetailInfo, ['kitchen'], $options['residence']);
// $data5['kitchen'] = !empty($kitchen) ? implode('', $this->getAllName($kitchen)) : '——';
//其他
// $other = Survey::getOptionField($surveyDetailInfo, ['other'], $options['residence']);
// $data5['other'] = !empty($other) ? implode('、', $other['value']) : '——';
$other = Survey::getOptionField1($surveyDetailInfo, ['other'], $options['residence']);
$other = $this->getFacilityName($other);
$data5['other'] = !empty($other) ? implode('、', $other) : '——';
$materialData[] = $data5;
//估价对象区位状况描述与分析
$info['materialData'] = $materialData;
$info['survey_type'] = $surveyInfo['survey_type'];
$info['business_content'] = $surveyDetailInfo['business_content']; // 商业查勘备注(使用之前的经营内容字段)
// $land_use_enddate = new \DateTime($reportDetailData['land_use_end_time']);
// $max_land_use_years = empty($reportDetailData['max_land_use_years']) ? '不动产权证上未记载' : $reportDetailData['max_land_use_years'] . '年,从' .date('Y年m月d日', strtotime($reportDetailData['land_use_start_time'])) . '到' . $land_use_enddate->format('Y年m月d日') . '止';
// //权益状况描述与分析(商铺)
// $data8 = [];
// // $data8['name'] = numToWordone($key + 1);
// $data8['estate_name'] = $inquiryDetailInfo['property_full_name'];
// $data8['zdbh'] = $reportDetailData['parcel_no'];
// $data8['land_use'] = $reportDetailData['parcel_usage'];
// $data8['land_use_year'] = $max_land_use_years;
// $data8['deed_number'] = $property_cert;
// $data8['usage_str'] = getDictionaryName('HOUSE_USAGE', $inquiryDetailInfo['usage']);
// $data8['obligee'] = $reportDetailData['obligee'];
// $usage_condition = Survey::getArrayField($surveyDetailInfo, ['usage_condition'],$options['shop']['shop_usage_status']);
// $data8['shop_usage_status'] = !empty($usage_condition['shop_usage_status']) ? $usage_condition['shop_usage_status'] : '——';
// $equityData[] = $data8;
// $info['equityData'] = $equityData;
// 光大银行签收表
$info['ceb_branch_bank_name'] = $inquiryInfo['bank_sub_name'];
$info['ceb_product_type'] = !empty($reportInfo['ceb_product_type']) ? getDictionaryName('CEB_PRODUCT_TYPE', $reportInfo['ceb_product_type']) : ''; // 贷款品种
$info['ceb_estate_name'] = $inquiryDetailInfo['property_full_name']; // 评估物业名称(简称)
$info['ceb_obligee'] = $reportDetailInfo['obligee']; // 抵押人姓名
$info['tenure_type'] = $inquiryDetailInfo['ownership_type']; // 产权人类型
$info['test_func'] = $reportDetailInfo['test_method'];
if (strpos($reportDetailInfo['test_method'], ',') !== false) {
$info['test_func_str'] = '比较法、收益法';
} elseif ($reportDetailInfo['test_method'] == 2) {
$info['test_func_str'] = '收益法';
} else {
$info['test_func_str'] = '比较法';
}
// 变现能力分析
$info['universality_desc'] = $reportDetailInfo['gen_saleablility_desc'];
$info['indep_usability_desc'] = $reportDetailInfo['indp_use_desc'];
$info['divi_transferability_desc'] = $reportDetailInfo['seg_transfer_desc'];
$info['degree_develop_desc'] = $reportDetailInfo['dev_lv_desc'];
$info['parking_garage_type'] = $surveyDetailInfo['parking_lot_usage'];
if($inquiryInfo['bank_name'] == '中国银行'){
$estate_info_data = Db::name('estate_info')
// ->where(['full_estate_name', '=', $inquiryDetailInfo['property_full_name']])
->where('property_full_name', '=', $inquiryDetailInfo['property_full_name'])
->order('id', 'desc')
->find();
$info['estate_status'] = !empty($estate_info_data['estate_status']) ? $estate_info_data['estate_status'] : '';
$info['mortgagee1'] = !empty($estate_info_data['mortgagee1']) ? $estate_info_data['mortgagee1'] : '';
$info['mortgagee_date1'] = !empty($estate_info_data['mortgagee_date1']) ? $estate_info_data['mortgagee_date1'] : '';
$info['mortgagee2'] = !empty($estate_info_data['mortgagee2']) ? $estate_info_data['mortgagee2'] : '';
$info['mortgagee_date2'] = !empty($estate_info_data['mortgagee_date2']) ? $estate_info_data['mortgagee_date2'] : '';
$info['mortgagee3'] = !empty($estate_info_data['mortgagee3']) ? $estate_info_data['mortgagee3'] : '';
$info['mortgagee_date3'] = !empty($estate_info_data['mortgagee_date3']) ? $estate_info_data['mortgagee_date3'] : '';
$info['mortgagee4'] = !empty($estate_info_data['mortgagee4']) ? $estate_info_data['mortgagee4'] : '';
$info['mortgagee_date4'] = !empty($estate_info_data['mortgagee_date4']) ? $estate_info_data['mortgagee_date4'] : '';
$info['mortgagee5'] = !empty($estate_info_data['mortgagee5']) ? $estate_info_data['mortgagee5'] : '';
$info['mortgagee_date5'] = !empty($estate_info_data['mortgagee_date5']) ? $estate_info_data['mortgagee_date5'] : '';
$info['mortgagee6'] = !empty($estate_info_data['mortgagee6']) ? $estate_info_data['mortgagee6'] : '';
$info['mortgagee_date6'] = !empty($estate_info_data['mortgagee_date6']) ? $estate_info_data['mortgagee_date6'] : '';
$info['mortgagee7'] = !empty($estate_info_data['mortgagee7']) ? $estate_info_data['mortgagee7'] : '';
$info['mortgagee_date7'] = !empty($estate_info_data['mortgagee_date7']) ? $estate_info_data['mortgagee_date7'] : '';
$info['mortgagee8'] = !empty($estate_info_data['mortgagee8']) ? $estate_info_data['mortgagee8'] : '';
$info['mortgagee_date8'] = !empty($estate_info_data['mortgagee_date8']) ? $estate_info_data['mortgagee_date8'] : '';
$info['mortgagee9'] = !empty($estate_info_data['mortgagee9']) ? $estate_info_data['mortgagee9'] : '';
$info['mortgagee_date9'] = !empty($estate_info_data['mortgagee_date9']) ? $estate_info_data['mortgagee_date9'] : '';
$info['seal_up_unit'] = !empty($estate_info_data['seal_up_unit']) ? $estate_info_data['seal_up_unit'] : '';
$info['seal_up_date'] = !empty($estate_info_data['seal_up_date']) ? $estate_info_data['seal_up_date'] : '';
}
return $info;
}
//多位数组获取列数据
public function array_column($rows, $column_key, $index_key = null) {
$data = [];
foreach ($rows as $row) {
if (empty($index_key)) {
$data[] = $row[$column_key];
} else {
$data[$row[$index_key]] = $row[$column_key];
}
}
return $data;
}
/**
* 他项权利说明类型
*
* @var array
*/
public static $OTHERRIGHTS_TYPE = ['','已抵押未注销','未抵押','查封','--'];
/**
* 背离事实假设的描述
* 对应 ['','已抵押未注销','未抵押']
* @var array
*/
public static $DFFA_DESC = ['根据委托方提供的《不动产权证书》复印件和深圳市房地产信息系统的产权查档情况,估价对象已进行抵押登记并尚未注销,根据贷款银行惯例,办理抵押贷款之前原有抵押关系必须先注销,本次评估基于估价对象原有抵押关系在本次办理抵押贷款前已注销',
'根据估价目的及注册房地产估价师的实地查勘情况,估价对象设定状况与实际状况无不一致情况,故本次估价无背离事实假设。',
'根据估价目的及注册房地产估价师的实地查勘情况,估价对象设定状况与实际状况无不一致情况,故本次估价无背离事实假设。',
'根据估价目的及注册房地产估价师的实地查勘情况,估价对象设定状况与实际状况无不一致情况,故本次估价无背离事实假设。',
'根据估价目的及注册房地产估价师的实地查勘情况,估价对象设定状况与实际状况无不一致情况,故本次估价无背离事实假设。'];
/**
* 获取背离事实假设的类型的文字描述
*
* @param [type] $type
* @return string
*/
public function getOtherRightsType( $type ){
//if(empty($type) || $type <=0 || $type >count(OffsiteOneTemplate::$OTHERRIGHTS_TYPE))
if( null == $type || $type <=0 )
return "";
return OffsiteOneTemplate::$OTHERRIGHTS_TYPE[$type];
}
/**
* 获取背离事实假设的文字描述
*
* @param [type] $type
* @return string
*/
public function getDFFADesc( $type ){
//$DESC = ['已抵押未注销','未抵押','查封'];
if( empty($type) || $type <=0 || $type >count(OffsiteOneTemplate::$DFFA_DESC) )
return "";
return OffsiteOneTemplate::$DFFA_DESC[$type];
}
//合并信息
public function getAllName($data) {
$result = [];
if (empty($data['value'])) return $result;
foreach ($data['value'] as $key => $value) {
if (!empty($value['value'])) {
$list = $value['name'] . '' . implode('、', array_filter($value['value']));
$result[] = $list;
}
}
return $result;
}
//获取设施
public function getFacilityName($data) {
$result = [];
if (empty($data['value'])) return $result;
foreach ($data['value'] as $key => $value) {
if (!empty($value)) {
if (!empty($value['value']) && count(array_filter($value['value'])) >= 1 ) {
if ($value['name'] == '空调') {
$result['conditioner'] = implode('、', array_filter($value['value']));
} elseif($value['name'] == '水电') {
$result['hydropower'] = implode('、', array_filter($value['value']));
} elseif($value['name'] == '通讯') {
$result['communication'] = implode('、', array_filter($value['value']));
} elseif($value['name'] == '电梯') {
$result['lift'] = implode('、', array_filter($value['value']));
} elseif($value['name'] == '地面') {
$result['ground'] = implode('、', array_filter($value['value']));
} elseif($value['name'] == '天花板') {
$result['ceiling'] = implode('、', array_filter($value['value']));
} elseif($value['name'] == '内墙') {
$result['interior_wall'] = implode('、', array_filter($value['value']));
} elseif($value['name'] == '其他') {
$result['other'] = implode('、', array_filter($value['value']));
}
}
}
}
return $result;
}
/**
* 获取是否被政府批准列入棚改或旧改12
*
* @param [type] $value
* @return string 描述文字
*/
private function __getIsOldChangeDesc($value)
{
static $IS_OLD_CHANGE = 2;
static $IS_NOT_OLD_CHANGE = 1;
if( $IS_OLD_CHANGE == $value)
{
return "⑥估价对象所在小区已被政府批准列入棚改或旧改项目";
}
else if( $IS_NOT_OLD_CHANGE == $value )
{
return "⑥估价对象所在小区未被政府批准列入棚改或旧改项目";
}
else{
return "(此项有误,请重新调整)";
}
}
//获取电梯
public function getLift($lift) {
$arr = $result = [];
if ($lift) {
$lift = explode('、', $lift);
foreach ($lift as $lk => $lv) {
if (strstr($lv, "客梯")) {
preg_match_all('/\d+/', $lv, $arr);
}
}
}
if (!empty($arr)) {
$result = join('',$arr[0]);
} else {
$result = '';
}
return $result;
}
//服务设施
public function getPublicFacility($data) {
$result = '';
$arr = ['bank', 'club', 'park', 'hotel', 'school', 'hospital', 'food_market', 'post_office', 'supermarket'];
$res = [];
foreach ($arr as $key => $value) {
if (!empty($data[$value])) {
$res[] = $data[$value];
}
}
if ($res) {
$result = implode('、', $res);
}
return $result;
}
//四至
public function getDirectional($data) {
$result = [];
$arr = json_decode($data, true);
if ($arr) {
if (!empty($arr['east'])) {
$result[] = '东至' . $arr['east'];
}
if(!empty($arr['west'])) {
$result[] = '西至' . $arr['west'];
}
if(!empty($arr['south'])) {
$result[] = '南至' . $arr['west'];
}
if(!empty($arr['north'])) {
$result[] = '北至' . $arr['north'];
}
}
return implode('、', $result);
}
//获取数据信息
public function getDataName($data) {
$result = [];
if (empty($data['value'])) return '';
foreach ($data['value'] as $key => $value) {
if (!empty($value)) {
if (count(array_filter($value['value'])) >= 1 ) {
if ($value['name'] == '天花板') {
$result['ceiling'] = implode('、', array_filter($value['value']));
} elseif($value['name'] == '地面') {
$result['ground'] = implode('、', array_filter($value['value']));
} elseif($value['name'] == '内墙') {
$result['interior_wall'] = implode('、', array_filter($value['value']));
}
}
}
}
return $result;
}
//获取户型
public function getHouseStatus($data) {
$result = $data;
$data = explode('-', $data);
if (is_array($data) && count($data) == 4) {
$room = !empty($data[0]) && $data[0] > 0 ? $data[0] . "" : '';
$hall = !empty($data[1]) && $data[1] > 0 ? $data[1] . "" : '';
$toilet = !empty($data[2]) && $data[2] > 0 ? $data[2] . "" : '';
$balcony = !empty($data[3]) && $data[3] > 0 ? $data[3] . "阳台" : '';
$result = $room . $hall . $toilet . $balcony;
}
return $result;
}
}