alias("cir") ->leftJoin('pg_inquiry pi','pi.business_no = cir.business_no') ->leftJoin('pg_property_cert_info pid','pid.quot_id= pi.id') ->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') ->order("time","desc") //->where($where) // ->page($page) // ->limit($limit) ->select(); return $res; } //获取用户列表 public function getUserList() { $userList = 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; } /** * 检查此Inquiry是否存在 function * * @param [type] $quot_id 请求id * @return array 返回inquiry表中 id 数组 { 1='id1', 2='id2'} * */ public function checkReportIsReady($quot_id) { $res = Db::name('inquiry') ->field('id') ->where(['id'=>$quot_id]) ->select(); return $res; } /** * 组装中国光大银行询价结果 * 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 评估公司返回评估结果时的系统时间 * @Author owen * @DateTime 2023-03-13 * @version 2.0 * @param string $preEstimateNo 预评估编号 * @return object */ /** * 预告 */ public const BUSINESS_TYPE_PREREPORT = '03'; // /** * 正式预告 */ public const BUSINESS_TYPE_REPORT = '04'; public function builfFailedResult($businessNo,$estimateDealNo,$businessType,$reason,$report_type){ $ret['business_no'] = $businessNo; $ret['company_code'] = '04'; $ret['business_type'] = $businessType; //业务类型 03-贷中预评估 04-正式评估 $ret['estimate_deal_no'] = $estimateDealNo;//评估交易编号 $ret['return_report_type' ] = $report_type; $ret['eva_total_value'] = '0'; $ret['eva_unit_price'] = '0';//评估单价 $ret['total_tax'] = '0'; $ret['detail_tax'] = ''; $ret['charge_amt'] = "0"; $ret['return_report_type'] = $this->where('business_no',$businessNo)->value('return_report_type'); $ret['guide_price'] = '0'; $ret['eva_net_value'] = '0'; $ret['field1'] = date('Y-m-d H:i:s');//光大银行要求如果是退回操作,填写当前日期 $ret['field2'] = ""; $ret['field3'] = ""; $ret['estimate_report_name'] = ''; $ret['estimate_report_end'] = ''; $ret['estimate_report_path'] = ''; $ret['mortgagor1'] = ''; $ret['mortgagor2'] = ''; $ret['mortgagor3'] = ''; $ret['mortgagor4'] = ''; $ret['mortgagor5'] = ''; $ret['mortgagor6'] = ''; $ret['estimate_time'] = date('Y-m-d H:i:s'); $ret['result_status'] = '02'; $ret['handle_status'] = '2'; $ret['reason'] = $reason; return $ret; } /** * 组装报告结果数据 function * * @param [type] $quot_id 请求id * @param [type] $businessNo 业务id * @return void */ public function buildResult($quot_id, $businessNo, $business_type) { $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,eva_total_value, appraiser_name, create_time,total_taxes1,eva_unit_price from `pg_return_price` t1 INNER JOIN (select max(create_time) as lastUpdate from `pg_return_price` GROUP BY property_cert_info_id) t2 ON t2.lastUpdate = t1.create_time ) as rp', 'rp.property_cert_info_id=d.id') ->field('i.estimated_no, i.order_no, rp.eva_total_value, rp.appraiser_name, rp.create_time, rp.total_taxes1, rp.eva_unit_price, rp.guide_price, rp.area, rp.eva_total_value, d.obligee ') ->where('i.id',$quot_id) ->selectOrFail(); $res = $res[0]; $ri = Db::name('ceb_report_apply') ->field('business_no,company_code,estimate_deal_no,business_type,file_name,file_end,file_path') ->where(['business_no' => $businessNo, 'business_type' => $business_type]) ->selectOrFail(); $total_info = $this->getTotalReturnPrice( $quot_id ); $ri = $ri[0]; $ret['business_no'] = $ri['business_no']; $ret['company_code'] = $ri['company_code']; $ret['business_type'] = $business_type; //业务类型 03-贷中预评估 04-正式评估 $ret['estimate_deal_no'] = $ri['estimate_deal_no'];//评估交易编号 $ret['eva_total_value'] = strval($total_info['total_all_assestment']); //strval($res['eva_total_value']); $ret['eva_unit_price'] = strval($res['eva_unit_price']);//评估单价 $ret['total_tax'] = strval($total_info['total_all_tax']);//strval($res['total_taxes1']); // 总税费 $ret['detail_tax'] = $this->getTaxDetailStr($quot_id); $ret['charge_amt'] = "600.00"; $ret['guide_price'] = sprintf('%.2f',$res['guide_price']*$res['area']); $ret['eva_net_value'] = strval($res['eva_total_value']); $ret['evaluator_name'] = $res['appraiser_name']; $ret['estimate_report_name'] = $this->getReportFileName($ret['business_no'] , $ret['company_code'],$ret['business_type'] ); $ret['estimate_report_end'] = 'pdf'; $report = new Report(); $makeTime = $report->getReportMakeTimeByInquiryDetailID( $quot_id ); $ret['field1'] = date('Y-m-d', strtotime( $makeTime."+1 year"));// if($business_type =='03'){ $ret['estimate_report_path'] = '/cebbank/inLoan/save/' . date('Ymd') . '/'; }else { $ret['estimate_report_path'] = '/cebbank/formLoan/save/' . date('Ymd') . '/'; } $ret['reason'] = ''; // 如果业务类型是报告,才显示权利人 if( CebReportResult::BUSINESS_TYPE_REPORT == $business_type) { //抵押人(权利人) $mortgagor_list = explode(',',$res['obligee']);//权利人 for($i=0;$i < 6;$i++) { if($igetUserPhone($res['appraiser_name']); $ret['telephone_number'] = $phone; $ret['estimate_time'] = date('Y-m-d H:i:s',$res['create_time']); $ret['result_status'] = '01'; $ret['handle_status'] = '2'; return $ret; } /** * 通过 Inquiry_id 获取资产总值和税费总值 * * @param [int] $inquiryID * @return [array] [total_all_assestment,total_all_tax ] */ private function getTotalReturnPrice( $inquiryID) { $tRp = new ReturnPrice(); $property_cert_info = new Property_cert_info(); $detailList = $property_cert_info->getListByInquiryID( $inquiryID ); $total_all_assestment = 0; $total_all_tax = 0; foreach( $detailList as $detail ) { $rprice = $tRp->getNewInfoByInquiryDetailID( $detail['id'] ); $total_all_assestment += $rprice['eva_total_value']; $total_all_tax += $rprice['total_taxes1']; } return [ 'total_all_assestment'=>$total_all_assestment, 'total_all_tax'=>$total_all_tax ]; } public static $TAX_COL = [ 'corporate_income_tax',//企业所得税 'urban_construction_tax',//城建税 'deed_tax',//契税 'stamp_duty',//印花税 'land_value_added_tax',//土地增值税 'personal_income_tax',//个人所得税 'added_tax',//增值税 'edu_surcharge',//教育附加税 ]; public static $TAX_COL_STR = [ '企业所得税', '城建税', '契税', '印花税', '土地增值税', '个人所得税', '增值税', '教育附加税' ]; /** * 获取税费的文字说明 function * * @param [type] $quot_id * @return []string] (土增税:xxx元;个人所得税:xxxxx元) */ private function getTaxDetailStr( $quot_id ) { $iDetailInfo = Db::name('property_cert_info')->where(['quot_id'=>$quot_id])->field('id')->select(); if( 0 ==count($iDetailInfo) ) { return ""; } $rpList = Db::name('return_price')->where(['property_cert_info_id'=> $iDetailInfo[0]['id']])->order('create_time','desc')->select(); if( 0== count($rpList)) { return ""; } $totalTaxList = []; $idx = 0; // 计算税费总值 for($idx=0;$idxwhere('business_no',$businessNo)->delete(); } public function insertResult($data){ // var_dump($data); Db::startTrans(); $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->return_report_type = $data['return_report_type']; $this->eva_unit_price = $data['eva_unit_price']; $this->eva_total_value = $data['eva_total_value']; $this->total_tax = $data['total_tax']; $this->detail_tax = $data['detail_tax']; $this->charge_amt = $data['charge_amt']; $this->result_status = $data['result_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->reason = $data['reason']; $this->estimate_report_name = $data['estimate_report_name']; $this->estimate_report_end = $data['estimate_report_end']; $this->estimate_report_path = $data['estimate_report_path']; $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; } } ?>