request->post(); $page = !empty($postData['page'])?$postData['page']:1; $limit = !empty($postData['limit'])?$postData['limit']:10; $bocpreapply = new BocPreapply(); $result = $bocpreapply->getPreApplyList($page,$limit); $card = json_decode($result[0]['property_card']); var_dump($card[0]);*/ //$url = "https://pgevasys.oss-cn-shenzhen.aliyuncs.com/uploads/20221208/0418fe6b311bd8585b4c5bb3fef042df.pdf"; //$url = "https://pgevasys.oss-cn-shenzhen.aliyuncs.com\\uploads\\20221212\\6811538bd12b4282f2d5fdec73446845.pdf"; /*$bocApi = new BOCApi(); $arr_header[] ="content-type:application/octet-stream"; $content = $bocApi->http_get($url,[],$arr_header); var_dump($content);*/ //$url = substr($url,strlen("https://pgevasys.oss-cn-shenzhen.aliyuncs.com")); //var_dump($url); //$url = str_replace("\\","/",$url); //var_dump($url); //$ossService = new OssService(); //$ossService->getOSSFile($url); //$this->applyOfficial(); $reportNo = '2022GA-1200005-BOC'; //$reportNo = $this->request->post('report_no'); //$uploadfile = $this->request->post('uploadfile'); $bankEstimateNo = 'sdfsfsfsdfsfsdfsf';//$uploadfile['bankEstimateNo']; //构建正式评估结果 $bocofficialresult = new BocOfficialresult(); $data = $bocofficialresult->buildOfficialresult($reportNo); //插入数据库 $data['bankEstimateNo'] = $bankEstimateNo; $ac = $data['acOffHouseEstates']; // var_dump($ac[0]['land_use_start_time']); $data['acOffHouseEstates'][0]['land_use_start_time'] = preg_replace('/(\d+)-(\d+)-(\d+)/','$1年$2月$3日',$ac[0]['land_use_start_time']); //$data['uploadfile'] = $uploadfile; //$bocofficialresult->insertOfficialresult($data); //传输到中行 //$ossService = new OssService(); //$bocdata['fileIndex'] = $ossService->getOSSFile($uploadfile['url']); $formatpreresult = $data;//$this->formatOfficialResult($bocdata); } /** * @api {post} admin/boc/preApply 获取中国银行预评估申请列表 *ciphertext 返回结果的json字符串用AES加密,转base64。UrlBase64(AES(tojson(返回结果))) *cipherkey 用RSA公钥对AES的秘钥进行加密,转base64。UrlBase64(RSA(AES秘钥)) *sign MD5(SALT+ciphertext) * */ public function preApply() { $postData= $this->request->post(); $cipherkey = $postData['cipherkey']; $ciphertext = $postData['ciphertext']; $sign = $postData['sign']; $bocApi = new BOCApi(); $data = $bocApi->decodeFromBOC($cipherkey,$ciphertext,$sign); $bocpreapply = new BocPreapply(); $inserResult = $bocpreapply->addPreapply($data); if($inserResult) { $msg = "接收成功"; }else { $msg = "写数据库出错,请联系接收方处理"; } return $bocApi->responseToBOC(0,$msg,"{}"); } /** * 获取预评估申请列表 * * */ public function preApplyList() { //todo 增加状态过滤 $postData= $this->request->post(); $page = !empty($postData['page'])?$postData['page']:1; $limit = !empty($postData['limit'])?$postData['limit']:10; $handle_status = !empty($postData['handle_status'])?$postData['handle_status']:'all'; $bocpreapply = new BocPreapply(); $keyword = $this->request->post('keyword', '','trim'); $result = $bocpreapply->getPreApplyList($page,$limit,$handle_status, $keyword); return $this->buildSuccess($result); } /** * 获取预评估结果列表 * * */ public function preResultList() { $postData= $this->request->post(); $page = !empty($postData['page'])?$postData['page']:1; $limit = !empty($postData['limit'])?$postData['limit']:10; $bocpreresult = new BocPreresult(); $result = $bocpreresult->getPreResultList($page,$limit); return $this->buildSuccess($result); } /** * @api {post} admin/boc/preResult 组装中国银行预评估结果 *ciphertext 返回结果的json字符串用AES加密,转base64。UrlBase64(AES(tojson(返回结果))) *cipherkey 用RSA公钥对AES的秘钥进行加密,转base64。UrlBase64(RSA(AES秘钥)) *sign MD5(SALT+ciphertext) * 接收预评估结果的URL https://app-host:30012/estimate/receivePreResult */ public function preResult() { $preEstimateNo = $this->request->post('preEstimateNo'); $bankPreEstimateNo = $this->request->post('bankPreEstimateNo'); $assessmentType = $this->request->post('assessmentType'); $uploadfile = $this->request->post('uploadfile'); $bocpreresult = new BocPreresult(); //构建预评估结果 $res = $bocpreresult->buildPreresult($preEstimateNo); $data['assessmentType'] = $assessmentType; //插入数据库 $data['data'] = $res[0]; $data['data']['finished_year'] = date('Y年m月d日',strtotime($data['data']['completion_time']));//substr($data['data']['completion_time'],0,4); $data['data']['bankPreEstimateNo'] = $bankPreEstimateNo; $data['uploadfile'] = $uploadfile; $data['data']['timestamp'] = (int)microtime(true)*1000;//time(); $insertResult = $bocpreresult->insertPreresult($data); //写数据库出错,删除上传的文件 if(!$insertResult) { //删除上传的文件 $oss = new OssService(); $oss->deleteOSSFile($uploadfile['url']); return $this->buildFailed("写数据库出错,请查看日志"); } //传输到中行 $bocdata = $res[0]; $bocdata['timestamp'] = $data['data']['timestamp']; $bocdata['finished_year'] = date('Y年m月d日',strtotime( $bocdata['completion_time']));//substr($bocdata['completion_time'],0,4); $bocdata['bankPreEstimateNo'] = $bankPreEstimateNo; $bocdata['assessmentType'] = $assessmentType; $bocdata['status'] = '0'; $ossService = new OssService(); $bocdata['fileIndex'] = $ossService->getOSSFile($uploadfile['url']); $bocdata['eva_net_value'] = $bocdata['eva_net_value']-$bocdata['statutory_payment']; $formatpreresult = $this->formatPreResult($bocdata); $bocapi = new BOCApi(); $response = $bocapi->sendPreResult($formatpreresult); if(!empty($response['http_code'])) { $oss = new OssService(); $oss->deleteOSSFile($uploadfile['url']); $bocpreresult->deletePreresult($bankPreEstimateNo); return $this->buildFailed('发送数据失败',$response,$response['http_code']); } //更新预评估申请的状态为已处理 $bocpreapply = new BocPreapply(); $bocpreapply->updatePreapplyStatus($bankPreEstimateNo,'1'); return $this->buildSuccess($response); } public function formatPreResult($data) { $res['companyCode'] = '20';//评估公司编码 $res['bankPreEstimateNo'] = $data['bankPreEstimateNo'];//银行预评估申请编号 $res['preEstimateNo'] = $data['estimated_no'];//预评估结果编号 $res['roomArea'] = $data['size'];//建筑面积 $res['unitPrice'] = $data['eva_unit_price'];//评估单价 $res['totalPrice'] = $data['eva_total_value'];//评估总价 $res['propertyName'] = $data['land_location'] . $data['property_name'];//物业名称 $res['timestamp'] = $data['timestamp'];//记录回复时间-中行是按毫秒计算时间戳 $d = new Dictionary(); $data['usage'] = $d->getValnameByCode('HOUSE_USAGE',$data['usage']); $res['propertyUse'] = $data['usage'];//房屋用途 $res['ownerName'] = $data['obligee'];//权利人名 $res['finishedYear'] = $data['finished_year']; $res['price'] = $data['eva_net_value'];//评估净值 $res['tax'] = $data['total_taxes1'];//税费总值 //$res['fileContent'] = '指导价:' . number_format($data['guide_price']/10000, 2) . '万元/平方米'; //$data['external_remarks'];//备注 $res['fileContent'] = $data['external_remarks'];//备注 $res['name'] = '待定';//$data['user_name'];//评估师 $res['status'] = $data['status']; $res['assessmentType'] = $data['assessmentType']; $res['referencePrice'] = $data['guide_price'] ; $res['referenceNetWorth'] = ($data['guide_price'] * $data['size'] - $data['total_guide_tax']) / $data['size']; $res['fileIndex'] = $data['fileIndex']; $res['taxDetail'] = array(array('TaxName'=>"营业税",'TaxValue'=>$data['corporate_income_tax']), array('TaxName'=>"城建税",'TaxValue'=>$data['urban_construction_tax']), array('TaxName'=>"契税",'TaxValue'=>$data['deed_tax']), array('TaxName'=>"印花税",'TaxValue'=>$data['stamp_duty']), array('TaxName'=>"增值税",'TaxValue'=>$data['added_tax']), array('TaxName'=>"土地增值税",'TaxValue'=>$data['land_value_added_tax']), array('TaxName'=>"个人所得税",'TaxValue'=>$data['personal_income_tax'])); return $res; } /*****************************************正式评估******************************************/ /** * @api {post} admin/boc/applyOfficial 获取中国银行正式评估申请列表 *ciphertext 返回结果的json字符串用AES加密,转base64。UrlBase64(AES(tojson(返回结果))) *cipherkey 用RSA公钥对AES的秘钥进行加密,转base64。UrlBase64(RSA(AES秘钥)) *sign MD5(SALT+ciphertext) * */ public function applyOfficial() { $postData= $this->request->post(); $cipherkey = $postData['cipherkey']; $ciphertext = $postData['ciphertext']; $sign = $postData['sign']; //$cipherkey = 'sly/FD9vhTCUx921CgoMplTJZWu1K1aBJ0zOYUMW2kjFH5tVOigUOU4nKwfmqVOW1O7Ocq4mfXEkljRCp4KvMynQzaFZBohGJtx3ABQ8xgY06LEKgk3XupXgBLg0IX3W8WVpFbad6EoT8D2pfaFmlDW6uvzTTF7gp74SBWhKQS8='; //$ciphertext = '3D9mwl1Y8I/5nyfpmnK4mxV9h03mHbKcA33KxhHRRwRpAzOy9eDJZzGH+QgJAbTvkP5B3smlvqKDFV71gs16oizsf56E1CmOGC9b5o7UhkiG0kNHuWiTtMZKNSiEwqc/qrG31ddEvSqpBQAzfrpnpbXH+SD/Hg8GEDsL0CaFrWwI7nwvcWRruNcVzUU43PYucpBy1hooNPy5r5AmA2DsLgqnLjhQeOw+s4uke1dCOgvAk1mOyNZqHTG9QUOy0XT0LDkG6MbnMaaRL4CQfRsokLgC6B9Coosw9aOKR6+C8U4zx4pmkUtslCoj5IG0R2jog49gNlVkgohcL+Vp7T7y+g03vVUgs7KZZ19QzHlA2IMdTZ2v418Oimgsqpf8dKvet52ItdXKdpbTOKER3wuBiPJvodbVD6kmIuJtXY5Cf/sWUesuq8OJKQxGmeoHDf+rMpmfxk2urzVVEpjHVMxjRQ=='; //$sign = '4f611ba4e3dff300e51748aa8a770e3a'; $bocApi = new BOCApi(); $data = $bocApi->decodeFromBOC($cipherkey,$ciphertext,$sign); $data['preEstimateNoList'] = json_encode($data['preEstimateNoList']); $bocapplyofficial = new BocApplyofficial(); $inserResult = $bocapplyofficial->addApplyofficial($data); if($inserResult) { $msg = "接收成功"; }else { $msg = "写数据库出错,请联系接收方处理"; } return $bocApi->responseToBOC(0,$msg,"{}"); } /** * 获取正式评估申请列表 * * */ public function applyOfficialList() { $postData= $this->request->post(); $keyword = !empty($postData['keyword'])?$postData['keyword']:''; $page = !empty($postData['page'])?$postData['page']:1; $limit = !empty($postData['limit'])?$postData['limit']:10; $handle_status = !empty($postData['handle_status'])?$postData['handle_status']:'all'; $bocapplyofficial = new BocApplyofficial(); $result = $bocapplyofficial->getApplyOfficialList($page,$limit,$handle_status,$keyword); return $this->buildSuccess($result); } /** * 获取正式评估结果列表 * * */ public function officialResultList() { $postData= $this->request->post(); $page = !empty($postData['page'])?$postData['page']:1; $limit = !empty($postData['limit'])?$postData['limit']:10; $bocOfficialresult = new BocOfficialresult(); $result = $bocOfficialresult->getOfficialResultList($page,$limit); return $this->buildSuccess($result); } public function reportIsReady($pre_estimate_no_array) { $arrlength=count($pre_estimate_no_array); $bor = null; $inquiry_id_array = array(); for($x=0;$x<$arrlength;$x++) { $pre_estimate_no = $pre_estimate_no_array[$x]; if ($bor == null) { $bor = new BocOfficialresult(); } $res = $bor->checkInquiryIsReady($pre_estimate_no); if(count($res) == 0) { $res['code'] = -1; $res['msg'] = '询价单不存在预估单号为 ' . $pre_estimate_no . '的记录, 请重新回价,上传预估单'; return $res; } $inquiry = array(); $inquiry['id'] = $res[0]['id']; $inquiry['pre_estimate_no'] = $pre_estimate_no; $inquiry_id_array[$x] = $inquiry; } for($x=0;$x<$arrlength;$x++) { $inquiry = $inquiry_id_array[$x]; if ($bor == null) { $bor = new BocOfficialresult(); } $res = $bor->checkReportIsReady($inquiry['id']); if(count($res) == 0) { $res['code'] = -1; $res['msg'] = '无报告关联预估单号为 ' . $inquiry['pre_estimate_no'] . '的记录, 请先生成报告'; return $res; } $report_inquiry = array(); $report_inquiry['reportid'] = $res[0]['id']; $report_inquiry['quot_id'] = $inquiry['id']; $report_inquiry['pre_estimate_no'] = $inquiry['pre_estimate_no']; $report_inquiry_array[$x] = $report_inquiry; } $ret = array(); $ret['code'] = 1; $ret['report_inquiry_array'] = $report_inquiry_array; return $ret; } public function checkReportIsReady() { $pre_estimate_no_list = $this->request->post('pre_estimate_no_list'); $pre_estimate_no_array = json_decode($pre_estimate_no_list,true); $ret = $this->reportIsReady($pre_estimate_no_array); return $this->buildSuccess($ret); } public function test() { //构建正式评估结果 /* $bocofficialresult = new BocOfficialresult(); $res = $bocofficialresult->buildOfficialresult([ [ 'reportid'=> 22,'pre_estimate_no' => "2023-GY021300001","2023-GY021600001","2023-GY021000010" ] ]); return var_dump($res);*/ echo (microtime(true)*10000); } /** * @api {post} admin/boc/officialResult 组装中国银行正式评估结果 *ciphertext 返回结果的json字符串用AES加密,转base64。UrlBase64(AES(tojson(返回结果))) *cipherkey 用RSA公钥对AES的秘钥进行加密,转base64。UrlBase64(RSA(AES秘钥)) *sign MD5(SALT+ciphertext) * 接收预评估结果的URL https://app-host:30012/estimate/receiveOff */ public function officialResult() { //$reportNo = $this->request->post('report_no'); $pre_estimate_no_list = $this->request->post('pre_estimate_no_list'); $pre_estimate_no_array = json_decode($pre_estimate_no_list,true); $ret = $this->reportIsReady($pre_estimate_no_array); if ($ret['code'] == -1) { return $this->buildFailed($ret['msg']); } $report_inquiry_array = $ret['report_inquiry_array']; $uploadfile = $this->request->post('uploadfile'); $assessmentType = $this->request->post('assessmentType'); $bankEstimateNo = $uploadfile['bankEstimateNo']; //构建正式评估结果 $bocofficialresult = new BocOfficialresult(); $data = $bocofficialresult->buildOfficialresult($report_inquiry_array); $data['assessmentType'] = $assessmentType; //插入数据库 $data['bankEstimateNo'] = $bankEstimateNo; $data['uploadfile'] = $uploadfile; //$data['eva_net_value'] = $data['eva_net_value']-$data['statutory_payment']; $insertResult = $bocofficialresult->insertOfficialresult($data); //写数据库出错,删除上传的文件 if(!$insertResult) { //删除上传的文件 $oss = new OssService(); $oss->deleteOSSFile($uploadfile['url']); return $this->buildFailed("写数据库出错,请查看日志"); } $data['timestamp'] = (int)microtime(true)*1000;//time();//date('Y-m-d H:i:s'); //传输到中行 $ossService = new OssService(); $data['fileIndex'] = $ossService->getOSSFile($uploadfile['url']); $formatpreresult = $this->formatOfficialResult($data); $bocapi = new BOCApi(); // var_dump($formatpreresult['acOffHouseEstates']) ; $response = $bocapi->sendOfficialResult($formatpreresult); if(!empty($response['http_code'])) { $oss = new OssService(); $oss->deleteOSSFile($uploadfile['url']); $bocofficialresult->deleteOfficialresult($bankEstimateNo); return $this->buildFailed('发送数据失败',$response,$response['http_code']); } //更新正式评估申请的状态为已处理 $bocapplyofficial = new BocApplyofficial(); $bocapplyofficial->updateApplyofficialStatus($bankEstimateNo,'1'); return $this->buildSuccess($response); } // 获取报告处理状态 public function getOfficialResultStatus() { // 预估号 $bankEstimateNo = $this->request->post('pre_estimate_no'); $bocofficialresult = new BocApplyofficial(); $result = $bocofficialresult->getApplyofficialStatus($bankEstimateNo); if(empty($result)) { return $this->buildFailed("没有找到对应的数据"); } return $this->buildSuccess($result); } public function formatOfficialResult($data) { //$res['companyCode'] = '20';//评估公司编码 $res['timestamp'] = $data['timestamp'];//时间戳,中行是按毫秒计算时间戳的 $res['bankEstimateNo'] = $data['bankEstimateNo'];//银行正式评估申请编号 $res['estimateNo'] = $data['report_no'];//正式评估结果编号 $res['fileIndex'] = $data['fileIndex']; $res['fileUrl'] = ''; $res['evalTime'] = preg_replace('/(\d+)-(\d+)-(\d+)/','$1年$2月$3日', $data['appraisal_time']);//估价时间 $res['name'] = $data['appraiser_name'] . ',' . $data['appraiser2_name'];//评估师 $res['assessmentType'] = $data['assessmentType']; $res['acOffHouseEstates'] = array(); $arrlength=count($data['acOffHouseEstates']); for($x=0;$x<$arrlength;$x++) { $acOffHouseEstates = $data['acOffHouseEstates'][$x]; $res['acOffHouseEstates'][$x]['preEstimateNo'] = $acOffHouseEstates['estimated_no']; $res['acOffHouseEstates'][$x]['propertyName'] = $acOffHouseEstates['land_location'] . $acOffHouseEstates['property_full_name']; $res['acOffHouseEstates'][$x]['propertyId'] = !empty($acOffHouseEstates['year']) ? '粤('.$acOffHouseEstates['year'].')深圳市不动产权第'.$acOffHouseEstates['property_cert'].'号' : $acOffHouseEstates['property_cert']; //'深房地字第'.$acOffHouseEstates['property_cert'].'号';//$acOffHouseEstates['property_cert'];//'粤(2021)深圳市不动产权第0144705号';// $d = new Dictionary(); $acOffHouseEstates['usage'] = $d->getValnameByCode('HOUSE_USAGE',$acOffHouseEstates['usage']); $res['acOffHouseEstates'][$x]['propertyUse'] = $acOffHouseEstates['usage'];//$acOffHouseEstates['house_use']; $res['acOffHouseEstates'][$x]['landNo'] = $acOffHouseEstates['parcel_no']; $res['acOffHouseEstates'][$x]['landLimitDate'] = $acOffHouseEstates['max_land_use_years'] . '年'; $res['acOffHouseEstates'][$x]['landBgnDate'] = preg_replace('/(\d+)-(\d+)-(\d+)/','$1年$2月$3日',$acOffHouseEstates['land_use_start_time']); $res['acOffHouseEstates'][$x]['landEndDate'] = preg_replace('/(\d+)-(\d+)-(\d+)/','$1年$2月$3日',$acOffHouseEstates['land_use_end_time']); $res['acOffHouseEstates'][$x]['finishedYear'] = date('Y年m月d日',strtotime($acOffHouseEstates['completion_time'])); $res['acOffHouseEstates'][$x]['registPrice'] = $acOffHouseEstates['reg_price']; $res['acOffHouseEstates'][$x]['registDate'] = preg_replace('/(\d+)-(\d+)-(\d+)/','$1年$2月$3日',$acOffHouseEstates['purchase_date']); $res['acOffHouseEstates'][$x]['houseFlag'] = $acOffHouseEstates['type']; $res['acOffHouseEstates'][$x]['houseArea'] = $acOffHouseEstates['building_area']; $res['acOffHouseEstates'][$x]['houseCity'] = $acOffHouseEstates['city'] . '市'; $res['acOffHouseEstates'][$x]['ownerName'] = $acOffHouseEstates['obligee']; $res['acOffHouseEstates'][$x]['ownerCertId'] = $acOffHouseEstates['cert_no']; if(strpos($res['acOffHouseEstates'][$x]['ownerName'],',') !== false) { $res['acOffHouseEstates'][$x]['ownerPortion'] = ''; }else { $res['acOffHouseEstates'][$x]['ownerPortion'] = '100%';//$acOffHouseEstates['']; } $res['acOffHouseEstates'][$x]['mortName'] = '';//$acOffHouseEstates['']; $res['acOffHouseEstates'][$x]['mortDate'] = '';//$acOffHouseEstates['']; $res['acOffHouseEstates'][$x]['propertStatus'] = '';//$acOffHouseEstates['']; $res['acOffHouseEstates'][$x]['sealupOrg'] = '';//$acOffHouseEstates['']; $res['acOffHouseEstates'][$x]['sealupDate'] = '';//$acOffHouseEstates['']; $res['acOffHouseEstates'][$x]['roomArea'] = null;//$acOffHouseEstates['']; $res['acOffHouseEstates'][$x]['unitPrice'] = $acOffHouseEstates['eva_unit_price']; $res['acOffHouseEstates'][$x]['totalPrice'] = $acOffHouseEstates['eva_total_value']; $res['acOffHouseEstates'][$x]['price'] = $acOffHouseEstates['eva_net_value'] - $acOffHouseEstates['statutory_payment']; $res['acOffHouseEstates'][$x]['tax'] = $acOffHouseEstates['total_taxes1']; $res['referencePrice'] = $acOffHouseEstates['guide_price'] ; $res['referenceNetWorth'] = ($acOffHouseEstates['guide_price'] * $acOffHouseEstates['area'] - $acOffHouseEstates['total_guide_tax']) / $acOffHouseEstates['area']; $res['acOffHouseEstates'][$x]['taxDetail'] = array(array('TaxName'=>"营业税",'TaxValue'=>$acOffHouseEstates['corporate_income_tax']), array('TaxName'=>"城建税",'TaxValue'=>$acOffHouseEstates['urban_construction_tax']), array('TaxName'=>"契税",'TaxValue'=>$acOffHouseEstates['deed_tax']), array('TaxName'=>"印花税",'TaxValue'=>$acOffHouseEstates['stamp_duty']), array('TaxName'=>"增值税",'TaxValue'=>$acOffHouseEstates['added_tax']), array('TaxName'=>"土地增值税",'TaxValue'=>$acOffHouseEstates['land_value_added_tax']), array('TaxName'=>"个人所得税",'TaxValue'=>$acOffHouseEstates['personal_income_tax'])); } return $res; } }