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

157 lines
4.5 KiB
PHP

<?php
namespace app\model;
use think\Db;
use think\db\Where;
class CebEsz012Apply extends Base
{
const BUSINESS_TYPE_PRE_EVATION = "03"; //03-贷中预评估 04-正式评估
const BUSINESS_TYPE_FORMAL = "04";
const APPLY_REPORT_TYPE_REDO = "01"; // 01-重传报告 02-查勘现场预估单
const APPLY_REPORT_TYPE_SURVEY = "02";
// 未处理
const NOT_DONE = 1;
//已处理
const DONE = 2;
/**
* 获取未处理请求数量
*
* @return void
*/
public function getNotDoneApplyCount()
{
return Db::name('ceb_esz012_apply')->where(['status'=>'1'])->count();
}
/**
* 获取业务号关联的申请
* @Author llz
* @DateTime 2023-06-09
* @version 2.0
* @param array $field 查询字段值
* @param array $where 查询条件
* @param array $paginate 分页设置
* @return array
*/
public function getApply($business_no,$business_type,$apply_report_type){
$where = new Where();
if($business_type != '1') {
$where['cra.business_type'] = $business_type;
if($business_type == "04") {
$where['cra.apply_report_type'] = "01";
}else {
$where['cra.apply_report_type'] = $apply_report_type;
}
}
$where['cra.is_done'] = 1;
$where['cra.business_no'] = $business_no;
$res = Db::name('ceb_esz012_apply')->alias('cra')
->leftJoin('pg_inquiry pi','pi.business_no = cra.business_no')
->leftJoin('pg_property_cert_info pid','pid.quot_id= pi.id')
->field('cra.*,if(cra.update_time,cra.update_time,cra.create_time) as time')
->field('pid.property_full_name,pi.bank_name,pi.bank_sub_name,pi.bank_customer_mgr_name')
->order('is_done','asc')
->order("time","desc")
->where($where)
->select();
return $res;
}
/**
* 获取申请列表
* @Author llz
* @DateTime 2023-06-20
* @version 2.0
* @param array $field 查询字段值
* @param array $where 查询条件
* @param array $paginate 分页设置
* @return array
*/
public function getApplyList($page,$limit,$handle_status,$business_no,$business_type){
$where = new Where();
if($business_type != '1') {
$where['cra.business_type'] = $business_type;
}
if($business_no != '1') {
$where['cra.business_no'] = $business_no;
}
$res = Db::name('ceb_esz012_apply')->alias('cra')
->leftJoin('pg_inquiry pi','pi.business_no = cra.business_no')
->leftJoin('pg_property_cert_info pid','pid.quot_id= pi.id')
->field('cra.*,if(cra.update_time,cra.update_time,cra.create_time) as time')
->field('pid.property_full_name,pi.bank_name,pi.bank_sub_name,pi.bank_customer_mgr_name')
->order('is_done','asc')
->order("time","desc")
->where($where)
// ->page($page)
// ->limit($limit)
->select();
return $res;
}
/**
* 更新报告状态
*
* @param [type] $business_no
* @param [type] $status 枚举[ NOT_DONE ; DONE ]
* @return void
*/
public function updateStatus($business_no, $business_type, $status) {
$where = new Where();
$where['business_no'] = $business_no;
$where['business_type'] = $business_type;
$res = Db::name('ceb_esz012_apply')->where($where)
->update(['is_done' => $status]);
}
public function addApply(array $data){
Db::startTrans();
$this->business_no = $data['businessNo'];
$this->company_code = $data['companyCode'];
$this->estimate_deal_no = $data['estimateDealNo'];
$this->business_type = $data['businessType'];
$this->apply_report_type = $data['applyReportType'];
if (isset($data['field1'])) {
$this->field1 = $data['field1'];
}
if (isset($data['field2'])) {
$this->field2 = $data['field2'];
}
if (isset($data['field3'])) {
$this->field3 = $data['field3'];
}
if (isset($data['createTime']))
{
$this->create_date = $data['createTime'];
}
$this->is_done = self::NOT_DONE;
$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;
}
public function getTotalApply(){
return Db::name('ceb_esz012_apply')->count();
}
}
?>