getQueryDateTime(); $keyword=input('keyword'); $bill_status=input('bill_status'); $where=[]; if (!in_array("ROLE_ADMIN", $this->userInfo['roleCode'])) { if (in_array("general_manager_CSPG", $this->userInfo['roleCode'])) { $where['b.bill_cate_type'] = 2; } elseif(in_array("Finance_CSPG", $this->userInfo['roleCode'])) { $where['b.bill_cate_type'] = 1; } else { $user_ids = array($this->userInfo['user_id']); //$this->userInfo['user_ids'] ? implode(',', $this->userInfo['user_ids']) : ''; $where['b.salesman_id'] = ['in', $user_ids]; } } !empty($salesman_name) && $where['b.salesman_name']=['like','%'.$salesman_name.'%']; !empty($bill_type) && $where['b.bill_type']=$bill_type; !empty($paramTime) && $where['b.apply_time']=$paramTime; !empty($keyword) && $where['b.order_no']=['like','%'.$keyword.'%']; $bill_status && $where['b.bill_status']=$bill_status; $fields='b.bill_id,b.order_no,b.estate_name,b.bill_type,b.bill_cate,b.apply_time,b.salesman_name,b.bill_no,bd.bill_amount,bd.bill_title,bd.create_time,b.recipient_name,b.reject_reason,b.get_bill_time,bd.invoice_type,b.bill_status, i.bank_name as i_bank_name,i.bank_branch_name,i.bank_sub_name'; $res=BillModel::getBillList($fields,$where,$this->getPage()); if($res){ return $this->buildSuccess(['list' => $res['data'], 'count' => $res['total']]); }else{ return $this->buildFailed('查无数据'); } } // 已取发票数据导出 public function billExport(){ $salesman_name=input('user_name'); $bill_type=input('bill_type'); $paramTime=$this->getQueryDateTime(); $keyword=input('keyword'); $bill_status=input('bill_status'); $where=[]; if (!in_array("ROLE_ADMIN", $this->userInfo['roleCode'])) { if (in_array("general_manager_CSPG", $this->userInfo['roleCode'])) { $where['b.bill_cate_type'] = 2; } elseif(in_array("Finance_CSPG", $this->userInfo['roleCode'])) { $where['b.bill_cate_type'] = 1; } else { $user_ids = array($this->userInfo['user_id']);//$this->userInfo['user_ids'] ? implode(',', $this->userInfo['user_ids']) : ''; $where['b.salesman_id'] = ['in', $user_ids]; } } !empty($salesman_name) && $where['b.salesman_name']=['like','%'.$salesman_name.'%']; !empty($bill_type) && $where['b.bill_type']=$bill_type; !empty($paramTime) && $where['b.apply_time']=$paramTime; !empty($keyword) && $where['b.order_no']=['like','%'.$keyword.'%']; $bill_status && $where['b.bill_status']=$bill_status; $fields='b.bill_id,b.order_no,b.building_name,b.bill_type,b.bill_cate,b.apply_time,b.salesman_name,b.bill_no,bd.bill_amount,bd.bill_title,bd.create_time,b.recipient_name,b.reject_reason,b.get_bill_time,bd.invoice_type,b.bill_status, i.bank_name as i_bank_name,i.bank_branch_name,i.bank_sub_name'; $res=BillModel::getBillList($fields, $where, ['list_rows' => 10000000, 'page' => 1]); if($res){ $indexKey = ['order_no', 'building_name', 'bill_type_str', 'bill_cate_str', 'bill_no', 'bill_amount', 'apply_time', 'bill_title', 'apply_time', 'salesman_name', 'recipient_name', 'get_bill_time']; $indexValue = ['单号', '物业名称', '票据类型', '开票种类', '票据号码', '票据金额', '开票时间', '票据抬头', '申请日期', '业务员', '领取人', '领取时间']; (new ChargeManage())->exportExcel($res['data'], date('Ymd'), $indexKey, $indexValue); } } /** * 业务管理-票据列表 * @DateTime 2020-05-07 * @param bill_status int 票据状态,4:待取,5:已取,6:驳回 * @return \think\Response * @version 2.0 */ public function businessBillList(){ $salesman_name=input('user_name'); $bill_type=input('bill_type'); $paramTime=$this->getQueryDateTime(); $keyword=input('keyword'); $bill_status=input('bill_status'); $where=[]; !empty($salesman_name) && $where['b.salesman_name']=['like','%'.$salesman_name.'%']; !empty($bill_type) && $where['b.bill_type']=$bill_type; !empty($paramTime) && $where['b.apply_time']=$paramTime; !empty($keyword) && $where['b.order_no']=['like','%'.$keyword.'%']; if (!in_array("ROLE_ADMIN", $this->userInfo['roleCode'])) { $user_ids = array($this->userInfo['user_id']);// $this->userInfo['user_ids'] ? implode(',', $this->userInfo['user_ids']) : []; $where['b.salesman_id'] = ['in', $user_ids]; //权限 } $bill_status && $where['b.bill_status']=$bill_status; $fields='b.bill_id,b.order_no,b.building_name,b.bill_type,b.bill_cate,b.apply_time,b.salesman_name,b.bill_no,bd.bill_amount,bd.bill_title,bd.create_time,b.recipient_name,b.reject_reason,b.get_bill_time,bd.invoice_type,b.bill_status, i.bank_name as i_bank_name,i.bank_branch_name,i.bank_sub_name'; $res=BillModel::getBillList($fields,$where,$this->getPage()); if($res){ return $this->buildSuccess(['list' => $res['data'], 'count' => $res['total']]); }else{ return $this->buildFailed('查无数据'); } } /** * 票据详情 * @Author pser * @DateTime 2020-05-07 * @return \think\Response * @version 2.0 */ public function billDetail(){ $bill_id=input('bill_id'); if(empty($bill_id)){ return $this->buildFailed('id不能为空'); } $where['b.bill_id']=$bill_id; $fields='b.bill_id,b.bank_customer_mgr_name,b.order_no,b.building_name,b.bill_type,b.bill_cate,b.salesman_name,b.department_name,b.pay,b.confirm_pay,b.paid_status,bd.bill_amount,bd.taxpayer_no,bd.tel,bd.bank_name,bd.bank_account,bd.company_addr,bd.apply_reason,b.bill_no,bd.bill_title,bd.invoice_type,bd.bill_attachment, i.bank_name as i_bank_name,i.bank_branch_name,i.bank_sub_name,bd.bill_content'; $res=BillModel::getBillList($fields,$where,[]); if($res){ //只有一条结果,取第一条返回 return $this->buildSuccess($res['data'][0]); }else{ return $this->buildFailed('查无数据'); } } /** * 申请驳回 * @Author pser * @DateTime 2020-05-07 * @return \think\Response * @version 2.0 */ public function back(){ $bill_id=input('bill_id'); $reject_reason=input('reject_reason'); if(empty($bill_id)){ return $this->buildFailed('id不能为空'); } if(empty($reject_reason)){ return $this->buildFailed('驳回原因不能为空'); } // Db::startTrans(); // $billIdArr=explode(',',$bill_id); // foreach ($billIdArr as $k => $v) { // try{ // $where['bill_id']=$v; // $where['bill_status']=6; // $where['reject_reason']=$reject_reason; // $res=Db::name('bill')->update($where); // if($res===false){ // Db::rollback(); // return $this->buildFailed('保存失败'); // } // }catch(\Exception $e){ // Db::rollback(); // return $this->buildFailed('保存失败'); // } // } // Db::commit(); // return $this->buildSuccess(); $where['bill_id'] = $bill_id; $where['bill_status'] = 6; $where['reject_reason'] = $reject_reason; $where['update_time'] = date('Y-m-d H:i:s'); $bill_data = Db::name('bill')->where(['bill_id'=>$bill_id])->find(); // 获取询价id $quot_id = Db::name('inquiry')->where(['order_no'=>$bill_data['order_no']])->field('id')->find(); // 判断开票种类是常规开票还是非常规开票 if ($bill_data['bill_cate'] == 1) { // 常规开票 if (!in_array("Finance_CSPG", $this->userInfo['roleCode'])) { return $this->buildFailed('常规开票只有财务有操作权限'); } $where['financial_reviewer'] = $this->userInfo['user_name']; $where['financial_reviewer_id'] = $this->userInfo['user_id']; $message_type = 28; } else { // 非常规开票,校验总经理是否已经审核通过 if ($bill_data['bill_cate_type'] == 1) { if (!in_array("Finance_CSPG", $this->userInfo['roleCode'])) { return $this->buildFailed('只有财务有操作权限'); } $where['financial_reviewer'] = $this->userInfo['user_name']; $where['financial_reviewer_id'] = $this->userInfo['user_id']; $message_type = 28; } else { if (!in_array("general_manager_CSPG", $this->userInfo['roleCode'])) { return $this->buildFailed('只有总经理有操作权限'); } $where['manager_reviewer'] = $this->userInfo['user_name']; $where['manager_reviewer_id'] = $this->userInfo['user_id']; $message_type = 25; } } $update_result = Db::name('bill')->update($where); if ($update_result) { // 写入消息 PublicMessage($quot_id['id'], 9, $message_type); return $this->buildSuccess('', '驳回成功'); } else { return $this->buildFailed('驳回失败'); } } /** * 通过 * @Author pser * @DateTime 2020-05-07 * @return \think\Response * @version 2.0 */ public function agree(){ $bill_id=input('bill_id'); if(empty($bill_id)){ return $this->buildFailed('id不能为空'); } // $where['bill_id']=$bill_id; // $where['bill_status']=3; // $res=Db::name('bill')->update($where); // // if($res!==false){ // return $this->buildSuccess(); // }else{ // return $this->buildFailed('失败'); // } $where['bill_id'] = $bill_id; $where['update_time'] = date('Y-m-d H:i:s'); $bill_data = Db::name('bill')->where(['bill_id'=>$bill_id])->find(); // 获取询价id $quot_id = Db::name('inquiry')->where(['order_no'=>$bill_data['order_no']])->field('id')->find(); // 判断开票种类是常规开票还是非常规开票 if ($bill_data['bill_cate'] == 1) { // 常规开票 if (!in_array("Finance_CSPG", $this->userInfo['roleCode'])) { return $this->buildFailed('常规开票只有财务有操作权限'); } $where['bill_status'] = 3; $where['financial_reviewer'] = $this->userInfo['user_name']; $where['financial_reviewer_id'] = $this->userInfo['user_id']; $message_type = 27; } else { // 非常规开票,校验总经理是否已经审核通过 if ($bill_data['bill_cate_type'] == 1) { if (!in_array("Finance_CSPG", $this->userInfo['roleCode'])) { return $this->buildFailed('只有财务有操作权限'); } $where['bill_status'] = 3; $where['financial_reviewer'] = $this->userInfo['user_name']; $where['financial_reviewer_id'] = $this->userInfo['user_id']; $message_type = 27; } else { if (!in_array("general_manager_CSPG", $this->userInfo['roleCode'])) { return $this->buildFailed('只有总经理有操作权限'); } $where['bill_cate_type'] = 1; $where['manager_reviewer'] = $this->userInfo['user_name']; $where['manager_reviewer_id'] = $this->userInfo['user_id']; $message_type = 24; } } $update_result = Db::name('bill')->update($where); if ($update_result) { // 写入消息 PublicMessage($quot_id['id'], 9, $message_type); return $this->buildSuccess('', '通过成功'); } else { return $this->buildFailed('通过失败'); } } public function draw(){ $bill_id=input('bill_id'); $recipient_name=input('user_name'); if(empty($bill_id)){ return $this->buildFailed('id不能为空'); } if(empty($recipient_name)){ return $this->buildFailed('领取人姓名不能为空'); } Db::startTrans(); $billIdArr=explode(',',$bill_id); foreach ($billIdArr as $k => $v) { try{ $data['bill_id']=$v; $data['bill_status']=5; $data['recipient_name']=$recipient_name; $data['update_time']=date('Y-m-d H:i:s',time()); $data['get_bill_time']=$data['update_time']; $res=Db::name('bill')->update($data); if($res===false){ Db::rollback(); return $this->buildFailed('保存失败'); } }catch(\Exception $e){ Db::rollback(); return $this->buildFailed('保存失败'); } } Db::commit(); return $this->buildSuccess(); } /** * 开具票据 * @Author pser * @DateTime 2020-05-07 * @return \think\Response * @version 2.0 */ public function invoicing(){ $bill_amount=input('bill_amount'); $bill_no=input('bill_no'); $bill_id=input('bill_id'); if(empty($bill_id)){ return $this->buildFailed('id不能为空'); } if(empty($bill_amount)){ return $this->buildFailed('票据金额不能为空'); } if(empty($bill_no)){ return $this->buildFailed('票据号码不能为空'); } Db::startTrans(); $where['bill_id']=$bill_id; $where['bill_no']=$bill_no; $where['bill_status']=4; $res=Db::name('bill')->update($where); // $awhere['bill_id']=$bill_id; $awhere['bill_amount']=$bill_amount; $res1=Db::name('bill_detail')->where('bill_id',$bill_id)->update($awhere); if($res!==false && $res1!==false){ Db::commit(); return $this->buildSuccess(); }else{ Db::rollback(); return $this->buildFailed('失败'); } } public function orderList() { $data = $this->getOrderData($this->getPage()); if($data){ return $this->buildSuccess($data); }else{ return $this->buildFailed('查无数据'); } } public function export() { $data = $this->getOrderData(['list_rows' => 10000000, 'page' => 1]); $result_data = []; foreach ($data['data'] as $key=>$value) { //if ($value['estate_num'] > 1) { $buss_username = Db::name('inquiry')->where(['order_no'=>$value['order_no']])->field('buss_username')->find(); $report_id = Db::name('report')->where(['report_no'=>$value['report_no']])->field('id,borrower_name')->find(); $multi_data = Db::name('report_detail')->alias('a')->leftJoin('property_cert_info b', 'a.property_cert_info_id = b.id')->where(['a.report_id'=>$report_id['id']])->field('a.building_area,a.obligee,a.cert_no,a.property_cert,a.purchase_date,a.small_district_name,a.client,a.parcel_area,a.land_location,a.building_name as e_name,a.use_right_source,a.max_land_use_years,a.land_use_start_time,a.house_use,a.test_method,b.property_full_name,b.year,b.usage,b.id as quot_id,b.survey_user_name')->select(); $temp = []; foreach ($multi_data as $k=>$v) { $return_data = Db::name('return_price')->where(['property_cert_info_id'=>$v['quot_id']])->field('property_name,eva_unit_price,eva_total_value,eva_net_value,eva_net_value2,appraiser_name')->order(['id'=>'desc'])->find(); $survey_time = Db::name('survey')->where(['property_cert_info_id'=>$v['quot_id']])->value('complete_time'); $temp['cid'] = $value['cid']; $temp['report_no'] = $value['report_no']; $temp['report_no_str'] = $value['report_no_str']; $temp['appraisal_item'] = $v['land_location'].$v['property_full_name'].'一套'.getDictionaryName('HOUSE_USAGE', $v['usage']).'用途房地产抵押价值评估'; $temp['company'] = $value['company']; $temp['valuation_time'] = $value['valuation_time']; $temp['parcel_area'] = $v['parcel_area']; $temp['appraisal_time'] = $value['appraisal_time']; $temp['building_name'] = $v['property_full_name']; $temp['bank_name'] = $value['bank_name']; $temp['bank_branch_name'] = $value['bank_branch_name']; $temp['bank_sub_name'] = $value['bank_sub_name']; $temp['city'] = $value['city']; $temp['area'] = $value['area']; $temp['type'] = $value['type']; $temp['eva_purpose'] = $value['eva_purpose']; $temp['order_src'] = $value['order_src']; if ($k == 0) { $temp['receivable'] = $value['receivable']; $temp['received'] = $value['received']; $temp['confirm_amount'] = $value['confirm_amount']; $temp['uncollected_amount'] = $value['uncollected_amount']; $temp['check_amount'] = $value['check_amount']; } else { $temp['receivable'] = 0; $temp['received'] = 0; $temp['confirm_amount'] = 0; $temp['uncollected_amount'] = 0; $temp['check_amount'] = 0; } $temp['account_manager_id'] = $value['account_manager_id']; $temp['bank_customer_mgr_name'] = $value['bank_customer_mgr_name']; $temp['buss_username'] = $buss_username['buss_username']; $temp['user_name'] = $value['user_name']; $temp['obligee'] = $v['obligee']; // $temp['property_cert'] = $v['property_cert']; // $temp['deed_number_string'] = $value['deed_number_string']; $temp['property_cert'] = !empty($v['year']) ? $v['year'].'-'.$v['property_cert'] : $v['property_cert']; $temp['deed_number_string'] = !empty($v['year']) ? '粤('.$v['year'].')深圳市不动产权第'.$v['property_cert'].'号' : '深房地字第'.$v['property_cert'].'号'; $temp['cert_no'] = $v['cert_no']; $temp['purchase_date'] = $v['purchase_date']; $temp['e_case_code'] = $value['e_case_code']; $temp['produce_time'] = $value['produce_time']; $temp['building_area'] = $v['building_area']; $temp['eva_unit_price'] = $return_data['eva_unit_price']; $temp['eva_total_value'] = $return_data['eva_total_value']; $temp['eva_net_value'] = $return_data['eva_net_value'];//净值1 $temp['eva_net_value2'] = $return_data['eva_net_value2'];//净值2 $temp['survey_user_name'] = $v['survey_user_name']; $temp['type_str'] = $value['type_str']; $temp['property_full_name'] = $value['property_full_name']; $temp['full_estate_name_str'] = $v['property_full_name']; $temp['business_source_str'] = $value['business_source_str']; $temp['estate_num'] = $value['estate_num']; $temp['report_completion_time'] = $value['report_completion_time']; $temp['bank_customer_mgr_phone'] = $value['bank_customer_mgr_phone']; $temp['producer_name'] = $value['producer_name']; $temp['reviewer_name'] = $value['reviewer_name']; $temp['small_district_name'] = $v['small_district_name']; $temp['client'] = $v['client']; $temp['appraiser_name'] = $return_data['appraiser_name']; $temp['usage'] = getDictionaryName('HOUSE_USAGE', $v['usage']); $temp['results'] = $value['results']; $temp['pay_type'] = $value['pay_type']; $temp['pay_type_str'] = $value['pay_type_str']; $temp['business_type'] = $value['business_type']; $temp['business_type_str'] = $value['business_type_str']; $temp['bank_type_str'] = $value['bank_type_str']; $temp['is_simple'] = $value['is_simple']; $temp['is_simple_str'] = $value['is_simple_str']; $temp['remark'] = $value['remark']; $temp['report_make_score'] = $value['report_make_score']; $temp['project_leader'] = '胡轩, 邹旭焘'; $temp['valuers'] = $value['appraiser_name'].', '.$value['appraiser2_name']; $temp['remark'] = $value['remark']; $temp['local_community'] = $v['land_location'].$v['e_name']; $temp['address'] = $v['land_location'].$v['property_full_name']; $temp['unit_type'] = ''; // 户型 $temp['use_right_source'] = $v['use_right_source']; $temp['field1'] = ''; $temp['field2'] = ''; $temp['field3'] = ''; $temp['field4'] = ''; $temp['field5'] = ''; $temp['field6'] = $v['test_method']==2?'收益法':'比较法'; $temp['field7'] = '周边类似房地产市场交易活跃,交易案例丰富,适用于市场比较法。'; $temp['max_land_use_years'] = $v['max_land_use_years']; $temp['land_use_start_time'] = $v['land_use_start_time']; $temp['field8'] = ''; $temp['field9'] = ''; $temp['field10'] = ''; $temp['field11'] = ''; $temp['field12'] = ''; $temp['field13'] = ''; $temp['field14'] = ''; $temp['field15'] = '国中'; $temp['appraiser_name'] = $value['appraiser_name']; $temp['certificate_number'] = $value['certificate_number']; $temp['appraiser2_name'] = $value['appraiser2_name']; $temp['certificate_number_two'] = $value['certificate_number_two']; $temp['borrower_name'] = $report_id['borrower_name']; $temp['survey_complete'] = date('y-m-d', strtotime($survey_time)); // 剩余年限 $remain = $v['max_land_use_years'] - floor((time()-strtotime($v['land_use_start_time']))/(365*24*3600)); $temp['remain'] = $remain; $result_data[] = $temp; } } if($result_data){ $indexKey = [ 'appraisal_item', 'report_no_str', 'client', 'company', 'eva_purpose', 'eva_purpose', 'valuation_time', 'parcel_area', 'building_area', 'eva_total_value', 'receivable', 'appraisal_time', 'project_leader', 'valuers', 'remark', 'estate_num', 'city', 'area', 'local_community', 'address', 'usage', 'unit_type', // 户型new 'use_right_source', 'parcel_area', 'building_area', 'field1', 'field2', 'field3', 'field4', 'field5', 'max_land_use_years', 'land_use_start_time', 'field6', 'field7', 'field8', 'eva_unit_price', 'field9', 'eva_total_value', 'eva_total_value', 'parcel_area', 'valuation_time', 'appraisal_time', 'parcel_area', 'building_area', 'eva_total_value', 'eva_unit_price', 'address', 'client', 'field10', 'field11', 'field12', 'appraiser_name', 'certificate_number', 'appraiser2_name', 'certificate_number_two', 'field13', 'field14', // 'full_estate_name_str', // 'type_str', // 'business_type_str', // 'bank_type_str', // 'business_source_str', // 'received', // 'confirm_amount', // 'uncollected_amount', // 'check_amount', // 'pay_type_str', // 'is_simple_str', // 'eva_unit_price', // 'eva_net_value', // 'eva_net_value2', // 'bank_customer_mgr_phone', 'buss_username', 'user_name', 'survey_user_name', // 'usage', 'obligee', // 'cert_no', // 'property_cert', // 'deed_number_string', // 'purchase_date', // 'e_case_code', // 'report_completion_time', 'producer_name', 'reviewer_name', // 'small_district_name', 'appraiser_name', // 'results', // 'report_make_score', 'bank_sub_name', 'bank_customer_mgr_name', 'field15', 'borrower_name', 'building_name', 'estate_num', 'receivable', 'eva_net_value', 'survey_complete', 'remain' ]; $indexValue = [ '估价项目', '估价报告编号', '估价委托人', '房地产估价机构', '估价目的', '价值类型', '价值时点', '项目总土地面积(平方米)', '项目总建筑面积(平方米)', '项目总价值(万元)', '项目合同收费(元)', '项目完成时间', '项目负责人', '签字估价师', '备注', '本报告的估价对象个数', '估价对象所在城市', '估价对象所在行政区', '估价对象所在小区', '估价对象详细地址', '房屋用途', '房屋类型', '房屋性质', '估价对象土地面积(平方米)', '估价对象建筑面积(平方米)', '户型结构', '户型', '朝向', '所在楼层', '装修程度', '使用年限', '土地使用开始日期', '估价方法', '估价方法说明', '土地评估单价(元/平方米)', '建筑评估单价(元/平方米)', '土地总价值(万元)', '建筑总价值(万元)', '估价对象评估总价(万元)', '宗地面积', '估价作业开始日', '估价作业结束日', '土地面积(㎡)', '建筑面积(㎡)', '评估总值(万元)', '评估单价(元)', '估价对象位置', '委托人', '委托人地址', '委托人邮编', '委托人电话', '第一报告人', '第一报告人注册号', '参与报告人1', '注册号', '参与报告人2', '注册号', // '物业名称', // '业务类型', // '是否对公(供综管部结单参考)', // '银行/非银', // '业务来源', // '实收金额', // '确认金额', // '未收金额', // '结单金额', // '结款方式', // '是否简易报告', // '评估单价(元)', // '评估净值1', // '评估净值2', // '客户经理电话', '业务员', '录单员', '查勘员', // '物业用途', '权利人', // '权利人证件号码', // '房产证号(一)', // '房产证号(二)', // '房产证登记日期', // '电子提取码', // '评估报告日期', '报告制作员', '报告审核员', // '所在片区', '回价员', // '个贷(对公)业绩', // '报告制作评分', '支行', '客户经理', '评估公司', '借款企业名称', '物业名称', '物业套数', '评估费用', '净值', '查勘完成日期', '剩余年限' ]; (new ChargeManage())->exportExcel($result_data, 'order_'.date('Ymd'), $indexKey, $indexValue); } } public function export1() { $data = $this->getOrderData(['list_rows' => 10000000, 'page' => 1]); $result_data = []; $nod = 1; foreach ($data['data'] as $key=>$value) { if ($value['estate_num'] > 1) { $report_id = Db::name('report')->where(['report_no'=>$value['report_no']])->value('id'); $multi_data = Db::name('report_detail')->alias('a')->leftJoin('property_cert_info b', 'a.property_cert_info_id = b.id')->where(['a.report_id'=>$report_id])->field('a.building_area,a.obligee,a.cert_no,a.property_cert,a.purchase_date,a.small_district_name,a.client,b.property_full_name,b.building_name,b.building_no,b.year,b.usage,b.id as quot_id,b.survey_user_name,b.ownership_type')->select(); $temp = []; foreach ($multi_data as $k=>$v) { $return_data = Db::name('return_price')->where(['property_cert_info_id'=>$v['quot_id']])->field('eva_total_value,eva_net_value,eva_net_value2,appraiser_name')->order(['id'=>'desc'])->find(); $temp['cid'] = $value['cid']; $temp['report_no'] = $value['report_no']; $temp['report_no_str'] = $value['report_no_str']; $temp['building_name'] = $v['property_full_name']; $temp['bank_name'] = trim($value['bank_name']); $temp['bank_branch_name'] = trim($value['bank_branch_name']); $temp['bank_sub_name'] = trim($value['bank_sub_name']); $temp['city'] = $value['city']; $temp['area'] = $value['area']; $temp['type'] = $value['type']; $temp['eva_purpose'] = $value['eva_purpose']; $temp['order_src'] = $value['order_src']; if ($k == 0) { $temp['receivable'] = $value['receivable']; $temp['received'] = $value['received']; $temp['confirm_amount'] = $value['confirm_amount']; $temp['uncollected_amount'] = $value['uncollected_amount']; $temp['check_amount'] = $value['check_amount']; } else { $temp['receivable'] = 0; $temp['received'] = 0; $temp['confirm_amount'] = 0; $temp['uncollected_amount'] = 0; $temp['check_amount'] = 0; } $temp['account_manager_id'] = $value['account_manager_id']; $temp['bank_customer_mgr_name'] = trim($value['bank_customer_mgr_name']); $temp['user_name'] = $value['user_name']; $temp['obligee'] = $v['obligee']; // 权利人须隐藏一个字符,如:张*或张*丰(建行对账要求2023-09-18) if (strpos($v['obligee'],",, ,, 、")!==false) { $obligee_arr = explode("[,,、]", $v['obligee']); $name = []; foreach ($obligee_arr as $k_o=>$v_o) { $name_arr = preg_split('/(?10000000 && $return_data['eva_total_value']<=30000000){ $temp['total_price_interval'] = '评估总值1000万-3000万(含)'; }elseif($return_data['eva_total_value']>30000000){ $temp['total_price_interval'] = '评估总值3000万以上'; } $temp['eva_net_value'] = $return_data['eva_net_value']; $temp['eva_net_value2'] = $return_data['eva_net_value2']; $temp['survey_user_name'] = $v['survey_user_name']; $temp['type_str'] = $value['type_str']; $temp['property_full_name'] = $value['property_full_name']; $temp['full_estate_name_str'] = $v['property_full_name']; $temp['business_source_str'] = $value['business_source_str']; $temp['estate_num'] = $value['estate_num']; $temp['report_completion_time'] = $value['report_completion_time']; $temp['bank_customer_mgr_phone'] = $value['bank_customer_mgr_phone']; $temp['producer_name'] = $value['producer_name']; $temp['reviewer_name'] = $value['reviewer_name']; $temp['small_district_name'] = $v['small_district_name']; $temp['client'] = $v['client']; $temp['appraiser_name'] = $return_data['appraiser_name']; $temp['usage'] = getDictionaryName('HOUSE_USAGE', $v['usage']); $temp['results'] = $value['results']; $temp['pay_type'] = $value['pay_type']; $temp['pay_type_str'] = $value['pay_type_str']; $temp['business_type'] = $value['business_type']; $temp['business_type_str'] = $value['business_type_str']; $temp['bank_type_str'] = $value['bank_type_str']; $temp['is_simple'] = $value['is_simple']; $temp['is_simple_str'] = $value['is_simple_str']; $temp['remark'] = $value['remark']; $temp['report_make_score'] = $value['report_make_score']; $temp['nod'] = $nod; $temp['institution_name'] = '深圳市国中资产土地房地产评估有限公司'; $temp['bank_estate'] = $v['building_name'].(!empty($v['building_no'])?$v['building_no']:''); $temp['bank_report_time'] = date('Y/m/d', strtotime($value['report_completion_time'])); $result_data[] = $temp; $nod++; } } else { $value['nod'] = $nod; $name = ''; $name_arr = preg_split('/(?10000000 && (int)$eva_total_value<=30000000){ $value['total_price_interval'] = '评估总值1000万-3000万(含)'; }elseif((int)$eva_total_value>30000000){ $value['total_price_interval'] = '评估总值3000万以上'; } $result_data[] = $value; $nod++; } } if($result_data){ $indexKey = ['report_no', 'report_no_str', 'bank_name', 'bank_sub_name', 'city', 'area', 'full_estate_name_str', 'type_str', 'business_type_str', 'client', 'bank_type_str', 'eva_purpose', 'business_source_str', 'receivable', 'received', 'confirm_amount', 'uncollected_amount', 'check_amount', 'pay_type_str', 'is_simple_str', 'building_area', 'eva_total_value', 'eva_net_value', 'eva_net_value2', 'bank_customer_mgr_name', 'bank_customer_mgr_phone', 'user_name', 'survey_user_name', 'estate_num', 'usage', 'obligee', 'cert_no', 'property_cert', 'deed_number_string', 'purchase_date', 'e_case_code', 'report_completion_time', 'producer_name', 'reviewer_name', 'small_district_name', 'appraiser_name', 'results', 'remark', 'report_make_score', 'nod', 'obligee_bank', 'bank_estate', 'institution_name', 'bank_report_time', 'e_case_code', 'eva_total_value', 'total_price_interval', 'receivable', 'bank_sub_name', 'bank_customer_mgr_name']; $indexValue = ['报告编号', '报告编号(带中文)', '银行', '支行', '城市', '城区', '物业名称', '业务类型', '是否对公(供综管部结单参考)', '委托方', '银行/非银', '评估目的', '业务来源', '应收金额', '实收金额', '确认金额', '未收金额', '结单金额', '结款方式', '是否简易报告', '面积', '评估总值', '评估净值1', '评估净值2', '客户经理', '客户经理电话', '业务员', '查勘员', '物业套数', '物业用途', '权利人', '权利人证件号码', '房产证号(一)', '房产证号(二)', '房产证登记日期', '电子提取码', '评估报告日期', '报告制作员', '报告审核员', '所在片区', '回价员', '个贷(对公)业绩', '备注', '报告制作评分', '序号', '房产所有人名称', '评估房产名称', '评估公司名称', '评估报告日期', '评估电子提取码', '评估总值/元', '评估总值所对应付费区间', '评估费用/元', '经办支行', '客户经理']; (new ChargeManage())->exportExcel($result_data, 'CCB_order_'.date('Ymd'), $indexKey, $indexValue); } } // 建行导出 public function bankExport1() { $data = $this->getOrderData(['list_rows' => 10000000, 'page' => 1], 777); $result_data = []; $nod = 1; foreach ($data['data'] as $key=>$value) { if ($value['estate_num'] > 1) { $report_id = Db::name('report')->where(['report_no'=>$value['report_no']])->value('id'); $multi_data = Db::name('report_detail')->alias('a')->leftJoin('property_cert_info b', 'a.property_cert_info_id = b.id')->where(['a.report_id'=>$report_id])->field('a.building_area,a.obligee,a.cert_no,a.property_cert,a.purchase_date,a.small_district_name,a.client,b.property_full_name,b.building_name,b.building_no,b.year,b.usage,b.id as quot_id,b.survey_user_name,b.ownership_type')->select(); $temp = []; foreach ($multi_data as $k=>$v) { $return_data = Db::name('return_price')->where(['property_cert_info_id'=>$v['quot_id']])->field('eva_total_value,eva_net_value,eva_net_value2,appraiser_name')->order(['id'=>'desc'])->find(); $temp['cid'] = $value['cid']; $temp['report_no'] = $value['report_no']; $temp['report_no_str'] = $value['report_no_str']; $temp['building_name'] = $v['property_full_name']; $temp['bank_name'] = trim($value['bank_name']); $temp['bank_branch_name'] = trim($value['bank_branch_name']); $temp['bank_sub_name'] = trim($value['bank_sub_name']); $temp['city'] = $value['city']; $temp['area'] = $value['area']; $temp['type'] = $value['type']; $temp['eva_purpose'] = $value['eva_purpose']; $temp['order_src'] = $value['order_src']; if ($k == 0) { $temp['receivable'] = $value['receivable']; $temp['received'] = $value['received']; $temp['confirm_amount'] = $value['confirm_amount']; $temp['uncollected_amount'] = $value['uncollected_amount']; $temp['check_amount'] = $value['check_amount']; } else { $temp['receivable'] = 0; $temp['received'] = 0; $temp['confirm_amount'] = 0; $temp['uncollected_amount'] = 0; $temp['check_amount'] = 0; } $temp['account_manager_id'] = $value['account_manager_id']; $temp['bank_customer_mgr_name'] = trim($value['bank_customer_mgr_name']); $temp['user_name'] = $value['user_name']; $temp['obligee'] = $v['obligee']; // 权利人须隐藏一个字符,如:张*或张*丰(建行对账要求2023-09-18) if (strpos($v['obligee'],",, ,, 、")!==false) { $obligee_arr = explode("[,,、]", $v['obligee']); $name = []; foreach ($obligee_arr as $k_o=>$v_o) { $name_arr = preg_split('/(?10000000 && $return_data['eva_total_value']<=30000000){ $temp['total_price_interval'] = '评估总值1000万-3000万(含)'; }elseif($return_data['eva_total_value']>30000000){ $temp['total_price_interval'] = '评估总值3000万以上'; } $temp['eva_net_value'] = $return_data['eva_net_value']; $temp['eva_net_value2'] = $return_data['eva_net_value2']; $temp['survey_user_name'] = $v['survey_user_name']; $temp['type_str'] = $value['type_str']; $temp['property_full_name'] = $value['property_full_name']; $temp['full_estate_name_str'] = $v['property_full_name']; $temp['business_source_str'] = $value['business_source_str']; $temp['estate_num'] = $value['estate_num']; $temp['report_completion_time'] = $value['report_completion_time']; $temp['bank_customer_mgr_phone'] = $value['bank_customer_mgr_phone']; $temp['producer_name'] = $value['producer_name']; $temp['reviewer_name'] = $value['reviewer_name']; $temp['small_district_name'] = $v['small_district_name']; $temp['client'] = $v['client']; $temp['appraiser_name'] = $return_data['appraiser_name']; $temp['usage'] = getDictionaryName('HOUSE_USAGE', $v['usage']); $temp['results'] = $value['results']; $temp['pay_type'] = $value['pay_type']; $temp['pay_type_str'] = $value['pay_type_str']; $temp['business_type'] = $value['business_type']; $temp['business_type_str'] = $value['business_type_str']; $temp['bank_type_str'] = $value['bank_type_str']; $temp['is_simple'] = $value['is_simple']; $temp['is_simple_str'] = $value['is_simple_str']; $temp['remark'] = $value['remark']; $temp['report_make_score'] = $value['report_make_score']; $temp['nod'] = $nod; $temp['institution_name'] = '深圳市国中资产土地房地产评估有限公司'; $temp['bank_estate'] = $v['building_name'].(!empty($v['building_no'])?$v['building_no']:''); $temp['bank_report_time'] = date('Y/m/d', strtotime($value['report_completion_time'])); $result_data[] = $temp; $nod++; } } else { $value['nod'] = $nod; $name = ''; $name_arr = preg_split('/(?10000000 && (int)$eva_total_value<=30000000){ $value['total_price_interval'] = '评估总值1000万-3000万(含)'; }elseif((int)$eva_total_value>30000000){ $value['total_price_interval'] = '评估总值3000万以上'; } $result_data[] = $value; $nod++; } } if($result_data){ $indexKey = ['report_no', 'report_no_str', 'bank_name', 'bank_sub_name', 'city', 'area', 'full_estate_name_str', 'type_str', 'business_type_str', 'client', 'bank_type_str', 'eva_purpose', 'business_source_str', 'receivable', 'received', 'confirm_amount', 'uncollected_amount', 'check_amount', 'pay_type_str', 'is_simple_str', 'building_area', 'eva_total_value', 'eva_net_value', 'eva_net_value2', 'bank_customer_mgr_name', 'bank_customer_mgr_phone', 'user_name', 'survey_user_name', 'estate_num', 'usage', 'obligee', 'cert_no', 'property_cert', 'deed_number_string', 'purchase_date', 'e_case_code', 'report_completion_time', 'producer_name', 'reviewer_name', 'small_district_name', 'appraiser_name', 'results', 'remark', 'report_make_score', 'nod', 'obligee_bank', 'bank_estate', 'institution_name', 'bank_report_time', 'e_case_code', 'eva_total_value', 'total_price_interval', 'receivable', 'bank_sub_name', 'bank_customer_mgr_name']; $indexValue = ['报告编号', '报告编号(带中文)', '银行', '支行', '城市', '城区', '物业名称', '业务类型', '是否对公(供综管部结单参考)', '委托方', '银行/非银', '评估目的', '业务来源', '应收金额', '实收金额', '确认金额', '未收金额', '结单金额', '结款方式', '是否简易报告', '面积', '评估总值', '评估净值1', '评估净值2', '客户经理', '客户经理电话', '业务员', '查勘员', '物业套数', '物业用途', '权利人', '权利人证件号码', '房产证号(一)', '房产证号(二)', '房产证登记日期', '电子提取码', '评估报告日期', '报告制作员', '报告审核员', '所在片区', '回价员', '个贷(对公)业绩', '备注', '报告制作评分', '序号', '房产所有人名称', '评估房产名称', '评估公司名称', '评估报告日期', '评估电子提取码', '评估总值/元', '评估总值所对应付费区间', '评估费用/元', '经办支行', '客户经理']; (new ChargeManage())->exportExcel($result_data, 'CCB_order_'.date('Ymd'), $indexKey, $indexValue); } } // 建行对账导出 // public function bankExportReconciliation() { public function bankExport() { $data = $this->getOrderData(['list_rows' => 10000000, 'page' => 1], 777); $result_data = []; $nod = 1; foreach ($data['data'] as $key=>$value) { if ($value['estate_num'] > 1) { $report_id = Db::name('report') ->where(['report_no'=>$value['report_no']]) ->value('id'); $multi_data = Db::name('report_detail')->alias('a') ->leftJoin('property_cert_info b', 'a.property_cert_info_id = b.id') ->where(['a.report_id'=>$report_id]) ->field(' a.obligee, b.property_full_name, b.building_name, b.building_no, b.id as quot_id, b.ownership_type ') ->select(); $temp = []; foreach ($multi_data as $k=>$v) { $return_data = Db::name('return_price') ->where(['property_cert_info_id'=>$v['quot_id']]) ->field('eva_total_value') ->order(['id'=>'desc']) ->find(); // 权利人须隐藏一个字符,如:张*或张*丰(建行对账要求2023-09-18) if (strpos($v['obligee'],",, ,, 、")!==false) { $obligee_arr = explode("[,,、]", $v['obligee']); $name = []; foreach ($obligee_arr as $k_o=>$v_o) { $name_arr = preg_split('/(?10000000 && $eva_total_value<=30000000){ $temp['total_price_interval'] = '评估总值1000万-3000万(含)'; }elseif($eva_total_value>30000000){ $temp['total_price_interval'] = '评估总值3000万以上'; } $temp['receivable'] = $value['receivable']; $temp['bank_sub_name'] = trim($value['bank_sub_name']); $temp['bank_customer_mgr_name'] = trim($value['bank_customer_mgr_name']); $temp['beizhu'] = '多套'; $temp['eva_unit_price'] = $value['eva_unit_price']; $temp['estate_area'] = $value['estate_area']; $result_data[] = $temp; $nod++; } else { $value['nod'] = $nod; if (strpos($value['obligee'],",, ,, 、")!==false) { $obligee_arr = explode("[,,、]", $value['obligee']); $name = []; foreach ($obligee_arr as $k_o=>$v_o) { $name_arr = preg_split('/(?10000000 && (int)$eva_total_value<=30000000){ $value['total_price_interval'] = '评估总值1000万-3000万(含)'; }elseif((int)$eva_total_value>30000000){ $value['total_price_interval'] = '评估总值3000万以上'; } $value['beizhu'] = ''; $result_data[] = $value; $nod++; } } if($result_data){ $indexKey = ['nod', 'obligee_bank', 'bank_estate', 'institution_name', 'bank_report_time', 'e_case_code', 'eva_total_value', 'total_price_interval', 'receivable', 'bank_sub_name', 'bank_customer_mgr_name', 'beizhu', 'estate_area', 'eva_unit_price']; $indexValue = ['序号', '房产所有人名称', '评估房产名称', '评估公司名称', '评估报告日期', '评估电子提取码', '评估总值/元', '评估总值所对应付费区间', '评估费用/元', '经办支行', '客户经理', '备注', '面积', '评估单价']; (new ChargeManage())->exportExcel($result_data, 'CCB_Reconciliation_'.date('Ymd'), $indexKey, $indexValue); } } public function index() { $map = []; $flag = true; $bank_id = $this->request->param('bank'); if (!empty($bank_id)) { $map[] = ['bank_id', '=', $bank_id]; } $start_time = $this->request->param('report_start_time'); $end_time = $this->request->param('report_file_produce_time'); if (!empty($start_time)) { $map[] = ['report_completion_time', '>', $start_time]; } if (!empty($end_time)) { $map[] = ['report_completion_time', '<', $end_time]; } if (!empty($start_time) && !empty($end_time) && $start_time>$end_time) { $flag = false; } // 银行 $bank_data = Db::name('bank')->where(['type'=>1, 'status'=>1])->select(); $count = Db::name('charge')->where($map)->count(); $this->assign( 'data', [ 'count'=>$count, 'bank_data'=>$bank_data, 'report_start_time'=>$start_time?$start_time:'', 'report_file_produce_time'=>$end_time?$end_time:'', 'bank'=>$bank_id?$bank_id:0, 'flag'=>$flag ] ); return view(); } // 房产信息解析方法 public function analyzingPropertyInformation($property_cert) { $return_data = []; $consult_obj = new Consultfiles; if (strpos($property_cert, '-') !== false) { $deed_number_arr = explode('-', $property_cert); $param = ['proveCode1'=>$deed_number_arr[0], 'proveCode2'=>$deed_number_arr[1]]; } else { $param = ['proveCode'=>$property_cert]; } $res = $consult_obj->Consultfiles($param); $return_data['property_status'] = $res['code']==1?$res['estatestatus']:'没有房产'; $return_data['mortgagee'] = ''; $return_data['mortgage_date'] = ''; $result_text = $res['result']['data'][0]['printResult']; if ($return_data['property_status'] != '没有房产') { $result_text_arr = explode('【产权信息】', $result_text); if (strpos($result_text_arr[1], '状态为:') !== false) { $property_status_arr = explode('状态为:', $result_text_arr[1]); if (strpos($property_status_arr[1], ',') !== false) { $property_info_arr = explode(',', $property_status_arr[1]); if ($property_info_arr[0] == '抵押') { if (strpos($property_info_arr[1], '抵押权人:') !== false) { $mortgagee_arr = explode('抵押权人:', $property_info_arr[1]); unset($mortgagee_arr[0]); $mortgagee_data = []; foreach ($mortgagee_arr as $key=>$value) { $mortgagee_date_arr = explode('抵押日期:', $value); $mortgagee_data[trim($mortgagee_date_arr[0])] = trim($mortgagee_date_arr[1]); } $return_data['mortgage_date'] = max($mortgagee_data); $return_data['mortgagee'] = array_search($return_data['mortgage_date'], $mortgagee_data); } } elseif ($property_info_arr[0] == '抵押查封') { if (strpos($property_info_arr[1], '查封机关:') !== false) { $mortgagee_arr = explode('查封机关:', $property_info_arr[1]); unset($mortgagee_arr[0]); $mortgagee_data = []; foreach ($mortgagee_arr as $key=>$value) { $mortgagee_date_arr = explode('查封日期:', $value); $mortgagee_data[trim($mortgagee_date_arr[0])] = trim($mortgagee_date_arr[1]); } $return_data['mortgage_date'] = max($mortgagee_data); $return_data['mortgagee'] = array_search($return_data['mortgage_date'], $mortgagee_data); } } } } } return $return_data; } // 批量查档导出 public function chaDangExport() { $data = $this->getOrderData(['list_rows' => 200, 'page' => 1]); $result_data = []; foreach ($data['data'] as $key=>$value) { if ($value['estate_num'] > 1) { $report_id = Db::name('report') ->where(['report_no'=>$value['report_no']]) ->value('id'); $multi_data = Db::name('report_detail') ->alias('a') ->leftJoin('property_cert_info b', 'a.property_cert_info_id = b.id') ->where(['a.report_id'=>$report_id]) ->field(' a.building_area, a.obligee, a.cert_no, a.property_cert, a.purchase_date, a.small_district_name, b.property_full_name, b.year, b.usage, b.id as quot_id, b.survey_user_name ') ->select(); $temp = []; foreach ($multi_data as $k=>$v) { $return_data = Db::name('return_price') ->where(['property_cert_info_id'=>$v['quot_id']]) ->field(' eva_total_value, eva_net_value, eva_net_value2, appraiser_name ') ->order(['id'=>'desc']) ->find(); $temp['cid'] = $value['cid']; $temp['report_no'] = $value['report_no']; $temp['building_name'] = $v['property_full_name']; $temp['bank_name'] = $value['bank_name']; $temp['bank_branch_name'] = $value['bank_branch_name']; $temp['bank_sub_name'] = $value['bank_sub_name']; $temp['city'] = $value['city']; $temp['area'] = $value['area']; $temp['type'] = $value['type']; $temp['eva_purpose'] = $value['eva_purpose']; $temp['order_src'] = $value['order_src']; if ($k == 0) { $temp['receivable'] = $value['receivable']; $temp['received'] = $value['received']; $temp['confirm_amount'] = $value['confirm_amount']; $temp['uncollected_amount'] = $value['uncollected_amount']; $temp['check_amount'] = $value['check_amount']; } else { $temp['receivable'] = 0; $temp['received'] = 0; $temp['confirm_amount'] = 0; $temp['uncollected_amount'] = 0; $temp['check_amount'] = 0; } $temp['account_manager_id'] = $value['account_manager_id']; $temp['bank_customer_mgr_name'] = $value['bank_customer_mgr_name']; $temp['user_name'] = $value['user_name']; $temp['obligee'] = $v['obligee']; $temp['property_cert'] = $v['property_cert']; $temp['cert_no'] = $v['cert_no']; $temp['purchase_date'] = $v['purchase_date']; $temp['e_case_code'] = $value['e_case_code']; $temp['produce_time'] = $value['produce_time']; $temp['building_area'] = $v['building_area']; $temp['eva_total_value'] = $return_data['eva_total_value']; $temp['eva_net_value'] = $return_data['eva_net_value']; $temp['eva_net_value2'] = $return_data['eva_net_value2']; $temp['survey_user_name'] = $v['survey_user_name']; $temp['type_str'] = $value['type_str']; $temp['property_full_name'] = $value['property_full_name']; $temp['full_estate_name_str'] = $v['property_full_name']; $temp['business_source_str'] = $value['business_source_str']; $temp['estate_num'] = $value['estate_num']; $temp['report_completion_time'] = $value['report_completion_time']; $temp['bank_customer_mgr_phone'] = $value['bank_customer_mgr_phone']; $temp['producer_name'] = $value['producer_name']; $temp['small_district_name'] = $v['small_district_name']; $temp['appraiser_name'] = $return_data['appraiser_name']; $temp['usage'] = getDictionaryName('HOUSE_USAGE', $v['usage']); $temp['results'] = $value['results']; $estate_info = $this->analyzingPropertyInformation($v['property_cert']); $temp['property_status'] = $estate_info['property_status']; $temp['mortgagee'] = $estate_info['mortgagee']; $temp['mortgage_date'] = $estate_info['mortgage_date']; $result_data[] = $temp; } } else { $estate_info = $this->analyzingPropertyInformation($value['property_cert']); $value['property_status'] = $estate_info['property_status']; $value['mortgagee'] = $estate_info['mortgagee']; $value['mortgage_date'] = $estate_info['mortgage_date']; $result_data[] = $value; } sleep(0.5); // 暂停0.5秒 } if($result_data){ $indexKey = [ 'report_no', 'property_status', 'mortgagee', 'mortgage_date', 'bank_name', 'bank_sub_name', 'city', 'area', 'full_estate_name_str', 'type_str', 'eva_purpose', 'business_source_str', 'receivable', 'received', 'confirm_amount', 'uncollected_amount', 'check_amount', 'pay_type', 'building_area', 'eva_total_value', 'eva_net_value', 'eva_net_value2', 'bank_customer_mgr_name', 'bank_customer_mgr_phone', 'user_name', 'survey_user_name', 'estate_num', 'usage', 'obligee', 'cert_no', 'property_cert', 'purchase_date', 'e_case_code', 'report_completion_time', 'producer_name', 'small_district_name', 'appraiser_name', 'results' ]; $indexValue = [ '报告编号', '产权状态', '抵押权人(银行)', '抵押日期', '银行', '支行', '城市', '城区', '物业名称', '业务类型', '评估目的', '业务来源', '应收金额', '实收金额', '确认金额', '未收金额', '结单金额', '结款方式', '面积', '评估总值', '评估净值1', '评估净值2', '客户经理', '客户经理电话', '业务员', '查勘员', '物业套数', '物业用途', '权利人', '权利人证件号码', '房产证号', '房产证登记日期', '电子提取码', '评估报告日期', '报告制作员', '所在片区', '回价员', '个贷(对公)业绩' ]; (new ChargeManage())->exportExcel( $result_data, 'chadang_'.date('Ymd'), $indexKey, $indexValue ); } } public function getOrderData($paginate = [], $bank_id = 0) { $map = []; // $map[] = ['is_simple', '=', 0]; $bank = $this->request->param('bank'); if (!empty($bank) && $bank_id == 0) { $map[] = ['bank_id', '=', $bank]; } elseif ($bank_id != 0) { $map[] = ['bank_id', '=', $bank_id]; } $city = $this->request->param('city'); if (!empty($city)) { $map[] = ['city_id', '=', $city]; } $area = $this->request->param('area'); if (!empty($area)) { $map[] = ['region_id', '=', $area]; } $type = $this->request->param('type'); if (!empty($type)) { $map[] = ['inquiry_type', '=', $type]; } $property_full_name = $this->request->param('property_full_name'); if (!empty($property_full_name)) { $map[] = ['building_name|report_no', 'like', '%'.$property_full_name.'%']; } $user_name = $this->request->param('user_name'); if (!empty($user_name)) { $map[] = ['salesman_name', 'like', '%'.$user_name.'%']; } $start_time = $this->request->param('report_start_time'); if (!empty($start_time)) { $map[] = ['report_completion_time', '>', $start_time . ' 00:00:00']; } $end_time = $this->request->param('report_file_produce_time'); if (!empty($end_time)) { $map[] = ['report_completion_time', '<', $end_time . ' 23:59:59']; } $field = [ 'charge_id as cid', 'order_no', 'report_no', 'building_name', 'estate_num', 'bank_id', 'bank as bank_name', 'bank_branch as bank_branch_name', 'bank_sub_branch as bank_sub_name', 'city', 'region as area', 'inquiry_type as type', 'assessment_purpose as eva_purpose', 'order_src', 'receivable', 'received', 'confirm_amount', 'uncollected_amount', 'check_amount', 'pay_type', 'business_type', 'is_simple', 'account_manager_id', 'account_manager_name as bank_customer_mgr_name', 'salesman_name as user_name', 'obligee', 'property_cert', 'cert_no', 'purchase_date', 'report_code as e_case_code', 'report_completion_time as produce_time', 'estate_area as building_area', 'eva_unit_price', 'assessment_total as eva_total_value', 'assessment_net_total_one as eva_net_value', 'assessment_net_total_two as eva_net_value2', 'survey_user_name', 'remark' ]; $data = Db::name('charge') ->where($map) ->field($field) ->paginate($paginate) ->each(function ($item,$key){ $code = ''; if ($item['city'] == '北京') { $code = 'B'; } elseif ($item['city'] == '武汉') { $code = 'C'; } else { $code = 'A'; } $year = mb_substr($item['report_no'], 0, 4); $numberings = mb_substr($item['report_no'], 4, 10); $suffix = mb_substr($item['report_no'], 14); $item['report_no_str'] = '深国中评字['.$year.$code.']第'.$numberings.'号'.$suffix;//估价报告编号 $item['type_str'] = getDictionaryName('INQUIRY_TYPE', $item['type']); $item['property_full_name'] = []; $item['full_estate_name_str'] = $item['building_name']; $item['business_source_str'] = getDictionaryName('BUSINESS_SOURCE', $item['order_src']); // $item['estate_num'] = 1; $item['report_completion_time'] = date('Y-m-d', strtotime($item['produce_time'])); $item['pay_type_str'] = $item['pay_type']==1?'月结':'个人自行付费'; $item['business_type_str'] = $item['business_type']==2?'是':'否'; $item['is_simple_str'] = $item['is_simple']==1?'是':'否'; $bank_data = Db::name('bank')->where('id='.$item['bank_id'])->find(); dump($item['bank_id']); die; $item['bank_type_str'] = $bank_data['bank_type']==1?'银行':'非银'; if(!empty($item['building_name'])){ $temp['show'] = explode(',',$item['building_name'])[0]; $temp['list'] = explode(',',$item['building_name']); // $item['estate_num'] = count($temp['list']); $item['property_full_name']=$temp; } if (strpos($item['building_area'], '/')!==false) { $item['estate_area'] = $item['building_area']; $area_arr = explode('/', $item['building_area']); $item['building_area'] = number_format(array_sum($area_arr)); }else{ $item['estate_area'] = $item['building_area']; } if (strpos($item['eva_total_value'], '/')!==false) { $item['eva_total_value'] = str_replace(',', '', $item['eva_total_value']); $total_price_arr = explode('/', $item['eva_total_value']); $item['eva_total_value'] = number_format(array_sum($total_price_arr)); } // $customer_info = Db::name('account_manager')->where(['id'=>$item['account_manager_id']])->field('mobile')->find(); // $item['bank_customer_mgr_phone'] = $customer_info['mobile']; $item['bank_customer_mgr_phone'] = $item['account_manager_id'] ? Db::name('account_manager')->where(['id'=>$item['account_manager_id']])->value('mobile') : ''; // 导出需要新增报告制作人字段 // $producer_name = Db::name('report')->where(['report_no'=>$item['report_no']])->value('producer_name'); $producer_name = Db::name('report')->where(['report_no'=>$item['report_no']])->field('id,quot_id,producer_name,reviewer_name,company,valuation_time,appraisal_time,appraiser_id,appraiser_name,appraiser2_id,appraiser2_name')->find(); $item['company'] = $producer_name['company']; $item['valuation_time'] = $producer_name['valuation_time']; $item['appraisal_time'] = $producer_name['appraisal_time']; $item['certificate_number'] = $producer_name['appraiser_id'] ? Db::name('valuer')->where('id='.$producer_name['appraiser_id'])->value('certificate_number') : ''; $item['appraiser_name'] = $producer_name['appraiser_name']; $item['certificate_number_two'] = $producer_name['appraiser2_id'] ? Db::name('valuer')->where('id='.$producer_name['appraiser2_id'])->value('certificate_number') : ''; $item['appraiser2_name'] = $producer_name['appraiser2_name']; if ($producer_name) { $item['producer_name'] = $producer_name['producer_name']; $item['reviewer_name'] = $producer_name['reviewer_name']; // 获取小片区 $small_district_name = Db::name('report_detail')->where(['report_id'=>$producer_name['id']])->field('small_district_name,client,parcel_area,land_location,building_name as e_name,use_right_source,max_land_use_years,land_use_start_time,house_use,test_method')->select(); if (count($small_district_name) > 1) { $item['small_district_name'] = implode('/', array_column($small_district_name, 'small_district_name')); $item['parcel_area'] = implode('/', array_column($small_district_name, 'parcel_area')); $item['land_location'] = implode('、', array_column($small_district_name, 'land_location')); $item['e_name'] = implode('、', array_column($small_district_name, 'e_name')); $item['use_right_source'] = implode('、', array_column($small_district_name, 'use_right_source')); $item['max_land_use_years'] = implode('/', array_column($small_district_name, 'max_land_use_years')); $item['land_use_start_time'] = implode('/', array_column($small_district_name, 'land_use_start_time')); $item['house_use'] = implode('/', array_column($small_district_name, 'house_use')); $item['test_method'] = implode('/', array_column($small_district_name, 'test_method')); $client_name = []; foreach ($small_district_name as $k_c=>$v_c) { $client_name[] = $v_c['client']; } $item['client'] = implode('、', array_unique($client_name)); // 估价委托人 } elseif (count($small_district_name) == 1) { $item['small_district_name'] = $small_district_name[0]['small_district_name']; $item['client'] = $small_district_name[0]['client']; $item['parcel_area'] = $small_district_name[0]['parcel_area']; $item['land_location'] = $small_district_name[0]['land_location']; $item['e_name'] = $small_district_name[0]['e_name']; $item['use_right_source'] = $small_district_name[0]['use_right_source']; $item['max_land_use_years'] = $small_district_name[0]['max_land_use_years']; $item['land_use_start_time'] = $small_district_name[0]['land_use_start_time']; $item['house_use'] = $small_district_name[0]['house_use']; $item['test_method'] = $small_district_name[0]['test_method']; } // 获取回价人 $item['appraiser_name'] = ''; $appraiser_names = []; $item['property_cert'] = ''; $item['deed_number_string'] = ''; $deed_numbers = []; $deed_number_strings = []; $item['usage'] = ''; $usages = []; $areas = []; $tenure_types = []; $bank_estates = []; $inquiry_detail_ids = []; $property_cert_info = Db::name('property_cert_info')->where(['quot_id'=>$producer_name['quot_id']])->field('id,year,usage,ownership_type,building_name,building_no')->select(); foreach ($property_cert_info as $k=>$v) { //回价人取第一个回价的人-2021-11-23修改,2022-05-05再还原 $appraiser_name = Db::name('return_price')->where(['property_cert_info_id'=>$v['id']])->order('id asc')->value('appraiser_name'); $appraiser_names[] = $appraiser_name; $property_cert = Db::name('report_detail')->where(['property_cert_info_id'=>$v['id']])->value('property_cert'); $deed_numbers[] = !empty($v['year']) ? $v['year'].'-'.$property_cert : $property_cert; $deed_number_strings[] = !empty($v['year']) ? '粤('.$v['year'].')深圳市不动产权第'.$property_cert.'号' : '深房地字第'.$property_cert.'号'; $usages[] = getDictionaryName('HOUSE_USAGE', $v['usage']); $area = Db::name('survey')->where(['property_cert_info_id'=>$v['id']])->value('area'); $areas[] = $area; $tenure_types[] = $v['ownership_type']; $bank_estates[] = $v['building_name'].(!empty($v['building_no'])?$v['building_no']:''); $inquiry_detail_ids[] = $v['id']; } $inquiry_detail_ids_str = null; if (count($inquiry_detail_ids) > 1) { $inquiry_detail_ids_str = implode(',', $inquiry_detail_ids); } elseif (count($inquiry_detail_ids) == 1) { $inquiry_detail_ids_str = $inquiry_detail_ids[0]; } if( null != $inquiry_detail_ids_str ) { $score_where[] = ['property_cert_info_id', 'in', $inquiry_detail_ids_str]; $report_make_score = Db::name('approval_opinion')->field('second_instance_opinion')->where($score_where)->find(); $item['report_make_score'] = is_numeric($report_make_score['second_instance_opinion']) ? $report_make_score['second_instance_opinion'] : ''; } if (count($appraiser_names) > 1) { $item['appraiser_name'] = implode('/', $appraiser_names); } elseif (count($appraiser_names) == 1) { $item['appraiser_name'] = $appraiser_names[0]; } if (count($deed_numbers) > 1) { $item['property_cert'] = implode('/', $deed_numbers); $item['deed_number_string'] = implode('/', $deed_number_strings); } elseif (count($deed_numbers) == 1) { $item['property_cert'] = $deed_numbers[0]; $item['deed_number_string'] = $deed_number_strings[0]; } if (count($usages) > 1) { $item['usage'] = implode('/', $usages); } elseif (count($usages) == 1) { $item['usage'] = $usages[0]; } if (count($tenure_types) > 1) { $item['ownership_type'] = implode('/', $tenure_types); } elseif (count($tenure_types) == 1) { $item['ownership_type'] = $tenure_types[0]; } if (count($bank_estates) > 1) { $item['bank_estate'] = implode('/', $bank_estates); } elseif (count($bank_estates) == 1) { $item['bank_estate'] = $bank_estates[0]; } if (count($areas) > 1) { $item['area'] = implode('/', $areas); } else { if(count($areas) >0 ){ $item['area'] = $areas[0]; } else{ trace("bill.php: area 无数据!","error"); } } } else { $item['producer_name'] = ''; $item['small_district_name'] = ''; $item['parcel_area'] = ''; $item['land_location'] = ''; $item['e_name'] = ''; $item['use_right_source'] = ''; $item['max_land_use_years'] = ''; $item['land_use_start_time'] = ''; $item['house_use'] = ''; } if ($item['type'] == 1) { $item['results'] = '胡轩'; } else { $item['results'] = '欧汉奇'; } return $item; })->toArray(); // dump(Db::name('charge')->getLastSql()); $data['count'] = $data['total']; return $data; } // 转换付款方式,修改字段pay_type的值 public function editPayType() { $charge_id = $this->request->param('charge_id'); // 必须 if (empty($charge_id)) { return $this->buildFailed('参数charge_id的值不能为空!'); } $pay_type = $this->request->param('pay_type'); // 必须 if ($pay_type!=1 && $pay_type!=2) { return $this->buildFailed('参数pay_type的值不正确!'); } // 获取费用表相关字段信息 $charge_data = Db::name('charge') ->where(['charge_id'=>$charge_id]) ->field('report_no') ->find(); if (!$charge_data) { return $this->buildFailed('没有找到相关记录!'); } // 启动事务 Db::startTrans(); // 更新费用表pg_charge的字段pay_type的值 $upd_charge = Db::name('charge') ->where(['charge_id'=>$charge_id]) ->update(['pay_type'=>$pay_type]); // 更新报告主表pg_report的字段pay_type的值 $upd_report = Db::name('report') ->where(['report_no'=>$charge_data['report_no']]) ->update(['pay_type'=>$pay_type]); if (!$upd_charge || !$upd_report) { // 事务回滚 Db::rollback(); return $this->buildFailed('修改失败'); } // 事务提交 Db::commit(); return $this->buildSuccess('', '修改成功!'); } public function orderListOld(){ $bank=input('bank'); $city=input('city'); $area=input('area'); $type=input('type'); $property_full_name=input('property_full_name'); $user_name=input('user_name'); $start_time=input('report_start_time'); $end_time=input('report_file_produce_time'); if ($start_time && $end_time) { if ($start_time > $end_time) { $date_params = ['between', [$end_time.' 00:00:00', $start_time.' 23:59:59']]; } else if ($start_time < $end_time) { $date_params = ['between', [$start_time.' 00:00:00', $end_time.' 23:59:59']]; } else { $date_params = ['between', [$start_time.' 00:00:00', $end_time.' 23:59:59']]; } } else { $start_time && $date_params = ['egt', $start_time.' 00:00:00']; $end_time && $date_params = ['elt', $end_time.' 23:59:59']; } $where=[]; $where['i.status']=8; !empty($bank) && $where['i.bank_id']=$bank; !empty($city) && $where['id.city_id']=$city; !empty($area) && $where['rd.area_id']=$area; !empty($type) && $where['i.type']=$type; !empty($property_full_name) && $where['id.property_full_name']=['like','%'.$property_full_name.'%']; !empty($user_name) && $where['i.user_name']=['like','%'.$user_name.'%']; !empty($date_params) && $where['r.produce_time']=$date_params; $order=''; $fields='c.charge_id as cid,i.id as iid,r.id as rid,c.report_no as order_no,i.bank_name,i.bank_branch_name,i.bank_sub_name,id.city,rd.area,i.type,i.eva_purpose,i.bank_customer_mgr_name,i.bank_customer_mgr_phone,i.user_name,rd.obligee,rd.cert_no,r.e_case_code,r.produce_time'; $res=Inquiry::getInquiryReportList($where,$fields,$this->getPage(),$order); if($res){ return $this->buildSuccess(['list' => $res['data'], 'count' => $res['total']]); }else{ return $this->buildFailed('查无数据'); } } public function exportOld(){ $bank=input('bank'); $city=input('city'); $area=input('area'); $type=input('type'); $property_full_name=input('property_full_name'); $user_name=input('user_name'); $start_time=input('report_start_time'); $end_time=input('report_file_produce_time'); if ($start_time && $end_time) { if ($start_time > $end_time) { $date_params = ['between', [$end_time.' 00:00:00', $start_time.' 23:59:59']]; } else if ($start_time < $end_time) { $date_params = ['between', [$start_time.' 00:00:00', $end_time.' 23:59:59']]; } else { $date_params = ['between', [$start_time.' 00:00:00', $end_time.' 23:59:59']]; } } else { $start_time && $date_params = ['egt', $start_time.' 00:00:00']; $end_time && $date_params = ['elt', $end_time.' 23:59:59']; } $where=[]; $where['i.status']=8; !empty($bank) && $where['i.bank_name']=$bank; !empty($city) && $where['id.city']=$city; !empty($area) && $where['rd.area']=$area; !empty($type) && $where['i.type']=$type; !empty($property_full_name) && $where['id.property_full_name']=['like','%'.$property_full_name.'%']; !empty($user_name) && $where['i.user_name']=['like','%'.$user_name.'%']; $order=''; $fields='i.id as iid,r.id as rid,c.report_no as order_no,i.bank_name,i.bank_branch_name,i.bank_sub_name,id.city,rd.area,i.type,i.eva_purpose,i.bank_customer_mgr_name,i.bank_customer_mgr_phone,i.user_name,rd.obligee,rd.cert_no,r.e_case_code,r.produce_time'; $res=Inquiry::getInquiryReportList($where,$fields,'',$order); if($res){ $indexKey = ['order_no', 'bank_customer_mgr_name', 'city', 'area', 'full_estate_name_str', 'type_str', 'eva_purpose', 'building_area', 'eva_total_value', 'eva_net_value', 'eva_net_value2', 'bank_customer_mgr_name', 'bank_customer_mgr_phone', 'user_name', 'obligee', 'cert_no', 'property_cert', 'purchase_date', 'e_case_code', 'produce_time']; $indexValue = ['报告编号', '银行', '城市', '城区', '物业名称', '业务类型', '评估目的', '面积', '评估总值', '评估净值1', '评估净值2', '客户经理', '客户经理电话', '业务员', '权利人', '权利人证件号码', '房产证号', '房产证登记日期', '电子提取码', '评估报告日期']; (new ChargeManage())->exportExcel($res['data'], 'update_'.date('Ymd'), $indexKey, $indexValue); // if(!empty($url)){ // return $this->buildSuccess($url); // }else{ // return $this->buildFailed('导出失败'); // } } } function pdf($html=array(),$title="",$fileName=""){ $util=new publicbankTemplate(); $res=$util->getdata('1'); // dump($res); // $url=ROOT_PATH . 'public' . DS . 'uploads' . DS ."img\img_01.png"; // $url1=ROOT_PATH . 'public' . DS . 'uploads' . DS ."img\img_02.png"; // //设置了背景图片的类 // $pdf =new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // // 设置打印模式 // //设置文件信息,头部的信息设置 // $pdf->SetCreator(PDF_CREATOR); // $pdf->SetAuthor("toppinggu"); // $pdf->SetTitle('12312'); // $pdf->SetSubject('TCPDF Tutorial'); // $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // 设置关键字 // $pdf->setPrintHeader(false); // // $pdf->SetHeaderMargin('4'); // 页眉距离顶部的距离 // // $pdf->setPrintFooter(true); // 是否显示页脚 // // $pdf->setFooterData(array(0,64,0), array(0,64,128)); // 设置页脚显示的内容 // // $pdf->setFooterFont(Array('stsongstdlight', '', '10')); // 设置页脚的字体 // // $pdf->SetFooterMargin('10'); // 设置页脚距离底部的距离 // $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // 设置默认等宽字体 // $pdf->setImageScale(1.25); // 设置图像比例因子 // // $pdf->setCellHeightRatio(1); // 设置行高 // $pdf->SetMargins('20', '0', '10'); // 设置左、上、右的间距 // $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // 设置图像比例因子 // $pdf->setFontSubsetting(true); // 设置默认字体构造子集模式 // $pdf->AddPage("A4","Landscape",true,true); // 添加一个页面 // //设置背景(这样设置只能实现第一页背景图) // // $img = file_get_contents('http://'.$_SERVER['HTTP_HOST'].'/branches/v2.0.4/vendor/images/logo.png'); // // $pdf->Image('@'.$img, 0, 0, 60, 60, '', '', '', false, 300, 'C', false, false, 1, false, false, true); // $pdf->SetFont('stsongstdlight', '', 14, '', true); // 设置字体 // $pdf->writeHTML('');//HTML生成PDF //设置样式 // //PDF输出的方式。I,在浏览器中打开;D,以文件形式下载;F,保存到服务器中;S,以字符串形式输出;E:以邮件的附件输出。 // $showType= 'F'; // //保存中文文件名的文件 // $pdf->Output(ROOT_PATH . 'public' . DS . 'uploads' . DS ."fileName.pdf", $showType); } /** * 校验报告 */ public function checkReportNo(){ $report_no = trim($this->request->post('report_no')); if(!$report_no) return $this->buildFailed('参数错误'); if(!Db::name('report')->where(['report_no'=>$report_no])->find()) return $this->buildFailed('报告编号错误,无此报告'); if(Db::name('report')->alias('r')->join('inquiry i', 'r.quot_id = i.id')->where(['r.report_no'=>$report_no, 'i.is_simple'=>1])->find()) return $this->buildFailed('简易报告不可申请'); if(Db::name('report')->alias('r')->join('inquiry i', 'r.quot_id=i.id')->where(['r.report_no'=>$report_no])->value('i.status') != 8) return $this->buildFailed('此报告未完成,不可申请'); if(Db::name('bill')->where('bill_status', '<>', 6)->where(['report_no'=>$report_no])->find()) return $this->buildFailed('已开票的报告不可重复提交开票'); return $this->buildSuccess(); } /** * 申请票据 - 获取相关信息 */ public function getBill(){ $report_no = trim($this->request->post('report_no')); if(!$report_no) return $this->buildFailed('参数错误'); $res = Db::name('report')->alias('r') ->field('group_concat(ide.property_full_name) as building_name, i.bank_name,i.bank_branch_name,i.bank_sub_name,i.order_no, i.user_name,i.department_name,c.receivable as pay,c.confirm_amount as confirm_pay') ->join('inquiry i', 'r.quot_id = i.id') ->join('property_cert_info ide', 'i.id = ide.quot_id') ->join('charge c','c.order_no=i.order_no') ->group('i.id') ->where(['r.report_no'=>$report_no]) ->find(); // $res['pay'] = ''; // $res['confirm_pay'] = ''; $res['paid_status'] = ''; return $this->buildSuccess($res); } /** * 申请票据 */ public function addBill(){ $data = $this->request->post(); if(!isset($data['bill_type']) || !$data['bill_type']) return $this->buildFailed('参数错误'); //验证 $validate = new BillValidate(); if($data['bill_type'] == 1 && isset($data['invoice_type']) && $data['invoice_type'] == 3){ //企业专票 if (!$validate->scene('companyTicket')->check($data)) return $this->buildFailed($validate->getError()); }elseif($data['bill_type'] == 1 && isset($data['invoice_type']) && $data['invoice_type'] == 2){ //企业普票 if (!$validate->scene('companyGeneral')->check($data)) return $this->buildFailed($validate->getError()); }elseif($data['bill_type'] == 1 && isset($data['invoice_type']) && $data['invoice_type'] == 1){ //个人普票 if (!$validate->scene('personGeneral')->check($data)) return $this->buildFailed($validate->getError()); }elseif($data['bill_type'] == 2){ //票据 if (!$validate->scene('bill')->check($data)) return $this->buildFailed($validate->getError()); }else{ return $this->buildFailed('参数错误'); } $data['user_id'] = $this->userInfo['user_id']; $data['user_name'] = $this->userInfo['user_name']; $data['bill_cate_type'] = $data['bill_cate']; $result = (new BillModel())->addBill($data); if(!$result) return $this->buildFailed('申请票据失败'); // 获取询价id $quot_id = Db::name('inquiry')->where(['order_no'=>$data['order_no']])->field('id')->find(); if ($data['bill_cate'] == 2) { // 非常规开票写入消息 PublicMessage($quot_id['id'], 8, 23); } else { // 常规开票写入消息 PublicMessage($quot_id['id'], 8, 26); } return $this->buildSuccess(); } }