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

299 lines
14 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\model;
use think\Db;
use think\db\Where;
use app\lib\AuthApi;
use think\Cache;
class CebInquiryResult extends Base
{
//获取用户列表
public function getUserList()
{
$userList = null;//cache('userList');
if (!$userList ) {
$Auth = new AuthApi();
$user_list = $Auth->getUserList();
$ret = json_decode($user_list,true);
if($ret['code'] == 200){
//cache('userList',$ret['data']);
return $ret['data'];
}else {
return null;
}
}
return $userList;
}
public function getUserPhone($nickname) {
$userList = $this->getUserList();
$arrlen = count($userList);
$phone ='unknown';
for ($i = 0; $i < $arrlen; $i += 1) {
if ($userList[$i]['userNickName'] == $nickname){
$phone = $userList[$i]['phonenumber'];
break;
}
}
return $phone;
}
/**
* 获取中国光大银行询价结果列表
* @Author llz
* @DateTime 2023-03-13
* @version 2.0
* @param array $field 查询字段值
* @param array $where 查询条件
* @param array $paginate 分页设置
* @return array
*/
public function getInquiryResultList($page,$limit,$handle_status,$keyword){
$paginate = [
'list_rows' => $limit,
'page' => $page
];
//$where = new Where();
//if(!empty($postData['keyword'])) $where['name'] = ['like',['%'.trim($postData['keyword']).'%']];
//if(!empty($postData['bank_id'])) $where['bank_id'] = ['=',trim($postData['bank_id'])];
//if(!empty($postData['bank_branch_id'])) $where['bank_branch_id'] = ['=',trim($postData['bank_branch_id'])];
//if(!empty($postData['bank_sub_id'])) $where['bank_sub_id'] = ['=',trim($postData['bank_sub_id'])];
$where = "";
if($keyword)
$where = "bussiness_no like %".$keyword."%";
$res = Db::name('ceb_inquiry_result')->alias("cir")
->leftJoin('pg_inquiry pi','pi.id = cir.inquiry_id')
->leftJoin('pg_property_cert_info pid','pid.quot_id= pi.id')
->leftJoin('pg_ceb_inquiry_apply cia','pi.business_no= cia.business_no')
->field('cir.*,if(cir.update_time,cir.update_time,cir.create_time) as time')
->field('pid.property_full_name,pi.bank_name,pi.bank_sub_name,pi.bank_customer_mgr_name,cia.business_line_type as business_line_type')
->order("time","desc")
->where($where)
->where('cir.update_time','>','2023-06-30')
->paginate($paginate);
return $res;
}
public function checkInquiryIsReady($pre_estimate_no) {
$res = Db::name('inquiry')
->field('id')
->where(['estimated_no'=>$pre_estimate_no])
->select();
return $res;
}
public function checkReportIsReady($quot_id) {
$res = Db::name('report')
->field('id')
->where(['quot_id'=>$quot_id])
->select();
return $res;
}
/**
* 通过业务编号,获取询价回复信息
*
* @param [string] $business_no 业务编号
* @return [array] 返回null或array (使用 find()方法)
*/
public function findInfoByBusinessNo( $business_no )
{
return Db::name('ceb_inquiry_result')->where(['business_no'=>$business_no])->find();
}
/**
* 组装中国光大银行询价结果
* 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 buildInquiryFailResult($businessNo,$reason,$userName,$userPhone) {
$ri = Db::name('ceb_inquiry_apply')
->field('business_no,company_code,business_type,certificate_no')
->where('business_no',$businessNo)
->selectOrFail();
$ri = $ri[0];
$ret['business_no'] = $ri['business_no'];
$ret['company_code'] = $ri['company_code'];
$ret['business_type'] = $ri['business_type'];
// if ($ri['business_type']) {
//
// }
$ret['unitPriceDetail'] = "0";
$ret['guidedUnitPriceDetail'] = "0";
$ret['certificate_no'] = $ri['certificate_no'];
$ret['estimate_deal_no'] = $ri['company_code'] . '0000000000' . date('YmdHis');
$ret['eva_total_value'] = "0";
$ret['charge_amt'] = "0";
$ret['guide_price'] = "0";
$ret['eva_net_value'] = "0";
$ret['evaluator_name'] = $userName;
$ret['telephone_number'] = $userPhone;
$ret['estimate_time'] = date('Y-m-d H:i:s');;
$ret['status'] = '02';
$ret['reason'] = $reason;
$ret['handle_status'] = '2';
$ret['quot_id'] = 99999999;
return $ret;
}
private function buildInquiryDetail($quot_id,$inquiryNo,$businessNo) {
$res = Db::name('inquiry')->alias('i')
->leftJoin('pg_property_cert_info d', 'i.id=d.quot_id')
->leftJoin('(select property_cert_info_id,eva_unit_price,eva_total_value,guide_price*area as guide_price,eva_total_value,
appraiser_name, create_time
from `pg_return_price` t1
where t1.create_time = (select max(create_time) as lastUpdate
from `pg_return_price` where property_cert_info_id =t1.property_cert_info_id)
) as rp', 'rp.property_cert_info_id=d.id')
->field('
i.id,
i.estimated_no,
i.order_no,
d.property_cert,
rp.guide_price,
rp.eva_unit_price,
rp.eva_total_value,
rp.eva_total_value,
rp.appraiser_name,
rp.create_time
')
->where('i.id',$quot_id)
->selectOrFail();
$unitPriceDetail = "";
$guidedUnitPriceDetail = "";
for ($i = 0, $count = count($res); $i < $count; ++$i) {
$unitPriceDetail = $unitPriceDetail . $res[$i]['property_cert'] . ":" . sprintf("%.2f",$res[$i]['eva_unit_price']) . ";";
$guidedUnitPriceDetail = $guidedUnitPriceDetail . $res[$i]['property_cert'] . ":" . sprintf("%.2f",$res[$i]['guide_price']) . ";";
}
$result = array();
$result['unitPriceDetail'] = $unitPriceDetail;
$result['guidedUnitPriceDetail'] = $guidedUnitPriceDetail;
return $result;
}
public function buildInquiryResult($quot_id,$inquiryNo,$businessNo) {
$res = Db::name('inquiry')->alias('i')
->leftJoin('pg_property_cert_info d', 'i.id=d.quot_id')
->leftJoin('(select property_cert_info_id,eva_total_value,guide_price*area as guide_price,eva_total_value,
appraiser_name, create_time
from `pg_return_price` t1
where t1.create_time = (select max(create_time) as lastUpdate
from `pg_return_price` where property_cert_info_id =t1.property_cert_info_id)
) as rp', 'rp.property_cert_info_id=d.id')
->field('
i.id,
i.estimated_no,
i.order_no,
sum(rp.guide_price) as guide_price,
sum(rp.eva_total_value) as eva_total_value,
sum(rp.eva_total_value) as eva_total_value,
rp.appraiser_name,
rp.create_time
')
->where('i.id',$quot_id)
->group('i.id')
->selectOrFail();
$res = $res[0];
$ri = Db::name('ceb_inquiry_apply')
->field('business_no,company_code,business_type,certificate_no,interface_type')
->where('business_no',$businessNo)
->selectOrFail();
$ri = $ri[0];
$ret['quot_id'] = $res['id'];
$ret['business_no'] = $ri['business_no'];
$ret['company_code'] = $ri['company_code'];
$ret['business_type'] = $ri['business_type'];
if($ri['business_type'] == "02" && $ri['interface_type'] != 3) {
$detail = $this->buildInquiryDetail($quot_id,$inquiryNo,$businessNo);
$ret['unitPriceDetail'] = $detail['unitPriceDetail'];
$ret['guidedUnitPriceDetail'] = $detail['guidedUnitPriceDetail'];
}else {
$ret['unitPriceDetail'] = "0";
$ret['guidedUnitPriceDetail'] = "0";
}
$ret['certificate_no'] = $ri['certificate_no'];
$ret['estimate_deal_no'] = $ri['company_code'] . $res['order_no'];
$ret['eva_total_value'] = strval($res['eva_total_value']);
$ret['charge_amt'] = "600.00";
$ret['guide_price'] = sprintf("%.2f",$res['guide_price']);
$ret['eva_net_value'] = strval($res['eva_total_value']);
$ret['evaluator_name'] = $res['appraiser_name'];
$phone = $this->getUserPhone($res['appraiser_name']);
$ret['telephone_number'] = $phone;
$ret['estimate_time'] = date('Y-m-d H:i:s',$res['create_time']);
$ret['status'] = '01';
$ret['handle_status'] = '2';
return $ret;
}
public function deleteInquiryResult($businessNo) {
Db::name('ceb_inquiry_result')->where('business_no',$businessNo)->delete();
}
/**
**`id` int(11) NOT NULL,
** `business_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '业务编号',
** `company_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '评估公司编号',
** `estimate_deal_no` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '评估交易编号',
** `business_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '业务类型',
** `certificate_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '房产证书编号',
** `eva_total_value` decimal(18, 2) NULL DEFAULT NULL COMMENT '评估总价',
** `charge_amt` decimal(18, 2) NULL DEFAULT NULL COMMENT '收费金额',
** `status` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '评估状态01询价成功02询价失败',
** `evaluator_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '评估师姓名',
** `telephone_number` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '评估师电话',
** `field1` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段 1',
** `field2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段 2',
** `field3` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段 3',
** `estimate_time` datetime(0) NOT NULL COMMENT '评估公司评估时间',
** `handle_status` tinyint(1) NULL DEFAULT 1 COMMENT '询价结果是否上传1未上传2已上传',
** `reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '询价结果上传失败原因',
** `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
** `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
*/
public function insertInquiryResult($data){
Db::startTrans();
$this->quot_id = $data['quot_id'];
$this->business_no = $data['business_no'];
$this->company_code = $data['company_code'];
$this->estimate_deal_no = $data['estimate_deal_no'];
$this->business_type = $data['business_type'];
$this->certificate_no = $data['certificate_no'];
$this->eva_total_value = $data['eva_total_value'];
$this->charge_amt = $data['charge_amt'];
$this->guide_price = $data['guide_price'];
$this->eva_net_value = $data['eva_net_value'];
$this->status = $data['status'];
$this->evaluator_name = $data['evaluator_name'];
$this->telephone_number = $data['telephone_number'];
$this->estimate_time = $data['estimate_time'];
$this->handle_status = $data['handle_status'];
$this->create_time = date('Y-m-d H:i:s');
$this->update_time = date('Y-m-d H:i:s');
if (!$this->save()){
Db::rollback();
return false;
}
Db::commit();
return true;
}
}
?>