[ 'class' => AccessControl::className(), 'rules' => [ [ 'actions' => [], 'allow' => true, 'roles' => ['@'], ], ], ], ]; } //新加板样房、 工地 public static function add_building(){ $model = new Building(); if($model->load(Yii::$app->request->get())){ $opening_begin = strtotime(Yii::$app->request->get('opening_begin')); $opening_end = strtotime(Yii::$app->request->get('opening_end')); if(!is_numeric($opening_begin)&&!is_numeric($opening_end)){ $opening_begin = strtotime($opening_begin); $opening_end = strtotime($opening_end); } $pickup_address_coordinate = Yii::$app->request->get('pickup_address_coordinate');//地址坐标 $url ="http://restapi.amap.com/v3/geocode/regeo?key=9176f3987ffff3aaadfe2af13a2fccdb&location={$pickup_address_coordinate}&poitype=&radius=&extensions=base&batch=false&roadlevel="; $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $html = curl_exec($ch); curl_close($ch); $html = json_decode($html); if($html->info == "OK") { if($html->regeocode->addressComponent->adcode != Yii::$app->request->get("Building")['district'] && $html->regeocode->addressComponent->adcode !=Yii::$app->request->get("Building")['city']){ $result=['sign'=>1,'msg'=>"您选择的地区和地图的坐标地点不符合"]; return json_encode($result); } } $arr = explode(',',$pickup_address_coordinate); $living_room = Yii::$app->request->get('living_room');//客厅照片 $master_bedroom = Yii::$app->request->get('master_bedroom');//主卧照片 $portion = Yii::$app->request->get('portion');//局部美图 $portion2 = Yii::$app->request->get('portion2');//局部美图2 $portion3 = Yii::$app->request->get('portion3');//局部美图3 $portion4 = Yii::$app->request->get('portion4');//局部美图4 $portion5 = Yii::$app->request->get('portion5');//局部美图5 $build = Yii::$app->request->get('build');//施工图 $build2 = Yii::$app->request->get('build2');//施工图 $flat = Yii::$app->request->get('flat');//平面图 $model->longitude = isset($arr[0])?$arr[0]:""; $model->latitude = isset($arr[1])?$arr[1]:""; if(!empty($model->longitude)&&!empty($model->latitude)) { $geohash = new ZM_Geohash(); $geohash->init_codingMap(); $model->hashcode =$geohash->encode($model->latitude,$model->longitude); } $model->uid = Yii::$app->user->id; $model->opening_begin = $opening_begin; $model->opening_end = $opening_end; $model->created_at = time(); $model->updated_at = time(); $model->status = Building::STATUS_REVIEW; //客厅照片 if($model->validate()&&$model->save()){ if(!empty($living_room)){ $living_room_image = new ImageSource(); $living_room_image->topid = $model->id; $living_room_image->type = ImageSource::TYPE_LIVING_ROOM; $living_room_image->pic = isset($living_room)?$living_room:""; $living_room_image->status = ImageSource::STATUS_YES; $living_room_image->created_at = time(); $living_room_image->updated_at = time(); if($living_room_image->validate()&&$living_room_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>4000,'msg'=>'失败,客厅照片']; return json_encode($result); } } //主卧照片 if(!empty($master_bedroom)){ $master_bedroom_image = new ImageSource(); $master_bedroom_image->topid = $model->id;; $master_bedroom_image->type = ImageSource::TYPE_MASTER_BEDROOM; $master_bedroom_image->pic = isset($master_bedroom)?$master_bedroom:""; $master_bedroom_image->status = ImageSource::STATUS_YES; $master_bedroom_image->created_at = time(); $master_bedroom_image->updated_at = time(); if($master_bedroom_image->validate()&&$master_bedroom_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>4000,'msg'=>'失败,主卧照片']; return json_encode($result); } } //局部美图 if(!empty($portion)){ $portion_image = new ImageSource(); $portion_image->topid = $model->id;; $portion_image->type = ImageSource::TYPE_PORTION; $portion_image->pic = isset($portion)?$portion:""; $portion_image->status = ImageSource::STATUS_YES; $portion_image->created_at = time(); $portion_image->updated_at = time(); if($portion_image->validate()&&$portion_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>4000,'msg'=>'失败,局部美图']; return json_encode($result); } } //局部美图2 if(!empty($portion2)){ $portion2_image = new ImageSource(); $portion2_image->topid = $model->id;; $portion2_image->type = ImageSource::TYPE_PORTION2; $portion2_image->pic = isset($portion2)?$portion2:""; $portion2_image->status = ImageSource::STATUS_YES; $portion2_image->created_at = time(); $portion2_image->updated_at = time(); if($portion2_image->validate()&&$portion2_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>4000,'msg'=>'失败,局部美图']; return json_encode($result); } } //局部美图3 if(!empty($portion3)){ $portion3_image = new ImageSource(); $portion3_image->topid = $model->id;; $portion3_image->type = ImageSource::TYPE_PORTION3; $portion3_image->pic = isset($portion3)?$portion3:""; $portion3_image->status = ImageSource::STATUS_YES; $portion3_image->created_at = time(); $portion3_image->updated_at = time(); if($portion3_image->validate()&&$portion3_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>4000,'msg'=>'失败,局部美图']; return json_encode($result); } } //局部美图4 if(!empty($portion4)){ $portion4_image = new ImageSource(); $portion4_image->topid = $model->id;; $portion4_image->type = ImageSource::TYPE_PORTION4; $portion4_image->pic = isset($portion4)?$portion4:""; $portion4_image->status = ImageSource::STATUS_YES; $portion4_image->created_at = time(); $portion4_image->updated_at = time(); if($portion4_image->validate()&&$portion4_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>4000,'msg'=>'失败,局部美图']; return json_encode($result); } } //局部美图5 if(!empty($portion5)){ $portion5_image = new ImageSource(); $portion5_image->topid = $model->id;; $portion5_image->type = ImageSource::TYPE_PORTION5; $portion5_image->pic = isset($portion5)?$portion5:""; $portion5_image->status = ImageSource::STATUS_YES; $portion5_image->created_at = time(); $portion5_image->updated_at = time(); if($portion5_image->validate()&&$portion5_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>4000,'msg'=>'失败,局部美图']; return json_encode($result); } } //施工图1 if(!empty($build)){ $build_image = new ImageSource(); $build_image->topid = $model->id;; $build_image->type = ImageSource::TYPE_BUILD; $build_image->pic = isset($build)?$build:""; $build_image->status = ImageSource::STATUS_YES; $build_image->created_at = time(); $build_image->updated_at = time(); if($build_image->validate()&&$build_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>4000,'msg'=>'失败,施工图']; return json_encode($result); } } //施工图2 if(!empty($build2)){ $build2_image = new ImageSource(); $build2_image->topid = $model->id;; $build2_image->type = ImageSource::TYPE_BUILD2; $build2_image->pic = isset($build2)?$build2:""; $build2_image->status = ImageSource::STATUS_YES; $build2_image->created_at = time(); $build2_image->updated_at = time(); if($build2_image->validate()&&$build2_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>4000,'msg'=>'失败,施工图']; return json_encode($result); } } //平面图 if(!empty($flat)){ $flat_image = new ImageSource(); $flat_image->topid = $model->id;; $flat_image->type = ImageSource::TYPE_FLAT; $flat_image->pic = isset($flat)?$flat:""; $flat_image->status = ImageSource::STATUS_YES; $flat_image->created_at = time(); $flat_image->updated_at = time(); if($flat_image->validate()&&$flat_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>4000,'msg'=>'失败,平面图']; return json_encode($result); } } $result=['sign'=>0,'msg'=>'发布成功']; return json_encode($result); }else{ $result=['sign'=>4000,'msg'=>'添加失败']; return json_encode($result); } }else{ $result=['sign'=>4000,'msg'=>'数据有误']; return json_encode($result); } } //更新板样房、 工地 public static function update_building($id){ if(empty($id)){ $id = Yii::$app->request->get('topid'); } $model = Building::find()->where('id=:id',[':id'=>$id])->one(); if($model->load(Yii::$app->request->get())){ $opening_begin = strtotime(Yii::$app->request->get('opening_begin')); $opening_end = strtotime(Yii::$app->request->get('opening_end')); $pickup_address_coordinate = Yii::$app->request->get('pickup_address_coordinate');//地址坐标 $url ="http://restapi.amap.com/v3/geocode/regeo?key=9176f3987ffff3aaadfe2af13a2fccdb&location={$pickup_address_coordinate}&poitype=&radius=&extensions=base&batch=false&roadlevel="; $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $html = curl_exec($ch); curl_close($ch); $html = json_decode($html); if($html->info == "OK") { if($html->regeocode->addressComponent->adcode != Yii::$app->request->get("Building")['district'] && $html->regeocode->addressComponent->adcode !=Yii::$app->request->get("Building")['city']){ $result=['sign'=>1,'msg'=>"您选择的地区和地图的坐标地点不符合"]; return json_encode($result); } } $arr = explode(',',$pickup_address_coordinate); $model->latitude = isset($arr[1])?$arr[1]:""; $model->longitude = isset($arr[0])?$arr[0]:""; if(!empty($model->longitude)&&!empty($model->latitude)) { $geohash = new ZM_Geohash(); $geohash->init_codingMap(); $model->hashcode =$geohash->encode($model->latitude,$model->longitude); } $living_room = Yii::$app->request->get('living_room');//客厅照片 $master_bedroom = Yii::$app->request->get('master_bedroom');//主卧照片 $portion = Yii::$app->request->get('portion');//局部美图 $portion2 = Yii::$app->request->get('portion2');//局部美图2 $portion3 = Yii::$app->request->get('portion3');//局部美图3 $portion4 = Yii::$app->request->get('portion4');//局部美图4 $portion5 = Yii::$app->request->get('portion5');//局部美图5 $build = Yii::$app->request->get('build');//施工图 $build2 = Yii::$app->request->get('build2');//施工图2 $flat = Yii::$app->request->get('flat');//平面图 $living_room_delete = Yii::$app->request->get('living_room_delete'); $master_bedroom_delete = Yii::$app->request->get('master_bedroom_delete'); $portion_delete = Yii::$app->request->get('portion_delete'); $portion2_delete = Yii::$app->request->get('portion2_delete'); $portion3_delete = Yii::$app->request->get('portion3_delete'); $portion4_delete = Yii::$app->request->get('portion4_delete'); $portion5_delete = Yii::$app->request->get('portion5_delete'); $build_delete = Yii::$app->request->get('build_delete'); $build2_delete = Yii::$app->request->get('build2_delete'); $flat_delete = Yii::$app->request->get('flat_delete'); $model->uid = Yii::$app->user->id; $model->opening_begin = $opening_begin; $model->opening_end = $opening_end; $model->created_at = time(); $model->updated_at = time(); $model->status = Building::STATUS_REVIEW; //客厅照片 if($model->validate()&&$model->save()){ if($living_room_delete == -1) { $living_room_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_LIVING_ROOM,':status'=>ImageSource::STATUS_YES])->one(); $living_room_image->status = ImageSource::STATUS_NO; $living_room_image->updated_at = time(); $living_room_image->save(); } if(!empty($living_room)){ $living_room_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_LIVING_ROOM,':status'=>ImageSource::STATUS_YES])->one(); if(empty($living_room_image)){ $living_room_image = new ImageSource(); $living_room_image->created_at = time(); } $living_room_image->topid = $model->id; $living_room_image->type = ImageSource::TYPE_LIVING_ROOM; $living_room_image->pic = isset($living_room)?$living_room:""; $living_room_image->status = ImageSource::STATUS_YES; $living_room_image->updated_at = time(); if($living_room_image->validate()&&$living_room_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>1,'msg'=>'失败,客厅照片']; return json_encode($result); } } if($master_bedroom_delete == -1) { $master_bedroom_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_MASTER_BEDROOM,':status'=>ImageSource::STATUS_YES])->one(); $master_bedroom_image->status = ImageSource::STATUS_NO; $master_bedroom_image->updated_at = time(); $master_bedroom_image->save(); } //主卧照片 if(!empty($master_bedroom)){ $master_bedroom_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_MASTER_BEDROOM,':status'=>ImageSource::STATUS_YES])->one(); if(empty($master_bedroom_image)){ $master_bedroom_image = new ImageSource(); $master_bedroom_image->created_at = time(); } $master_bedroom_image->topid = $model->id;; $master_bedroom_image->type = ImageSource::TYPE_MASTER_BEDROOM; $master_bedroom_image->pic = isset($master_bedroom)?$master_bedroom:""; $master_bedroom_image->status = ImageSource::STATUS_YES; $master_bedroom_image->updated_at = time(); if($master_bedroom_image->validate()&&$master_bedroom_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>1,'msg'=>'失败,主卧照片']; return json_encode($result); } } if($portion_delete == -1) { $portion_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_PORTION,':status'=>ImageSource::STATUS_YES])->one(); $portion_image->status = ImageSource::STATUS_NO; $portion_image->updated_at = time(); $portion_image->save(); } //局部美图 if(!empty($portion)){ $portion_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_PORTION,':status'=>ImageSource::STATUS_YES])->one(); if(empty($portion_image)){ $portion_image = new ImageSource(); $portion_image->created_at = time(); } $portion_image->topid = $model->id;; $portion_image->type = ImageSource::TYPE_PORTION; $portion_image->pic = isset($portion)?$portion:""; $portion_image->status = ImageSource::STATUS_YES; $portion_image->updated_at = time(); if($portion_image->validate()&&$portion_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>1,'msg'=>'失败,局部美图']; return json_encode($result); } } if($portion2_delete == -1) { $portion2_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_PORTION2,':status'=>ImageSource::STATUS_YES])->one(); $portion2_image->status = ImageSource::STATUS_NO; $portion2_image->updated_at = time(); $portion2_image->save(); } //局部美图2 if(!empty($portion2)){ $portion2_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_PORTION2,':status'=>ImageSource::STATUS_YES])->one(); if(empty($portion2_image)){ $portion2_image = new ImageSource(); $portion2_image->created_at = time(); } $portion2_image->topid = $model->id;; $portion2_image->type = ImageSource::TYPE_PORTION2; $portion2_image->pic = isset($portion2)?$portion2:""; $portion2_image->status = ImageSource::STATUS_YES; $portion2_image->updated_at = time(); if($portion2_image->validate()&&$portion2_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>1,'msg'=>'失败,局部美图']; return json_encode($result); } } if($portion3_delete == -1) { $portion3_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_PORTION3,':status'=>ImageSource::STATUS_YES])->one(); $portion3_image->status = ImageSource::STATUS_NO; $portion3_image->updated_at = time(); $portion3_image->save(); } //局部美图3 if(!empty($portion3)){ $portion3_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_PORTION3,':status'=>ImageSource::STATUS_YES])->one(); if(empty($portion3_image)){ $portion3_image = new ImageSource(); $portion3_image->created_at = time(); } $portion3_image->topid = $model->id;; $portion3_image->type = ImageSource::TYPE_PORTION3; $portion3_image->pic = isset($portion3)?$portion3:""; $portion3_image->status = ImageSource::STATUS_YES; $portion3_image->updated_at = time(); if($portion3_image->validate()&&$portion3_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>1,'msg'=>'失败,局部美图']; return json_encode($result); } } if($portion4_delete == -1) { $portion4_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_PORTION4,':status'=>ImageSource::STATUS_YES])->one(); $portion4_image->status = ImageSource::STATUS_NO; $portion4_image->updated_at = time(); $portion4_image->save(); } //局部美图4 if(!empty($portion4)){ $portion4_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_PORTION4,':status'=>ImageSource::STATUS_YES])->one(); if(empty($portion4_image)){ $portion4_image = new ImageSource(); $portion4_image->created_at = time(); } $portion4_image->topid = $model->id;; $portion4_image->type = ImageSource::TYPE_PORTION4; $portion4_image->pic = isset($portion4)?$portion4:""; $portion4_image->status = ImageSource::STATUS_YES; $portion4_image->updated_at = time(); if($portion4_image->validate()&&$portion4_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>1,'msg'=>'失败,局部美图']; return json_encode($result); } } if($portion5_delete == -1) { $portion5_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_PORTION5,':status'=>ImageSource::STATUS_YES])->one(); $portion5_image->status = ImageSource::STATUS_NO; $portion5_image->updated_at = time(); $portion5_image->save(); } //局部美图5 if(!empty($portion5)){ $portion5_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_PORTION5,':status'=>ImageSource::STATUS_YES])->one(); if(empty($portion5_image)){ $portion5_image = new ImageSource(); $portion5_image->created_at = time(); } $portion5_image->topid = $model->id;; $portion5_image->type = ImageSource::TYPE_PORTION5; $portion5_image->pic = isset($portion5)?$portion5:""; $portion5_image->status = ImageSource::STATUS_YES; $portion5_image->updated_at = time(); if($portion5_image->validate()&&$portion5_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>1,'msg'=>'失败,局部美图']; return json_encode($result); } } if($build_delete == -1) { $build_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_BUILD,':status'=>ImageSource::STATUS_YES])->one(); $build_image->status = ImageSource::STATUS_NO; $build_image->updated_at = time(); $build_image->save(); } //施工图 if(!empty($build)){ $build_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_BUILD,':status'=>ImageSource::STATUS_YES])->one(); if(empty($build_image)){ $build_image = new ImageSource(); $build_image->created_at = time(); } $build_image->topid = $model->id;; $build_image->type = ImageSource::TYPE_BUILD; $build_image->pic = isset($build)?$build:""; $build_image->status = ImageSource::STATUS_YES; $build_image->updated_at = time(); if($build_image->validate()&&$build_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>1,'msg'=>'失败,施工图']; return json_encode($result); } } if($build2_delete == -1) { $build2_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_BUILD2,':status'=>ImageSource::STATUS_YES])->one(); $build2_image->status = ImageSource::STATUS_NO; $build2_image->updated_at = time(); $build2_image->save(); } //施工图2 if(!empty($build2)){ $build2_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_BUILD2,':status'=>ImageSource::STATUS_YES])->one(); if(empty($build2_image)){ $build2_image = new ImageSource(); $build2_image->created_at = time(); } $build2_image->topid = $model->id;; $build2_image->type = ImageSource::TYPE_BUILD2; $build2_image->pic = isset($build2)?$build2:""; $build2_image->status = ImageSource::STATUS_YES; $build2_image->updated_at = time(); if($build2_image->validate()&&$build2_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>1,'msg'=>'失败,施工图2']; return json_encode($result); } } if($flat_delete == -1) { $flat_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_FLAT,':status'=>ImageSource::STATUS_YES])->one(); $flat_image->status = ImageSource::STATUS_NO; $flat_image->updated_at = time(); $flat_image->save(); } //平面图 if(!empty($flat)){ $flat_image = ImageSource::find()->where('topid=:topid and type=:type and status=:status',[':topid'=>$id,':type'=>ImageSource::TYPE_FLAT,':status'=>ImageSource::STATUS_YES])->one(); if(empty($flat_image)){ $flat_image = new ImageSource(); $flat_image->created_at = time(); } $flat_image->topid = $model->id;; $flat_image->type = ImageSource::TYPE_FLAT; $flat_image->pic = isset($flat)?$flat:""; $flat_image->status = ImageSource::STATUS_YES; $flat_image->updated_at = time(); if($flat_image->validate()&&$flat_image->save()){ $result=['sign'=>0,'msg'=>'成功']; }else{ $result=['sign'=>1,'msg'=>'失败,平面图']; return json_encode($result); } } $result=['sign'=>0,'msg'=>'成功']; return json_encode($result); }else{ $result=['sign'=>4000,'msg'=>'有问题']; return json_encode($result); } }else{ $result=['sign'=>4000,'msg'=>'数据有误']; return json_encode($result); } } //删除板样房、 工地 public static function delede_building($id){ $model = Building::find()->where('id=:id',[':id'=>$id])->one(); // if(!empty($model)){ // $image_model = ImageSource::find() // ->where('topid=:topid and (type=:type1 or type=:type2 or type=:type3 or type=:type4)', // [ // ':topid'=>$model->id, // ':type1'=>ImageSource::TYPE_LIVING_ROOM, // ':type1'=>ImageSource::TYPE_MASTER_BEDROOM, // ':type1'=>ImageSource::TYPE_PORTION, // ':type1'=>ImageSource::TYPE_FLAT, // ])->all(); // } $model->posted = Building::POSTED_DELETE; $model->updated_at = time(); if($model->validate()&&$model->save()){ $result=['sign'=>1,'msg'=>'删除成功']; }else{ var_dump($model->getErrors()); $result=['sign'=>4000,'msg'=>'数据有误']; } return json_encode($result); } //发布板样房、 工地 public static function delede_posted($id){ $model = Building::find()->where('id=:id and posted=:posted',[':id'=>$id,':posted'=>Building::POSTED_NO])->one(); $model->posted = Building::POSTED_YES; $model->updated_at = time(); if($model->validate()&&$model->save()){ $result=['sign'=>1,'msg'=>'发布成功']; }else{ var_dump($model->getErrors()); $result=['sign'=>4000,'msg'=>'数据有误']; } return json_encode($result); } //停止板样房、 工地 public static function stop_posted($id){ $model = Building::find()->where('id=:id and posted=:posted',[':id'=>$id,':posted'=>Building::POSTED_YES])->one(); $model->posted = Building::POSTED_NO; $model->updated_at = time(); if($model->validate()&&$model->save()){ $result=['sign'=>1,'msg'=>'停止成功']; }else{ var_dump($model->getErrors()); $result=['sign'=>4000,'msg'=>'数据有误']; } return json_encode($result); } }