基于VUE的酒店管理系统的设计与实现

发布于:2022-11-09 ⋅ 阅读:(796) ⋅ 点赞:(0)

作者主页:编程指南针

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

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

文末获取源码 

一,项目简介

随着社会和科技的发展,现代化是当今社会的一个重要改革,而这其中酒店行业的出现和发展已经具有很长的历史了,发展到现在酒店的管理模式也较为完整了,但随着人口的增长、酒店多元化的出现,酒店行业在业务上的发展也到了一定的瓶颈期。在如此庞大信息量的情况下,如果像以前所有的事情都由人工操作显然是及其困难,并且极易出错的。要想提高劳动生产力,进而促进酒店的经济效益,必须借助计算机来进行改革。由此酒店管理系统就应运而生。

本系统主要是为了解决人手不足,管理方便而设计的,使用VUE作为网页前端开发语言和SpringBoot及Mybatis作为后台服务器开发语言,使用MySQL数据库作为酒店管理系统的数据库,前端开发工具为Hbuilder、后台用IDEA,模式采用前后端分离模式进行开发。主要实现了添加员工功能、登记入住功能、退房功能、房间管理功能、系统通知、好友聊天、登录功能等功能。基本上满足了旅客到店里来入住以及酒店日常管理的功能,极大的方便了酒店的管理,减少了劳动力与出错率。

在这个时代,社会随着科技日新月异改变,电脑软件的使用不仅在群众中的普及率越来越高,在日常的生活中人们使用电脑的情况也越来越多,因此电脑软件在人们工作和生活中起到了非常重要的作用。而随着国家对旅游业的发展和支持,酒店行业激烈的竞争着客户的资源,为此酒店行业争取客源、提高酒店的满员率、制定正确的营销策略已经成为酒店的一项重要任务,而借助于当前蓬勃发展的系统工具来拓展销售能力,创造客观的经济效益已经成为许多酒店的首选。再加上国际、国内名优企业的扩展力度的加大,宾馆、酒店业集团化的步伐加快,预示着传统的宾馆、酒店正逐步步向信息化管理,但是国内中小型酒店占着绝大多数的情况,宾馆由于资金少、人员缺乏等多方面的原因不易使用酒店管理类软件,所以依靠原始的手工记录管理会出现效率低、容易出错等问题,而且大型的酒店管理系统对于中小型酒店来说,有很多功能根本用不上。所以结合酒店前台管理的需要进行扩展性而开发的一套酒店管理系统。本系统是一套适用于中小型酒店使用的优秀系统。

主要针对的是中小型酒店的设计的,基本符合他们所要用到的功能。目前,本设计应解决的主要的功能有三个:

  1. 客户的管理

要对客户进行有效的管理,减少入住、退房、个人信息等的出错,为酒店带来不必要的麻烦。

  1. 酒店员工的管理

对员工的管理,是酒店管理的一个重要的部分,只有管理好员工,酒店才能正常的运作。

  1. 权限的管理

每个酒店的都有不同的职位,老板,前台,清洁工等,要对他们进行权限的分配,不然酒店的管理会出现混乱。

本系统主要由以下几个功能模块组成;

登录功能:员工可以通过登陆界面的进入,系统的主界面。

系统通知功能:管理员可以通过系统发送通知功能给员工发送通知。

登记入住功能:在有客户想要住店时,员工可以纪录客户的信息。

客户管理功能:可以查看已入住的客户,并且进行退房和修改信息以及查询的操作。

员工管理功能:可以查看员工的信息,修改员工的信息。

权限管理功能:可以管理员工的权限,防止任意操作。

房间管理功能:可以设定酒店房间的类型和价格。

员工聊天功能:此模块可以供员工之间的信息沟通,更方便工作的交流。

系统的架构如图4.1所示,操作大致的流程如图4.2所示,操作员以及相应功能如图4.3所示。

图4.1系统架构图

图4.2操作流程图

图4.3管理用例图


 

二,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

后台开发技术:Springboot+Mybatis

前台开技术:VUE+ElementUI

三,系统展示

6.1 系统登陆界面

要登陆酒店管理系统必须通过系统的登陆平台,输入正确的用户名和密码,通过login()接口将数据通过axios传输到后台,后台通过loginControl调取数据表hr的信息,经过验证后才可以进入系统的主页面,如果输入的信息有误,系统会出现相应的错误提示。如输入用户名admin,密码123,点击登录,就可以进入主界面,并得到登录成功的提示。登录界面如图6.1所示,成功提示如图6.2所示。

图6.1登录界面图

图6.2登录成功图

6.2 系统主界面

通过登录后,界面会进入到主界面,此时主界面会根据用户的权限显示相应的功能。这里以系统管理员为例,管理员进入主界面后可以看到员工管理客户管理系统管以及左上角的系统通知等功能,如图6.3所示。而普通员工只能看到客户管理的业务,如图6.4所示。

图6.3管理员界面图

图6.4普通员工图

6.3 系统通知

点击右上角的铃铛图标,进入系统通知的界面,员工可以看到系统管理员发送的信息,但是只有系统管理员可以发送系统通知,其他人只能查看通知,未查看的通知会标记为红色。已读时红色标记会消失,而在通知列表里面还可以看到以往所有的通知包括标题,通知时间。系统通知界面如图6.5所示。

图6.5 系统通知图

6.4 聊天功能

点击好友聊天,进入聊天界面,可以实现与好友聊天的功能,例如选择李白聊天,在输入框输入信息点击发送就可以发送聊天信息,这时就会在聊天信息界面显示聊天的信息,但是当你关闭聊天信息界面时,所有的聊天信息将会清除。聊天功能界面如图6.6所示。

图6.6聊天功能图

6.5 添加员工

点击员工资料,再点击基本资料,可以看到酒店所有员工的基本信息,如图6.7所示,再点击右边的添加员工按钮可以进入添加员工的界面,输入完整有效的信息如员工姓名、电话、员工卡号、身份证等信息,然后点击确定按钮,即可添加成功,如图6.8所示。同时会显示在列表中。如果不想添加点击取消按钮即可返回列表界面。

图6.7员工界面图

图6.8添加功能图

6.6 员工查询

在查询输入框中,输入员工的姓名,点击查询即可查询到员工的信息,如输入“陈静”,点击查询,在列表中就可以显示出有陈静二字的员工信息,如图6.9所示。

图6.9员工查询图

6.7 修改员工信息

点击员工列表右侧修改信息按钮,在弹出的修改界面,选者修改的信息,修改完成后,点击确认按钮,系统会提示修改成功,就可以在员工列表上看到相应员工信息已经修改,如图6.10所示。

图6.10员工修改图

6.8 登记入住

点击客户管理,进入界面后点击登记入住按钮,在弹出的登记界面填写正确的客户信息如姓名、电话、身份证、选择房间等信息,点击确认,即可登记客户的入住信息如图6.11所示。同时在客户列表中可以看到登记的信息。

图6.11登记入住图

6.9 退房功能

    在有客户想退房时,点击客户列表右侧的退房按钮,就可以给客户进行退房的程序,退房界面如图6.12所示。

图6.12 退房功能图

6.10 添加房间

点击添加房间按钮,进入房间管理界面,可进行添加房间的操作,输入房号,房型,定价,备注再点击保存按钮即可添加房间,如果不添加则点击取消。添加房间界面如图6.13所示。

图6.13 添加房间图

6.11 权限分配

点击权限分配菜单进入权限分配界面,可以对相应职位给予相应的酒店管理权限,操作员进入后,只会看到相应的权限菜单,如李白给予的权限为员工管理和客户管理,这进入主界面后只能看到两个菜单,如图6.13所示。

图6.14 权限分配图

6.12 权限管理

点击系统管理菜单,进入操作员管理界面,可看到部分操作员的信息如图6.15所示,可对操作员进行登录权限的修改,禁止或启动操作员的权限,一旦禁止后,该操作员将不能登陆系统。

图6.15 权限管理图


 

四,核心代码展示

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
 *
 */
@RequestMapping("/admin/account")
@Controller
public class AccountController {
	
	@Autowired
	private AccountService accountService;
	
	
	/**
	 * 客户管理列表页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/list",method=RequestMethod.GET)
	public ModelAndView list(ModelAndView model){
		model.setViewName("account/list");
		return model;
	}
	
	/**
	 * 客户信息添加操作
	 * @param account
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	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
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	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
	 */
	@RequestMapping(value="/list",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> list(
			@RequestParam(name="name",defaultValue="") String name,
			@RequestParam(name="realName",defaultValue="") String realName,
			@RequestParam(name="idCard",defaultValue="") String idCard,
			@RequestParam(name="mobile",defaultValue="") String mobile,
			@RequestParam(name="status",required=false) Integer status,
			Page page
			){
		Map<String,Object> ret = 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
	 */
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	@ResponseBody
	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;
	}
}
package com.ischoolbar.programmer.controller.admin;

import java.util.Date;
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.BookOrder;
import com.ischoolbar.programmer.entity.RoomType;
import com.ischoolbar.programmer.page.admin.Page;
import com.ischoolbar.programmer.service.AccountService;
import com.ischoolbar.programmer.service.BookOrderService;
import com.ischoolbar.programmer.service.RoomTypeService;

/**
 * 预定订单管理后台控制器
 * @author Administrator
 *
 */
@RequestMapping("/admin/book_order")
@Controller
public class BookOrderController {
	
	@Autowired
	private AccountService accountService;
	@Autowired
	private RoomTypeService roomTypeService;
	@Autowired
	private BookOrderService bookOrderService;
	
	
	/**
	 * 预定订单管理列表页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/list",method=RequestMethod.GET)
	public ModelAndView list(ModelAndView model){
		model.addObject("roomTypeList", roomTypeService.findAll());
		model.addObject("accountList", accountService.findAll());
		model.setViewName("book_order/list");
		return model;
	}
	
	/**
	 * 预定订单信息添加操作
	 * @param bookOrder
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, String> add(BookOrder bookOrder){
		Map<String, String> ret = new HashMap<String, String>();
		if(bookOrder == null){
			ret.put("type", "error");
			ret.put("msg", "请填写正确的预定订单信息!");
			return ret;
		}
		if(bookOrder.getAccountId() == null){
			ret.put("type", "error");
			ret.put("msg", "客户不能为空!");
			return ret;
		}
		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());
		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
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, String> edit(BookOrder bookOrder){
		Map<String, String> ret = new HashMap<String, String>();
		if(bookOrder == null){
			ret.put("type", "error");
			ret.put("msg", "请填写正确的预定订单信息!");
			return ret;
		}
		if(bookOrder.getAccountId() == null){
			ret.put("type", "error");
			ret.put("msg", "客户不能为空!");
			return ret;
		}
		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 existBookOrder = bookOrderService.find(bookOrder.getId());
		if(existBookOrder == null){
			ret.put("type", "error");
			ret.put("msg", "请选择正确的数据进行编辑!");
			return ret;
		}
		if(bookOrderService.edit(bookOrder) <= 0){
			ret.put("type", "error");
			ret.put("msg", "编辑失败,请联系管理员!");
			return ret;
		}
		//判断房型是否发生变化
		if(existBookOrder.getRoomTypeId().longValue() != bookOrder.getRoomTypeId().longValue()){
			//房型发生了变化
			//首先恢复原来房型的预定数及可用数
			RoomType oldRoomType = roomTypeService.find(existBookOrder.getRoomTypeId());
			oldRoomType.setAvilableNum(oldRoomType.getAvilableNum() + 1);
			oldRoomType.setBookNum(oldRoomType.getBookNum() - 1);
			roomTypeService.updateNum(oldRoomType);
			if(oldRoomType.getStatus() == 0){
				//旧的房间原来是满房,现在不满房的话,恢复状态
				if(oldRoomType.getAvilableNum() > 0){
					//设置成状态可用
					oldRoomType.setStatus(1);
					roomTypeService.edit(oldRoomType);
				}
			}
			//修改新的房型的可用数和预定数
			RoomType newRoomType = roomTypeService.find(bookOrder.getRoomTypeId());
			newRoomType.setAvilableNum(newRoomType.getAvilableNum() - 1);
			newRoomType.setBookNum(newRoomType.getBookNum() + 1);
			roomTypeService.updateNum(newRoomType);
			if(newRoomType.getAvilableNum() <= 0){
				//没有可用房间数
				newRoomType.setStatus(0);//设置成满房
				roomTypeService.edit(newRoomType);
			}
		}
		ret.put("type", "success");
		ret.put("msg", "修改成功!");
		return ret;
	}
	
	/**
	 * 分页查询预定订单信息
	 * @param name
	 * @param page
	 * @return
	 */
	@RequestMapping(value="/list",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> list(
			@RequestParam(name="name",defaultValue="") String name,
			@RequestParam(name="accountId",defaultValue="") Long accountId,
			@RequestParam(name="roomTypeId",defaultValue="") Long roomTypeId,
			@RequestParam(name="idCard",defaultValue="") String idCard,
			@RequestParam(name="mobile",defaultValue="") String mobile,
			@RequestParam(name="status",required=false) Integer status,
			Page page
			){
		Map<String,Object> ret = new HashMap<String, Object>();
		Map<String,Object> queryMap = new HashMap<String, Object>();
		queryMap.put("name", name);
		queryMap.put("status", status);
		queryMap.put("accountId", accountId);
		queryMap.put("roomTypeId", roomTypeId);
		queryMap.put("idCard", idCard);
		queryMap.put("mobile", mobile);
		queryMap.put("offset", page.getOffset());
		queryMap.put("pageSize", page.getRows());
		ret.put("rows", bookOrderService.findList(queryMap));
		ret.put("total", bookOrderService.getTotal(queryMap));
		return ret;
	}
	
	
}
package com.ischoolbar.programmer.controller.admin;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
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.BookOrder;
import com.ischoolbar.programmer.entity.RoomType;
import com.ischoolbar.programmer.entity.admin.Checkin;
import com.ischoolbar.programmer.entity.admin.Room;
import com.ischoolbar.programmer.page.admin.Page;
import com.ischoolbar.programmer.service.BookOrderService;
import com.ischoolbar.programmer.service.RoomTypeService;
import com.ischoolbar.programmer.service.admin.CheckinService;
import com.ischoolbar.programmer.service.admin.RoomService;

/**
 * 入住管理后台控制器
 * @author Administrator
 *
 */
@RequestMapping("/admin/checkin")
@Controller
public class CheckinController {
	
	@Autowired
	private RoomService roomService;
	@Autowired
	private RoomTypeService roomTypeService;
	@Autowired
	private BookOrderService bookOrderService;
	@Autowired
	private CheckinService checkinService;
	
	/**
	 * 入住管理列表页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/list",method=RequestMethod.GET)
	public ModelAndView list(ModelAndView model){
		model.addObject("roomTypeList", roomTypeService.findAll());
		model.addObject("roomList", roomService.findAll());
		model.setViewName("checkin/list");
		return model;
	}
	
	/**
	 * 入住信息添加操作
	 * @param checkin
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, String> add(Checkin checkin,
			@RequestParam(name="bookOrderId",required=false) Long bookOrderId
			){
		Map<String, String> ret = new HashMap<String, String>();
		if(checkin == null){
			ret.put("type", "error");
			ret.put("msg", "请填写正确的入住信息!");
			return ret;
		}
		if(checkin.getRoomId() == null){
			ret.put("type", "error");
			ret.put("msg", "房间不能为空!");
			return ret;
		}
		if(checkin.getRoomTypeId() == null){
			ret.put("type", "error");
			ret.put("msg", "房型不能为空!");
			return ret;
		}
		if(StringUtils.isEmpty(checkin.getName())){
			ret.put("type", "error");
			ret.put("msg", "入住联系人名称不能为空!");
			return ret;
		}
		if(StringUtils.isEmpty(checkin.getMobile())){
			ret.put("type", "error");
			ret.put("msg", "入住联系人手机号不能为空!");
			return ret;
		}
		if(StringUtils.isEmpty(checkin.getIdCard())){
			ret.put("type", "error");
			ret.put("msg", "联系人身份证号不能为空!");
			return ret;
		}
		if(StringUtils.isEmpty(checkin.getArriveDate())){
			ret.put("type", "error");
			ret.put("msg", "到达时间不能为空!");
			return ret;
		}
		if(StringUtils.isEmpty(checkin.getLeaveDate())){
			ret.put("type", "error");
			ret.put("msg", "离店时间不能为空!");
			return ret;
		}
		checkin.setCreateTime(new Date());
		if(checkinService.add(checkin) <= 0){
			ret.put("type", "error");
			ret.put("msg", "添加失败,请联系管理员!");
			return ret;
		}
		RoomType roomType = roomTypeService.find(checkin.getRoomTypeId());
		
		if(bookOrderId != null){
			//从预定来的入住单(入住既可以是直接入住也可以是已经预定的人来入住)
			BookOrder bookOrder = bookOrderService.find(bookOrderId);
			bookOrder.setStatus(1);
			bookOrderService.edit(bookOrder);
			//roomType.setBookNum(roomType.getBookNum() - 1);//预定数减1
		}else{
			roomType.setAvilableNum(roomType.getAvilableNum() - 1);
		}
		//入住成功后去修改该房型的预定数
		if(roomType != null){
			roomType.setLivedNum(roomType.getLivedNum() + 1);//入住数加1
			roomTypeService.updateNum(roomType);
			//如果可用的房间数为0,则设置该房型状态已满
			if(roomType.getAvilableNum() == 0){
				roomType.setStatus(0);
				roomTypeService.edit(roomType);
			}
		}
		Room room = roomService.find(checkin.getRoomId());
		if(room != null){
			//要把房间状态设置为已入住
			room.setStatus(1);
			roomService.edit(room);
		}
		ret.put("type", "success");
		ret.put("msg", "添加成功!");
		return ret;
	}
	
	/**
	 * 入住信息编辑操作
	 * @param account
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, String> edit(Checkin checkin,
			@RequestParam(name="bookOrderId",required=false) Long bookOrderId
			){
		Map<String, String> ret = new HashMap<String, String>();
		if(checkin == null){
			ret.put("type", "error");
			ret.put("msg", "请填写正确的入住信息!");
			return ret;
		}
		if(checkin.getRoomId() == null){
			ret.put("type", "error");
			ret.put("msg", "房间不能为空!");
			return ret;
		}
		if(checkin.getRoomTypeId() == null){
			ret.put("type", "error");
			ret.put("msg", "房型不能为空!");
			return ret;
		}
		if(StringUtils.isEmpty(checkin.getName())){
			ret.put("type", "error");
			ret.put("msg", "入住联系人名称不能为空!");
			return ret;
		}
		if(StringUtils.isEmpty(checkin.getMobile())){
			ret.put("type", "error");
			ret.put("msg", "入住联系人手机号不能为空!");
			return ret;
		}
		if(StringUtils.isEmpty(checkin.getIdCard())){
			ret.put("type", "error");
			ret.put("msg", "联系人身份证号不能为空!");
			return ret;
		}
		if(StringUtils.isEmpty(checkin.getArriveDate())){
			ret.put("type", "error");
			ret.put("msg", "到达时间不能为空!");
			return ret;
		}
		if(StringUtils.isEmpty(checkin.getLeaveDate())){
			ret.put("type", "error");
			ret.put("msg", "离店时间不能为空!");
			return ret;
		}
		Checkin existCheckin = checkinService.find(checkin.getId());
		if(existCheckin == null){
			ret.put("type", "error");
			ret.put("msg", "请选择正确的入住信息进行编辑!");
			return ret;
		}
		if(checkinService.edit(checkin) <= 0){
			ret.put("type", "error");
			ret.put("msg", "编辑失败,请联系管理员!");
			return ret;
		}
		//编辑成功之后:1:判断房型是否发生变化,2:判断房间是否发生变化,3:判断是否是从预定订单来的信息
		//首先判断是否是从预定来的入住信息
		RoomType oldRoomType = roomTypeService.find(existCheckin.getRoomTypeId());
		RoomType newRoomType = roomTypeService.find(checkin.getRoomTypeId());
		
		//房型入住数不收预定订单的影响
		if(oldRoomType.getId().longValue() != newRoomType.getId().longValue()){
			//说明房型发生了变化,原来的房型入住数恢复,新的房型入住数增加
			oldRoomType.setLivedNum(oldRoomType.getLivedNum() - 1);
			newRoomType.setLivedNum(newRoomType.getLivedNum() + 1);
			if(bookOrderId == null){
				oldRoomType.setAvilableNum(oldRoomType.getAvilableNum() + 1);
				newRoomType.setAvilableNum(newRoomType.getAvilableNum() - 1);
			}
		}
		/**
		if(bookOrderId == null){
			//表示不是从预定订单来的,此时需判断原来的入住信息是否来源于预定
			if(existCheckin.getBookOrderId() == null){
				oldRoomType.setAvilableNum(oldRoomType.getAvilableNum() + 1);
				newRoomType.setAvilableNum(newRoomType.getAvilableNum() - 1);
			}
			if(existCheckin.getBookOrderId() != null){
				//表示原来的入住信息来源于预定,但是新的入住信息不是来源于预定,需恢复原来的预定状态
				BookOrder oldBookOrder = bookOrderService.find(existCheckin.getBookOrderId());
				oldBookOrder.setStatus(0);
				bookOrderService.edit(oldBookOrder);
				oldRoomType.setBookNum(oldRoomType.getBookNum() + 1);
			}
		}
		//表示此时的订单是来源于预定
		if(bookOrderId != null){
			//表示是从预定订单来的,此时需判断原来的入住信息是否来源于预定
			if(existCheckin.getBookOrderId() != null){
				//表示原来的入住信息来源于预定,但是新的入住信息不是来源于预定,需恢复原来的预定状态
				BookOrder oldBookOrder = bookOrderService.find(existCheckin.getBookOrderId());
				if(bookOrderId.longValue() != oldBookOrder.getId().longValue()){
					oldBookOrder.setStatus(0);
					bookOrderService.edit(oldBookOrder);
					//oldRoomType.setBookNum(oldRoomType.getBookNum() + 1);
				}
			}
			if(oldRoomType.getId().longValue() != newRoomType.getId().longValue()){
				newRoomType.setBookNum(newRoomType.getBookNum() - 1);
				
				if(existCheckin.getBookOrderId() == null){
					oldRoomType.setAvilableNum(oldRoomType.getAvilableNum() + 1);
				}else{
					oldRoomType.setBookNum(oldRoomType.getBookNum() + 1);
				}
			}
			BookOrder newBookOrder = bookOrderService.find(bookOrderId);
			newBookOrder.setStatus(1);
			bookOrderService.edit(newBookOrder);
		}**/
		roomTypeService.updateNum(newRoomType);
		roomTypeService.updateNum(oldRoomType);
		//判断房间是否发生变化
		if(checkin.getRoomId().longValue() != existCheckin.getRoomId().longValue()){
			//表示房间发生了变化
			Room oldRoom = roomService.find(existCheckin.getRoomId());
			Room newRoom = roomService.find(checkin.getRoomId());
			oldRoom.setStatus(0);//原来的房间可入住
			newRoom.setStatus(1);//现在的房间已入住
			roomService.edit(newRoom);
			roomService.edit(oldRoom);
		}
		ret.put("type", "success");
		ret.put("msg", "修改成功!");
		return ret;
	}
	
	/**
	 * 分页查询入住信息
	 * @param name
	 * @param page
	 * @return
	 */
	@RequestMapping(value="/list",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> list(
			@RequestParam(name="name",defaultValue="") String name,
			@RequestParam(name="roomId",defaultValue="") Long roomId,
			@RequestParam(name="roomTypeId",defaultValue="") Long roomTypeId,
			@RequestParam(name="idCard",defaultValue="") String idCard,
			@RequestParam(name="mobile",defaultValue="") String mobile,
			@RequestParam(name="status",required=false) Integer status,
			Page page
			){
		Map<String,Object> ret = new HashMap<String, Object>();
		Map<String,Object> queryMap = new HashMap<String, Object>();
		queryMap.put("name", name);
		queryMap.put("status", status);
		queryMap.put("roomId", roomId);
		queryMap.put("roomTypeId", roomTypeId);
		queryMap.put("idCard", idCard);
		queryMap.put("mobile", mobile);
		queryMap.put("offset", page.getOffset());
		queryMap.put("pageSize", page.getRows());
		ret.put("rows", checkinService.findList(queryMap));
		ret.put("total", checkinService.getTotal(queryMap));
		return ret;
	}
	
	/**
	 * 退房操作
	 * @param checkId
	 * @return
	 */
	@RequestMapping(value="/checkout",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, String> checkout(Long checkId
			){
		Map<String, String> ret = new HashMap<String, String>();
		if(checkId == null){
			ret.put("type", "error");
			ret.put("msg", "请选择数据!");
			return ret;
		}
		Checkin checkin = checkinService.find(checkId);
		if(checkin == null){
			ret.put("type", "error");
			ret.put("msg", "请选择正确的数据!");
			return ret;
		}
		checkin.setStatus(1);
		if(checkinService.edit(checkin) <= 0){
			ret.put("type", "error");
			ret.put("msg", "退房失败,请联系管理员!");
			return ret;
		}
		//首先操作房间状态
		Room room = roomService.find(checkin.getRoomId());
		if(room != null){
			room.setStatus(2);
			roomService.edit(room);
		}
		//其次修改房型可用数、入住数、状态
		RoomType roomType = roomTypeService.find(checkin.getRoomTypeId());
		if(roomType != null){
			roomType.setAvilableNum(roomType.getAvilableNum() + 1);
			if(roomType.getAvilableNum() > roomType.getRoomNum()){
				roomType.setAvilableNum(roomType.getRoomNum());
			}
			roomType.setLivedNum(roomType.getLivedNum() - 1);
			if(roomType.getStatus() == 0){
				roomType.setStatus(1);
			}
			if(checkin.getBookOrderId() != null){
				roomType.setBookNum(roomType.getBookNum() - 1);
			}
			roomTypeService.updateNum(roomType);
			roomTypeService.edit(roomType);
		}
		//判断是否来自预定
		if(checkin.getBookOrderId() != null){
			BookOrder bookOrder = bookOrderService.find(checkin.getBookOrderId());
			bookOrder.setStatus(2);
			bookOrderService.edit(bookOrder);
			
		}
		ret.put("type", "success");
		ret.put("msg", "退房成功!");
		return ret;
	}
	
	/**
	 * 根据房间类型获取房间
	 * @param roomTypeId
	 * @return
	 */
	@RequestMapping(value="/load_room_list",method=RequestMethod.POST)
	@ResponseBody
	public List<Map<String, Object>> load_room_list(Long roomTypeId){
		List<Map<String, Object>> retList = new ArrayList<Map<String,Object>>();
		Map<String, Object> queryMap = new HashMap<String, Object>();
		queryMap.put("roomTypeId", roomTypeId);
		queryMap.put("status", 0);
		queryMap.put("offset", 0);
		queryMap.put("pageSize", 999);
		List<Room> roomList = roomService.findList(queryMap);
		for(Room room:roomList){
			Map<String, Object> option = new HashMap<String, Object>();
			option.put("value", room.getId());
			option.put("text", room.getSn());
			retList.add(option);
		}
		return retList;
	}
}

五,项目总结

随着社会的发展,酒店管理系统在国内外的发展都有了不小的成就,在国家发展到80年代至90年代的时候,国内的酒店管理系统已经开始发展起来了,充分接纳了国外酒店管理系统的管理模式,再结合国内酒店行业的实际情况,在已形成了几个较为成熟的软件系统的同时,产生了几家专职从事酒店业管理系统的公司。到了后期,随着计算机在酒店中的普及应用,计算机技术的不断发展,酒店管理系统的发展到了一个新的时期,新的系统平台、新的系统特点及发展方向不断涌现,功能更加细致完善,系统更加稳定可靠。但是也存在着不少的问题,如需求不明确、没有行业统一的标准等等,使得大型的酒店可以使用的上很多的功能,以至于小型的酒店在系统的使用上得不到满足。因此提供一套完善的中小型酒店管理软件是必不可少的。一套完善的酒店管理软件有利于提高宾馆的综合服务水平,更是帮助酒店管理好内部的秩序,减少工作量。

本文含有隐藏内容,请 开通VIP 后查看