[ 'class' => QueryParamAuth::className(), 'tokenParam' => "token",//access-token修改为token 'optional' => [//不需要认证方法名 array ], ] ]); } /** * 添加样板房 */ public function actionAddRoom() { $post = Yii::$app->request->post(); if(empty($post['name']) || empty($post['acreage']) || empty($post['budget']) || empty($post['opening_begin']) || empty($post['opening_end']) || empty($post['layout']) || empty($post['style'])) return Apireturn::sent(0,'请填写完整信息',200); $str_opening_begin = strtotime($post['opening_begin']); $str_opening_end = strtotime($post['opening_end']); if($str_opening_begin > $str_opening_end) return Apireturn::sent(0,'可约时间不能大于结束时间',200); if(empty($post['designer_id']) || empty($post['manager_id'])) return Apireturn::sent(0,'请选择设计师和项目经理',200); if(empty($post['province']) || empty($post['city']) || empty($post['district']) ) return Apireturn::sent(0,'请选择地区',200); if(empty($post['address'])) return Apireturn::sent(0,'请输入详细地址',200); if(empty($post['longitude']) || empty($post['latitude'])) return Apireturn::sent(0,'缺少经纬度',200); $model = new Building(); $model->uid = Yii::$app->user->id; $model->name = $post['name']; $model->type = Building::TYPE_HOUSE; $model->latitude = $post['latitude']; $model->longitude = $post['longitude']; if(!empty($model->longitude)&&!empty($model->latitude)) { $geohash = new ZM_Geohash(); $geohash->init_codingMap(); $model->hashcode = $geohash->encode($model->latitude, $model->longitude); } $model->province = $post['province']; $model->city = $post['city']; $model->district = $post['district']; $model->address = $post['address']; $model->created_at = time(); $model->updated_at = time(); $model->status = Building::STATUS_SUCCESS; $model->acreage = $post['acreage']; $model->budget = $post['budget']; $model->layout = $post['layout']; $model->style = $post['style']; $model->opening_begin =$str_opening_begin; $model->opening_end = $str_opening_end; $model->manager_id = $post['manager_id']; $model->designer_id = $post['designer_id']; $model->posted = Building::POSTED_YES; if($model->save()) { $this->uploadBuildingImg($model->id,$post); return Apireturn::sent(1,'添加样板房成功',200); }else{ return Apireturn::sent(0,'添加样板房失败',200); } } /** * 查看样板房 */ public function actionCheckRoom() { $id = Yii::$app->request->post('id'); if(empty($id)) return Apireturn::sent(0,'非法操作',200); $info = Building::find()->where(['id'=>$id,'uid'=>Yii::$app->user->id])->select("id,name,latitude,longitude,province,city,district,address,layout,acreage,opening_begin,opening_end,budget,style,manager_id,designer_id")->one(); if(empty($info)) return Apireturn::sent(0,'找不到该样板房',200); $arr = array(); foreach ($info->getOldAttributes() as $key =>$value) { $arr[$key] = $value; } //设计师详情 $data['designer'] = array(); if(!empty($info->designer)) { $arr['designer']['id'] = $info->designer->id; $arr['designer']['realname'] = $info->designer->realname; } //项目经理详情 $data['manager'] = array(); if(!empty($info->manager)) { $arr['manager']['id'] = $info->manager->id; $arr['manager']['realname'] = $info->manager->realname; } $arr['living_room'] = $info->living ? $info->living->pic : "" ; $arr['master_bedroom'] = $info->master ? $info->master->pic : "" ; $arr['portion'] = $info->portion ? $info->portion->pic : "" ; $arr['portion2'] = $info->portion2 ? $info->portion2->pic : "" ; $arr['portion3'] = $info->portion3 ? $info->portion3->pic : "" ; $arr['portion4'] = $info->portion4 ? $info->portion4->pic : "" ; $arr['portion5'] = $info->portion5 ? $info->portion5->pic : "" ; $arr['flat'] = $info->flat ? $info->flat->pic : "" ; $arr['province_name'] = !empty($info->province) ? Area::queryCity($info->province) : ""; $arr['city_name'] = !empty($info->city) ? Area::queryCity($info->city) : ""; $arr['district_name'] = !empty($info->district) ? Area::queryCity($info->district) : ""; return Apireturn::sent(1,'success',200,$arr); } /** * 编辑样板房 */ public function actionEditRoom() { $post = Yii::$app->request->post(); if(empty($post['id'])) return Apireturn::sent(0,'缺少id',200); $model = Building::find()->where(['id'=>$post['id'],'uid'=>Yii::$app->user->id])->one(); if(empty($model)) return Apireturn::sent(0,'找不到该样板房',200); if(empty($post['name']) || empty($post['acreage']) || empty($post['budget']) || empty($post['opening_begin']) || empty($post['opening_end']) || empty($post['layout']) || empty($post['style'])) return Apireturn::sent(0,'请填写完整信息',200); $str_opening_begin = strtotime($post['opening_begin']); $str_opening_end = strtotime($post['opening_end']); if($str_opening_begin > $str_opening_end) return Apireturn::sent(0,'可约时间不能大于结束时间',200); if(empty($post['designer_id']) || empty($post['manager_id'])) return Apireturn::sent(0,'请选择设计师和项目经理',200); if(empty($post['province']) || empty($post['city']) || empty($post['district']) ) return Apireturn::sent(0,'请选择地区',200); if(empty($post['address'])) return Apireturn::sent(0,'请输入详细地址',200); if(empty($post['longitude']) || empty($post['latitude'])) return Apireturn::sent(0,'缺少经纬度',200); if(!empty($model->longitude)&&!empty($model->latitude)) { $geohash = new ZM_Geohash(); $geohash->init_codingMap(); $model->hashcode = $geohash->encode($model->latitude, $model->longitude); } $model->name = $post['name']; $model->latitude = $post['latitude']; $model->longitude = $post['longitude']; $model->province = $post['province']; $model->city = $post['city']; $model->district = $post['district']; $model->address = $post['address']; $model->updated_at = time(); $model->acreage = $post['acreage']; $model->budget = $post['budget']; $model->layout = $post['layout']; $model->style = $post['style']; $model->opening_begin =$str_opening_begin; $model->opening_end = $str_opening_end; $model->manager_id = $post['manager_id']; $model->designer_id = $post['designer_id']; if($model->save()) { $this->uploadBuildingImg($model->id,$post,'edit'); return Apireturn::sent(1,'修改样板房成功',200); }else{ return Apireturn::sent(0,'修改样板房失败',200); } } /** * 添加工地 */ public function actionAddWork() { $post = Yii::$app->request->post(); if(empty($post['name']) || empty($post['acreage']) || empty($post['budget']) || empty($post['opening_begin']) || empty($post['opening_end']) || empty($post['layout']) || empty($post['style']) || empty($post['stage']) || empty($post['pattern']) ) return Apireturn::sent(0,'请填写完整信息',200); $str_opening_begin = strtotime($post['opening_begin']); $str_opening_end = strtotime($post['opening_end']); if($str_opening_begin > $str_opening_end) return Apireturn::sent(0,'可约时间不能大于结束时间',200); if(empty($post['designer_id']) || empty($post['manager_id'])) return Apireturn::sent(0,'请选择设计师和项目经理',200); if(empty($post['province']) || empty($post['city']) || empty($post['district']) ) return Apireturn::sent(0,'请选择地区',200); if(empty($post['address'])) return Apireturn::sent(0,'请输入详细地址',200); if(empty($post['longitude']) || empty($post['latitude'])) return Apireturn::sent(0,'缺少经纬度',200); $model = new Building(); $model->uid = Yii::$app->user->id; $model->name = $post['name']; $model->type = Building::TYPE_SITE; $model->latitude = $post['latitude']; $model->longitude = $post['longitude']; if(!empty($model->longitude)&&!empty($model->latitude)) { $geohash = new ZM_Geohash(); $geohash->init_codingMap(); $model->hashcode = $geohash->encode($model->latitude, $model->longitude); } $model->stage = $post['stage']; $model->pattern = $post['pattern']; $model->province = $post['province']; $model->city = $post['city']; $model->district = $post['district']; $model->address = $post['address']; $model->created_at = time(); $model->updated_at = time(); $model->status = Building::STATUS_SUCCESS; $model->acreage = $post['acreage']; $model->budget = $post['budget']; $model->layout = $post['layout']; $model->style = $post['style']; $model->opening_begin =$str_opening_begin; $model->opening_end = $str_opening_end; $model->manager_id = $post['manager_id']; $model->designer_id = $post['designer_id']; $model->posted = Building::POSTED_YES; if($model->save()) { $this->uploadBuildingImg($model->id,$post); return Apireturn::sent(1,'添加样板房成功',200); }else{ return Apireturn::sent(0,'添加样板房失败',200); } } /** * 查看工地 */ public function actionCheckWork() { $id = Yii::$app->request->post('id'); if(empty($id)) return Apireturn::sent(0,'非法操作',200); $info = Building::find()->where(['id'=>$id,'uid'=>Yii::$app->user->id])->select("id,name,latitude,longitude,province,city,district,address,layout,stage,pattern,acreage,opening_begin,opening_end,budget,style,manager_id,designer_id")->one(); if(empty($info)) return Apireturn::sent(0,'找不到该工地',200); $arr = array(); foreach ($info->getOldAttributes() as $key =>$value) { $arr[$key] = $value; } //设计师详情 $data['designer'] = array(); if(!empty($info->designer)) { $arr['designer']['id'] = $info->designer->id; $arr['designer']['realname'] = $info->designer->realname; } //项目经理详情 $data['manager'] = array(); if(!empty($info->manager)) { $arr['manager']['id'] = $info->manager->id; $arr['manager']['realname'] = $info->manager->realname; } $arr['living_room'] = $info->living ? $info->living->pic : "" ; $arr['master_bedroom'] = $info->master ? $info->master->pic : "" ; $arr['portion'] = $info->portion ? $info->portion->pic : "" ; $arr['build'] = $info->build ? $info->build->pic : "" ; $arr['build2'] = $info->build2 ? $info->build2->pic : "" ; $arr['flat'] = $info->flat ? $info->flat->pic : "" ; $arr['province_name'] = !empty($info->province) ? Area::queryCity($info->province) : ""; $arr['city_name'] = !empty($info->city) ? Area::queryCity($info->city) : ""; $arr['district_name'] = !empty($info->district) ? Area::queryCity($info->district) : ""; return Apireturn::sent(1,'success',200,$arr); } /** * 工地详情 */ public function actionWorkInfo() { $id = Yii::$app->request->post('id'); $model = Building::find()->where(['id'=>$id,'uid'=>Yii::$app->user->id,'type'=>Building::TYPE_SITE])->select('id,name,latitude,longitude,layout,budget,stage,style,acreage,pattern,address,opening_begin,opening_end,manager_id,designer_id,view')->one(); if(empty($model)) return Apireturn::sent(0,'找不到该工地',200); $data = array(); foreach ($model->getOldAttributes() as $key => $value) { $data[$key] = $value; } /*公司名称 $data['companyName'] = ""; $userCompany = UserCompany::find()->select('company')->where(['uid'=>Yii::$app->user->id])->one(); if(!empty($userCompany)) $data['companyName'] = $userCompany->company;*/ //户型图 $data['flat']=""; if(!empty($model->flat->pic)) $data['flat'] = $model->flat->pic; //设计师详情 $data['designer'] = array(); if(!empty($model->designer)) { $data['designer']['id'] = $model->designer->id; $data['designer']['pic'] = !empty($model->designer->image->pic) ? $model->designer->image->pic : ""; $data['designer']['realname'] = $model->designer->realname; } //项目经理详情 $data['manager'] = array(); if(!empty($model->manager)) { $data['manager']['id'] = $model->manager->id; $data['manager']['pic'] = !empty($model->manager->image->pic) ? $model->manager->image->pic : ""; $data['manager']['realname'] = $model->manager->realname; } //轮播图列表 $data['imgs'] = array(); if(!empty($model->allimg)) { foreach ($model->allimg as $img_val) { $data['imgs'][] = $img_val->pic; } } //预约人列表 $data['appoints'] = array(); if(!empty($model->appointment)) { foreach ($model->appointment as $user) { $data['appoints'][] = !empty($user->user->userinfo->portrait) ? UserInfo::imagesUrl($user->user->userinfo->portrait):""; } } //所有评论 $comment = Comment::find()->select("id,star,uid,content,created_at")->where('pid=:id and status = :status',[':id'=>$id,':status'=>Comment::STATUS_ACTIVE])->orderBy("created_at DESC")->all(); $data['comments'] = array(); if(!empty($comment)) { foreach ($comment as $com_key => $com_val) { $data['comments'][$com_key]['id'] = $com_val->id; $data['comments'][$com_key]['star'] = $com_val->star; $data['comments'][$com_key]['content'] = $com_val->content; $data['comments'][$com_key]['created_at'] = Comment::time_tran($com_val->created_at); $data['comments'][$com_key]['imgs'] = ImageSource::find()->select('pic')->where(['topid'=>$com_val->id,'type'=>ImageSource::TYPE_COMMENT,'status'=>ImageSource::STATUS_YES])->asArray()->all(); if(!empty($com_val->userinfo)) { $data['comments'][$com_key]['portrait'] = !empty($com_val->userinfo->portrait) ? UserInfo::imagesUrl($com_val->userinfo->portrait):"";; $data['comments'][$com_key]['nickname'] = $com_val->userinfo->nickname; } $data['comments'][$com_key]['replys'] = array(); $replys = Reply::find()->where(['cid'=>$com_val->id,'status'=>Reply::STATUS_ACTIVE])->select('id,from_userid,to_userid,content')->orderBy('created_at ASC')->all(); if(!empty($replys)) { foreach ($replys as $rep_key => $rep_val) { $data['comments'][$com_key]['replys'][$rep_key]['own'] = $rep_val->from_userid == Yii::$app->user->id ? 1 : 0 ; $data['comments'][$com_key]['replys'][$rep_key]['content'] = $rep_val->content; } } } } return Apireturn::sent(1,'success',200,$data); } /** * 编辑工地 */ public function actionEditWork() { $post = Yii::$app->request->post(); if(empty($post['id'])) return Apireturn::sent(0,'缺少id',200); $model = Building::find()->where(['id'=>$post['id'],'uid'=>Yii::$app->user->id])->one(); if(empty($model)) return Apireturn::sent(0,'找不到该样板房',200); if(empty($post['name']) || empty($post['acreage']) || empty($post['budget']) || empty($post['opening_begin']) || empty($post['opening_end']) || empty($post['layout']) || empty($post['style']) || empty($post['stage']) || empty($post['pattern']) ) return Apireturn::sent(0,'请填写完整信息',200); $str_opening_begin = strtotime($post['opening_begin']); $str_opening_end = strtotime($post['opening_end']); if($str_opening_begin > $str_opening_end) return Apireturn::sent(0,'可约时间不能大于结束时间',200); if(empty($post['designer_id']) || empty($post['manager_id'])) return Apireturn::sent(0,'请选择设计师和项目经理',200); if(empty($post['province']) || empty($post['city']) || empty($post['district']) ) return Apireturn::sent(0,'请选择地区',200); if(empty($post['address'])) return Apireturn::sent(0,'请输入详细地址',200); if(empty($post['longitude']) || empty($post['latitude'])) return Apireturn::sent(0,'缺少经纬度',200); $model->name = $post['name']; $model->latitude = $post['latitude']; $model->longitude = $post['longitude']; if(!empty($model->longitude)&&!empty($model->latitude)) { $geohash = new ZM_Geohash(); $geohash->init_codingMap(); $model->hashcode = $geohash->encode($model->latitude, $model->longitude); } $model->stage = $post['stage']; $model->pattern = $post['pattern']; $model->province = $post['province']; $model->city = $post['city']; $model->district = $post['district']; $model->address = $post['address']; $model->updated_at = time(); $model->acreage = $post['acreage']; $model->budget = $post['budget']; $model->layout = $post['layout']; $model->style = $post['style']; $model->opening_begin =$str_opening_begin; $model->opening_end = $str_opening_end; $model->manager_id = $post['manager_id']; $model->designer_id = $post['designer_id']; if($model->save()) { $this->uploadBuildingImg($model->id,$post,'edit'); return Apireturn::sent(1,'修改成功',200); }else{ return Apireturn::sent(0,'修改失败',200); } } /** * 更改样板房/工地发布状态 */ public function actionUpdatePosted() { $post = Yii::$app->request->post(); if(empty($post['id'])) return Apireturn::sent(0,'非法操作'); $model = Building::find()->where(['id'=>$post['id'],'uid'=>Yii::$app->user->id])->one(); if(empty($model)) return Apireturn::sent(0,'找不到记录'); if(!in_array($post['posted'],array(Building::POSTED_YES,Building::POSTED_NO))) return Apireturn::sent(0,'参数错误'); $posted = $post['posted']; $model->posted = $posted; if($model->save()) return Apireturn::sent(1,'操作成功'); else return Apireturn::sent(0,'操作失败'); } /** * 获取设计师 */ public function actionDesigner() { $list = Designer::find()->where(['company'=>Yii::$app->user->id,'status'=>Designer::STATUS_YES])->select('id,realname,introduction')->orderBy('id DESC')->all(); $arr =array(); if(!empty($list)){ foreach ($list as $value) { $arr[] = array('id'=>$value->id,'realname'=>$value->realname,'introduction'=>$value->introduction,'pic'=>$value->image?$value->image->pic:""); } } return Apireturn::sent(1,'success',200,$arr); } /** * 获取项目经理 */ public function actionManager() { $list = Manager::find()->where(['company'=>Yii::$app->user->id,'status'=>Manager::STATUS_YES])->select('id,realname,introduction')->orderBy('id DESC')->all(); $arr =array(); if(!empty($list)){ foreach ($list as $value) { $arr[] = array('id'=>$value->id,'realname'=>$value->realname,'introduction'=>$value->introduction,'pic'=>$value->image?$value->image->pic:""); } } return Apireturn::sent(1,'success',200,$arr); } /** * 我的工地列表 */ public function actionWorkList() { $page = Yii::$app->request->POST('page', 1);//分页页数 $display = Yii::$app->request->POST('display', self::DISPLAY);//分页页数 $list = Building::findBySql("SELECT id,name,layout,acreage,style,designer_id,posted FROM {{%building}} WHERE uid = :uid AND type = :type AND (posted = :posted OR posted = :posted2) ORDER BY id DESC limit " . ($page - 1) * $display . "," . $display,[':uid'=>Yii::$app->user->id,':posted'=>Building::POSTED_YES,':posted2'=>Building::POSTED_NO,':type'=>Building::TYPE_SITE])->all(); $count = Building::find()->where('uid = :uid AND type = :type AND (posted = :posted OR posted = :posted2)',[':uid'=>Yii::$app->user->id,':posted'=>Building::POSTED_YES,':posted2'=>Building::POSTED_NO,':type'=>Building::TYPE_SITE])->count(); $arr = array(); if(!empty($list)){ foreach ($list as $key => $value) { foreach ($value->getOldAttributes() as $key2 =>$value2) { $arr[$key][$key2] = $value2; } $arr[$key]['design_name'] = $value->designer?$value->designer->realname:""; $arr[$key]['pic'] = $value->all?$value->all->pic:""; } } return Apireturn::sent(1,'success',200,array('count'=>$count,'list'=>$arr)); } /** * 我的样板房列表 */ public function actionRoomList() { $page = Yii::$app->request->POST('page', 1);//分页页数 $display = Yii::$app->request->POST('display', self::DISPLAY);//分页页数 $list = Building::findBySql("SELECT id,name,layout,acreage,style,designer_id,posted FROM {{%building}} WHERE uid = :uid AND type = :type AND (posted = :posted OR posted = :posted2) ORDER BY id DESC limit " . ($page - 1) * $display . "," . $display,[':uid'=>Yii::$app->user->id,':posted'=>Building::POSTED_YES,':posted2'=>Building::POSTED_NO,':type'=>Building::TYPE_HOUSE])->all(); $count = Building::find()->where('uid = :uid AND type = :type AND (posted = :posted OR posted = :posted2)',[':uid'=>Yii::$app->user->id,':posted'=>Building::POSTED_YES,':posted2'=>Building::POSTED_NO,':type'=>Building::TYPE_HOUSE])->count(); $arr = array(); if(!empty($list)){ foreach ($list as $key => $value) { foreach ($value->getOldAttributes() as $key2 =>$value2) { $arr[$key][$key2] = $value2; } $arr[$key]['design_name'] = $value->designer?$value->designer->realname:""; $arr[$key]['pic'] = $value->all?$value->all->pic:""; } } return Apireturn::sent(1,'success',200,array('count'=>$count,'list'=>$arr)); } /** * 样板房详情 */ public function actionRoomInfo() { $id = Yii::$app->request->post('id'); $model = Building::find()->where(['id'=>$id,'uid'=>Yii::$app->user->id,'type'=>Building::TYPE_HOUSE])->select('id,name,latitude,longitude,layout,budget,style,acreage,address,opening_begin,opening_end,manager_id,designer_id,view')->one(); if(empty($model)) return Apireturn::sent(0,'找不到该工地',200); $data = array(); foreach ($model->getOldAttributes() as $key => $value) { $data[$key] = $value; } /*公司名称 $data['companyName'] = ""; $userCompany = UserCompany::find()->select('company')->where(['uid'=>Yii::$app->user->id])->one(); if(!empty($userCompany)) $data['companyName'] = $userCompany->company;*/ //户型图 $data['flat']=""; if(!empty($model->flat->pic)) $data['flat'] = $model->flat->pic; //设计师详情 $data['designer'] = array(); if(!empty($model->designer)) { $data['designer']['id'] = $model->designer->id; $data['designer']['pic'] = !empty($model->designer->image->pic) ? $model->designer->image->pic : ""; $data['designer']['realname'] = $model->designer->realname; } //项目经理详情 $data['manager'] = array(); if(!empty($model->manager)) { $data['manager']['id'] = $model->manager->id; $data['manager']['pic'] = !empty($model->manager->image->pic) ? $model->manager->image->pic : ""; $data['manager']['realname'] = $model->manager->realname; } //轮播图列表 $data['imgs'] = array(); if(!empty($model->allimg)) { foreach ($model->allimg as $img_val) { $data['imgs'][] = $img_val->pic; } } //预约人列表 $data['appoints'] = array(); if(!empty($model->appointment)) { foreach ($model->appointment as $user) { $data['appoints'][] = !empty($user->user->userinfo->portrait) ? UserInfo::imagesUrl($user->user->userinfo->portrait):""; } } //所有评论 $comment = Comment::find()->select("id,star,uid,content,created_at")->where('pid=:id and status = :status',[':id'=>$id,':status'=>Comment::STATUS_ACTIVE])->orderBy("created_at DESC")->all(); $data['comments'] = array(); if(!empty($comment)) { foreach ($comment as $com_key => $com_val) { $data['comments'][$com_key]['id'] = $com_val->id; $data['comments'][$com_key]['star'] = $com_val->star; $data['comments'][$com_key]['content'] = $com_val->content; $data['comments'][$com_key]['created_at'] = Comment::time_tran($com_val->created_at); $data['comments'][$com_key]['imgs'] = ImageSource::find()->select('pic')->where(['topid'=>$com_val->id,'type'=>ImageSource::TYPE_COMMENT,'status'=>ImageSource::STATUS_YES])->asArray()->all(); if(!empty($com_val->userinfo)) { $data['comments'][$com_key]['portrait'] =!empty($com_val->userinfo->portrait) ? UserInfo::imagesUrl($com_val->userinfo->portrait):"";; $data['comments'][$com_key]['nickname'] = $com_val->userinfo->nickname; } $data['comments'][$com_key]['replys'] = array(); $replys = Reply::find()->where(['cid'=>$com_val->id,'status'=>Reply::STATUS_ACTIVE])->select('id,from_userid,to_userid,content')->orderBy('created_at ASC')->all(); if(!empty($replys)) { foreach ($replys as $rep_key => $rep_val) { $data['comments'][$com_key]['replys'][$rep_key]['own'] = $rep_val->from_userid == Yii::$app->user->id ? 1 : 0 ; $data['comments'][$com_key]['replys'][$rep_key]['content'] = $rep_val->content; } } } } return Apireturn::sent(1,'success',200,$data); } /** * 添加更新工地图片 */ public function uploadBuildingImg($id,$post,$type = 'add') { //客厅照片,开工大吉 if(!empty($post['living_room'])) { if($type != 'add'){//编辑 $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_LIVING_ROOM])->one(); if(empty($model)) { $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_LIVING_ROOM; } }else{//添加 $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_LIVING_ROOM; } $model->pic = $post['living_room']; $model->updated_at = time(); $model->save(); unset($model); }elseif (empty($post['living_room']) && $type == 'edit') { $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_LIVING_ROOM])->one(); if(!empty($model)) { $model->status = ImageSource::STATUS_NO; $model->updated_at = time(); $model->save(); } } //主卧照片,现场施工 if(!empty($post['master_bedroom'])) { if($type != 'add'){//编辑 $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_MASTER_BEDROOM])->one(); if(empty($model)) { $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_MASTER_BEDROOM; } }else{//添加 $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_MASTER_BEDROOM; } $model->pic = $post['master_bedroom']; $model->updated_at = time(); $model->save(); unset($model); }elseif (empty($post['master_bedroom']) && $type == 'edit') { $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_MASTER_BEDROOM])->one(); if(!empty($model)) { $model->status = ImageSource::STATUS_NO; $model->updated_at = time(); $model->save(); } } //局部美照,现场施工 if(!empty($post['portion'])) { if($type != 'add'){//编辑 $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_PORTION])->one(); if(empty($model)) { $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_PORTION; } }else{//添加 $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_PORTION; } $model->pic = $post['portion']; $model->updated_at = time(); $model->save(); unset($model); }elseif (empty($post['portion']) && $type == 'edit') { $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_PORTION])->one(); if(!empty($model)) { $model->status = ImageSource::STATUS_NO; $model->updated_at = time(); $model->save(); } } //现场施工照片2 if(!empty($post['build'])) { if($type != 'add'){//编辑 $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_BUILD])->one(); if(empty($model)) { $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_BUILD; } }else{//添加 $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_BUILD; } $model->pic = $post['build']; $model->updated_at = time(); $model->save(); unset($model); }elseif (empty($post['build']) && $type == 'edit') { $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_BUILD])->one(); if(!empty($model)) { $model->status = ImageSource::STATUS_NO; $model->updated_at = time(); $model->save(); } } //现场施工照片3 if(!empty($post['build2'])) { if($type != 'add'){//编辑 $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_BUILD2])->one(); if(empty($model)) { $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_BUILD2; } }else{//添加 $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_BUILD2; } $model->pic = $post['build2']; $model->updated_at = time(); $model->save(); unset($model); }elseif (empty($post['build2']) && $type == 'edit') { $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_BUILD2])->one(); if(!empty($model)) { $model->status = ImageSource::STATUS_NO; $model->updated_at = time(); $model->save(); } } //局部美照2 if(!empty($post['portion2'])) { if($type != 'add'){//编辑 $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_PORTION2])->one(); if(empty($model)) { $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_PORTION2; } }else{//添加 $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_PORTION2; } $model->pic = $post['portion2']; $model->updated_at = time(); $model->save(); unset($model); }elseif (empty($post['portion2']) && $type == 'edit') { $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_PORTION2])->one(); if(!empty($model)) { $model->status = ImageSource::STATUS_NO; $model->updated_at = time(); $model->save(); } } //局部美照3 if(!empty($post['portion3'])) { if($type != 'add'){//编辑 $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_PORTION3])->one(); if(empty($model)) { $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_PORTION3; } }else{//添加 $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_PORTION3; } $model->pic = $post['portion3']; $model->updated_at = time(); $model->save(); unset($model); }elseif (empty($post['portion3']) && $type == 'edit') { $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_PORTION3])->one(); if(!empty($model)) { $model->status = ImageSource::STATUS_NO; $model->updated_at = time(); $model->save(); } } //局部美照4 if(!empty($post['portion4'])) { if($type != 'add'){//编辑 $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_PORTION4])->one(); if(empty($model)) { $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_PORTION4; } }else{//添加 $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_PORTION4; } $model->pic = $post['portion4']; $model->updated_at = time(); $model->save(); unset($model); }elseif (empty($post['portion4']) && $type == 'edit') { $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_PORTION4])->one(); if(!empty($model)) { $model->status = ImageSource::STATUS_NO; $model->updated_at = time(); $model->save(); } } //局部美照5 if(!empty($post['portion5'])) { if($type != 'add'){//编辑 $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_PORTION5])->one(); if(empty($model)) { $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_PORTION5; } }else{//添加 $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_PORTION5; } $model->pic = $post['portion5']; $model->updated_at = time(); $model->save(); unset($model); }elseif (empty($post['portion5']) && $type == 'edit') { $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_PORTION5])->one(); if(!empty($model)) { $model->status = ImageSource::STATUS_NO; $model->updated_at = time(); $model->save(); } } //户型平面图 if(!empty($post['flat'])) { if($type != 'add'){//编辑 $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_FLAT])->one(); if(empty($model)) { $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_FLAT; } }else{//添加 $model = new ImageSource(); $model->topid = $id; $model->created_at = time(); $model->status = ImageSource::STATUS_YES; $model->type = ImageSource::TYPE_FLAT; } $model->pic = $post['flat']; $model->updated_at = time(); $model->save(); unset($model); }elseif (empty($post['flat']) && $type == 'edit') { $model = ImageSource::find()->where(['topid'=>$id,'status'=>ImageSource::STATUS_YES,'type'=>ImageSource::TYPE_FLAT])->one(); if(!empty($model)) { $model->status = ImageSource::STATUS_NO; $model->updated_at = time(); $model->save(); } } } /** * 工地/样板房预约列表 */ public function actionAppointments() { $page = Yii::$app->request->post('page', 1);//分页页数 $display = Yii::$app->request->post('display', self::DISPLAY);//分页页数 $id = Yii::$app->request->post('id');//工地,样板房id $list = Appointment::findBySql("SELECT a.applicant_name,a.applicant_tel,a.state,a.booking_time,b.portrait FROM {{%appointment}} a LEFT JOIN {{%user_info}} b ON a.uid = b.uid WHERE a.pid = :id AND a.status = :status ORDER BY a.id DESC LIMIT ".($page-1) * $display.",".$display,[':id'=>$id,':status'=>Appointment::STATE_YES])->asArray()->all(); if(!empty($list)) { foreach ($list as $key => $value) { $list[$key]['portrait'] = empty($value['portrait']) ? "":UserInfo::imagesUrl($value['portrait']); //$list[$key]['applicant_tel'] = empty($value['applicant_tel']) ? "":Appointment::telPreg($value['applicant_tel']); $building = Building::find()->where(['id'=>$id])->select('name')->one(); if(!empty($building)) $list[$key]['name'] = $building->name; else $list[$key]['name'] = ""; } } $userCompany = UserCompany::find()->where(['uid'=>Yii::$app->user->id])->select('member')->one(); $member = 0; if(!empty($userCompany)) $member = $userCompany->member; return Apireturn::sent(1,'success',200,array('member'=>$member,'list'=>$list)); } /** * 装修进度,户型,装修方式,装修风格 * @return array */ public function actionData() { $array = array('stage'=>self::$stage_arr,'layout'=>self::$layout_arr,'style'=>self::$style_arr,'pattern'=>self::$pattern_arr); return Apireturn::sent(1,'success',200,$array); } }