'new','name'=>'','page'=>1,'limit'=>10,'collect'=>0]); $order = $param['order']=='new' ? 'update_time desc' : 'share_log_count desc'; $model = BuildingModel::with(['share_log'])->withCount(['share_log' => function ($query) { $query->where([['type', '=', 'Building']]); }]); $where[] = ['root_id', '=', $this->rootId]; $where[] = ['del', '=', 0]; if ($param['name']) { $condition = [ ['root_id', '=', $this->rootId], ['type', '=', 0], ['name', 'like', '%' . $param['name'] . '%'] ]; $community_id = Community::where($condition)->column('id'); $where[] = ['community_id', 'in', $community_id]; } //查询收藏 if ($param['collect']) { $bids = UserCollect::where([['user_id','=',$this->uid],['content_type','=','building']])->column('content_id'); if(empty($bids)) return json(['code' => 0, 'data' => []]); $where[] = ['id','in',$bids]; } //权限区分 设置可见人可以查看全部 否则 查询指派给我的 和 没有指派的 $special=BuildingSpecialEmp::where([['root_id','=',$this->rootId],['assign_employee','find in set',$this->employeeId]])->field('id')->findOrEmpty(); $info = Employee::where('id',$this->employeeId)->field('id,org_id,uid')->find(); if ($special->isEmpty()) { $where1 = array_merge($where,[['assign_employee','find in set',$this->employeeId]]); $where2 = array_merge($where,[['from','=',0],['assign_employee','null',null]]); $where3 = array_merge($where,[['from','=',1],['org_id','=',$info->org_id]]); $model = $model->whereOr([$where1,$where2,$where3]); }else{ $model = $model->where($where); } $list = $model->page((int)$param['page'],(int)$param['limit'])->order($order)->select()->each(function ($item) use($info) { $area_list = BuildingHousetype::where('building_id', '=', $item['id'])->order('area asc')->column('area'); $item->area_list = array_values(array_unique(array_filter($area_list))); $collectedIds = UserCollect::where(['user_id' => $info->uid, 'content_type' => 'building'])->column('content_id'); if (in_array($item['id'], $collectedIds)) { $item['collected'] = true; } else { $item['collected'] = false; } })->toArray(); return json(['code' => 0, 'data' => $list]); } /** * 楼书详情 */ public function view() { $param = Request::only(['id'=>0]); $info = BuildingModel::where([['root_id','=',$this->rootId],['id','=',$param['id']]])->findOrEmpty(); if($info->isEmpty()) return json(['code' => 1, 'msg' => '数据不存在']); $id = $param['id']; $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']; //小区户型 $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()->toArray(); $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); foreach ($housetype as $key => $value) { //分享加密参数 店面id ,分享人id , 楼盘id , 户型id , 案例id , 在施工地id $ids = [$this->rootId,$this->employeeId,$param['id'],$value['id'],'','']; $housetype[$key]['str'] = $aec->encrypt(implode('#',$ids)); } $xin = null; $vrObj = new Vr(); if(!empty($housetype)){ $houselist=$housetype; 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']); } } } foreach($houselist as $key => $val){ $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'] = count($housetype); $emp = Employee::where('id',$this->employeeId)->field('id,org_id,uid')->find(); $collectedIds = UserCollect::where(['user_id' => $emp->uid, 'content_type' => 'building','content_id'=>$info['id']])->count(); if ($collectedIds) { $info['collected'] = true; } else { $info['collected'] = false; } //增加进度图片视频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; //分享加密参数 店面id ,分享人id , 楼盘id , 户型id , 案例id , 在施工地id $ids = [$this->rootId,$this->employeeId,$param['id'],'','','']; $value = $aec->encrypt(implode('#',$ids)); if (empty($info->vr_link) && $info->vr_group_ids) { $info->vr_link = config('app.vr_show_domain').VrGroup::where('id',$info->vr_group_ids)->value('sid'); } return json(['code' => 0, 'data' => $info,'str'=>$value]); } /** * 楼盘进度 */ public function progress() { $id = input('id', '', 'intval'); $type = input('type','','trim'); $where[]=['building_id', '=', $id]; if(!empty($type)){ $where[]=['type', '=', $type]; } $page = input('page',1); $limit = input('limit',3); $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; } return json(['code' => 0, 'data' => $list]); } /** * 户型下的在施工地 */ public function construction(){ //$building_id = input('building_id', '', 'intval'); //$construction_id = BuildingConstruction::where('building_id', '=', $building_id)->column('construction_id'); //$where[] = ['id', 'in', $construction_id]; $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->rootId; $where[] = ['root_id', '=', $root_id]; $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 = 'update_time 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'; $list = $model->where($where)->page($page, $limit)->order($order)->select(); } else if ($order_input == 'hot') { $list = $model->where($where)->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; //收藏状态 $user_id = $this->uid; $had = UserCollect::where(['user_id' => $user_id , 'content_type' => 'construction' , 'content_id' => $item['id']])->count(); if ($had) { $item['collect'] = 1; } else { $item['collect'] = 0; } })->toArray(); if ($order_input == 'hot') { $list_all = $list; $share_log_count = array_column($list_all, 'share_log_count'); array_multisort($share_log_count, SORT_DESC, $list_all); $list = array_slice($list_all, $limit*($page-1), $limit); } $count = $model->where($where)->count(); return json(['code' => 0, 'data' => $list, 'count' => $count]); } /** * 户型关联案例 */ public function material_case() { $housetype_id = input('housetype_id',0); $page = input('page',1,'intval'); $limit = input('limit',10,'intval'); $info = Employee::where('id',$this->employeeId)->field('id,org_id,uid')->find(); $case_ids = BuildingMaterialCase::where([['housetype_id','=',$housetype_id],['root_id','=',$this->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($page,$limit)->where($where)->select(); $collectedIds = UserCollect::where(['user_id' => $info->uid, 'content_type' => 'materialCase'])->column('content_id'); $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); foreach ($list as &$item) { if (in_array($item['id'], $collectedIds)) { $item['collected'] = true; } else { $item['collected'] = false; } //分享加密参数 店面id ,分享人id , 楼盘id , 户型id , 案例id , 在施工地id $ids = [$this->rootId,$this->employeeId,'','',$item['id'],'']; $item['str'] = $aec->encrypt(implode('#',$ids)); } $data = ['list'=> $list]; $count = MaterialCase::where($where)->count(); return json(['code' => 0, 'data' => $data,'count'=>$count, 'msg' => '获取成功']); } /** * 收藏 */ public function collect() { $id = input('id',0); $user_id = $this->uid; $had = UserCollect::where(['user_id' => $user_id, 'content_type' => 'building', 'content_id' => $id])->count(); if ($had > 0) return json(['code' => 1, 'msg' => '您已收藏']); UserCollect::insert(['user_id' => $user_id, 'content_type' => 'building', 'content_id' => $id]); return json(['code' => 0, 'msg' => '收藏成功']); } /** * 取消收藏 */ public function collectCancel($id) { $user_id = $this->uid; UserCollect::where(['user_id' => $user_id, 'content_type' => 'building', 'content_id' => $id])->delete(); return json(['code' => 0, 'msg' => '取消收藏']); } //户型详情 public function housetype_detail() { $id = input('id', '', 'intval'); 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') : ''; } //是否收藏 $where = [ ['root_id','=',$this->rootId], ['employee_id','=',$this->employeeId], ['building_id','=',$data->building_id], ['building_housetype_id','=',$id], ['type','=',1] ]; $data->is_collect = BuildingHousetypeCollect::where($where)->value('id') ? 1 : 0; //分享加密参数 店面id ,分享人id , 楼盘id , 户型id , 案例id , 在施工地id $ids = [$this->rootId,$this->employeeId,'',$id,'','']; $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); $value = $aec->encrypt(implode('#',$ids)); 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'=> '获取成功','str'=>$value]); } /* * 案例列表 */ 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(); } $collectedIds = UserCollect::where(['user_id' => $this->uid, 'content_type' => 'materialCase'])->column('content_id'); $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) { if (in_array($item['id'], $collectedIds)) { $item['collected'] = true; } else { $item['collected'] = false; } $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'] = []; $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); foreach ($list as $k => $v){ //分享加密参数 店面id ,分享人id , 楼盘id , 户型id , 案例id , 在施工地id $ids = [$this->rootId,$this->employeeId,'','',$v['id'],'']; $v['str'] = $aec->encrypt(implode('#',$ids)); 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); } 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; }); return json(['code' => 0, 'data' => $list->toArray(), 'count' => $list->count()]); } /** * 装修案例 */ public function casedetail() { $id = input('id',0); $token['uid'] = $this->uid; $token['employee_id'] = $this->employeeId; $token['root_org'] = $this->rootId; $colected = UserCollect::where(['user_id' => $token['uid'], 'content_type' => 'materialCase', 'content_id' => $id])->count(); $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(); $data['collected'] = $colected > 0 ? true : false; // 关联案例 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'] : ''; //分享加密参数 店面id ,分享人id , 楼盘id , 户型id , 案例id , 在施工地id $ids = [$this->rootId,$this->employeeId,'','',$id,'']; $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); $value = $aec->encrypt(implode('#',$ids)); return json(['code' => 0, 'data' => $data, 'msg' => '获取成功','str'=>$value]); } //在施工地详情 public function constrationView() { $id = input('id', '', 'intval'); if (empty($id)) { return json(['code' => self::error_msg, '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; //分享加密参数 店面id ,分享人id , 楼盘id , 户型id , 案例id , 在施工地id $ids = [$this->rootId,$this->employeeId,'','','',$id]; $aec = new Aec(config('app.aec_key'), config('app.aec_iv')); $value = $aec->encrypt(implode('#',$ids)); return json(['code'=> 0, 'msg'=> '请求成功', 'data'=> $info,'str'=>$value]); } /** * 收藏 */ public function collects() { $param = input(''); $data = [ 'user_id' => $this->uid, 'content_type' => $param['content_type'], 'content_id' => $param['content_id'] ]; $collect = UserCollect::where($data)->find(); if ($collect) { $collect->delete(); return json(['code' => 0, 'msg' => '取消收藏']); } else { UserCollect::create($data); return json(['code' => 0, 'msg' => '收藏成功']); } } /** * 个人信息 */ public function getUserInfo() { $emp = Employee::where('id',$this->employeeId)->field('org_id,qrcode,id,phone,uid,root_id,name,opt_name,wx,position,image_photo,xq_mobile_openid')->find(); //数据问题导致报错 $user = User::where('id',$emp->uid)->findOrEmpty(); if ($user->isEmpty()) { $emp->headimgurl = ''; $emp->nickname = ''; }else{ $emp->headimgurl = $user->headimgurl; $emp->nickname = $user->nickname; } $emp->company_name = $emp->companyJoin->company_name; $emp->logo = $emp->companyJoin->logo; $emp->org_name = $emp->org->name; $ali_oss_bindurl = config('app.ali_oss_bindurl'); $emp->qrcode = ($emp->qrcode&&strpos($emp->qrcode,'http')===false) ? 'https://' . $ali_oss_bindurl . '/' . $emp->qrcode : $emp->qrcode; $emp->notify = Miniprogram::where('root_id',$emp->root_id)->value('notify'); $emp = $emp->toArray(); unset($emp['user']); unset($emp['companyJoin']); unset($emp['org']); return json(['code' => 0,'data'=>$emp , 'msg' => '']); } /** * 收藏楼盘户型 */ public function collectHousetype(){ $param = Request::only(['building_id'=>0,'building_housetype_id'=>0]); $token = [ 'root_org' => $this->rootId, 'employee_id'=>$this->employeeId, ]; $where = [ ['root_id','=',$token['root_org']], ['building_id','=',$param['building_id']], ['id','=',$param['building_housetype_id']] ]; $check = BuildingHousetype::where($where)->findOrEmpty(); if($check->isEmpty()) return json(['code'=> 1, 'msg'=> '收藏失败', 'data'=> []]); $where = [ ['root_id','=',$token['root_org']], ['employee_id','=',$token['employee_id']], ['building_id','=',$param['building_id']], ['building_housetype_id','=',$param['building_housetype_id']], ['type','=',1] ]; $info = BuildingHousetypeCollect::where($where)->findOrEmpty(); if (!$info->isEmpty()) return json(['code'=> 1, 'msg'=> '已经收藏', 'data'=> []]); BuildingHousetypeCollect::insert([ 'root_id'=>$token['root_org'], 'employee_id'=>$token['employee_id'], 'building_id'=>$param['building_id'], 'building_housetype_id'=>$param['building_housetype_id'], 'type'=>1 ]); return json(['code'=> 0, 'msg'=> '收藏成功', 'data'=> []]); } /** * 取消收藏 */ public function cancelCollectHousetype(){ $param = Request::only(['building_id'=>0,'building_housetype_id'=>0]); $token = [ 'root_org' => $this->rootId, 'employee_id'=>$this->employeeId, ]; $where = [ ['root_id','=',$token['root_org']], ['employee_id','=',$token['employee_id']], ['building_id','=',$param['building_id']], ['building_housetype_id','=',$param['building_housetype_id']], ['type','=',1] ]; $info = BuildingHousetypeCollect::where($where)->field('id')->findOrEmpty(); if($info->isEmpty()) return json(['code'=> 1, 'msg'=> '取消失败', 'data'=> []]); BuildingHousetypeCollect::where($where)->delete(); return json(['code'=> 0, 'msg'=> '取消成功', 'data'=> []]); } /** * 获取楼盘标签 */ public function getBuildingLabel() { $data = ModelBuildingLabel::where(['root_id' => $this->rootId])->field('id,name')->select(); return json(['code'=>0, 'data'=>$data]); } }