decrypt($arr['data']); parse_str($queryData, $token); $emp_id = $token['employee_id']; }elseif ($str) { $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); $arr = $aec->decrypt($str); $arr = explode('#',$arr); $emp_id = $arr[1]; } $employee = Employee::where('id', '=', $emp_id)->findOrEmpty(); return $employee; } public function info(){ $sid = input('sid', '', 'trim'); $token = input('tokens','');//分享人token $str = input('str','');//分享人加密字符串 if (empty($sid)) { return json(['code'=> 0, 'data'=> [], 'msg'=> '获取成功']); } $info = VrGroup::where('sid', '=', $sid)->findOrEmpty(); if ($info->isEmpty()) { return json(['code'=> 0, 'data'=> [], 'msg'=> '获取成功']); } // $employee = Employee::where('id', '=', $info['emp_id'])->findOrEmpty(); $employee = $this->analysisToken($token,$str,$info['emp_id']); if ($employee->isEmpty()) { $info['employee_name'] = ''; $info['employee_headimgurl'] = ''; $info['employee_phone'] = ''; $info['employee_qrcode'] = ''; $info['uid'] = 0; }else{ $info['employee_name'] = $employee['name']; $info['employee_headimgurl'] = User::where('id',$employee['uid'])->value('headimgurl'); $info['employee_phone'] = $employee['phone']; $info['employee_qrcode'] = $employee['qrcode']; $info['uid'] = $employee['uid']; } $vr_view = VrView::with(['hotspot'])->where('vr_group_id', '=', $info['id'])->order('sort asc')->select()->toArray(); $ali_oss_bindurl = config('app.vr_ali_oss_bindurl'); $url = 'https://' . $ali_oss_bindurl; foreach ($vr_view as $k => $v) { $vr_view[$k]['vr_path'] = $url.'/'.$v['structure']; foreach ($v['hotspot'] as $k2 => $v2) { $arr = []; $arr1 = $v2['embedValue'] ? explode('|',$v2['embedValue']) : []; foreach ($arr1 as $v3) { $arr1_1 = explode(',',$v3); $arr[] = ['ath'=>$arr1_1[0],'atv'=>$arr1_1[1]]; } $v2['embedValue'] = $arr; $arr2 = $v2['titlePosition'] ? explode(',',$v2['titlePosition']) : []; $v2['titlePosition'] = $arr2 ? ['ath'=>$arr2[0],'atv'=>$arr2[1]] : []; $json = json_encode($v2); $vr_view[$k]['hotspot'][$k2] = ['content'=>$json]; unset($json); } } $info['view'] = array_values($vr_view); $info['str'] = $this->employee['str']; $notify = Miniprogram::where('root_id',$employee['root_id'])->value('notify'); return json(['code'=> 0, 'data'=> $info, 'msg'=> '获取成功','notify'=>$notify]); } /** * 详情 */ public function view(){ $id = $this->params['buildingId']; if(!$id) return json(['code' => 0, 'data' => [], 'msg' => '获取成功']); $share = input('share', '', 'trim'); $info = BuildingModel::find($id); if (empty($info)){ return json(['code'=> 1, 'msg'=> '数据不存在']); } $area_list = BuildingHousetype::where('building_id', '=', $id)->order('area asc')->column('area'); $info['area_list'] = array_values(array_unique(array_filter($area_list))); $company = Company::where('root_id', '=', $info['root_id'])->field(['company_name', 'logo'])->find(); $info['company_name'] = $company['company_name']; $info['company_logo'] = $company['logo']; $info['company_address'] = $company['company_address']; //小区户型 $housetype = BuildingHousetype::with(['devcase'=>function($query){ $query->field('housetype_id,id,name,type,vr_link,content,cover,decostyles_id'); }])->where('building_id', '=', $id)->withCount(['materialCase'])->select(); $xin = null; $vrObj = new Vr(); if(!empty($housetype->toArray())){ $houselist=$housetype->toArray(); foreach($houselist as $key=>$val){ if(empty($val['house_img']) && !empty($val['vr_link'])){ $houselist[$key]['house_img'][] = $vrObj->getFirstImg($val['vr_link']); } if(empty($val['devcase'])) continue; foreach($val['devcase'] as $k=>$v){ $houselist[$key]['devcase'][$k]['decostyles_name']=Decostyle::where('id',$v['decostyles_id'])->value('name'); $houselist[$key]['devcase'][$k]['area']=$val['area']; $houselist[$key]['devcase'][$k]['room']=$val['room']; $houselist[$key]['devcase'][$k]['hall']=$val['hall']; $houselist[$key]['devcase'][$k]['bathroom']=$val['bathroom']; if($v['type']==1){ $houselist[$key]['devcase'][$k]['cover'] = $vrObj->getFirstImg($v['vr_link']); } } } //分享加密参数 店面id ,分享人id , 楼盘id , 户型id , 案例id , 在施工地id $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); foreach($houselist as $key => $val){ $ids = [$this->params['rootId'],$this->params['employeeId'],'',$val['id'],'','']; $val['str'] = $houselist[$key]['str'] = $aec->encrypt(implode('#',$ids)); $xin[$val['room']][] = $val; } $xin[0] = $houselist; } $info['vr_link_cover']=''; if(!empty($info['vr_link'])){ $info['vr_link_cover']=$vrObj->getFirstImg($info['vr_link']); } $info['housetype'] = $xin; $info['housetype_count'] = $housetype->count(); //增加进度图片视频VR数量查询 $prtype_list = BuildingProgress::where([['building_id', '=', $id]])->field('count(*) as count,type')->group('type')->select()->toArray(); $info['prtype_list']=!empty($prtype_list)?$prtype_list:null; BuildingModel::where('id', '=', $id)->inc('view_times')->update(); if (empty($info->vr_link) && $info->vr_group_ids) { $group = VrGroup::where('id',$info->vr_group_ids)->field('sid,pic_path')->find(); $info->vr_link = config('app.vr_show_domain').$group->sid; $info->vr_link_img = $group->pic_path; } return json(['code'=> 0, 'data'=> $info]); } //户型详情 public function housetype_detail() { $id = $this->params['housetypeId']; if(!$id) return json(['code' => 0, 'data' => [], 'msg' => '获取成功']); if(empty($id)) return json(['code'=> 1,'msg'=> '参数错误']); $data = BuildingHousetype::find($id); $data['new_orientation'] = $data->getData('orientation'); $data['vr_link_img'] = ''; if (!empty($data['vr_link'])) { $vrObj = new Vr(); $data['vr_link_img'] = getFirstImg($data['vr_link']); } //查询楼盘地址和小区 $bulid = BuildingModel::where('id',$data->building_id)->field('community_id,address')->findOrEmpty(); if (!$bulid->isEmpty()){ $bulid->community = $bulid->community_id ? Community::where('id',$bulid->community_id)->value('name') : ''; } if (empty($data->vr_link) && $data->vr_group_ids) { $group = VrGroup::where('id',$data->vr_group_ids)->field('sid,pic_path')->find(); $data->vr_link = config('app.vr_show_domain').$group->sid; $data->vr_link_img = $group->pic_path; } return json(['code'=> 0, 'data'=> $data,'bulid'=>$bulid, 'msg'=> '获取成功']); } /** * 楼盘进度 */ public function progress(){ // $id = input('id', '', 'intval'); $id = $this->params['buildingId']; $page = input('page',1); $limit = input('limit',10); if(!$id) return json(['code' => 0, 'data' => [], 'msg' => '获取成功']); $type = input('type','','trim'); $where[]=['building_id', '=', $id]; if(!empty($type)){ $where[]=['type', '=', $type]; } $label_id = input('label_id',0); if($label_id) $where[] = ['label_id','=',$label_id]; $list = BuildingProgress::where($where)->page((int)$page,(int)$limit)->order('addtime desc')->select(); if (empty($list)) $list = []; else $list = $list->toArray(); $vrObj = new Vr(); foreach ($list as &$item) { $vrData = []; if ($item['type']=='vr' && $item['vr']) { $vrUrlList = explode(',', $item['vr']); foreach ($vrUrlList as $url) { $vrData[] = [ 'vrUrl' => $url, 'vrfirstImg' => $vrObj->getFirstImg($url) ]; } }elseif ($item['type']=='group' && $item['vr_group_ids']) { $url = config('app.vr_show_domain'); $vrgroup = VrGroup::where('id',$item['vr_group_ids'])->field('id,pic_path,sid')->findOrEmpty(); $item['show_url'] = ''; $item['show_img'] = ''; if (!$vrgroup->isEmpty()) { $item['show_url'] = $url.$vrgroup->sid; $item['show_img'] = $vrgroup->pic_path; } } $item['vr'] = $vrData; } $count = BuildingProgress::where($where)->count(); return json(['code' =>0, 'data' => $list,'count'=>$count]); } /** * 个人信息 */ public function getUserInfo() { $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); $emp = Employee::where([['id','=',$this->params['employeeId']],['root_id','=',$this->params['rootId']]])->field('qrcode,id,phone,uid,root_id,name,opt_name')->findOrEmpty(); if($emp->isEmpty()) return json(['code' => 0,'data'=>[] , 'msg' => '']); $emp->headimgurl = $emp->user->headimgurl; $emp->company_name = $emp->companyJoin->company_name; $emp->logo = $emp->companyJoin->logo; $emp->notify = Miniprogram::where('root_id',$emp->root_id)->value('notify'); $emp->str = $aec->encrypt($emp->root_id.'#'.$emp->id); $emp = $emp->toArray(); unset($emp['user']); unset($emp['company']); return json(['code' => 0,'data'=>$emp , 'msg' => '']); } /** * 户型关联案例 */ public function materialCase() { // $housetype_id = input('housetype_id',0); $housetype_id = $this->params['housetypeId']; $page = input('page',1,'intval'); $limit = input('limit',10,'intval'); if(!$housetype_id) return json(['code' => 0, 'data' => ['list'=>[]], 'msg' => '获取成功']); $info = Employee::where('id',$this->params['employeeId'])->field('id,org_id,uid')->find(); $case_ids = BuildingMaterialCase::where([['housetype_id','=',$housetype_id],['root_id','=',$this->params['rootId']]])->column('material_case_id'); if(empty($case_ids)) return json(['code' => 0, 'data' => ['list'=>[]], 'msg' => '获取成功']); $where[] = ['id', 'in', $case_ids]; $list = MaterialCase::with(['designer' => function ($query) { $query->field('id,name, headimgurl,addtime'); }, 'community' => function ($query) { $query->field('id,name'); }, 'decostyle' => function ($query) { $query->field('id,name'); }])->page((int)$page,(int)$limit)->where($where)->select()->toArray(); //分享加密参数 店面id ,分享人id , 楼盘id , 户型id , 案例id , 在施工地id $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); foreach ($list as $key => $val) { $ids = [$this->params['rootId'],$this->params['employeeId'],'','',$val['id'],'']; $list[$key]['str'] = $aec->encrypt(implode('#',$ids)); } $data = ['list'=> $list]; $count = MaterialCase::where($where)->count(); return json(['code' => 0, 'data' => $data,'count'=>$count, 'msg' => '获取成功']); } /** * 户型下的在施工地 */ public function construction(){ $housetype_id = $this->params['housetypeId']; if(!$housetype_id) return json(['code' => 0, 'data' => [], 'msg' => '获取成功']); // $housetype_id = input('housetype_id', '', 'intval'); $construction_str = BuildingHousetype::where('id',$housetype_id)->value('constructionid'); $construction_id = !empty($construction_str) ? explode(',',$construction_str) : []; $where[] = ['id', 'in', $construction_id]; $page = input('page', 1, 'intval'); $limit = input('limit', 10, 'intval'); $root_id = $this->params['rootId']; $where[] = ['root_id', '=', $root_id]; $step_list = ConstructionStep::where('root_id', '=', $root_id)->order('order asc')->select()->toArray(); $order_input = input('order', 'new', 'trim'); $order = 'update_time desc'; $model = ConstructionModel::with(['style', 'designer', 'housetype', 'community'])->withCount(['share_log'=> function ($query) { $query->where([['type', '=', 'construction']]); }]); $order = 'update_time desc'; $list = $model->where($where)->page($page, $limit)->order($order)->select(); // $list = $list->each(function ($item) use ($step_list) { $record_list = ConstructionRecord::where([['construction_id', '=', $item['id']]])->order('update_time desc')->select(); $step_now = 0; //进行到哪一步了 foreach ($step_list as $k => $v) { foreach ($record_list as $kk => $vv) { if ($v['id'] == $vv['step_id'] && $v['order'] > $step_now) { $step_now = $v['order']; } } } foreach ($step_list as $k => $v) { $step_list[$k]['upload'] = 0; // 判断是否上传 $step_list[$k]['need_upload'] = 0; // 判断节点是否变色(已过此节点,但是没上传) $have = false; //是否有上传 true有 $need_have = false; //没上传,但是后面的节点上传了 true是 foreach ($record_list as $kk => $vv) { if ($v['id'] == $vv['step_id']) { $have = true; } } if ($have == false && $v['order'] < $step_now) { $need_have = true; } if ($have) { $step_list[$k]['upload'] = 1; } elseif ($need_have) { $step_list[$k]['need_upload'] = 1; } } $item->step_list = $step_list; })->toArray(); //分享加密参数 店面id ,分享人id , 楼盘id , 户型id , 案例id , 在施工地id $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); foreach ($list as $key => $val) { $ids = [$this->params['rootId'],$this->params['employeeId'],'','','',$val['id']]; $list[$key]['str'] = $aec->encrypt(implode('#',$ids)); } $count = $model->where($where)->count(); return json(['code' => 0, 'data' => $list, 'count' => $count]); } /* * 案例列表 查看更多 */ public function caselist() { $param = input(''); $order = (!isset($param['order']) || !$param['order']) ? 'addtime' : $param['order']; $desc = (!isset($param['desc']) || !$param['desc']) ? 'desc' : $param['desc']; // $order = $order . ' ' . $desc; $where[] = ['root_id', '=', $this->rootId]; // 我上传的 if (!empty($param['my_case'])) { switch ($param['my_case']) { case 'publish': //通过的 $where[] = ['publish', '=', 1]; $where[] = ['del', '=', 0]; $where[] = ['employee_id', '=', $this->employeeId]; $where[] = ['from', '=', 1]; break; case 'all': //全部的 $where[] = ['employee_id', '=', $this->employeeId]; $where[] = ['from', '=', 1]; break; default: $where[] = ['publish', '=', 1]; $where[] = ['del', '=', 0]; $where[] = ['employee_id', '=', $this->employeeId]; $where[] = ['from', '=', 1]; break; } } else { $where[] = ['del', '=', 0]; $where[] = ['publish', '=', 1]; } setCondition($param, ['commu_id', 'community_id'], '=', $where); setCondition($param, 'style_id', '=', $where); setCondition($param, ['square_start', 'square'], '>=', $where); setCondition($param, ['square_end', 'square'], '<', $where); setCondition($param, ['keyword', 'title'], ['like', '%VALUE%'], $where); setCondition($param, 'housetype_id', '=', $where); if (!empty($param['id'])) $where[] = ['designer_id', '=', $param['id']]; if (!empty($param['case_type'])) { if ($param['case_type'] == 1) { $where[] = ['desc', '<>', '']; $where[] = ['desc', 'not null','']; } if ($param['case_type'] == 2) { $where[] = ['real_case', '<>', '']; $where[] = ['real_case', 'not null','']; } } $page = !empty($param['page']) ? $param['page'] : 1; $limit = !empty($param['limit']) ? $param['limit'] : 15; $list = MaterialCase::with(['designer' => function ($query) { $query->field('id,name, headimgurl,addtime'); }, 'community' => function ($query) { $query->field('id,name'); }, 'decostyle' => function ($query) { $query->field('id,name'); }])->where($where); if ($order == 'clue_number' || empty($param['order'])) { $list = $list->order('addtime desc')->select()->toArray(); } else { $list = $list->page($page, $limit)->order($order . ' ' . $desc)->select()->toArray(); } $list_ids = array_column($list, 'id'); $clue_number = CustomerClue::where([['pipe_type', '=', 'materialCase'], ['pipe_id', 'in', $list_ids]])->group('pipe_id')->column('count(id) as id_count', 'pipe_id'); foreach ($list as &$item) { $item['clue_number'] = isset($clue_number[$item['id']]) ? $clue_number[$item['id']] : 0; } // 排序 if ($order == 'clue_number') { $sort = $desc == 'desc' ? SORT_DESC : SORT_ASC; array_multisort(array_column($list, $order), $sort, array_column($list, 'addtime'), SORT_DESC, $list); $list = array_slice($list, ($page-1) * $limit, $limit); } // 默认排序 vr&video->vr->video->article if (empty($param['order'])){ $new_list['vr_video'] = []; $new_list['vr'] = []; $new_list['video'] = []; $new_list['article'] = []; foreach ($list as $k => $v){ if (!empty($v['vr_case']) && !empty($v['video_case'])){ $new_list['vr_video'][] = $v; } elseif (!empty($v['vr_case'])){ $new_list['vr'][] = $v; } elseif (!empty($v['video_case'])){ $new_list['video'][] = $v; } else { $new_list['article'][] = $v; } } $all_list = []; foreach ($new_list as $k => $v){ foreach ($v as $vv){ $all_list[] = $vv; } } $list = array_slice($all_list, ($page-1) * $limit, $limit); } //分享加密参数 店面id ,分享人id , 楼盘id , 户型id , 案例id , 在施工地id $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); foreach ($list as $key => $val) { $ids = [$this->params['rootId'],$this->params['employeeId'],'','',$val['id'],'']; $list[$key]['str'] = $aec->encrypt(implode('#',$ids)); } return json(['code' => 0, 'data' => $list, 'msg' => '获取成功']); } /** * 装修案例风格 */ public function decostylelist() { $styleArr = Decostyle::where(['root_id' => $this->rootId])->where([['type', '=', 0]])->field('id, name')->select(); return json(['code' => 0, 'data' => $styleArr, 'msg' => '获取成功']); } /* * 装修案例户型 */ public function housetypelist() { $housetypeArr = Housetype::where(['root_id' => $this->rootId])->field('id,name')->select(); return json(['code' => 0, 'data' => $housetypeArr, 'msg' => '获取成功']); } /** * 装修案例小区列表 */ public function communitylist() { $name = input('name', '', 'trim'); if ($name) { $where[] = ['name', 'like', '%' . $name . '%']; } $from = input('from', '', 'trim'); $where[] = ['type', '=', 0]; $where[] = ['root_id', '=', $this->rootId]; $communityArr = Community::where($where)->field('id,name,pinyin,case_num')->order('pinyin asc')->select()->toArray(); $comidlist = array_column($communityArr, 'id'); $caseData = MaterialCase::where([['community_id', 'in', $comidlist], ['del', '=', 0], ['publish', '=', 1]])->group('community_id')->order('updatetime asc')->column('max(updatetime) as updatetime, sum(shared_times) as shared_times, count(id) as case_num', 'community_id'); // 个人上传装修案例,数量显示为此小区下此员工上传的数量 if ($from) { foreach ($caseData as $k => $v) { $caseData[$k]['case_num'] = MaterialCase::where([['community_id', '=', $v['community_id']], ['from', '=', 1], ['employee_id', '=', request()->token['employee_id']]])->count(); } } foreach ($communityArr as &$i) { if (isset($caseData[$i['id']])) { $i['updatetime'] = $caseData[$i['id']]['updatetime']; $i['shared_times'] = (int)$caseData[$i['id']]['shared_times']; $i['case_num'] = (int)$caseData[$i['id']]['case_num']; } else { $i['updatetime'] = 0; $i['shared_times'] = 0; $i['case_num'] = 0; } } return json(['code' => 0, 'data' => $communityArr, 'msg' => '获取成功']); } public function constructionList() { $page = input('page', 1, 'intval'); $limit = input('limit', 10, 'intval'); $root_id = $this->rootId; $where[] = ['root_id', '=', $root_id]; //2023-02-06增加审核字段 $where[] = ['status','=',1]; $where[] = ['del','=',0]; $community_id = input('community_id', '', 'intval'); if ($community_id) { $where[] = ['community_id', '=', $community_id]; } $step_list = ConstructionStep::where('root_id', '=', $root_id)->order('order asc')->select()->toArray(); $order_input = input('order', 'new', 'trim'); $order = 'id desc'; $model = ConstructionModel::with(['style', 'designer', 'housetype', 'community'])->withCount(['share_log'=> function ($query) { $query->where([['type', '=', 'construction']]); }]); if ($order_input == 'new'){ $order = 'update_time desc'; } else if ($order_input = 'hot') { $order = 'share_log_count desc'; } $list = $model->where($where)->page($page, $limit)->order($order)->select()->each(function ($item) use ($step_list) { $record_list = ConstructionRecord::where([['construction_id', '=', $item['id']]])->order('update_time desc')->select(); $step_now = 0; //进行到哪一步了 foreach ($step_list as $k => $v) { foreach ($record_list as $kk => $vv) { if ($v['id'] == $vv['step_id'] && $v['order'] > $step_now) { $step_now = $v['order']; } } } foreach ($step_list as $k => $v) { $step_list[$k]['upload'] = 0; // 判断是否上传 $step_list[$k]['need_upload'] = 0; // 判断节点是否变色(已过此节点,但是没上传) $have = false; //是否有上传 true有 $need_have = false; //没上传,但是后面的节点上传了 true是 foreach ($record_list as $kk => $vv) { if ($v['id'] == $vv['step_id']) { $have = true; } } if ($have == false && $v['order'] < $step_now) { $need_have = true; } if ($have) { $step_list[$k]['upload'] = 1; } elseif ($need_have) { $step_list[$k]['need_upload'] = 1; } } $item->step_list = $step_list; }); //分享加密参数 店面id ,分享人id , 楼盘id , 户型id , 案例id , 在施工地id $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); foreach ($list as $key => $val) { $ids = [$this->params['rootId'],$this->params['employeeId'],'','','',$val['id']]; $list[$key]['str'] = $aec->encrypt(implode('#',$ids)); } return json(['code' => 0, 'data' => $list->toArray(), 'count' => $list->count()]); } /** * 装修案例 */ public function casedetail() { $id = $this->params['caseId']; if(!$id) return json(['code' => 0, 'data' => [], 'msg' => '获取成功']); $token['employee_id'] = $this->employeeId; $token['root_org'] = $this->rootId; $data = MaterialCase::with([ 'community', 'designer', 'decostyle', 'housetype' ])->where(['id' => $id, 'root_id' => $token['root_org']])->find(); MaterialCase::where(['id' => $id, 'root_id' => $token['root_org']])->inc('view_times')->update(); // 关联案例 if (!empty($data['designer_id'])){ $relatedcaselist = MaterialCase::where([['designer_id', '=', $data['designer_id']],['id', '<>', $id], ['root_id', '=', $token['root_org']], ['del', '=', 0], ['publish', '=', 1]]) ->with(['community' => function ($query) { $query->field('id,name'); }, 'decostyle' => function ($query) { $query->field('id,name'); }])->page(1, 4)->order('id desc')->select()->each(function ($item) { $item->clue_number = CustomerClue::where([['pipe_type', '=', 'materialCase'], ['pipe_id', '=', $item['id']]])->count(); })->toArray(); } else { $relatedcaselist = []; } $data['designer_related_cases'] = $relatedcaselist; //设计师附属字段 if ($data->designer) { $designer = Designer::where([['employee_id', '=', $data->designer_id], ['root_id', '=', $token['root_org']]])->field('id,good_at,position')->findOrEmpty(); if ($designer->isEmpty()) { $data->designer->good_at = ''; $data->designer->position = ''; } else { $data->designer->good_at = !empty($designer->good_at) ? $designer->good_at : ''; $data->designer->position = $designer->position ? $designer->position : ''; } $data->designer->headimgurl = User::where('id', '=', $data->designer->uid)->value('headimgurl'); } // 为null处理,防止前端报错 $data['real_case'] = !is_null($data['real_case']) ? $data['real_case'] : ''; $data['desc'] = !is_null($data['desc']) ? $data['desc'] : ''; $data['vr_case'] = !is_null($data['vr_case']) ? $data['vr_case'] : ''; return json(['code' => 0, 'data' => $data, 'msg' => '获取成功']); } //在施工地详情 public function constrationView() { $id = $this->params['constructionId']; if(!$id) return json(['code' => 0, 'data' => [], 'msg' => '获取成功']); $share = input('share', '', 'trim'); $info = ConstructionModel::with(['style', 'designer', 'housetype', 'community'])->find($id); $root_id = $this->rootId; $step_list = ConstructionStep::where('root_id', '=', $root_id)->order('order asc')->select()->toArray(); $record_list = ConstructionRecord::where([['construction_id', '=', $id]])->order('update_time desc')->select(); $step_now = 0; //进行到哪一步了 foreach ($step_list as $k => $v) { foreach ($record_list as $kk => $vv) { if ($v['id'] == $vv['step_id'] && $v['order'] > $step_now) { $step_now = $v['order']; } } } $vrObj = new Vr(); foreach ($step_list as $k => $v) { $step_list[$k]['upload'] = 0; // 判断是否上传 $step_list[$k]['need_upload'] = 0; // 判断节点是否变色(已过此节点,但是没上传) $have = false; //是否有上传 true有 $need_have = false; //没上传,但是后面的节点上传了 true是 $step_list[$k]['data'] = []; foreach ($record_list as $kk => $vv) { if ($v['id'] == $vv['step_id']) { $have = true; if (!empty($vv['vr']) && $vv['type'] == 'vr') { $vrUrlList = explode(',', $vv['vr']); $vrData = []; foreach ($vrUrlList as $url) { $vrData[] = [ 'vrUrl' => $url, 'vrfirstImg' => $vrObj->getFirstImg($url) ]; } $vv['vr'] = $vrData; } $step_list[$k]['data'] = $vv; } } if ($have == false && $v['order'] < $step_now) { $need_have = true; } if ($have) { $step_list[$k]['upload'] = 1; } elseif ($need_have) { $step_list[$k]['need_upload'] = 1; } } $info['step_list'] = $step_list; return json(['code'=> 0, 'msg'=> '请求成功', 'data'=> $info]); } }