getAllHotel(); $data['createUserName'] = $operaHotelAffiche->getPublishName(); $res = $operaHotelAffiche->getAfficheList($hotelName, $afficheType, $sortType, $publishName, $moreSearch, $page_size, $current_page); $data['afficheList'] = $res['affiche_list']; $total_row = $res['total_row']; $base_area = new BaseArea(); $page_arr = $base_area->getPage($total_row, $page_size, $current_page); $data['page_size_arr'] = [10, 30, 50, 100]; $data['page'] = [ 'page_size' => $page_size, 'current_page' => $current_page, 'total_row' => $total_row, 'total_page' => ceil($total_row / $page_size) ]; $data['page_arr'] = $page_arr; $data['page_size'] = $page_size; return $data; } /** * Function Description:获取公告管理列表 * Function Name: getHotelAfficheList * @param $hotelName * @param $afficheType * @param $sortType * @param $publishName * @param $moreSearch * @param $page_size * @param $current_page * @return mixed * @author 田玲菲 */ public function getManageAfficheList($hotelName, $afficheType, $sortType, $publishName, $moreSearch, $page_size, $current_page) { $operaHotelAffiche = new OperaHotelAffiche(); $opera_hotel=new OperaHotel(); $data['hotelName'] = $opera_hotel->getAllHotel(); $data['createUserName'] = $operaHotelAffiche->getPublishName(); $res = $operaHotelAffiche->getManageList($hotelName, $afficheType, $sortType, $publishName, $moreSearch, $page_size, $current_page); $data['afficheList'] = $res['affiche_list']; $total_row = $res['total_row']; $base_area = new BaseArea(); $page_arr = $base_area->getPage($total_row, $page_size, $current_page); $data['page_size_arr'] = [10, 30, 50, 100]; $data['page'] = [ 'page_size' => $page_size, 'current_page' => $current_page, 'total_row' => $total_row, 'total_page' => ceil($total_row / $page_size) ]; $data['page_arr'] = $page_arr; $data['page_size'] = $page_size; return $data; } /** * Function Description:根据id得到公告的所有信息 * Function Name: getAffiche * @param $id * @return array|\yii\db\ActiveRecord[] * @author 田玲菲 */ public function getAffiche($id) { $operaHotelAffiche = new OperaHotelAffiche(); $res = $operaHotelAffiche->getAfficheDetail($id); return $res; } /** * Function Description:修改排序 * Function Name: changeSortbyId * @param $id * @param $sort * @return mixed * @author 田玲菲 */ public function changeSortbyId($id, $sort) { $operaHotelAffiche = new OperaHotelAffiche(); $res = $operaHotelAffiche->changeSort($id, $sort); if ($res) { $data['code'] = 0; $data['info'] = '修改成功!'; } else { $data['code'] = 1; $data['info'] = '修改失败!'; } return $data; } /** * Function Description:删除公告 * Function Name: deleteAfficheById * @param $id * @return mixed * @author 田玲菲 */ public function deleteAfficheById($id) { $operaHotelAffiche = new OperaHotelAffiche(); $res = $operaHotelAffiche->deleteAffine($id); if (!$res) { $json['code'] = '1'; $json['info'] = '删除公告失败'; } else { $json['code'] = '0'; $json['info'] = '删除公告成功'; } return $json; } /** * Function Description:校验标题唯一性 * Function Name: checkTitle * @param $title * @param int $id * * @return array|null|\yii\db\ActiveRecord * * @author 田玲菲 */ public function checkTitle($title, $id = 0) { $operaHotelAffiche = new OperaHotelAffiche(); $res = $operaHotelAffiche->checkTitle($title); if ($res) { if ($id != 0 && $res['id'] == $id) { $data['code'] = 0; } else { $data['code'] = 1; $data['info'] = '该标题已存在请勿重复添加'; } } else { $data['code'] = 0; } return $data; } /** * Function Description:修改公告 * Function Name: updateAffiche * @param $id * @param $hotelName * @param $afficheType * @param $sort * @param $importantLevel * @param $title * @param $content * @param $releaseType * @return array|null|\yii\db\ActiveRecord * @author 田玲菲 */ public function updateAffiche($id, $hotelName, $afficheType, $sort, $importantLevel, $title, $content, $releaseType) { // 校验标题 $json = $this->checkTitle($title, $id); if ($json['code'] != 0) { return $json; } $operaHotelAffiche = new OperaHotelAffiche(); $res = $operaHotelAffiche->changeAffiche($id, $hotelName, $afficheType, $sort, $importantLevel, $title, $content, $releaseType); if (!$res) { $json['code'] = 1; $json['info'] = '修改保存公告失败'; } else { $json['code'] = 0; if ($releaseType == 1) { $json['info'] = '修改并发布公告成功'; } else { $json['info'] = '修改并保存公告成功'; } } return $json; } /** * Function Description:发布(新增)酒店公告 * Function Name: saveAffiche * @param $hotelName * @param $afficheType * @param $sort * @param $importantLevel * @param $title * @param $content * @param $releaseType * @return array|null|\yii\db\ActiveRecord * @author 田玲菲 */ public function saveAffiche($hotelName, $afficheType, $sort, $importantLevel, $title, $content, $releaseType) { // 校验标题 $json = $this->checkTitle($title); if ($json['code'] != 0) { return $json; } $operaHotelAffiche = new OperaHotelAffiche(); $res = $operaHotelAffiche->addAffiche($hotelName, $afficheType, $sort, $importantLevel, $title, $content, $releaseType); if (!$res) { $json['code'] = 1; $json['info'] = '保存公告失败'; } else { $json['code'] = 0; if ($releaseType == 1) { $json['info'] = '保存并发布公告成功'; } else { $json['info'] = '保存公告成功'; } } return $json; } /** * Function Description:获取酒店的名字 * Function Name: getHotelList * @return array|\yii\db\ActiveRecord[] * @author 田玲菲 */ public function getHotelList(){ $opera_hotel=new OperaHotel(); $data = $opera_hotel->getAllHotel(); return $data; } /** * Function Description:发布未发布的公告 * Function Name: publish * @param $id * @return mixed * @author 田玲菲 */ public function publish($id,$type){ $operaHotelAffiche = new OperaHotelAffiche(); $res = $operaHotelAffiche->publishAffiche($id,$type); if (!$res) { $data['code'] = 1; $data['info'] = '操作失败'; }else{ $data['code'] = 0; $data['info'] = '操作成功'; } return $data; } }