'json', 'pub_serv' => 'json', // 'scenery' => 'json', 'living_room' => 'json', 'kitchen' => 'json', 'facility' => 'json', 'other' => 'json', 'prosperity_lv' => 'json', 'business_district_lv' => 'json', 'traffic' => 'json', 'shop_condition' => 'json', 'usage_condition' => 'json' ]; const STATUS_MAP = [ self::STATUS_ASKED => '查勘待派单', self::STATUS_RETURNED => '查勘已退回', self::STATUS_ASSIGNED => '查勘跟进中', self::STATUS_COMPLETED => '查勘已完成', ]; const STATUS_ASKED = 1; const STATUS_RETURNED = 4; const STATUS_ASSIGNED = 2; const STATUS_COMPLETED = 3; public function surveyDetail() { return $this->hasOne(SurveyDetail::class); } public function property_cert_info() { return $this->belongsTo(Property_cert_info::class); } /** * 获取我的查勘列表 * * @param array $data * @return array */ public function getSurveyList($paginate, $data) { $map = $this->buildMapFromArray($data); $res = Db::table('pg_inquiry') ->alias('a') ->join(['pg_property_cert_info' => 'b'], 'b.quot_id = a.id') ->join(['pg_survey' => 'c'], 'b.id = c.property_cert_info_id') ->where($map) ->field('b.id,a.order_no,b.city,b.city_id,b.property_full_name,a.is_multiple,c.status as survey_status,a.status,b.size,a.bank_name,a.bank_sub_name,a.create_time,a.user_name,c.complete_time as survey_time,c.user_name as survey_user_name,a.type,c.area,c.area_id') ->order('c.status', 'asc') ->order('a.create_time', 'asc') ->paginate($paginate)->each(function ($item,$key){ $return_price_info = Db::name('return_price') ->where(['property_cert_info_id'=>$item['id']]) ->order('id desc') ->field('eva_unit_price,eva_total_value,eva_net_value,eva_net_value2') ->find(); $item['eva_unit_price'] = $return_price_info['eva_unit_price']; $item['eva_total_value'] = $return_price_info['eva_total_value']; $item['eva_net_value'] = $return_price_info['eva_net_value']; $item['eva_net_value2'] = $return_price_info['eva_net_value2']; $item['status_str'] = getDictionaryName('ORDER_STATUS', $item['status']); $item['survey_status_str'] = getDictionaryName('SURVEY_STATUS', $item['survey_status']); $item['is_multi_str'] = getDictionaryName('INQUIRY_NUMBER', $item['is_multiple']); $item['type_str'] = getDictionaryName('BUSINESS_TYPE', $item['type']); $item['bank_name'] = $item['bank_name'] . $item['bank_sub_name']; unset($item['bank_sub_name']); return $item; })->toArray(); return $res; } /** * 导出我的查勘列表 */ public function exportSurveyList($data){ $map = $this->buildMapFromArray($data); $subsql = Db::table('pg_return_price')->field('property_cert_info_id,create_time,eva_unit_price,eva_total_value,eva_net_value,eva_net_value2') ->group('property_cert_info_id') ->order('property_cert_info_id', 'desc') ->buildSql(); $res = Db::table('pg_inquiry') ->alias('a') ->join(['pg_property_cert_info' => 'b'], 'b.quot_id = a.id') ->join(['pg_survey' => 'c'], 'b.id = c.property_cert_info_id and a.order_no = c.order_no') ->join([$subsql => 'd'], 'b.id = d.property_cert_info_id', 'left') ->where($map) ->order('c.status', 'asc') ->order('a.create_time', 'desc') ->group('b.id') ->field('b.id,a.order_no,b.city,b.city_id,b.property_full_name,a.is_multiple,c.status as survey_status,a.status,b.size,d.eva_unit_price,d.eva_net_value,d.eva_net_value2,d.eva_total_value,a.bank_name,a.bank_sub_name,a.create_time,a.user_name,c.complete_time as survey_time,c.user_name as survey_user_name,a.type,c.area,c.area_id') ->order('c.status', 'asc') ->order('a.create_time', 'asc') ->select(); foreach ($res as &$val){ $val['status_str'] = getDictionaryName('ORDER_STATUS', $val['status']); $val['survey_status_str'] = getDictionaryName('SURVEY_STATUS', $val['survey_status']); $val['is_multi_str'] = getDictionaryName('INQUIRY_NUMBER', $val['is_multiple']); $val['type_str'] = getDictionaryName('BUSINESS_TYPE', $val['type']); $val['bank_name'] = $val['bank_name'] . $val['bank_sub_name']; } return $res; } /** * 从数组构造查询条件 * * @param array $data * @return array */ public function buildMapFromArray($data = []) { $map = []; //todo 加上userId条件 if (isset($data['user_name']) && !empty($data['user_name'])){ $map[] = ['a.user_name','like','%'.trim($data['user_name']).'%']; } if (isset($data['survey_user_name']) && !empty($data['survey_user_name'])){ $map[] = ['c.user_name','like','%'.trim($data['survey_user_name']).'%']; } if (isset($data['type']) && !empty($data['type'])){ $map[] = ['a.type', '=', $data['type']]; } if (isset($data['status']) && !empty($data['status'])){ $map[] = ['a.status', '=', $data['status']]; } if (isset($data['is_multiple']) && ($data['is_multiple'] == 0 || $data['is_multiple'] == 1)){ $map[] = ['a.is_multiple', '=', $data['is_multiple']]; } if (isset($data['start_time']) && isset($data['end_time']) && ($data['start_time'] || $data['end_time'])){ $map[] = getQueryDate('b.survey_time', $data['start_time'], $data['end_time']); } if (isset($data['search_text']) && !empty($data['search_text'])){ $map[] = ['b.property_full_name|a.order_no','like','%'.trim($data['search_text']).'%']; } if (isset($data['survey_status']) && !empty($data['survey_status'])){ $map[] = ['c.status','=',trim($data['survey_status'])]; } if (isset($data['user_id']) && !empty($data['user_id'])){ //权限 $map[] = ['c.user_id','in',$data['user_id']]; } if (isset($data['city_id']) && !empty($data['city_id'])){ //城市 $map[] = ['b.city_id','=',$data['city_id']]; } if (isset($data['area_id']) && !empty($data['area_id'])){ //小片区 $map[] = ['c.area_id','in',$data['area_id']]; } return $map; } /** * 获取查勘详情 * * @param string $id * @return array */ public function getSurveyDetail($data) { $res = []; $inquiry = Db::table('pg_inquiry')->alias('a') ->field('a.id,a.order_no,b.survey_user_id,b.property_full_name,b.land_location,type,a.user_name,a.user_phone,b.city,a.bank_name,a.bank_customer_mgr_name,a.eva_purpose') ->join(['pg_property_cert_info' => 'b'], 'a.id = b.quot_id') ->where(['b.id' => $data['id']]) ->find(); $survey = $this->alias('c') ->join(['pg_survey_detail' => 'd'], 'c.id = d.survey_id','LEFT') ->where(['c.order_no' => $data['order_no'], 'c.property_cert_info_id' => $data['id']/*, 'c.user_id' => $inquiry['survey_user_id']*/]) ->find(); if(!empty($survey)){ $survey['scenery'] = $this->alias('c') ->join(['pg_survey_detail' => 'd'], 'c.id = d.survey_id') ->where(['c.order_no' => $data['order_no'], 'c.property_cert_info_id' => $data['id']/*, 'c.user_id' => $inquiry['survey_user_id']*/]) ->value('scenery'); $res = $this->getInfo($survey, $survey['survey_type']); } $res['inquiry'] = $inquiry; if (!empty($survey)) { $res['inquiry']['survey_contacts'] = $survey['contact_name']; $res['inquiry']['survey_contacts_phone'] = $survey['contact_phone']; $res['inquiry']['remark'] = Db::name('survey')->where(['order_no' => $data['order_no'] , 'property_cert_info_id' => $data['id']])->value('remark'); $res['remarks'] = $survey['remarks']; } //备注 cavan 2020年5月24日14:37:00 if($inquiry['city'] == '深圳'){ $res['area'] = Region::SZ_area; }elseif($inquiry['city'] == '北京'){ $res['area'] = Region::BJ_area; }elseif($inquiry['city'] == '东莞'){ $res['area'] = Region::DONGGUAN_area; }else{ $res['area'] = Region::WH_area; } return $res; } //查勘信息 public function getInfo($data, $type) { $surveyc=new SurveyC(); $options=$surveyc->surveyOptionsList(); $result = []; if ($type == 1) { //环境信息 $environment = array('adjacent_property', 'bus_lines', 'scenery', 'property_intro'); $result['environment_info'] = $this->getArrayField($data, $environment); $result['environment_info']['scenery'] = str_replace('"' , '' ,$result['environment_info']['scenery']); // TODO:处理四至和公共服务设施'boundaries', 'pub_serv', $result['boundaries']=!empty($this->getArrayField($data, ['boundaries'],$options['residence']['four_to_four']))?$this->getArrayField($data, ['boundaries'],$options['residence']['four_to_four']):(object)[]; $result['pub_serv']=!empty($this->getArrayField($data, ['pub_serv'],$options['residence']['public_sf']))?$this->getArrayField($data, ['pub_serv'],$options['residence']['public_sf']):(object)[]; //基本信息 $basic = array('address', 'unit_type', 'floor_height', 'floor_no', 'total_floors', 'elevator', 'parking_lot', 'decoration', 'property_mgm', 'structure', 'elevator_apartment_count', 'area'); $result['basic_info'] = $this->getArrayField($data, $basic); $result['basic_info']['towards'] = self::getDictionaryName1('residence_towards',$data['towards']); $result['basic_info']['parking_lot_usage'] = self::getDictionaryName1('residence_parking_garage_status',$data['parking_lot_usage']); $result['basic_info']['decoration'] = self::getDictionaryName1('residence_decoration_grade',$data['decoration']); $result['basic_info']['parking_lot'] = self::getDictionaryName1('residence_parking_garage',$data['parking_lot']); $result['basic_info']['newness_rate'] = self::getDictionaryName1('residence_new_rate',$data['newness_rate']); $result['basic_info']['usage'] = self::getDictionaryName1('residence_practical_application',$data['usage']); $result['basic_info']['user_name'] = $data['user_name'];//查勘员 $result['basic_info']['complete_time'] = $data['complete_time'];//查勘时间 //外景 $result['decorate'][] = $this->getOptionField($data, ['exterior_view', 'exterior_view_img_ids'],$options['residence']['residence_outdoor_scene']) ?: $this->getDecorateNull('外景'); // !empty($result['outdoor_scene_info']['exterior_view_img_ids']) && $result['outdoor_scene_info']['exterior_view_img_ids'] = $this->getAttachment($result['outdoor_scene_info']['exterior_view_img_ids']); //门牌 $result['decorate'][] = $this->getOptionField($data, ['doorplate', 'doorplate_img_ids'],$options['residence']['residence_doorplate']) ?: $this->getDecorateNull('门牌'); //客厅 $result['decorate'][] = $this->getOptionField1($data, ['living_room', 'living_room_img_ids'],$options['residence']) ?: $this->getDecorateNull('客厅/餐厅'); //阳台 // $result['decorate'][] = $this->getOptionField($data, ['balcony', 'balcony_img_ids'],$options['residence']['residence_balcony']) ?: $this->getDecorateNull('阳台'); //卧室 $result['decorate'][]= $this->getOptionField1($data, ['bedroom', 'bedroom_img_ids'],$options['residence']) ?: $this->getDecorateNull('卧室'); //厨房 $result['decorate'][]= $this->getOptionField1($data, ['kitchen', 'kitchen_img_ids'],$options['residence']) ?: $this->getDecorateNull('厨房'); //卫生间 $result['decorate'][] = $this->getOptionField1($data, ['bathroom', 'bathroom_img_ids'],$options['residence']) ?: $this->getDecorateNull('卫生间'); //设施 $result['decorate'][] = $this->getOptionField1($data, ['facility'],$options['residence']) ?: $this->getDecorateNull('设施'); //其他 $result['decorate'][] = $this->getOptionField1($data, ['other'],$options['residence']) ?: $this->getDecorateNull('其他'); //特殊户型备注 $result['decorate'][] = $this->getOptionField($data, ['special_remarks'],$options['residence']['residence_special_remarks']) ?: $this->getDecorateNull('特殊户型备注'); } else { //环境信息 $environment = array('prosperity_lv', 'business_district_lv', 'pub_fac', 'traffic'); // $result['environment_info'] = $this->getArrayField($data, $environment); // 商业繁华程度 $result['prosperity_lv'] = $this->getArrayField($data, ['prosperity_lv'],$options['shop']['shop_business_prosperity']); // 商圈等级 $result['business_district_lv'] = $this->getArrayField($data, ['business_district_lv'],$options['shop']['shop_business_level']); // 公共配套设施 $result['pub_fac'] = $this->getArrayField($data, ['pub_fac']); // 交通条件 $result['traffic'] = $this->getArrayField($data, ['traffic'],$options['shop']['shop_traffic_condition'],$options['shop']['shop_traffic_condition']); //基本信息 $basic = array('address', 'size', 'building_completion_time', 'total_floors', 'podium_floor', 'floor_no', 'floor_height', 'business_content', 'elevator_apartment_count', 'area'); $result['basic_info'] = $this->getArrayField($data, $basic); $result['basic_info']['property_form'] = self::getDictionaryName1('shop_property_form',$data['property_form']); $result['basic_info']['commercial_positioning'] = self::getDictionaryName1('shop_position',$data['commercial_positioning']); $result['basic_info']['user_name'] = $data['user_name'];//查勘员 $result['basic_info']['complete_time'] = $data['complete_time'];//查勘时间 //商铺状况 $result['shop_condition'] = $this->getShopStatus($data, ['shop_condition'],$options['shop']['shop_situation']); //停车状况 $result['parking_condition'] = $this->getArrayField($data, ['parking_condition'],$options['shop']['shop_parking_condition']); //使用状况 $result['usage_condition'] = $this->getArrayField($data, ['usage_condition'],$options['shop']['shop_usage_status']); //街景 $result['decorate'][] = $this->getOptionField($data, ['shop_treetscape','street_view_img_ids'],$options['shop']['shop_treetscape']) ?: $this->getDecorateNull('街景'); //外墙 $result['decorate'][] = $this->getOptionField($data, ['exterior_wall', 'exterior_wall_img_ids'],$options['shop']['shop_outdoor_scene']) ?: $this->getDecorateNull('外墙'); //门窗 $result['decorate'][] = $this->getOptionField($data, ['door_window', 'door_window_img_ids'],$options['shop']['shop_door_window']) ?: $this->getDecorateNull('门窗'); //内墙 $result['decorate'][] = $this->getOptionField($data, ['interior_wall', 'interior_wall_img_ids'],$options['shop']['shop_parlour']) ?: $this->getDecorateNull('内墙'); //地面 $result['decorate'][] = $this->getOptionField($data, ['ground', 'ground_img_ids'],$options['shop']['shop_kitchen']) ?: $this->getDecorateNull('地面'); // 天花板 $result['decorate'][] = $this->getOptionField($data, ['ceiling', 'ceiling_img_ids'],$options['shop']['shop_balcony']) ?: $this->getDecorateNull('天花板'); // 卫生间 $result['decorate'][] = $this->getOptionField1($data, ['bathroom', 'bathroom_img_ids'],$options['shop']['shop_toilet']) ?: $this->getDecorateNull('卫生间'); //厨房 $result['decorate'][]= $this->getOptionField1($data, ['kitchen', 'kitchen_img_ids'],$options['shop']['shop_kitchen2']) ?: $this->getDecorateNull('厨房'); // //设施 $result['decorate'][] = $this->getFacility($data, ['facility', 'facility_img_ids'],$options['shop']['shop_facilities']) ?: $this->getDecorateNull('设施'); } $result['auto_loc_img_ids'] = $this->getArrayField($data, ['auto_loc_img_ids']); $result['loc_img_ids'] = $this->getArrayField($data, ['loc_img_ids']); $result['supplement_img_ids']=$this->getArrayField($data,['supplement_img_ids']); $result['house_type_img_ids']=$this->getArrayField($data,['house_type_img_ids']); $result['appraisal_img_ids']=$this->getArrayField($data,['appraisal_img_ids']); $result['orientation_img_ids']=$this->getArrayField($data,['orientation_img_ids']); $result['loc_img_ids']=$this->getArrayField($data,['loc_img_ids']); $result['street_view_img_ids']=$this->getArrayField($data,['street_view_img_ids']); return $result; } public static function getDecorateNull($name) { $result = array( 'name' => $name, 'value' => [], 'img' => [] ); return $result; } /** * 获取附件信息 * * @param array $ids * @return array */ public static function getAttachment($ids) { $attachments = Db::table('pg_attachment') ->field('id,url,name,thum1,ext') ->whereNull('delete_time') ->whereIn('id', $ids) ->select(); // foreach ($attachments as &$v) { // $v['url'] = config('uploadFile.url') . $v['url']; // } return $attachments; } /** * 获取数组所需字段 * * @param array $data survey数组 * @param array $field 字段数组 * @return array */ public static function getArrayField($data, $field,$optionsArray=[]) { $result = []; $pic=new Attachment(); if(empty($optionsArray)){ foreach ($field as $key => $value) { if(strstr($value,'_img')){ if(empty($data[$value])){ $result['img']=array(); }else{ $result['img'] = $pic->getUrls($data[$value]); } }else{ $result[$value] = !empty($data[$value])?$data[$value]:''; } } }else{ foreach ($field as $key => $value) { if(isset($data[$value])){ if(self::is_json($data[$value])){ $data[$value]=json_decode($data[$value],true); } if(!is_array($data[$value])){//不是数组 if(!is_numeric($data[$value])){ foreach (explode(',',$data[$value]) as $column) { $result[$value][] = self::getDictionaryName1($optionsArray['code'],$column); } }else{ $result[$value] = self::getDictionaryName1($optionsArray['code'],$data[$value]); } }else{ foreach ($data[$value] as $k => $v) { if(isset($optionsArray[$k]) && !isset($optionsArray[$k]['_child']) && strstr($optionsArray[$k]['value'],'#')){//是否是输入型 $temp=$optionsArray[$k]; $result[$k]=str_replace('#', $v, $optionsArray[$k]['value']); } else{ if(!is_numeric($v)){//数据不是数字类型 if(!is_array($v) && strstr($v,',')){ $v=explode(',',$v); } if($v && is_array($v)){ foreach ($v as $column) { $result[$k][]=self::getDictionaryName1($k,$column); } } }else{ $result[$k]=self::getDictionaryName1($k,$v); } } } } }else{ return []; } } } return $result; } /** * 获取decorate数组所需字段 * * @param array $data survey数组 * @param array $field 字段数组 * @return array */ public static function getOptionField($data, $field,$optionsArray=[]) { $result = []; $pic=new Attachment(); foreach ($field as $key => $value) { // 判断是否是图片字段 if(strstr($value,'_img')){ if(empty($data[$value])){ $result['img']=array(); }else{ $result['img'] = $pic->getUrls($data[$value]);; } }else{ if(isset($data[$value])){ if(self::is_json($data[$value])){ $data[$value]=json_decode($data[$value],true); } if(!is_array($data[$value])){//不是数组 if(!is_numeric($data[$value])){ foreach (explode(',',$data[$value]) as $column) { $result['name'] = $optionsArray['name']; $result['value'][] = self::getDictionaryName1($optionsArray['code'],$column); } }else{ $result['name'] = $optionsArray['name']; $result['value'][] = self::getDictionaryName1($optionsArray['code'],$data[$value]); } }else{ foreach ($data[$value] as $k => $v) { if(isset($optionsArray[$k]) && !isset($optionsArray[$k]['_child']) && strstr($optionsArray[$k]['text'],'#')){ $temp=$optionsArray[$k]; $result['name']=$optionsArray['name']; $result['value'][]=$temp['name'].':'.$v; } else{ if(!is_numeric($v)){ if(!is_array($v) && strstr($v,',')){ $v=explode(',',$v); } foreach ($v as $i=>$column) { $result['name']=$optionsArray['name']; $result['value'][]=self::getDictionaryName1($k,$column); } }else{ $result['name']=$optionsArray['name']; $result['value'][]=self::getDictionaryName1($k,$v); } } } } }else{ $result['name']=$optionsArray['name']; $result['value'][]=''; // return []; } } } return $result; } /** * 获取decorate数组所需字段 * * @param array $data survey数组 * @param array $field 字段数组 * @return array */ public static function getOptionField1($data, $field,$optionsArray=[]) { $result = []; $name=array(); $pic=new Attachment(); foreach ($field as $key => $value) { // 判断是否是图片字段 if(strstr($value,'_img')){ if(empty($data[$value])){ $result['img']=array(); }else{ $result['img'] = $pic->getUrls($data[$value]);; } }else{ if(self::is_json($data[$value])){ $data[$value]=json_decode($data[$value],true); } if(isset($data[$value])){ foreach ($data[$value] as $k => $v) { if(!isset($optionsArray[$k])){ continue; } $name=explode('-',$optionsArray[$k]['name'])[0]; $temp['name']=isset(explode('-',$optionsArray[$k]['name'])[1])?explode('-',$optionsArray[$k]['name'])[1]:explode('-',$optionsArray[$k]['name'])[0]; $temp['value']=array(); if(!is_array($v) && strstr($v,',')){ $v=explode(',',$v); } if(is_numeric($v)){ $v=[$v]; } if($v){ foreach ($v as $i=>$column) { $temp['value'][]=self::getDictionaryName1($k,$column); } } $result[]=$temp; } }else{ return []; } } } $temp=array(); $temp['name'] = $field[0] == 'bathroom' ? '卫生间' : $name; foreach ($result as $k => $v) { if(!is_numeric($k)){ $temp['img'] = $v; }else{ $temp['value'][]=$v; } } return $temp; } /** * 获取查勘列表所需字段 * * @param array $where * @param array $paginate * @param array $order * @return array */ public static function getSurveyList1($where=[],$paginate=[],$order=[],$group=[]){ // $subsql = Db::table('pg_return_price')->field('property_cert_info_id,create_time,eva_unit_price,eva_total_value,eva_total_value,external_remarks,appraiser_name,create_time')->group('property_cert_info_id')->order('property_cert_info_id', 'desc')->buildSql(); $res=self::alias('survey') // ->join('survey_detail sd','survey.id=sd.survey_id') ->join('property_cert_info ind','survey.property_cert_info_id=ind.id','LEFT') ->join('inquiry i','ind.quot_id=i.id','LEFT') // ->join([$subsql => 'rp'],'ind.id=rp.property_cert_info_id','LEFT') // ->field('ind.id,survey.id as survey_id,i.order_no,ind.city,ind.city_id,ind.property_full_name,i.is_multiple,i.type,survey.id as survey_id,survey.status,survey.create_time,survey.user_name as surver_username,i.user_name,rp.external_remarks,survey.assign_time,survey.complete_time,survey.return_reason,rp.appraiser_name,ind.id as property_cert_info_id,survey.area,survey.survey_type,i.status as inquiry_status,i.bank_name') ->field('ind.id,survey.id as survey_id,i.order_no,i.id as quot_id,ind.city,ind.city_id,ind.property_full_name,i.is_multiple,i.type,survey.id as survey_id,survey.status,survey.create_time,survey.user_name as surver_username,i.buss_username,survey.assign_time,survey.complete_time,survey.return_reason,ind.id as property_cert_info_id,survey.area,survey.survey_type,i.status as inquiry_status,i.bank_name') ->where($where) ->order($order) ->group('survey.id') // ->group('ind.property_full_name') ->paginate($paginate) ->each(function ($item,$key){ $return_price_info = Db::name('return_price') ->where(['property_cert_info_id'=>$item['id']]) ->order('id desc') ->field('external_remarks,appraiser_name') ->find(); $item['external_remarks'] = $return_price_info['external_remarks']; $item['appraiser_name'] = $return_price_info['appraiser_name']; // $item['status_str'] = getDictionaryName('ORDER_STATUS', $item['status']); $item['survey_status_str'] = getDictionaryName('SURVEY_STATUS', $item['status']); $item['is_multi_str'] = getDictionaryName('INQUIRY_NUMBER', $item['is_multiple']); $item['type_str'] = getDictionaryName('BUSINESS_TYPE', $item['type']); $item['inquiry_status_str'] = getDictionaryName('ORDER_STATUS', $item['inquiry_status']); $return_report_info = Db::name('report') ->where(['quot_id'=>$item['quot_id']]) ->field('report_no,producer_name') ->find(); //var_dump($return_report_info); if ($item['city'] == '北京') { $code = 'B'; } elseif ($item['city'] == '武汉') { $code = 'C'; } else { $code = 'A'; } if(!empty($return_report_info['report_no'])){ $year = mb_substr($return_report_info['report_no'], 0, 4); $pos_f = mb_strpos($return_report_info['report_no'], '-'); $numberings = mb_substr($return_report_info['report_no'], 4, $pos_f+4); $suffix = mb_substr($return_report_info['report_no'], $pos_f+8); } $item['report_no'] = !empty($return_report_info['report_no']) ? '深国中评字['.$year.$code.']第'.$numberings.'号'.$suffix : ''; $item['producer_name'] = !empty($return_report_info['producer_name']) ? $return_report_info['producer_name'] : ''; unset($item['bank_sub_name']); return $item; })->toArray(); return $res; } /** * 获取查勘信息 * * @param int $id 询价详情id * @param int $type 1住宅 2商业 * @return array */ public function getSurveyData($id, $type) { $result = []; $survey = $this->alias('a') ->join(['pg_survey_detail' => 'b'], 'a.id = b.survey_id') ->where(['a.property_cert_info_id' => $id]) ->find(); if (!empty($survey)) { $result = $this->getInfo($survey, $type); //物业位置图 $result['loc_img_ids'] = $survey['loc_img_ids']; } return $result; } /* * 根据分类获取数据字典 * @param $type string * @return array */ public static function getdictionary1($type) { static $list; // if (empty($list)) { // $list = cache('options_list'); // } $key = "{$type}"; if (isset($list[$key])) { $dic = $list[$key]; } else { $info = Db::name('options_automation')->where(['key' => $type])->field('code,name,type')->select(); $list[$key] = $info; $dic = $list[$key]; cache('options_list', $list, 3600); } return $dic; } /** * 获取数据字典选中值 * @param type $type * @param type $status */ public static function getDictionaryName1($type, $status) { $res = self::getdictionary1($type); $name = ''; $arr = []; if (!empty($res)) { if(strstr($status , ',')){ foreach (explode(',',$status) as $key => $value) { foreach ($res as $k => $v) { if ($v['code'] == $value) { $arr[] = $v['name']; break; } } } $name = implode(',', $arr); }else{ foreach ($res as $k => $v) { if ($v['code'] == $status) { $name = $v['name']; break; } } } } return $name; } /** * 获取数据字典选中值 * @param type $type * @param type $status */ public static function getDictionaryType1($type, $status) { $res = self::getdictionary1($type); $type = ''; if (!empty($res)) { foreach ($res as $k => $v) { if ($v['code'] == $status) { $type = $v['type']; break; } } } return $type; } public static function is_json($data = '', $assoc = false) { if(!is_string($data)){ return false; } $data = json_decode($data, $assoc); if (($data && (is_object($data))) || (is_array($data) && !empty($data))) { return true; } return false; } public function getFacility($data, $field,$optionsArray=[]){ $result = []; $pic=new Attachment(); foreach ($field as $key => $value) { // 判断是否是图片字段 if(strstr($value,'_img')){ if(empty($data[$value])){ $result['img']=array(); }else{ $result['img'] = $pic->getUrls($data[$value]);; } }else{ if(isset($data[$value])){ foreach ($data[$value] as $k => $v) { $result[$k]['name']=$optionsArray[$k]['name']; if(is_array($v)){ foreach ($v as $key1 => $value1) { $result[$k]['value'][]=str_replace('#', $value1, $optionsArray[$k][$key1]['name']); } }else{ foreach (explode(',',$v) as $column) { $result[$k]['value'][]=$this->getDictionaryName1($k,$column); } } } }else{ return []; } } } unset($result['shop_facilities_elevator_option']); $temp['name'] = $optionsArray['name']; foreach ($result as $k => $v) { if($k=='img'){ $temp['img'] = $v; }else{ $temp['value'][]=$v; } } return $temp; } public function getShopStatus($data, $field,$optionsArray=[]){ $result = []; $pic=new Attachment(); foreach ($field as $key => $value) { // 判断是否是图片字段 if(strstr($value,'_img')){ if(empty($data[$value])){ $result['img']=array(); }else{ $result['img'] = $pic->getUrls($data[$value]); } }else{ if(isset($data[$value])){ foreach ($data[$value] as $k => $v) { if(is_array($v)){ foreach ($v as $key1 => $value1) { $valueTemp=[]; $valueTemp['name']=Db::name('options_automation')->where('code',$key1)->value('name'); if(!isset($optionsArray[$k][$key1])){ $options_automation=new OptionsAutomation(); $optionsArray[$k][$key1]=$options_automation->where([['key','like','shop_situation_%'],['code','=',$key1]])->find(); } if(!isset($optionsArray[$k][$key1]['_child']) && strstr($optionsArray[$k][$key1]['value'],'#')){//是否是输入型 // $valueTemp['name']=$this->getDictionaryName1($k,$optionsArray[$k][$key1]['key']); $valueTemp['value']=str_replace('#', $value1, $optionsArray[$k][$key1]['value']); $valueTemp['type']=$optionsArray[$k][$key1]['type']; }else{ if($key1=='shop_situation_ss' || $key1=='shop_situation_wss'){ // $valueTemp['name']='商铺形状:'; $valueTemp['value']=''.$this->getDictionaryName1($key1,$value1); }elseif($optionsArray[$k][$key1]['code']=='shop_ground_meter'){ $text=''; if($value1<0){ $text='比路面低'.$value1.'米'; }elseif($value1==0){ $text='与路面相平'; }elseif($value1>0){ $text='比路面高'.$value1.'米'; } $valueTemp['value']=$text; $valueTemp['type']=$optionsArray[$k][$key1]['type']; }else{ $valueTemp['value']=$this->getDictionaryName1($key1,$value1); } $valueTemp['type']=$this->getDictionaryType1($key1,$value1); } $result[]=$valueTemp; } }else{ foreach (explode(',',$v) as $column) { $valueTemp['value']=$this->getDictionaryName1($k,$column); $valueTemp['type']=$this->getDictionaryType1($k,$column); $result[]=$valueTemp; } } } }else{ return []; } } } return $result; } // 编辑查勘信息 public function editSurvey(){ //查勘信息 $validate=new SurveyValidate(); if(!$validate->scene(SurveyValidate::SCENE_SUBMIT)->batch()->check($data['surveyinfo'])){ Db::rollback(); return $this->buildFailed($validate->getError()); } $surveyService = new SurveyService(); $surveyController = new SurveyController(); $surveyInfo = $data['surveyinfo']; //删除arr不要的数据 foreach ($surveyInfo as $key=>$v){ if(strpos($key,'_arr')){ unset($surveyInfo[$key]); } if ($key == "facility") { unset($surveyInfo['facility']['shop_facilities_elevator_arr']); } } $surveydata=$surveyController->changeArrayToString($surveyInfo); if (!$surveyService->survey_detail($this->userInfo['user_id'], $surveydata,2)){ Db::rollback(); return $this->buildFailed('操作失败'); } return $this->buildSuccess('操作成功'); } }