基于SSM实现酒店入住预定管理系统
作者主页:
作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师
主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助
文末获取源码
项目编号:BS-XX-138
一,项目简介
本项目主要基于SSM框架开发实现了一个酒店预定入住管理系统,前端用户可以实现注册登陆,并在前端页面进行全文检索,预定需要的酒店。在个人中心处可以查看自己预定的酒店信息,管理个人信息等。后台管理人员登陆系统后可以进行用户和权限角色的管理和分配,酒店信息的管理,预定信息的管理,入住信息的管理,营业报表的图形统计功能等等。
二,环境介绍
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
前端开发技术: easyUI+Jquery+Ajax
后台开发技术:SSM开发框架
三,系统展示
前台用户功能展示:
首页展示

用户注册

用户登陆

用户中心

后台管理功能:

菜单管理

角色管理

用户管理

楼层管理

房型管理

房间管理

客户管理

预定管理

入住管理
营业统计

四,核心代码展示
package com.ischoolbar.programmer.controller.home;import java.util.Date;import java.util.HashMap;import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.apache.commons.lang.StringUtils;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.servlet.ModelAndView;import com.ischoolbar.programmer.entity.Account;import com.ischoolbar.programmer.entity.BookOrder;import com.ischoolbar.programmer.entity.RoomType;import com.ischoolbar.programmer.service.AccountService;import com.ischoolbar.programmer.service.BookOrderService;import com.ischoolbar.programmer.service.RoomTypeService;/**
* 前台用户控制器
* @author Administrator
*
*/public class HomeAccountController {
private RoomTypeService roomTypeService;
private AccountService accountService;
private BookOrderService bookOrderService; /**
* 前台用户中心首页
* @param model
* @param name
* @return
*/
public ModelAndView list(ModelAndView model,HttpServletRequest request
){ Account account = (Account)request.getSession().getAttribute("account");
Map<String,Object> queryMap = new HashMap<String, Object>();
queryMap.put("accountId", account.getId());
queryMap.put("offset", 0);
queryMap.put("pageSize", 999);
model.addObject("bookOrderList", bookOrderService.findList(queryMap));
model.addObject("roomTypeList", roomTypeService.findAll());
model.setViewName("home/account/index"); return model;
} /**
* 预定房间页面
* @param model
* @return
*/
public ModelAndView bookOrder(ModelAndView model,Long roomTypeId
){
model.addObject("roomType", roomTypeService.find(roomTypeId));
model.setViewName("home/account/book_order"); return model;
} /**
* 预定信息提交
* @param account
* @return
*/
public Map<String,String> bookOrderAct(BookOrder bookOrder,HttpServletRequest request){
Map<String, String> ret = new HashMap<String, String>(); if(bookOrder == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的预定订单信息!"); return ret;
} Account account = (Account)request.getSession().getAttribute("account"); if(account == null){
ret.put("type", "error");
ret.put("msg", "客户不能为空!"); return ret;
}
bookOrder.setAccountId(account.getId()); if(bookOrder.getRoomTypeId() == null){
ret.put("type", "error");
ret.put("msg", "房型不能为空!"); return ret;
} if(StringUtils.isEmpty(bookOrder.getName())){
ret.put("type", "error");
ret.put("msg", "预定订单联系人名称不能为空!"); return ret;
} if(StringUtils.isEmpty(bookOrder.getMobile())){
ret.put("type", "error");
ret.put("msg", "预定订单联系人手机号不能为空!"); return ret;
} if(StringUtils.isEmpty(bookOrder.getIdCard())){
ret.put("type", "error");
ret.put("msg", "联系人身份证号不能为空!"); return ret;
} if(StringUtils.isEmpty(bookOrder.getArriveDate())){
ret.put("type", "error");
ret.put("msg", "到达时间不能为空!"); return ret;
} if(StringUtils.isEmpty(bookOrder.getLeaveDate())){
ret.put("type", "error");
ret.put("msg", "离店时间不能为空!"); return ret;
}
bookOrder.setCreateTime(new Date());
bookOrder.setStatus(0); if(bookOrderService.add(bookOrder) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!"); return ret;
} RoomType roomType = roomTypeService.find(bookOrder.getRoomTypeId()); //预定成功后去修改该房型的预定数
if(roomType != null){
roomType.setBookNum(roomType.getBookNum() + 1);
roomType.setAvilableNum(roomType.getAvilableNum() - 1);
roomTypeService.updateNum(roomType); //如果可用的房间数为0,则设置该房型状态已满
if(roomType.getAvilableNum() == 0){
roomType.setStatus(0);
roomTypeService.edit(roomType);
}
}
ret.put("type", "success");
ret.put("msg", "预定成功!"); return ret;
} /**
* 修改个人信息提交
* @param account
* @return
*/
public Map<String,String> updateInfoAct(Account account,HttpServletRequest request){
Map<String,String> retMap = new HashMap<String, String>(); if(account == null){
retMap.put("type", "error");
retMap.put("msg", "请填写正确的用户信息!"); return retMap;
} if(StringUtils.isEmpty(account.getName())){
retMap.put("type", "error");
retMap.put("msg", "用户名不能为空!"); return retMap;
} Account loginedAccount = (Account)request.getSession().getAttribute("account"); if(isExist(account.getName(),loginedAccount.getId())){
retMap.put("type", "error");
retMap.put("msg", "该用户名已经存在!"); return retMap;
}
loginedAccount.setAddress(account.getAddress());
loginedAccount.setIdCard(account.getIdCard());
loginedAccount.setMobile(account.getMobile());
loginedAccount.setName(account.getName());
loginedAccount.setRealName(account.getRealName()); if(accountService.edit(loginedAccount) <= 0){
retMap.put("type", "error");
retMap.put("msg", "修改失败,请联系管理员!"); return retMap;
}
request.getSession().setAttribute("account", loginedAccount);
retMap.put("type", "success");
retMap.put("msg", "修改成功!"); return retMap;
} /**
* 修改密码提交
* @param account
* @return
*/
public Map<String,String> updatePwdAct(String oldPassword,String newPassword,HttpServletRequest request){
Map<String,String> retMap = new HashMap<String, String>(); if(StringUtils.isEmpty(oldPassword)){
retMap.put("type", "error");
retMap.put("msg", "请填写原来的密码!"); return retMap;
} if(StringUtils.isEmpty(newPassword)){
retMap.put("type", "error");
retMap.put("msg", "请填写新密码!"); return retMap;
} Account loginedAccount = (Account)request.getSession().getAttribute("account"); if(!oldPassword.equals(loginedAccount.getPassword())){
retMap.put("type", "error");
retMap.put("msg", "原密码错误!"); return retMap;
}
loginedAccount.setPassword(newPassword); if(accountService.edit(loginedAccount) <= 0){
retMap.put("type", "error");
retMap.put("msg", "修改失败,请联系管理员!"); return retMap;
}
retMap.put("type", "success");
retMap.put("msg", "修改密码成功!"); return retMap;
} /**
* 判断用户是否存在
* @param name
* @param id
* @return
*/
private boolean isExist(String name,Long id){ Account account = accountService.findByName(name); if(account == null)return false; if(account != null && account.getId().longValue() == id)return false; return true;
}
}
package com.ischoolbar.programmer.controller.home;import java.util.HashMap;import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.apache.commons.lang.StringUtils;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.servlet.ModelAndView;import com.ischoolbar.programmer.entity.Account;import com.ischoolbar.programmer.service.AccountService;import com.ischoolbar.programmer.service.RoomTypeService;/**
* 前台首页控制器
* @author Administrator
*
*/public class HomeController {
private RoomTypeService roomTypeService;
private AccountService accountService; /**
* 前台首页
* @param model
* @param name
* @return
*/
public ModelAndView list(ModelAndView model, {
Map<String,Object> queryMap = String name
)new HashMap<String, Object>();
queryMap.put("name", name);
queryMap.put("offset", 0);
queryMap.put("pageSize", 999);
model.addObject("roomTypeList", roomTypeService.findList(queryMap));
model.setViewName("home/index/index");
model.addObject("kw", name); return model;
} /**
* 登录页面
* @param model
* @return
*/
public ModelAndView login(ModelAndView model
){
model.setViewName("home/index/login"); return model;
} /**
* 注册页面
* @param model
* @return
*/
public ModelAndView reg(ModelAndView model
){
model.setViewName("home/index/reg"); return model;
} /**
* 登录信息提交
* @param account
* @return
*/
public Map<String,String> loginAct(Account account,String vcode,HttpServletRequest request){
Map<String,String> retMap = new HashMap<String, String>(); if(account == null){
retMap.put("type", "error");
retMap.put("msg", "请填写正确的用户信息!"); return retMap;
} if(StringUtils.isEmpty(account.getName())){
retMap.put("type", "error");
retMap.put("msg", "用户名不能为空!"); return retMap;
} if(StringUtils.isEmpty(account.getPassword())){
retMap.put("type", "error");
retMap.put("msg", "密码不能为空!"); return retMap;
} if(StringUtils.isEmpty(vcode)){
retMap.put("type", "error");
retMap.put("msg", "验证码不能为空!"); return retMap;
} Object attribute = request.getSession().getAttribute("accountLoginCpacha"); if(attribute == null){
retMap.put("type", "error");
retMap.put("msg", "验证码过期,请刷新!"); return retMap;
} if(!vcode.equalsIgnoreCase(attribute.toString())){
retMap.put("type", "error");
retMap.put("msg", "验证码错误!"); return retMap;
} Account findByName = accountService.findByName(account.getName()); if(findByName == null){
retMap.put("type", "error");
retMap.put("msg", "用户名不存在!"); return retMap;
} if(!account.getPassword().equals(findByName.getPassword())){
retMap.put("type", "error");
retMap.put("msg", "密码错误!"); return retMap;
} if(findByName.getStatus() == -1){
retMap.put("type", "error");
retMap.put("msg", "该用户已被禁用,请联系管理员!"); return retMap;
}
request.getSession().setAttribute("account", findByName);
request.getSession().setAttribute("accountLoginCpacha", null);
retMap.put("type", "success");
retMap.put("msg", "登录成功!"); return retMap;
} /**
* 注册信息提交
* @param account
* @return
*/
public Map<String,String> regAct(Account account){
Map<String,String> retMap = new HashMap<String, String>(); if(account == null){
retMap.put("type", "error");
retMap.put("msg", "请填写正确的用户信息!"); return retMap;
} if(StringUtils.isEmpty(account.getName())){
retMap.put("type", "error");
retMap.put("msg", "用户名不能为空!"); return retMap;
} if(StringUtils.isEmpty(account.getPassword())){
retMap.put("type", "error");
retMap.put("msg", "密码不能为空!"); return retMap;
} if(StringUtils.isEmpty(account.getMobile())){
retMap.put("type", "error");
retMap.put("msg", "手机号不能为空!"); return retMap;
} if(isExist(account.getName())){
retMap.put("type", "error");
retMap.put("msg", "该用户名已经存在!"); return retMap;
} if(accountService.add(account) <= 0){
retMap.put("type", "error");
retMap.put("msg", "注册失败,请联系管理员!"); return retMap;
}
retMap.put("type", "success");
retMap.put("msg", "注册成功!"); return retMap;
} /**
* 退出登录
* @param request
* @return
*/
public String logout(HttpServletRequest request){
request.getSession().setAttribute("account", null); return "redirect:login";
} private boolean isExist(String name){ Account account = accountService.findByName(name); if(account == null)return false; return true;
}
}
package com.ischoolbar.programmer.controller.admin;import java.util.HashMap;import java.util.Map;import org.apache.commons.lang.StringUtils;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.servlet.ModelAndView;import com.ischoolbar.programmer.entity.Account;import com.ischoolbar.programmer.page.admin.Page;import com.ischoolbar.programmer.service.AccountService;/**
* 客户管理后台控制器
* @author Administrator
*
*/public class AccountController {
private AccountService accountService;
/**
* 客户管理列表页面
* @param model
* @return
*/
public ModelAndView list(ModelAndView model){
model.setViewName("account/list"); return model;
}
/**
* 客户信息添加操作
* @param account
* @return
*/
public Map<String, String> add(Account account){
Map<String, String> ret = new HashMap<String, String>(); if(account == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的客户信息!"); return ret;
} if(StringUtils.isEmpty(account.getName())){
ret.put("type", "error");
ret.put("msg", "客户名称不能为空!"); return ret;
} if(StringUtils.isEmpty(account.getPassword())){
ret.put("type", "error");
ret.put("msg", "客户密码不能为空!"); return ret;
} if(isExist(account.getName(), 0l)){
ret.put("type", "error");
ret.put("msg", "该用户名已经存在!"); return ret;
} if(accountService.add(account) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!"); return ret;
}
ret.put("type", "success");
ret.put("msg", "添加成功!"); return ret;
}
/**
* 客户信息编辑操作
* @param account
* @return
*/
public Map<String, String> edit(Account account){
Map<String, String> ret = new HashMap<String, String>(); if(account == null){
ret.put("type", "error");
ret.put("msg", "请填写正确的客户信息!"); return ret;
} if(StringUtils.isEmpty(account.getName())){
ret.put("type", "error");
ret.put("msg", "客户名称不能为空!"); return ret;
} if(StringUtils.isEmpty(account.getPassword())){
ret.put("type", "error");
ret.put("msg", "客户密码不能为空!"); return ret;
} if(isExist(account.getName(), account.getId())){
ret.put("type", "error");
ret.put("msg", "该用户名已经存在!"); return ret;
} if(accountService.edit(account) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失败,请联系管理员!"); return ret;
}
ret.put("type", "success");
ret.put("msg", "修改成功!"); return ret;
}
/**
* 分页查询客户信息
* @param name
* @param page
* @return
*/
public Map<String,Object> list( {
Map<String,Object> ret = String name, String realName, String idCard, String mobile, Integer status,
Page page
)new HashMap<String, Object>();
Map<String,Object> queryMap = new HashMap<String, Object>();
queryMap.put("name", name);
queryMap.put("status", status);
queryMap.put("realName", realName);
queryMap.put("idCard", idCard);
queryMap.put("mobile", mobile);
queryMap.put("offset", page.getOffset());
queryMap.put("pageSize", page.getRows());
ret.put("rows", accountService.findList(queryMap));
ret.put("total", accountService.getTotal(queryMap)); return ret;
}
/**
* 客户信息删除操作
* @param id
* @return
*/
public Map<String, String> delete(Long id){
Map<String, String> ret = new HashMap<String, String>(); if(id == null){
ret.put("type", "error");
ret.put("msg", "请选择要删除的信息!"); return ret;
} try { if(accountService.delete(id) <= 0){
ret.put("type", "error");
ret.put("msg", "删除失败,请联系管理员!"); return ret;
}
} catch (Exception e) { // TODO: handle exception
ret.put("type", "error");
ret.put("msg", "该客户下存在订单信息,请先删除该客户下的所有订单信息!"); return ret;
}
ret.put("type", "success");
ret.put("msg", "删除成功!"); return ret;
}
/**
* 判断用户名是否存在
* @param name
* @param id
* @return
*/
private boolean isExist(String name,Long id){ Account findByName = accountService.findByName(name); if(findByName == null)return false; if(findByName.getId().longValue() == id.longValue())return false; return true;
}
}
五,项目总结
本项目基本功能完整,界面简洁大方,适合做毕业设计或课程设计使用,使用了常见的开发的工具和数据库,使用SSM框架和easyUI来完成酒店管理系统的开发和设计,值得学习和研究。