• 基于SSM实现酒店入住预定管理系统


    作者主页:编程指南针

    作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师

    主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助

    文末获取源码 

    项目编号:BS-XX-138

    一,项目简介

    本项目主要基于SSM框架开发实现了一个酒店预定入住管理系统,前端用户可以实现注册登陆,并在前端页面进行全文检索,预定需要的酒店。在个人中心处可以查看自己预定的酒店信息,管理个人信息等。后台管理人员登陆系统后可以进行用户和权限角色的管理和分配,酒店信息的管理,预定信息的管理,入住信息的管理,营业报表的图形统计功能等等。

    二,环境介绍

    语言环境:Java:  jdk1.8

    数据库:Mysql: mysql5.7

    应用服务器:Tomcat:  tomcat8.5.31

    开发工具:IDEA或eclipse

    前端开发技术: easyUI+Jquery+Ajax

    后台开发技术:SSM开发框架

    三,系统展示

    前台用户功能展示:

    首页展示

    用户注册

    用户登陆

    用户中心

    后台管理功能:

     菜单管理

     

    角色管理

    用户管理

    楼层管理

    房型管理

    房间管理

    客户管理

    预定管理

    入住管理

    营业统计

    四,核心代码展示

    1. package com.ischoolbar.programmer.controller.home;
    2. import java.util.Date;
    3. import java.util.HashMap;
    4. import java.util.Map;
    5. import javax.servlet.http.HttpServletRequest;
    6. import org.apache.commons.lang.StringUtils;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.stereotype.Controller;
    9. import org.springframework.web.bind.annotation.RequestMapping;
    10. import org.springframework.web.bind.annotation.RequestMethod;
    11. import org.springframework.web.bind.annotation.ResponseBody;
    12. import org.springframework.web.servlet.ModelAndView;
    13. import com.ischoolbar.programmer.entity.Account;
    14. import com.ischoolbar.programmer.entity.BookOrder;
    15. import com.ischoolbar.programmer.entity.RoomType;
    16. import com.ischoolbar.programmer.service.AccountService;
    17. import com.ischoolbar.programmer.service.BookOrderService;
    18. import com.ischoolbar.programmer.service.RoomTypeService;
    19. /**
    20. * 前台用户控制器
    21. * @author Administrator
    22. *
    23. */
    24. @RequestMapping("/home/account")
    25. @Controller
    26. public class HomeAccountController {
    27. @Autowired
    28. private RoomTypeService roomTypeService;
    29. @Autowired
    30. private AccountService accountService;
    31. @Autowired
    32. private BookOrderService bookOrderService;
    33. /**
    34. * 前台用户中心首页
    35. * @param model
    36. * @param name
    37. * @return
    38. */
    39. @RequestMapping(value="/index",method=RequestMethod.GET)
    40. public ModelAndView list(ModelAndView model,HttpServletRequest request
    41. ){
    42. Account account = (Account)request.getSession().getAttribute("account");
    43. Map queryMap = new HashMap();
    44. queryMap.put("accountId", account.getId());
    45. queryMap.put("offset", 0);
    46. queryMap.put("pageSize", 999);
    47. model.addObject("bookOrderList", bookOrderService.findList(queryMap));
    48. model.addObject("roomTypeList", roomTypeService.findAll());
    49. model.setViewName("home/account/index");
    50. return model;
    51. }
    52. /**
    53. * 预定房间页面
    54. * @param model
    55. * @return
    56. */
    57. @RequestMapping(value="/book_order",method=RequestMethod.GET)
    58. public ModelAndView bookOrder(ModelAndView model,Long roomTypeId
    59. ){
    60. model.addObject("roomType", roomTypeService.find(roomTypeId));
    61. model.setViewName("home/account/book_order");
    62. return model;
    63. }
    64. /**
    65. * 预定信息提交
    66. * @param account
    67. * @return
    68. */
    69. @RequestMapping(value="/book_order",method=RequestMethod.POST,produces = {"application/json;charset=utf-8"})
    70. @ResponseBody
    71. public Map bookOrderAct(BookOrder bookOrder,HttpServletRequest request){
    72. Map ret = new HashMap();
    73. if(bookOrder == null){
    74. ret.put("type", "error");
    75. ret.put("msg", "请填写正确的预定订单信息!");
    76. return ret;
    77. }
    78. Account account = (Account)request.getSession().getAttribute("account");
    79. if(account == null){
    80. ret.put("type", "error");
    81. ret.put("msg", "客户不能为空!");
    82. return ret;
    83. }
    84. bookOrder.setAccountId(account.getId());
    85. if(bookOrder.getRoomTypeId() == null){
    86. ret.put("type", "error");
    87. ret.put("msg", "房型不能为空!");
    88. return ret;
    89. }
    90. if(StringUtils.isEmpty(bookOrder.getName())){
    91. ret.put("type", "error");
    92. ret.put("msg", "预定订单联系人名称不能为空!");
    93. return ret;
    94. }
    95. if(StringUtils.isEmpty(bookOrder.getMobile())){
    96. ret.put("type", "error");
    97. ret.put("msg", "预定订单联系人手机号不能为空!");
    98. return ret;
    99. }
    100. if(StringUtils.isEmpty(bookOrder.getIdCard())){
    101. ret.put("type", "error");
    102. ret.put("msg", "联系人身份证号不能为空!");
    103. return ret;
    104. }
    105. if(StringUtils.isEmpty(bookOrder.getArriveDate())){
    106. ret.put("type", "error");
    107. ret.put("msg", "到达时间不能为空!");
    108. return ret;
    109. }
    110. if(StringUtils.isEmpty(bookOrder.getLeaveDate())){
    111. ret.put("type", "error");
    112. ret.put("msg", "离店时间不能为空!");
    113. return ret;
    114. }
    115. bookOrder.setCreateTime(new Date());
    116. bookOrder.setStatus(0);
    117. if(bookOrderService.add(bookOrder) <= 0){
    118. ret.put("type", "error");
    119. ret.put("msg", "添加失败,请联系管理员!");
    120. return ret;
    121. }
    122. RoomType roomType = roomTypeService.find(bookOrder.getRoomTypeId());
    123. //预定成功后去修改该房型的预定数
    124. if(roomType != null){
    125. roomType.setBookNum(roomType.getBookNum() + 1);
    126. roomType.setAvilableNum(roomType.getAvilableNum() - 1);
    127. roomTypeService.updateNum(roomType);
    128. //如果可用的房间数为0,则设置该房型状态已满
    129. if(roomType.getAvilableNum() == 0){
    130. roomType.setStatus(0);
    131. roomTypeService.edit(roomType);
    132. }
    133. }
    134. ret.put("type", "success");
    135. ret.put("msg", "预定成功!");
    136. return ret;
    137. }
    138. /**
    139. * 修改个人信息提交
    140. * @param account
    141. * @return
    142. */
    143. @RequestMapping(value="/update_info",method=RequestMethod.POST,produces = {"application/json;charset=utf-8"})
    144. @ResponseBody
    145. public Map updateInfoAct(Account account,HttpServletRequest request){
    146. Map retMap = new HashMap();
    147. if(account == null){
    148. retMap.put("type", "error");
    149. retMap.put("msg", "请填写正确的用户信息!");
    150. return retMap;
    151. }
    152. if(StringUtils.isEmpty(account.getName())){
    153. retMap.put("type", "error");
    154. retMap.put("msg", "用户名不能为空!");
    155. return retMap;
    156. }
    157. Account loginedAccount = (Account)request.getSession().getAttribute("account");
    158. if(isExist(account.getName(),loginedAccount.getId())){
    159. retMap.put("type", "error");
    160. retMap.put("msg", "该用户名已经存在!");
    161. return retMap;
    162. }
    163. loginedAccount.setAddress(account.getAddress());
    164. loginedAccount.setIdCard(account.getIdCard());
    165. loginedAccount.setMobile(account.getMobile());
    166. loginedAccount.setName(account.getName());
    167. loginedAccount.setRealName(account.getRealName());
    168. if(accountService.edit(loginedAccount) <= 0){
    169. retMap.put("type", "error");
    170. retMap.put("msg", "修改失败,请联系管理员!");
    171. return retMap;
    172. }
    173. request.getSession().setAttribute("account", loginedAccount);
    174. retMap.put("type", "success");
    175. retMap.put("msg", "修改成功!");
    176. return retMap;
    177. }
    178. /**
    179. * 修改密码提交
    180. * @param account
    181. * @return
    182. */
    183. @RequestMapping(value="/update_pwd",method=RequestMethod.POST,produces = {"application/json;charset=utf-8"})
    184. @ResponseBody
    185. public Map updatePwdAct(String oldPassword,String newPassword,HttpServletRequest request){
    186. Map retMap = new HashMap();
    187. if(StringUtils.isEmpty(oldPassword)){
    188. retMap.put("type", "error");
    189. retMap.put("msg", "请填写原来的密码!");
    190. return retMap;
    191. }
    192. if(StringUtils.isEmpty(newPassword)){
    193. retMap.put("type", "error");
    194. retMap.put("msg", "请填写新密码!");
    195. return retMap;
    196. }
    197. Account loginedAccount = (Account)request.getSession().getAttribute("account");
    198. if(!oldPassword.equals(loginedAccount.getPassword())){
    199. retMap.put("type", "error");
    200. retMap.put("msg", "原密码错误!");
    201. return retMap;
    202. }
    203. loginedAccount.setPassword(newPassword);
    204. if(accountService.edit(loginedAccount) <= 0){
    205. retMap.put("type", "error");
    206. retMap.put("msg", "修改失败,请联系管理员!");
    207. return retMap;
    208. }
    209. retMap.put("type", "success");
    210. retMap.put("msg", "修改密码成功!");
    211. return retMap;
    212. }
    213. /**
    214. * 判断用户是否存在
    215. * @param name
    216. * @param id
    217. * @return
    218. */
    219. private boolean isExist(String name,Long id){
    220. Account account = accountService.findByName(name);
    221. if(account == null)return false;
    222. if(account != null && account.getId().longValue() == id)return false;
    223. return true;
    224. }
    225. }

    1. package com.ischoolbar.programmer.controller.home;
    2. import java.util.HashMap;
    3. import java.util.Map;
    4. import javax.servlet.http.HttpServletRequest;
    5. import org.apache.commons.lang.StringUtils;
    6. import org.springframework.beans.factory.annotation.Autowired;
    7. import org.springframework.stereotype.Controller;
    8. import org.springframework.web.bind.annotation.RequestMapping;
    9. import org.springframework.web.bind.annotation.RequestMethod;
    10. import org.springframework.web.bind.annotation.RequestParam;
    11. import org.springframework.web.bind.annotation.ResponseBody;
    12. import org.springframework.web.servlet.ModelAndView;
    13. import com.ischoolbar.programmer.entity.Account;
    14. import com.ischoolbar.programmer.service.AccountService;
    15. import com.ischoolbar.programmer.service.RoomTypeService;
    16. /**
    17. * 前台首页控制器
    18. * @author Administrator
    19. *
    20. */
    21. @RequestMapping("/home")
    22. @Controller
    23. public class HomeController {
    24. @Autowired
    25. private RoomTypeService roomTypeService;
    26. @Autowired
    27. private AccountService accountService;
    28. /**
    29. * 前台首页
    30. * @param model
    31. * @param name
    32. * @return
    33. */
    34. @RequestMapping(value="/index",method=RequestMethod.GET)
    35. public ModelAndView list(ModelAndView model,
    36. @RequestParam(name="name",defaultValue="") String name
    37. ){
    38. Map queryMap = new HashMap();
    39. queryMap.put("name", name);
    40. queryMap.put("offset", 0);
    41. queryMap.put("pageSize", 999);
    42. model.addObject("roomTypeList", roomTypeService.findList(queryMap));
    43. model.setViewName("home/index/index");
    44. model.addObject("kw", name);
    45. return model;
    46. }
    47. /**
    48. * 登录页面
    49. * @param model
    50. * @return
    51. */
    52. @RequestMapping(value="/login",method=RequestMethod.GET)
    53. public ModelAndView login(ModelAndView model
    54. ){
    55. model.setViewName("home/index/login");
    56. return model;
    57. }
    58. /**
    59. * 注册页面
    60. * @param model
    61. * @return
    62. */
    63. @RequestMapping(value="/reg",method=RequestMethod.GET)
    64. public ModelAndView reg(ModelAndView model
    65. ){
    66. model.setViewName("home/index/reg");
    67. return model;
    68. }
    69. /**
    70. * 登录信息提交
    71. * @param account
    72. * @return
    73. */
    74. @RequestMapping(value="/login",method=RequestMethod.POST,produces = {"application/json;charset=utf-8"})
    75. @ResponseBody
    76. public Map loginAct(Account account,String vcode,HttpServletRequest request){
    77. Map retMap = new HashMap();
    78. if(account == null){
    79. retMap.put("type", "error");
    80. retMap.put("msg", "请填写正确的用户信息!");
    81. return retMap;
    82. }
    83. if(StringUtils.isEmpty(account.getName())){
    84. retMap.put("type", "error");
    85. retMap.put("msg", "用户名不能为空!");
    86. return retMap;
    87. }
    88. if(StringUtils.isEmpty(account.getPassword())){
    89. retMap.put("type", "error");
    90. retMap.put("msg", "密码不能为空!");
    91. return retMap;
    92. }
    93. if(StringUtils.isEmpty(vcode)){
    94. retMap.put("type", "error");
    95. retMap.put("msg", "验证码不能为空!");
    96. return retMap;
    97. }
    98. Object attribute = request.getSession().getAttribute("accountLoginCpacha");
    99. if(attribute == null){
    100. retMap.put("type", "error");
    101. retMap.put("msg", "验证码过期,请刷新!");
    102. return retMap;
    103. }
    104. if(!vcode.equalsIgnoreCase(attribute.toString())){
    105. retMap.put("type", "error");
    106. retMap.put("msg", "验证码错误!");
    107. return retMap;
    108. }
    109. Account findByName = accountService.findByName(account.getName());
    110. if(findByName == null){
    111. retMap.put("type", "error");
    112. retMap.put("msg", "用户名不存在!");
    113. return retMap;
    114. }
    115. if(!account.getPassword().equals(findByName.getPassword())){
    116. retMap.put("type", "error");
    117. retMap.put("msg", "密码错误!");
    118. return retMap;
    119. }
    120. if(findByName.getStatus() == -1){
    121. retMap.put("type", "error");
    122. retMap.put("msg", "该用户已被禁用,请联系管理员!");
    123. return retMap;
    124. }
    125. request.getSession().setAttribute("account", findByName);
    126. request.getSession().setAttribute("accountLoginCpacha", null);
    127. retMap.put("type", "success");
    128. retMap.put("msg", "登录成功!");
    129. return retMap;
    130. }
    131. /**
    132. * 注册信息提交
    133. * @param account
    134. * @return
    135. */
    136. @RequestMapping(value="/reg",method=RequestMethod.POST,produces = {"application/json;charset=utf-8"})
    137. @ResponseBody
    138. public Map regAct(Account account){
    139. Map retMap = new HashMap();
    140. if(account == null){
    141. retMap.put("type", "error");
    142. retMap.put("msg", "请填写正确的用户信息!");
    143. return retMap;
    144. }
    145. if(StringUtils.isEmpty(account.getName())){
    146. retMap.put("type", "error");
    147. retMap.put("msg", "用户名不能为空!");
    148. return retMap;
    149. }
    150. if(StringUtils.isEmpty(account.getPassword())){
    151. retMap.put("type", "error");
    152. retMap.put("msg", "密码不能为空!");
    153. return retMap;
    154. }
    155. if(StringUtils.isEmpty(account.getMobile())){
    156. retMap.put("type", "error");
    157. retMap.put("msg", "手机号不能为空!");
    158. return retMap;
    159. }
    160. if(isExist(account.getName())){
    161. retMap.put("type", "error");
    162. retMap.put("msg", "该用户名已经存在!");
    163. return retMap;
    164. }
    165. if(accountService.add(account) <= 0){
    166. retMap.put("type", "error");
    167. retMap.put("msg", "注册失败,请联系管理员!");
    168. return retMap;
    169. }
    170. retMap.put("type", "success");
    171. retMap.put("msg", "注册成功!");
    172. return retMap;
    173. }
    174. /**
    175. * 退出登录
    176. * @param request
    177. * @return
    178. */
    179. @RequestMapping(value="/logout",method=RequestMethod.GET)
    180. public String logout(HttpServletRequest request){
    181. request.getSession().setAttribute("account", null);
    182. return "redirect:login";
    183. }
    184. private boolean isExist(String name){
    185. Account account = accountService.findByName(name);
    186. if(account == null)return false;
    187. return true;
    188. }
    189. }

    1. package com.ischoolbar.programmer.controller.admin;
    2. import java.util.HashMap;
    3. import java.util.Map;
    4. import org.apache.commons.lang.StringUtils;
    5. import org.springframework.beans.factory.annotation.Autowired;
    6. import org.springframework.stereotype.Controller;
    7. import org.springframework.web.bind.annotation.RequestMapping;
    8. import org.springframework.web.bind.annotation.RequestMethod;
    9. import org.springframework.web.bind.annotation.RequestParam;
    10. import org.springframework.web.bind.annotation.ResponseBody;
    11. import org.springframework.web.servlet.ModelAndView;
    12. import com.ischoolbar.programmer.entity.Account;
    13. import com.ischoolbar.programmer.page.admin.Page;
    14. import com.ischoolbar.programmer.service.AccountService;
    15. /**
    16. * 客户管理后台控制器
    17. * @author Administrator
    18. *
    19. */
    20. @RequestMapping("/admin/account")
    21. @Controller
    22. public class AccountController {
    23. @Autowired
    24. private AccountService accountService;
    25. /**
    26. * 客户管理列表页面
    27. * @param model
    28. * @return
    29. */
    30. @RequestMapping(value="/list",method=RequestMethod.GET)
    31. public ModelAndView list(ModelAndView model){
    32. model.setViewName("account/list");
    33. return model;
    34. }
    35. /**
    36. * 客户信息添加操作
    37. * @param account
    38. * @return
    39. */
    40. @RequestMapping(value="/add",method=RequestMethod.POST)
    41. @ResponseBody
    42. public Map add(Account account){
    43. Map ret = new HashMap();
    44. if(account == null){
    45. ret.put("type", "error");
    46. ret.put("msg", "请填写正确的客户信息!");
    47. return ret;
    48. }
    49. if(StringUtils.isEmpty(account.getName())){
    50. ret.put("type", "error");
    51. ret.put("msg", "客户名称不能为空!");
    52. return ret;
    53. }
    54. if(StringUtils.isEmpty(account.getPassword())){
    55. ret.put("type", "error");
    56. ret.put("msg", "客户密码不能为空!");
    57. return ret;
    58. }
    59. if(isExist(account.getName(), 0l)){
    60. ret.put("type", "error");
    61. ret.put("msg", "该用户名已经存在!");
    62. return ret;
    63. }
    64. if(accountService.add(account) <= 0){
    65. ret.put("type", "error");
    66. ret.put("msg", "添加失败,请联系管理员!");
    67. return ret;
    68. }
    69. ret.put("type", "success");
    70. ret.put("msg", "添加成功!");
    71. return ret;
    72. }
    73. /**
    74. * 客户信息编辑操作
    75. * @param account
    76. * @return
    77. */
    78. @RequestMapping(value="/edit",method=RequestMethod.POST)
    79. @ResponseBody
    80. public Map edit(Account account){
    81. Map ret = new HashMap();
    82. if(account == null){
    83. ret.put("type", "error");
    84. ret.put("msg", "请填写正确的客户信息!");
    85. return ret;
    86. }
    87. if(StringUtils.isEmpty(account.getName())){
    88. ret.put("type", "error");
    89. ret.put("msg", "客户名称不能为空!");
    90. return ret;
    91. }
    92. if(StringUtils.isEmpty(account.getPassword())){
    93. ret.put("type", "error");
    94. ret.put("msg", "客户密码不能为空!");
    95. return ret;
    96. }
    97. if(isExist(account.getName(), account.getId())){
    98. ret.put("type", "error");
    99. ret.put("msg", "该用户名已经存在!");
    100. return ret;
    101. }
    102. if(accountService.edit(account) <= 0){
    103. ret.put("type", "error");
    104. ret.put("msg", "添加失败,请联系管理员!");
    105. return ret;
    106. }
    107. ret.put("type", "success");
    108. ret.put("msg", "修改成功!");
    109. return ret;
    110. }
    111. /**
    112. * 分页查询客户信息
    113. * @param name
    114. * @param page
    115. * @return
    116. */
    117. @RequestMapping(value="/list",method=RequestMethod.POST)
    118. @ResponseBody
    119. public Map list(
    120. @RequestParam(name="name",defaultValue="") String name,
    121. @RequestParam(name="realName",defaultValue="") String realName,
    122. @RequestParam(name="idCard",defaultValue="") String idCard,
    123. @RequestParam(name="mobile",defaultValue="") String mobile,
    124. @RequestParam(name="status",required=false) Integer status,
    125. Page page
    126. ){
    127. Map ret = new HashMap();
    128. Map queryMap = new HashMap();
    129. queryMap.put("name", name);
    130. queryMap.put("status", status);
    131. queryMap.put("realName", realName);
    132. queryMap.put("idCard", idCard);
    133. queryMap.put("mobile", mobile);
    134. queryMap.put("offset", page.getOffset());
    135. queryMap.put("pageSize", page.getRows());
    136. ret.put("rows", accountService.findList(queryMap));
    137. ret.put("total", accountService.getTotal(queryMap));
    138. return ret;
    139. }
    140. /**
    141. * 客户信息删除操作
    142. * @param id
    143. * @return
    144. */
    145. @RequestMapping(value="/delete",method=RequestMethod.POST)
    146. @ResponseBody
    147. public Map delete(Long id){
    148. Map ret = new HashMap();
    149. if(id == null){
    150. ret.put("type", "error");
    151. ret.put("msg", "请选择要删除的信息!");
    152. return ret;
    153. }
    154. try {
    155. if(accountService.delete(id) <= 0){
    156. ret.put("type", "error");
    157. ret.put("msg", "删除失败,请联系管理员!");
    158. return ret;
    159. }
    160. } catch (Exception e) {
    161. // TODO: handle exception
    162. ret.put("type", "error");
    163. ret.put("msg", "该客户下存在订单信息,请先删除该客户下的所有订单信息!");
    164. return ret;
    165. }
    166. ret.put("type", "success");
    167. ret.put("msg", "删除成功!");
    168. return ret;
    169. }
    170. /**
    171. * 判断用户名是否存在
    172. * @param name
    173. * @param id
    174. * @return
    175. */
    176. private boolean isExist(String name,Long id){
    177. Account findByName = accountService.findByName(name);
    178. if(findByName == null)return false;
    179. if(findByName.getId().longValue() == id.longValue())return false;
    180. return true;
    181. }
    182. }

    五,项目总结

       本项目基本功能完整,界面简洁大方,适合做毕业设计或课程设计使用,使用了常见的开发的工具和数据库,使用SSM框架和easyUI来完成酒店管理系统的开发和设计,值得学习和研究。

  • 相关阅读:
    sql---慢查询和语句耗时
    map-set
    爬虫 — 内容乱码与证书不信任网站
    华为面试宝典OD
    复盘:细数这些年写文字的成与败
    【Linux】线程池
    uniapp实现底部弹出菜单选择
    Vue中 computed 和 watch
    HTTP——HTTP的请求报文和响应报文的内容
    makefile之目标文件生成
  • 原文地址:https://blog.csdn.net/whirlwind526/article/details/126655043