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

1242 lines
47 KiB
PHP
Raw 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\admin\controller;
use app\lib\CEBApi;
use think\Controller;
use app\model\CebInquiryApply;
use app\model\CebInquiryResult;
use app\model\CebUrge;
use app\model\CebCheckApply;
use app\model\CebCheckResult;
use app\model\CebReevaluateApply;
use app\model\CebReevaluateResult;
use app\model\CebEsz012Apply;
use app\model\Dictionary;
use think\Exception;
use think\facade\Config;
use app\admin\service\OssService;
use app\model\CebReportApply;
use app\model\CebReportResult;
use think\facade\Response;
use think\Db;
use think\facade\Log;
use think\facade\Cache;
use think\facade\Request;
use think\Upload;
class Ceb extends Base
{
public $headers ='';
public function getBase64Img () {
$postData= $this->request->post();
$filePath = $postData['filePath'];
$fileName = $postData['fileName'];
$fileEnd = $postData['fileEnd'];
$remote_file=$filePath . $fileName . '.' . $fileEnd;
$cebapi = new CEBApi();
$ret = $cebapi->getFileFromFtp($remote_file);
if($ret['code'] == 1) {
$base64_image = 'data:' . $fileEnd . ';base64,' . chunk_split(base64_encode($ret['data']));
return $this->buildSuccess($base64_image);
}else {
return $this->buildFailed($ret['data']);
}
}
public function testCEB() {
$msg = 'download success';
$cebapi = new CEBApi();
$remote_file = '/cebbank/postLoan/save/20230328/2010902108946525143040404_0104.zip';
$ret = $cebapi->getFileFromFtp($remote_file);
if($ret['code'] == 1) {
return $this->buildSuccess($msg);
}else {
return $this->buildFailed('download fail');
}
}
public function responseToCEB($code,$msg,$data) {
$res['code'] = $code;
$res['message'] = $msg;
$res['data'] = $data;
$response = Response::create($res, 'json');
try{
Log::debug("-----------返回响应给光大-------------------");
Log::debug($data);
}catch (Exception $e){
Log::warning($e->getMessage());
}
return $response;
}
/**
*2.1.1 询价申请-不动产自动录入
*{地址}/webapi/Cebbank/ESZ001/reqESZ001Info
*businessNo 业务编号 是 String 32
*companyCode 评估公司编码 是 String 10
* businessType 业务类型 是 String 10 01-贷前询价 02-贷中询价
*collateralType 押品类型 是 String 100 见附件“类型码值”页
*provinceId 押品所在省份 是 String 100 国标2012
*cityId 押品所在城市 是 String 100
*custName 贷款人姓名 否 String 100 02-贷中询价时“必填”
*businessLineType 业务条线 是 String 100 10零售 20对公 30对公普惠
*certificateNo 房产证书编号 否 String 64
*estimateTimes 评估次数 是 String 2 01首次 02重估
*fileName 文件名 否 String 200
*fileEnd 文件后缀名 否 String 100
*filePath 文件存储路径 否 String 200 与评估公司约定
*field1 预留字段1 否 String 100
*field2 预留字段2 否 String 100
*field3 预留字段3 否 String 100
*createDate 业务创建时间 是 Timestamp 6
*}
*响应
* {
* "code": “0000”,
* "message": "请求成功",
* "data": {
*
* }
*/
public function esz001() {
$postData= $this->request->post();
Log::debug($postData);
$ceb = new CebInquiryApply();
$success = $ceb->addInquiryApply(1,$postData);
if($success) {
$msg = "接收成功";
}else {
$msg = "写数据库出错,请联系接收方处理";
}
$data ['businessNo']= $postData ['businessNo'];
return $this->responseToCEB("0000",$msg,$data);
}
/**
*2.1.2 询价申请-不动产手工录入(银行发起)
*{地址}/webapi/Cebbank/ESZ002/reqESZ002Info
*businessNo 业务编号 是 String 32
*companyCode 评估公司编码 是 String 10
*businessType 业务类型 是 String 10 01-贷前询价 02-贷中询价
*collateralType 押品类型 是 String 100 见附件“类型码值”页
*provinceId 押品所在省份 是 String 100 国标2012
*cityId 押品所在城市 是 String 100
*custName 贷款人姓名 否 String 100 02-贷中询价时“必填”
*businessLineType 业务条线 是 String 100 10零售 20对公 30对公普惠
*certificateNo 房产证书编号 否 String 64
*propertyName 物业名称 否 String 100
*coveredArea 建筑面积 否 NUMBER (18,2)
*registPrice 登记价 否 NUMBER (18,2)
*registDate 登记日期 否 DATE
*ownerName 权利人 否 String 100 企业或个人
*landLimitDate 使用年限 否 Integer
*housePurpose 房屋用途 否 String 100
*estimateTimes 评估次数 是 String 2 01首次 02重估
*fileName 文件名 否 String 200
*fileEnd 文件后缀名 否 String 100
*filePath 文件存储路径 否 String 200 与评估公司约定
*field1 预留字段1 否 String 100
*field2 预留字段2 否 String 100
*field3 预留字段3 否 String 100
*createDate 业务创建时间 是 Timestamp 6
*
*/
public function esz002() {
$postData= $this->request->post();
Log::debug($postData);
$ceb = new CebInquiryApply();
$success = $ceb->addInquiryApply(2,$postData);
if($success) {
$msg = "接收成功";
}else {
$msg = "写数据库出错,请联系接收方处理";
}
$data ['businessNo']= $postData ['businessNo'];
return $this->responseToCEB("0000",$msg,$data);
}
/**
*2.1.3 询价申请-动产手工录入(银行发起)
*{地址}/webapi/Cebbank/ESZ003/reqESZ003Info
*参数名 字段描述 必填 类型 长度 备注
*businessNo 业务编号 是 String 32
*companyCode 评估公司编码 是 String 10
*businessType 业务类型 是 String 10 01-贷前询价 02-贷中询价
*collateralType 押品类型 是 String 100 见附件“类型码值”页
*provinceId 押品所在省份 是 String 100 国标2012
*cityId 押品所在城市 是 String 100
*custName 贷款人姓名 否 String 100 02-贷中询价时“必填”
*businessLineType 业务条线 是 String 100 10零售 20对公 30对公普惠
*collateralName 押品名称 否 String 100
*collateralNum 数量 否 Integer 100
*estimateTimes 评估次数 是 String 2 01首次 02重估
*fileName 文件名 否 String 200
*fileEnd 文件后缀名 否 String 100
*filePath 文件存储路径 否 String 200 与评估公司约定
*field1 预留字段1 否 String 100
*field2 预留字段2 否 String 100
*field3 预留字段3 否 String 100
*createDate 业务创建时间 是 Timestamp 6
*/
public function esz003() {
$postData= $this->request->post();
Log::debug($postData);
$ceb = new CebInquiryApply();
$success = $ceb->addInquiryApply(3,$postData);
if($success) {
$msg = "接收成功";
}else {
$msg = "写数据库出错,请联系接收方处理";
}
$data ['businessNo']= $postData ['businessNo'];
return $this->responseToCEB("0000",$msg,$data);
}
/**
*2.1.4 评估报告申请(银行发起)
*{地址}/webapi/Cebbank/ESZ005/reqESZ005Info
*businessNo 业务编号 是 String 32
*companyCode 评估公司编码 是 String 10
* estimateDealNo 评估交易编号 是 String 32
*businessType 业务类型 是 String 10 03-贷中预评估 04-正式评估
*fileName 文件名 否 String 200
*fileEnd 文件后缀名 否 String 100
*filePath 文件存储路径 否 String 200 与评估公司约定
*field1 预留字段1 否 String 100
*field2 预留字段2 否 String 100
*field3 预留字段3 否 String 100
*createDate 业务创建时间 是 Timestamp 6
*
*/
public function esz005() {
$postData= $this->request->post();
Log::debug($postData);
$ceb = new CebReportApply();
$success = $ceb->addReportApply($postData);
if($success) {
$msg = "接收成功";
}else {
$msg = "写数据库出错,请联系接收方处理";
}
$data ['businessNo']= $postData ['businessNo'];
return $this->responseToCEB("0000",$msg,$data);
}
/***
*2.1.5 催办(银行发起)
{地址}/webapi/Cebbank/ESZ007/reqESZ007Info
*businessNo 业务编号 是 String 32
*companyCode 评估公司编码 是 String 10
*estimateDealNo 评估交易编号 否 String 32
*remindType 业务类型 是 String 10 01-贷中询价结果 02-贷中预评估报告 03-正式评估报告
*field1 预留字段1 否 String 100
*field2 预留字段2 否 String 100
*field3 预留字段3 否 String 100
*createDate 业务创建时间 是 Timestamp 6
*
*
*
*
*/
public function esz007() {
$postData= $this->request->post();
Log::debug($postData);
$ceb = new CebUrge();
$success = $ceb->addUrge($postData);
if($success) {
$msg = "接收成功";
}else {
$msg = "写数据库出错,请联系接收方处理";
}
$data ['businessNo']= $postData ['businessNo'];
return $this->responseToCEB("0000",$msg,$data);
}
/*
*2.1.6 核价(银行发起)
{地址}/webapi/Cebbank/ESZ008/reqESZ008Info
*businessNo 业务编号 是 String 32
companyCode 评估公司编码 是 String 10
estimateDealNo 评估交易编号 是 String 32
checkApply 核价申请标志 是 String 2 01-是(固定值)
field1 预留字段1 否 String 100
field2 预留字段2 否 String 100
field3 预留字段3 否 String 100
createDate 业务创建时间 是 Timestamp 6
*
*
*/
public function esz008() {
$postData= $this->request->post();
Log::debug($postData);
$ceb = new CebCheckApply();
$success = $ceb->addCheckApply($postData);
if($success) {
$msg = "接收成功";
}else {
$msg = "写数据库出错,请联系接收方处理";
}
$data ['businessNo']= $postData ['businessNo'];
return $this->responseToCEB("0000",$msg,$data);
}
/**
*2.1.7 贷后重估请求(银行发起)
*{地址}/webapi/Cebbank/ESZ010/reqESZ010Info
*businessNo 业务编号 是 String 32
*companyCode 评估公司编码 是 String 10
*reevaluateFileName 待重估清单名称 是 String 200
*reevaluateFileEnd 待重估清单后缀名 是 String 100
*reevaluateFilePath 待重估清单路径 是 String 200
*field1 预留字段1 否 String 100
*field2 预留字段2 否 String 100
*field3 预留字段3 否 String 100
*createDate 业务创建时间 是 Timestamp 6
*
*
*
*/
public function esz010() {
$postData= $this->request->post();
Log::debug($postData);
$ceb = new CebReevaluateApply();
$success = $ceb->addReevaluateApply($postData);
if($success) {
$msg = "接收成功";
}else {
$msg = "写数据库出错,请联系接收方处理";
}
$data ['businessNo']= $postData ['businessNo'];
return $this->responseToCEB("0000",$msg,$data);
}
/**2.1.8 报告申请(银行发起)
接口方法名 ESZ012
功能描述 行方向评估公司发起重传报告和现场查勘预估单请求
使用场合 行方在预评估阶段,通过该接口向评估公司发起预评估报告重传或者现场查勘预估单请
求;在正式评估阶段向评估公司发起正式评估报告重传请求
注意事项 评估公司通过 ESZ006 返回 ESZ012 的请求(注意区分业务类型)
访问路径 {地址}/webapi/Cebbank/ESZ012/reqESZ012Info
请求参数节点
参数名 字段描述 必填 类型 长度 备注
businessNo 业务编号 是 String 32
companyCode 评估公司编码 是 String 10
estimateDealNo 评估交易编号 是 String 32
businessType 业务类型 是 String 32 03-贷中预评估 04-正式评估
applyReportType 申请报告类型 是 String 32 01-重传报告 02-查勘现场预估单
field1 预留字段 1 否 String 100
field2 预留字段 2 否 String 100
field3 预留字段 3 否 String 100
createTime 业务创建时间 是 Timestamp 6
请求参数示例
{
"businessNo":"10101130730329237094405",
"companyCode":"01",
"estimateDealNo":"0120230612001",
"businessType":"03",
"applyReportType":"02",
"field1":"",
"field2":"",
"field3":"",
"createTime":"2023-06-12 09:28:32"
}
响应报文节点
参数名 字段描述 必填 类型 长度 备注
data
响应报文示例
{
"code": “0000”,
"message": "请求成功",
"data": {}
*
*/
public function esz012() {
$postData= $this->request->post();
Log::debug($postData);
$ceb = new CebEsz012Apply();
$success = $ceb->addApply($postData);
if($success) {
$msg = "接收成功";
}else {
$msg = "写数据库出错,请联系接收方处理";
}
$data ['businessNo']= $postData ['businessNo'];
return $this->responseToCEB("0000",$msg,$data);
}
/***
*2.2.1 询价结果返回申请
*评估公司在贷前询价、贷中询价阶段,通过该接口向行方发起询价结果返回请求,将询价结果返回给行方
*{地址}/webapi/Cebbank/ESZ004/returnESZ004Info
*businessNo 业务编号 是 String 32 回显
*companyCode 评估公司编号 是 String 10 回显
*estimateDealNo 评估交易编号 是 String 32 评估公司编号+自定义编号
businessType 业务类型 是 String 10 回显
certificateNo 房产证书编号 否 String 64 单一不动产必填
totalPrice 评估总价 否 NUMBER (18,2) 询价成功时必填,询价失败时可不填
chargeAmt 收费金额 否 NUMBER (18,2) 该笔业务评估预计支付费用(贷中询价必填)
status 评估状态 是 String 2 01-询价成功
02-询价失败
evaluatorName 评估师姓名 否 String 100 人工询价时必填
telephoneNumber 评估师电话 否 String 32 人工询价时必填
field1 预留字段1 否 String 100
field2 预留字段2 否 String 100
field3 预留字段3 否 String 100
estimateTime 公司评估时间 是 Timestamp 6 评估公司返回评估结果时的系统时间
*
*
*/
public function esz004()
{
$postData = $this->request->post();
$businessNo = $postData['businessNo'];
$inquiryNo = $postData['inquiryNo'];
$quot_id = $postData['quot_id'];
if (array_key_exists('reject', $postData)) {
$reject = true;
} else {
$reject = false;
}
$ceb = new CebInquiryResult();
$res = null;
if($reject) {
$reason = '';
if(isset($postData['reason'])){
$reason = $postData['reason'];
}
$userId = $this->request->header('userId');
$currentUserInfo = cache('userinfo'.$userId);
$userName = $currentUserInfo['user_name'];
$userPhone = $currentUserInfo['user_phone'] ;
$res = $ceb->buildInquiryFailResult($businessNo,$reason,$userName,$userPhone);
} else {
$res = $ceb->buildInquiryResult($quot_id, $inquiryNo, $businessNo);
}
if(!empty($res['quot_id'])){
$quot_id = $res['quot_id'];
unset($res['quot_id']);
}
$cebapi = new CEBApi();
$response = $cebapi->sendInquiryResult($res);
if (is_string($response)){
$response = json_decode($response,true);
}
if(empty($response['http_code']) && (!empty($response['result']) && $response['result'] == '01')){
$res['quot_id'] = $quot_id;
$insertSuccess = $ceb->insertInquiryResult($res);
if( !$insertSuccess) {
return $this->buildFailed('写数据库失败',$res,'');
}
//更新询价申请单状态
$cebInquiryApply = new CebInquiryApply();
$cebInquiryApply->updateInquiryApplyStatus($businessNo,2);
return $this->buildSuccess($response);
}else {
return $this->buildFailed('发送数据失败',$response);
}
}
/***
*2.2.2 评估报告结果返回申请
评估公司在贷中预评估、正式评估阶段,通过该接口向行方发起评估报告结果返回请求,将评估报告及相应结果返回给行方
{地址}/webapi/Cebbank/ESZ006/returnESZ006Info
*businessNo 业务编号 是 String 32 回显
companyCode 评估公司编号 是 String 10 回显
estimateDealNo 评估交易编号 是 String 32 评估公司编号+自定义编号
businessType 业务类型 是 String 10 回显
unitPrice 评估单价 否 NUMBER (18,2) 单一不动产必填
totalPrice 评估总价 否 NUMBER (18,2) resultStatus=“01”时必填
totalTax 税费总值 否 NUMBER (18,2) 总税费 resultStatus=“01”时必填
detailTax 税费明细说明 否 String 1000 明细税费名称+税费金额 resultStatus=“01”时必填
chargeAmt 收费金额 否 NUMBER (18,2) 该笔业务评估预计支付费用(贷中询价必填)
estimateReportName 评估报告名称 否 String 200 报告唯一性(业务编号+评估公司编号+业务类型) resultStatus=“01”时必填
estimateReportEnd 评估报告后缀名 否 String 100 resultStatus=“01”时必填
estimateReportPath 评估报告文件存储路径 否 String 200 resultStatus=“01”时必填
mortgagor1 抵押人1 否 String 64 03-贷中预评估 不填 04-正式评估 必填
mortgagor2 抵押人2 否 String 64
mortgagor3 抵押人3 否 String 64
mortgagor4 抵押人4 否 String 64
mortgagor5 抵押人5 否 String 64
mortgagor6 抵押人6 否 String 64
resultStatus 评估状态 是 String 2 01-评估成功并返回评估报告
02-评估失败
reason 评估失败原因 否 String 100 评估失败时必填
field1 预留字段1 否 String 100
field2 预留字段2 否 String 100
field3 预留字段3 否 String 100
estimateTime 公司评估时间 是 Timestamp 6 评估公司返回评估结果时的系统时间
*
*/
public function rejectReportApply(){
$postData= $this->request->post();
$businessNo = $postData['business_no'];
$estimateDealNo = $postData['estimate_deal_no'];
$businessType = $postData['business_type'];
$reason = $postData['reason'];
$ceb = new CebReportResult();
$ez0012 = new CebEsz012Apply();
$report_type = $ez0012->where('business_no',$businessNo)->value('apply_report_type');
$res = $ceb->builfFailedResult($businessNo,$estimateDealNo,$businessType,$reason,$report_type);
$insertSuccess = $ceb->insertResult($res);
if( !$insertSuccess) {
return $this->buildFailed('写数据库失败',$res,'');
}
$cebapi = new CEBApi();
$response = $cebapi->sendReportResult($res);
if (is_string($response)){
$response = json_decode($response,true);
}
if(empty($response['http_code']) && (!empty($response['result']) && $response['result'] == '01')){
// 更新报告申请状态
$M_reportApply = new CebReportApply();
$M_reportApply->updateIsDoneByBusinessNo( $businessNo,$businessType,CebReportApply::$IS_RETURN_YES );
return $this->buildSuccess($response);
}else {
$ceb->deleteResult($businessNo);
return $this->buildFailed('发送数据失败',$response);
}
}
public function setReportApplyDone(){
$postData= $this->request->post();
$businessNo = $postData['business_no'];
$businessType = $postData['business_type'];
$M_reportApply = new CebReportApply();
$M_reportApply->updateIsDoneByBusinessNo( $businessNo,$businessType,CebReportApply::$IS_RETURN_YES );
return $this->buildSuccess('设置成功');
}
public function esz006() {
// 检查上传文件
$path = ROOT_PATH . 'public' . DS . 'uploads' ;//存放路径
$fHandler = $this->request->file('reevaFile');
// path是否是目录
if (!is_dir($path)) {
mkdir($path, 0755, true);
}
// 移动文件到临时文件夹
$fileObj = $fHandler->move( $path);
if(!$fileObj){
return $this->buildFailed( '移动文件失败',$fileObj,'');
}
$postData= $this->request->post();
$businessNo = $postData['business_no'];
$company_Code = $postData['company_code'];
$business_type = $postData['business_type'];
$return_report_type = !empty($postData['return_report_type'])?$postData['return_report_type']:'00';
$status = '03';
$M_InquiryResult = new CebInquiryResult();
$irInfo = $M_InquiryResult->findInfoByBusinessNo( $businessNo );
if( null == $irInfo)
{
return $this->buildFailed('找不到编号:[' . $businessNo . "]关联的银行询价请求,请先联系银行客户经理");
}
$order_no = $this->getInquiryNoById($irInfo['quot_id']);
if(empty($order_no)) {
return $this->buildFailed('找不到编号:[' . $businessNo . "]关联的询价,请先录入询价单");
}
$res['inquiryNo'] = $order_no[0]['order_no'];
$ceb = new CebReportResult();
$res = $ceb->buildResult($irInfo['quot_id'], $businessNo,$business_type);
//组装数据
//上传清单文件到SFTP
$remote_file= $res['estimate_report_path'].$res['estimate_report_name'].'.'.$res['estimate_report_end'];//$reevaluateFilePath . $ceb->getReportFileName( $businessNo,$company_Code,'04' );//$reevaluateFileName . $company_Code . '.' . $reevaluateFileEnd;
$local_file = $path . DS . $fileObj->getSaveName();
// 发送文件到sftp
$cebapi = new CEBApi();
$sendFtpSucc = $cebapi->sendFileToFtp($local_file, $res['estimate_report_path'] , $remote_file);
if(!$sendFtpSucc) {
return $this->buildFailed('发送文件到FTP失败');
}
if(isset($res['quot_id'])) {
unset($res['quot_id']);
}
$res['return_report_type'] = $return_report_type;
$response = $cebapi->sendReportResult($res);
if (is_string($response)){
$response = json_decode($response,true);
}
if(empty($response['http_code']) && (!empty($response['result']) && $response['result'] == '01')){
$res['quot_id'] = $irInfo['quot_id'];
$insertSuccess = $ceb->insertResult($res);
if( !$insertSuccess) {
return $this->buildFailed('写数据库失败',$res,'');
}
// 更新报告申请状态
if($return_report_type == "00") {
$M_reportApply = new CebReportApply();
$M_reportApply->updateIsDoneByBusinessNo($businessNo, $business_type, CebReportApply::$IS_RETURN_YES);
}else{
$cebEsz012Apply = new CebEsz012Apply();
$cebEsz012Apply->updateStatus($businessNo,$business_type,CebEsz012Apply::DONE);
}
return $this->buildSuccess($response);
}else {
return $this->buildFailed('发送数据失败',$response);
}
}
public function testEsz006()
{
$postData= $this->request->post();
$quot_id = $postData['quot_id'];
$businessNo = $postData['business_no'];
$business_type = $postData['business_type'];
$ceb = new CebReportResult();
var_dump( $ceb->buildResult($quot_id, $businessNo,$business_type) );
}
/**
* 获取光大所有银行的未完成请求列表
*
* @return [array] 返回多个未处理银行请求的数量
*/
public function getCebRequestList()
{
$res = [];
$ceb_inquiry = new CebInquiryApply();
$res['new_inquiry_count'] = $ceb_inquiry->getNewInquiryCount();
$ceb_report = new CebReportApply();
$res['new_report_count'] = $ceb_report->getNewReportCount();
return $this->buildSuccess($res);
}
/***
*2.2.3 核价返回申请
评估公司在接收到行方发起的核价请求后,通过该接口向行方发起核价结果返回请求,将核价结果返回给行方
{地址}/webapi/Cebbank/ESZ009/returnESZ009Info
*businessNo 业务编号 是 String 32 回显
companyCode 评估公司编号 是 String 10 回显
estimateDealNo 评估交易编号 是 String 32 评估公司编号+自定义编号
checktotalPrice 核价评估总价 否 NUMBER (18,2) “核价成功”时必填
checkchargeAmt 核价收费金额 否 NUMBER (18,2) 该笔业务评估预计支付费用 “核价成功”时必填
checkStatus 核价状态 是 String 2 01-核价成功
02-核价失败
field1 预留字段1 否 String 100
field2 预留字段2 否 String 100
field3 预留字段3 否 String 100
checkTime 核价时间 是 Timestamp 6 评估公司返回核价结果时的系统时间
*
*/
public function esz009() {
$postData= $this->request->post();
$businessNo = $postData['businessNo'];
$estimateDealNo = $postData['estimateDealNo'];
$inquiryNo = substr($estimateDealNo,2);
$companyCode = $postData['companyCode'];
$ceb = new CebCheckResult();
$res = null;
if(isset($postData['reason'])){
$reason = $postData['reason'];
$res = $ceb->buildFailedCheckResult($businessNo, $inquiryNo, $companyCode, $reason);
}else {
$res = $ceb->buildCheckResult($businessNo, $inquiryNo, $companyCode);
}
$cebapi = new CEBApi();
$response = $cebapi->sendCheckResult($res);
if (is_string($response)){
$response = json_decode($response,true);
}
if(empty($response['http_code']) && (!empty($response['result']) && $response['result'] == '01')){
$insertSuccess = $ceb->insertCheckResult($res);
if( !$insertSuccess) {
return $this->buildFailed('写数据库失败',$res,'');
}
$cebCheckApply = new CebCheckApply();
$cebCheckApply->updateCheckApplyStatus($businessNo, 2);
return $this->buildSuccess($response);
}else {
return $this->buildFailed('发送数据失败',$response);
}
}
/**
* 用于验证光大的esz006接口
*
* */
public function createFake()
{
// testing
$makeTime = "2022-10-10 00:00:00";
var_dump( date('Y-m-d', strtotime( $makeTime."+1 year")));
return;
$res = [];
$res ['businessNo'] = '10109021992130629222402';
// $res ['businessNo'] = '20109021942257838080002';
$res ['companyCode'] = '04';
$res ['estimateDealNo'] = '2023-GY032000020';
$res ['businessType'] = '03';
$res ['unitPrice'] = '10000';
$res ['totalPrice'] = '110000000';
$res ['totalTax'] = '19990';
$res ['detailTax'] = '个税999元;土地增值税:111';
$res ['chargeAmt'] = '800';
// $res ['estimateReportName'] = '201090219422578380800010403';
$res ['estimateReportName'] = '2010902194225783808000203_01';
$res ['estimateReportEnd'] = 'pdf';
$res ['estimateReportPath'] = '/cebbank/inLoan/send/20230329/';
$res ['mortgagor1'] = '张三';
$res ['mortgagor2'] = '李四';
$res ['mortgagor3'] = '王五';
$res ['mortgagor4'] = '琴亿';
$res ['mortgagor5'] = '方凯';
$res ['resultStatus'] = '01';
$res ['reason'] = '';
$res ['field1'] = 'f1';
$res ['field2'] = '';
$res ['field3'] = '';
$res ['field3'] = '';
$res ['estimateTime'] = '2023-03-29 10:32:23';
$cebapi = new CEBApi();
$cebapi->sendToCEB($cebapi->getURLESZ006(),$res,"ESZ006");
}
/**
* 用于验证光大的esz004接口
*
* @return void
*/
public function createFake004()
{
$res = [];
$res ['businessNo'] = '10109021992130629222402'; // ---需要改
$res ['companyCode'] = '04';
$res ['estimateDealNo'] = '2023-GY032000020';
$res ['businessType'] = ''; // ---需要改
$res ['certificateNo'] = '粤2023深圳市不动产第10002号';//'深房地字第22003009号';
$res ['totalPrice'] = '110000000';
$res ['chargeAmt'] = '800';
$res ['status'] = '01';
$res ['evaluatorName'] = '陈晓明';
$res ['telephoneNumber'] = '17655544454';
$res ['field1'] = 'f1';
$res ['field2'] = '';
$res ['field3'] = '';
$res ['estimateTime'] = '2023-03-29 10:32:23';
$cebapi = new CEBApi();
$cebapi->sendToCEB($cebapi->getURLESZ004(),$res,"ESZ004");
}
/**
* 检查上传文件
*
* @param [type] $reqFileHandler
* @param [type] $path ROOT_PATH . 'public' . DS . 'uploads' ;//存放路径
* @return [obj] { [int]code:1 成功 ; 0 失败; [string]errMsg: }
*/
private function checkUploadFile( $reqFileHandler, $path )
{
$res = [ 'code'=>1, 'errMsg'=>'','fileObj'=>null];
if(null == $path || ''==$path )
{
$res['code'] = 0;
$res['msg'] = '文件路径异常';
return $res;
}
if(null == $reqFileHandler || ''==$reqFileHandler )
{
$res['code'] = 0;
$res['msg'] = $reqFileHandler;
return $res;
}
// path是否是目录
if (!is_dir($path)) {
mkdir($path, 0755, true);
}
// 移动文件失败
$fileObj = $reqFileHandler->move( $path);
if(!$fileObj){
$res['code'] = 0;
$res['msg'] = '上传文件失败';
return $res;
}
$res['fileObj'] = $fileObj;
return $res;
}
/*2.2.4 贷后重估结果返回申请
businessNo 业务编号 VARCHAR(32) Y 唯一索引
companyCode 评估公司编号 VARCHAR(10) Y
estimateDealNo 评估交易编号 VARCHAR(32) Y
reevaluatedFileName 已重估清单名称 VARCHAR(200) Y
reevaluatedFileEnd 已重估清单后缀名 VARCHAR(100) Y
reevaluatedFilePath 已重估清单路径 VARCHAR(200) Y
status 重估状态 VARCHAR(2) Y "03-重估成功 04-重估失败"
field1 预留字段1 VARCHAR(100) N
field2 预留字段2 VARCHAR(100) N
field3 预留字段3 VARCHAR(100) N
estimateTime 重估时间 timestamp(6) Y 评估公司返回重估结果时的系统时间
*/
public function testupload() {
$postData = $this->request->post();
$data['msg'] = '上传成功功';
return $this->buildSuccess($data);
}
public function rejectReevation(){
$businessNo = $this->request->post('business_no');
$companyCode = $this->request->post('company_code');
$reason = $this->request->post('reason');
//写数据库
$data['businessNo'] = $businessNo ;
$data['companyCode'] = $companyCode;
$data['reevaluatedFileName'] = '';
$data['reevaluatedFileEnd'] = '';
$data['reevaluatedFilePath'] = '' ;
$data['status'] = '04' ;
$data['estimateTime'] = date('Y-m-d H:i:s');
$data['estimateDealNo'] = $companyCode . '0000000000' . date('YmdHis');
$data['reason'] = $reason;
$data['field3'] = $reason;
//发送重估结果到光大
$cebapi = new CEBApi();
$response = $cebapi->sendReevaluateResult($data);
if (is_string($response)){
$response = json_decode($response,true);
}
if(empty($response['http_code']) && (!empty($response['result']) && $response['result'] == '01')){
$ceb = new CebReevaluateResult();
$insertSucc = $ceb->insertReevaluateResult($data);
if(!$insertSucc) {
return $this->buildFailed('写入数据库失败');
}
$cebReevaluteApply = new CebReevaluateApply();
$cebReevaluteApply->updateReevaluateApplyStatus($businessNo,2);
return $this->buildSuccess($response);
}else {
return $this->buildFailed('发送数据失败',$response);
}
}
public function esz011() {
$reevaFile = $this->request->file('reevaFile');
$path = ROOT_PATH . 'public' . DS . 'uploads' ;//存放路径
if (!is_dir($path)) {
mkdir($path, 0755, true);
}
$tmpFile = $reevaFile->move( $path);
if(!$tmpFile){
return $this->buildFailed('上传文件失败');
}
$businessNo = $this->request->post('business_no');
$companyCode = $this->request->post('company_code');
$reevaluateFileName = $this->request->post('reevaluate_file_name');
$reevaluateFileEnd = $this->request->post('reevaluate_file_end');
$reevaluateFilePath = $this->request->post('reevaluate_file_path');
$sentence = "Andrew prefers tea to coffee.";
$search = "send";
$replace = "save";
$reevaluateFilePath = str_replace($search, $replace, $reevaluateFilePath);
$status = '03';
$order_no = $this->getInquiryNo($businessNo);
if(empty($order_no)) {
return $this->buildFailed('找不到银行线上业务编号' . $businessNo . "关联的询价单,请先录入询价单");
}
$data['inquiryNo'] = $order_no[0]['order_no'];
//组装重估数据
//上传清单文件到SFTP
$remote_file=$reevaluateFilePath . $reevaluateFileName . $companyCode . '.' . $reevaluateFileEnd;
$local_file = $path . DS . $tmpFile->getSaveName();
$cebapi = new CEBApi();
$sendFtpSucc = $cebapi->sendFileToFtp($local_file, $reevaluateFilePath, $remote_file);
if(!$sendFtpSucc) {
return $this->buildFailed('发送文件到FTP失败');
}
//写数据库
$data['businessNo'] = $businessNo ;
$data['companyCode'] = $companyCode;
$data['reevaluatedFileName'] = $reevaluateFileName . $companyCode;
$data['reevaluatedFileEnd'] = $reevaluateFileEnd;
$data['reevaluatedFilePath'] = $reevaluateFilePath ;
$data['status'] = $status ;
$data['estimateTime'] = date('Y-m-d H:i:s');
$data['estimateDealNo'] = $companyCode . $data['inquiryNo'];
//发送重估结果到光大
//$cebapi = new CEBApi();
$response = $cebapi->sendReevaluateResult($data);
if (is_string($response)){
$response = json_decode($response,true);
}
if(empty($response['http_code']) && (!empty($response['result']) && $response['result'] == '01')){
$ceb = new CebReevaluateResult();
$insertSucc = $ceb->insertReevaluateResult($data);
if(!$insertSucc) {
return $this->buildFailed('写入数据库失败');
}
$cebReevaluteApply = new CebReevaluateApply();
$cebReevaluteApply->updateReevaluateApplyStatus($businessNo,2);
return $this->buildSuccess($response);
}else {
return $this->buildFailed('发送数据失败',$response);
}
}
private function getInquiryNoById($quot_id){
$res = Db::name('inquiry')
->field('order_no')
->where(['id'=>$quot_id])
->select();
return $res;
}
private function getInquiryNo($bussinessNo){
$res = Db::name('inquiry')
->field('order_no')
->where(['business_no'=>$bussinessNo])
->select();
return $res;
}
/**
* 获取询价申请列表
*
*
*/
public function getInquiryApply() {
$postData= $this->request->post();
$keyword = $this->request->post('keyword', '','trim');
$page = !empty($postData['page'])?$postData['page']:1;
$limit = !empty($postData['limit'])?$postData['limit']:10;
$handle_status = !empty($postData['handle_status'])?$postData['handle_status']:'1';
$business_no = !empty($postData['business_no'])?$postData['business_no']:'1';
$cebInquiryApply = new CebInquiryApply();
$result = $cebInquiryApply->getInquiryApply($page,$limit,$handle_status,$business_no,$keyword);
return $this->buildSuccess($result);
}
/**
* 获取询价申请列表
*
*
*/
public function getInquiryApplyList() {
$postData= $this->request->post();
$keyword = $this->request->post('keyword', '','trim');
$page = !empty($postData['page'])?$postData['page']:1;
$limit = !empty($postData['limit'])?$postData['limit']:10;
$handle_status = !empty($postData['handle_status'])?$postData['handle_status']:'1';
$business_no = !empty($postData['business_no'])?$postData['business_no']:'1';
$cebInquiryApply = new CebInquiryApply();
$result = $cebInquiryApply->getInquiryApplyList($page,$limit,$handle_status,$business_no,$keyword);
return $this->buildSuccess($result);
}
/**
* 获取询价回复列表
*
*
*/
public function getReplyInquriyList() {
$postData= $this->request->post();
$keyword = $this->request->post('keyword', '','trim');
$page = !empty($postData['page'])?$postData['page']:1;
$limit = !empty($postData['limit'])?$postData['limit']:10;
$handle_status = !empty($postData['handle_status'])?$postData['handle_status']:'1';
$cebInquiryResult = new CebInquiryResult();
$result = $cebInquiryResult->getInquiryResultList($page,$limit,$handle_status, $keyword);
return $this->buildSuccess($result);
}
/**
* 获取核价申请列表
*
*
*/
public function getCheckApplyList() {
$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']:'1';
$cebCheckApply = new CebCheckApply();
$result = $cebCheckApply->getCheckApplyList($page,$limit,$handle_status);
return $this->buildSuccess($result);
}
/**
* 获取核价回复列表
*
*
*/
public function getCheckResultList() {
$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']:'1';
$cebCheckResult = new CebCheckResult();
$result = $cebCheckResult->getCheckResultList($page,$limit,$handle_status);
return $this->buildSuccess($result);
}
/**
* 获取催办列表
*
*
*/
public function getUrgeList() {
$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']:'1';
$cebUrge = new CebUrge();
$result = $cebUrge->getUrgeList($page,$limit,$handle_status);
return $this->buildSuccess($result);
}
/**
* 获取贷后重估申请列表
*
*
*/
public function getReevaluateApplyList() {
$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']:'1';
$ceb = new CebReevaluateApply();
$result = $ceb->getReevaluateApplyList($page,$limit,$handle_status);
return $this->buildSuccess($result);
}
public function getReportApplylist2C()
{
$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']:'1';
$business_type = !empty($postData['business_type'])?$postData['business_type']:'1';
$business_no = !empty($postData['business_no'])?$postData['business_no']:'1';
$ceb = new CebReportApply();
$result = $ceb->getReportApplylist2C($page,$limit,$handle_status,$business_no,$business_type);
return $this->buildSuccess($result);
}
public function getReportApply()
{
$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']:'1';
$business_type = !empty($postData['business_type'])?$postData['business_type']:'1';
$business_no = !empty($postData['business_no'])?$postData['business_no']:'1';
$ceb = new CebReportApply();
$result = $ceb->getReportApply($page,$limit,$handle_status,$business_no,$business_type);
return $this->buildSuccess($result);
}
// public function getReportApplyList()
// {
// $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']:'1';
// $ceb = new CebReportApply();
// $quot_id = null;
// $result = $ceb->getReportApplyList($page,$limit,$quot_id);
// return $this->buildSuccess($result);
// }
public function getReportResultList()
{
$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']:'1';
$ceb = new CebReportResult();
$quot_id = null;
$result = $ceb->getResultList($page,$limit,$quot_id);
return $this->buildSuccess($result);
}
/**
* 获取贷后重估结果列表
*
*
*/
public function getReevaluateResultList() {
$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']:'1';
$ceb = new CebReevaluateResult();
$result = $ceb->getReevaluateResultList($page,$limit,$handle_status);
return $this->buildSuccess($result);
}
public function getEsz012ApplyList()
{
$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']:'1';
$business_type = !empty($postData['business_type'])?$postData['business_type']:'1';
$business_no = !empty($postData['business_no'])?$postData['business_no']:'1';
$ceb = new CebEsz012Apply();
$result = $ceb->getApplyList($page,$limit,$handle_status,$business_no,$business_type);
return $this->buildSuccess($result);
}
public function getEsz012Apply()
{
$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']:'1';
$business_type = !empty($postData['business_type'])?$postData['business_type']:'1';
$business_no = !empty($postData['business_no'])?$postData['business_no']:'1';
$apply_report_type = !empty($postData['apply_report_type'])?$postData['apply_report_type']:'01';
$ceb = new CebEsz012Apply();
$result = $ceb->getApply($business_no,$business_type,$apply_report_type);
return $this->buildSuccess($result);
}
public function getEsz012ResultList()
{
$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']:'1';
$ceb = new CebEsz012Result();
$quot_id = null;
$result = $ceb->getResultList($page,$limit,$quot_id);
return $this->buildSuccess($result);
}
public function isBusinessNoLinkInquiry() {
$postData= $this->request->post();
$business_no = $postData['business_no'];
$ceb = new CebInquiryApply();
$ret = $ceb->isBusinessNoLinkInquiry($business_no);
return $this->buildSuccess($ret);
}
public function getTotal(){
$inquiry = new CebInquiryApply();
$check = new CebCheckApply();
$report = new CebReportApply();
$reevaluate = new CebReevaluateApply();
$ret = [];
$ret['inquiry_total'] = $inquiry->getInquiryTotal()?$inquiry->getInquiryTotal():0;
$ret['check_total'] = $check->getCheckTotal()?$check->getCheckTotal():0;
$ret['report_total'] = $report->getReportTotal()?$report->getReportTotal():0;
$ret['reevaluate_total'] = $reevaluate->getReevaluateTotal()?$reevaluate->getReevaluateTotal():0;
return $this->buildSuccess($ret);
}
}