入住登记完成

This commit is contained in:
FreeeBird 2018-12-09 14:00:13 +08:00
parent 7ebdc00b16
commit c1591ad821
18 changed files with 184 additions and 45 deletions

View File

@ -22,21 +22,33 @@ public class CheckInController {
/** /**
* 入住登记 * 入住登记
* @param peo_count * @param peoCount
* @param persons * @param persons
* @param ids * @param ids
* @return * @return
*/ */
@RequestMapping(value = "/in") @RequestMapping(value = "/in")
public int addCheckIn(int orderId, int peo_count, String persons, String ids){ public int addCheckIn(int orderId, int peoCount, String persons, String ids){
CheckIn checkIn = new CheckIn(); CheckIn checkIn = new CheckIn();
checkIn.setOrderId(orderId); checkIn.setOrderId(orderId);
checkIn.setPeoCount(peo_count); checkIn.setPeoCount(peoCount);
checkIn.setPersons(persons); checkIn.setPersons(persons);
checkIn.setIds(ids); checkIn.setIds(ids);
return checkInService.insert(checkIn); return checkInService.checkIn(checkIn);
} }
/**
* 退房登记
*
* @param roomNumber
* @return
*/
@RequestMapping(value = "/out")
public int checkOut(String roomNumber){
return checkInService.updateByRoomNumber(roomNumber);
}
@RequestMapping(value = "/delete") @RequestMapping(value = "/delete")
public int deleteCheckIn(int checkId){ public int deleteCheckIn(int checkId){
return checkInService.delete(checkId); return checkInService.delete(checkId);
@ -50,10 +62,7 @@ public class CheckInController {
return checkInService.update(checkIn); return checkInService.update(checkIn);
} }
@RequestMapping(value = "/out")
public int checkOut(String roomNumber){
return checkInService.updateByRoomNumber(roomNumber);
}
@RequestMapping(value = "/withId") @RequestMapping(value = "/withId")
public CheckIn getById(int checkId){ public CheckIn getById(int checkId){

View File

@ -159,4 +159,15 @@ public class OrderController {
return orderService.selectById(orderId); return orderService.selectById(orderId);
} }
/**
* 根据姓名预留手机号查找订单
* 主要用于客户入住
* @param name
* @param phone
* @return
*/
@RequestMapping(value = "/withNameAndPhone")
public Order getByNameAndPhone(String name,String phone){
return orderService.selectByNameAndPhone(name,phone);
}
} }

View File

@ -7,6 +7,8 @@ public class CheckIn {
private Integer orderId; private Integer orderId;
private Integer roomId;
private String roomNumber; private String roomNumber;
private Integer peoCount; private Integer peoCount;
@ -55,6 +57,13 @@ public class CheckIn {
this.roomNumber = roomNumber == null ? null : roomNumber.trim(); this.roomNumber = roomNumber == null ? null : roomNumber.trim();
} }
public Integer getRoomId() {
return roomId;
}
public void setRoomId(Integer roomId) {
this.roomId = roomId;
}
public Integer getPeoCount() { public Integer getPeoCount() {
return peoCount; return peoCount;
@ -107,7 +116,8 @@ public class CheckIn {
public CheckIn() { public CheckIn() {
} }
public CheckIn(String roomNumber, String roomType, Integer peoCount, String persons, String ids, Date checkInTime) { public CheckIn(Integer roomId,String roomNumber, Integer peoCount, String persons, String ids, Date checkInTime) {
this.roomId = roomId;
this.roomNumber = roomNumber; this.roomNumber = roomNumber;
this.peoCount = peoCount; this.peoCount = peoCount;
this.persons = persons; this.persons = persons;
@ -130,4 +140,4 @@ public class CheckIn {
", updateTime=" + updateTime + ", updateTime=" + updateTime +
'}'; '}';
} }
} }

View File

@ -15,6 +15,8 @@ public interface CheckInMapper {
CheckIn selectByPrimaryKey(Integer checkInId); CheckIn selectByPrimaryKey(Integer checkInId);
CheckIn selectByRoomNumber(String roomNumber);
int updateByRoomNumber(String roomNumber); int updateByRoomNumber(String roomNumber);
int updateByPrimaryKeySelective(CheckIn record); int updateByPrimaryKeySelective(CheckIn record);
@ -23,4 +25,4 @@ public interface CheckInMapper {
List<CheckIn> selectAll(); List<CheckIn> selectAll();
} }

View File

@ -16,6 +16,8 @@ public interface OrderMapper {
Order selectByPrimaryKey(Integer orderId); Order selectByPrimaryKey(Integer orderId);
Order selectByNameAndPhone(Order record);
int updateByPrimaryKeySelective(Order record); int updateByPrimaryKeySelective(Order record);
int updateByPrimaryKey(Order record); int updateByPrimaryKey(Order record);

View File

@ -15,6 +15,8 @@ public interface RoomMapper {
Room selectByPrimaryKey(Integer roomId); Room selectByPrimaryKey(Integer roomId);
Room selectByNumber(String roomNumber);
int updateByPrimaryKeySelective(Room record); int updateByPrimaryKeySelective(Room record);
int updateByPrimaryKey(Room record); int updateByPrimaryKey(Room record);

View File

@ -8,6 +8,8 @@ public interface CheckInService {
int insert(CheckIn checkIn); int insert(CheckIn checkIn);
int checkIn(CheckIn checkIn);
int delete(int checkInId); int delete(int checkInId);
int update(CheckIn checkIn); int update(CheckIn checkIn);

View File

@ -14,6 +14,8 @@ public interface OrderService {
Order selectById(Integer orderId); Order selectById(Integer orderId);
Order selectByNameAndPhone(String name,String phone);
int update(Order record); int update(Order record);
int payOrder(int orderId); int payOrder(int orderId);

View File

@ -10,6 +10,7 @@ public interface RoomService {
int delete(int roomId); int delete(int roomId);
int update(Room room); int update(Room room);
Room selectById(int roomId); Room selectById(int roomId);
Room selectByNumber(String roomNumber);
List<Room> selectByStatus(int roomStatus); List<Room> selectByStatus(int roomStatus);
List<Room> selectByType(int typeId); List<Room> selectByType(int typeId);
List<Room> selectAll(); List<Room> selectAll();

View File

@ -1,11 +1,18 @@
package cn.mafangui.hotel.service.impl; package cn.mafangui.hotel.service.impl;
import cn.mafangui.hotel.entity.CheckIn; import cn.mafangui.hotel.entity.CheckIn;
import cn.mafangui.hotel.entity.Order;
import cn.mafangui.hotel.entity.Room; import cn.mafangui.hotel.entity.Room;
import cn.mafangui.hotel.entity.RoomType;
import cn.mafangui.hotel.enums.OrderStatus;
import cn.mafangui.hotel.mapper.CheckInMapper; import cn.mafangui.hotel.mapper.CheckInMapper;
import cn.mafangui.hotel.service.CheckInService; import cn.mafangui.hotel.service.CheckInService;
import cn.mafangui.hotel.service.OrderService;
import cn.mafangui.hotel.service.RoomService;
import cn.mafangui.hotel.service.RoomTypeService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
@ -13,13 +20,57 @@ import java.util.List;
public class CheckInServiceImpl implements CheckInService { public class CheckInServiceImpl implements CheckInService {
@Autowired @Autowired
private CheckInMapper checkInMapper; private CheckInMapper checkInMapper;
@Autowired
private OrderService orderService;
@Autowired
private RoomTypeService roomTypeService;
@Autowired
private RoomService roomService;
@Override @Override
public int insert(CheckIn checkIn) { public int insert(CheckIn checkIn) {
return checkInMapper.insert(checkIn); return checkInMapper.insert(checkIn);
} }
/**
* 入住登记
* @param checkIn
* 1.获取订单
* 2.获取房间类型
* 3.获取房间
* @return
*/
@Override
@Transactional
public int checkIn(CheckIn checkIn) {
Order order = orderService.selectById(checkIn.getOrderId());
RoomType rt = roomTypeService.selectById(order.getRoomTypeId());
Room r=roomService.selectById(roomService.inRoom(order.getRoomTypeId()));
if (r == null) return -3;
checkIn.setRoomId(r.getRoomId());
checkIn.setRoomNumber(r.getRoomNumber());
if (roomTypeService.updateRest(rt.getTypeId(),-1) <= 0) return -2;
order.setOrderStatus(OrderStatus.CHECK_IN.getCode());
if (orderService.update(order) <=0 ) return -1;
return checkInMapper.insert(checkIn);
}
/**
* 退房登记
* 1.获取房间
* 2.获取房型
* 3.获取checkIn
* @param roomNumber
* @return
*/
@Override
public int checkOut(String roomNumber) {
Room r = roomService.selectByNumber(roomNumber);
RoomType ty = roomTypeService.selectById(r.getTypeId());
CheckIn checkIn = checkInMapper.selectByPrimaryKey(1);
return 0;
}
@Override @Override
public int delete(int checkInId) { public int delete(int checkInId) {
return checkInMapper.deleteByPrimaryKey(checkInId); return checkInMapper.deleteByPrimaryKey(checkInId);
@ -30,10 +81,7 @@ public class CheckInServiceImpl implements CheckInService {
return checkInMapper.updateByPrimaryKeySelective(checkIn); return checkInMapper.updateByPrimaryKeySelective(checkIn);
} }
@Override
public int checkOut(String roomNumber) {
return 0;
}
@Override @Override
public int updateByRoomNumber(String roomNumber) { public int updateByRoomNumber(String roomNumber) {

View File

@ -47,6 +47,14 @@ public class OrderServiceImpl implements OrderService {
return orderMapper.selectByPrimaryKey(orderId); return orderMapper.selectByPrimaryKey(orderId);
} }
@Override
public Order selectByNameAndPhone(String name, String phone) {
Order order = new Order();
order.setName(name);
order.setPhone(phone);
return orderMapper.selectByNameAndPhone(order);
}
@Override @Override
public int update(Order order) { public int update(Order order) {
return orderMapper.updateByPrimaryKeySelective(order); return orderMapper.updateByPrimaryKeySelective(order);

View File

@ -35,6 +35,11 @@ public class RoomServiceImpl implements RoomService {
return roomMapper.selectByPrimaryKey(roomId); return roomMapper.selectByPrimaryKey(roomId);
} }
@Override
public Room selectByNumber(String roomNumber) {
return roomMapper.selectByNumber(roomNumber);
}
@Override @Override
public List<Room> selectByStatus(int roomStatus) { public List<Room> selectByStatus(int roomStatus) {
return roomMapper.selectByStatus(roomStatus); return roomMapper.selectByStatus(roomStatus);
@ -59,12 +64,19 @@ public class RoomServiceImpl implements RoomService {
return roomMapper.updateByPrimaryKeySelective(room); return roomMapper.updateByPrimaryKeySelective(room);
} }
/**
* 房间入住
* @param typeId
* @return
*/
@Override @Override
public int inRoom(int typeId) { public int inRoom(int typeId) {
Room room = roomMapper.randomSelectByTypeAndStatus(typeId,RoomStatus.ORDERED.getCode()); Room room = roomMapper.randomSelectByTypeAndStatus(typeId,RoomStatus.AVAILABLE.getCode());
if (room == null) return -1; System.out.println(room);
room.setRoomStatus(RoomStatus.IN_USE.getCode()); room.setRoomStatus(RoomStatus.IN_USE.getCode());
return roomMapper.updateByPrimaryKeySelective(room); if (roomMapper.updateByPrimaryKeySelective(room) <= 0)
return -1;
else return room.getRoomId();
} }
@Override @Override

View File

@ -0,0 +1,24 @@
Manifest-Version: 1.0
Class-Path: jackson-datatype-jdk8-2.9.6.jar spring-boot-2.0.5.RELEASE.
jar spring-tx-5.0.9.RELEASE.jar mybatis-spring-boot-starter-1.3.2.jar
logback-core-1.2.3.jar jackson-annotations-2.9.0.jar spring-web-5.0.
9.RELEASE.jar slf4j-api-1.7.25.jar log4j-api-2.10.0.jar jboss-logging
-3.3.2.Final.jar snakeyaml-1.19.jar tomcat-embed-core-8.5.34.jar spri
ng-boot-starter-2.0.5.RELEASE.jar log4j-to-slf4j-2.10.0.jar mysql-con
nector-java-5.1.47.jar spring-boot-starter-web-2.0.5.RELEASE.jar tomc
at-embed-websocket-8.5.34.jar spring-boot-starter-json-2.0.5.RELEASE.
jar jul-to-slf4j-1.7.25.jar logback-classic-1.2.3.jar jackson-module-
parameter-names-2.9.6.jar hibernate-validator-6.0.12.Final.jar jackso
n-datatype-jsr310-2.9.6.jar spring-beans-5.0.9.RELEASE.jar spring-web
mvc-5.0.9.RELEASE.jar tomcat-embed-el-8.5.34.jar spring-expression-5.
0.9.RELEASE.jar spring-jdbc-5.0.9.RELEASE.jar spring-boot-starter-jdb
c-2.0.5.RELEASE.jar spring-context-5.0.9.RELEASE.jar HikariCP-2.7.9.j
ar spring-boot-starter-logging-2.0.5.RELEASE.jar spring-jcl-5.0.9.REL
EASE.jar jackson-core-2.9.6.jar spring-boot-autoconfigure-2.0.5.RELEA
SE.jar spring-boot-starter-tomcat-2.0.5.RELEASE.jar mybatis-spring-bo
ot-autoconfigure-1.3.2.jar jackson-databind-2.9.6.jar javax.annotatio
n-api-1.3.2.jar spring-core-5.0.9.RELEASE.jar validation-api-2.0.1.Fi
nal.jar mybatis-spring-1.3.2.jar mybatis-3.4.6.jar spring-aop-5.0.9.R
ELEASE.jar classmate-1.3.4.jar
Main-Class: cn.mafangui.hotel.HotelApplication

Binary file not shown.

View File

@ -18,11 +18,17 @@
create_time, update_time create_time, update_time
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from check_in from check_in
where check_in_id = #{checkInId,jdbcType=INTEGER} where check_in_id = #{checkInId,jdbcType=INTEGER}
</select> </select>
<select id="selectByRoomNumber" parameterType="String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from check_in
where room_number = #{roomNumber,jdbcType=VARCHAR}
</select>
<select id="selectAll" resultMap="BaseResultMap"> <select id="selectAll" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
@ -33,13 +39,13 @@
where check_in_id = #{checkInId,jdbcType=INTEGER} where check_in_id = #{checkInId,jdbcType=INTEGER}
</delete> </delete>
<insert id="insert" parameterType="cn.mafangui.hotel.entity.CheckIn"> <insert id="insert" parameterType="cn.mafangui.hotel.entity.CheckIn">
insert into check_in (check_in_id, order_id, room_number, insert into check_in (check_in_id, order_id, room_id, room_number,
peo_count, persons, peo_count, persons,
ids, check_in_time, create_time, ids, check_in_time, create_time,
update_time) update_time)
values (#{checkInId,jdbcType=INTEGER}, #{orderId,jdbcType=INTEGER}, #{roomNumber,jdbcType=VARCHAR}, values (#{checkInId,jdbcType=INTEGER}, #{orderId,jdbcType=INTEGER},#{roomId,jdbcType=INTEGER}, #{roomNumber,jdbcType=VARCHAR},
#{peoCount,jdbcType=INTEGER}, #{persons,jdbcType=VARCHAR}, #{peoCount,jdbcType=INTEGER}, #{persons,jdbcType=VARCHAR},
#{ids,jdbcType=VARCHAR}, #{checkInTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, #{ids,jdbcType=VARCHAR}, #{checkInTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}) #{updateTime,jdbcType=TIMESTAMP})
</insert> </insert>
<insert id="insertSelective" parameterType="cn.mafangui.hotel.entity.CheckIn"> <insert id="insertSelective" parameterType="cn.mafangui.hotel.entity.CheckIn">
@ -145,4 +151,4 @@
update_time = now() update_time = now()
where check_in_id = #{checkInId,jdbcType=INTEGER} where check_in_id = #{checkInId,jdbcType=INTEGER}
</update> </update>
</mapper> </mapper>

View File

@ -32,6 +32,11 @@
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from order_info from order_info
</select> </select>
<select id="selectByNameAndPhone" parameterType="String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from order_info where name = #{name,jdbcType=VARCHAR} and phone = #{phone,jdbcType=VARCHAR}
</select>
<select id="selectByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />

View File

@ -23,6 +23,12 @@
from room_info from room_info
where room_id = #{roomId,jdbcType=INTEGER} where room_id = #{roomId,jdbcType=INTEGER}
</select> </select>
<select id="selectByNumber" parameterType="String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from room_info
where room_number = #{roomNumber,jdbcType=VARCHAR}
</select>
<select id="selectByType" parameterType="Integer" resultMap="BaseResultMap"> <select id="selectByType" parameterType="Integer" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />

View File

@ -9,18 +9,17 @@
<result column="name" jdbcType="VARCHAR" property="name" /> <result column="name" jdbcType="VARCHAR" property="name" />
<result column="gender" jdbcType="CHAR" property="gender" /> <result column="gender" jdbcType="CHAR" property="gender" />
<result column="phone" jdbcType="VARCHAR" property="phone" /> <result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="department" jdbcType="INTEGER" property="department" />
<result column="email" jdbcType="VARCHAR" property="email" /> <result column="email" jdbcType="VARCHAR" property="email" />
<result column="address" jdbcType="VARCHAR" property="address" /> <result column="address" jdbcType="VARCHAR" property="address" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
worker_id, role, username, password, name, gender, phone, department, email, address, worker_id, role, username, password, name, gender, phone, email, address,
create_time, update_time create_time, update_time
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from worker_info from worker_info
where worker_id = #{workerId,jdbcType=INTEGER} where worker_id = #{workerId,jdbcType=INTEGER}
@ -47,14 +46,14 @@
where worker_id = #{workerId,jdbcType=INTEGER} where worker_id = #{workerId,jdbcType=INTEGER}
</delete> </delete>
<insert id="insert" parameterType="cn.mafangui.hotel.entity.Worker"> <insert id="insert" parameterType="cn.mafangui.hotel.entity.Worker">
insert into worker_info (worker_id, role, username, insert into worker_info (worker_id, role, username,
password, name, gender, password, name, gender,
phone, department, email, phone,, email,
address, create_time, update_time address, create_time, update_time
) )
values (#{workerId,jdbcType=INTEGER}, #{role,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, values (#{workerId,jdbcType=INTEGER}, #{role,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{gender,jdbcType=CHAR}, #{password,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{gender,jdbcType=CHAR},
#{phone,jdbcType=VARCHAR}, #{department,jdbcType=INTEGER}, #{email,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR},
#{address,jdbcType=VARCHAR}, now(),now() #{address,jdbcType=VARCHAR}, now(),now()
) )
</insert> </insert>
@ -82,9 +81,6 @@
<if test="phone != null"> <if test="phone != null">
phone, phone,
</if> </if>
<if test="department != null">
department,
</if>
<if test="email != null"> <if test="email != null">
email, email,
</if> </if>
@ -116,9 +112,6 @@
<if test="phone != null"> <if test="phone != null">
#{phone,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
</if> </if>
<if test="department != null">
#{department,jdbcType=INTEGER},
</if>
<if test="email != null"> <if test="email != null">
#{email,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR},
</if> </if>
@ -150,9 +143,6 @@
<if test="phone != null"> <if test="phone != null">
phone = #{phone,jdbcType=VARCHAR}, phone = #{phone,jdbcType=VARCHAR},
</if> </if>
<if test="department != null">
department = #{department,jdbcType=INTEGER},
</if>
<if test="email != null"> <if test="email != null">
email = #{email,jdbcType=VARCHAR}, email = #{email,jdbcType=VARCHAR},
</if> </if>
@ -170,10 +160,9 @@
name = #{name,jdbcType=VARCHAR}, name = #{name,jdbcType=VARCHAR},
gender = #{gender,jdbcType=CHAR}, gender = #{gender,jdbcType=CHAR},
phone = #{phone,jdbcType=VARCHAR}, phone = #{phone,jdbcType=VARCHAR},
department = #{department,jdbcType=INTEGER},
email = #{email,jdbcType=VARCHAR}, email = #{email,jdbcType=VARCHAR},
address = #{address,jdbcType=VARCHAR}, address = #{address,jdbcType=VARCHAR},
where worker_id = #{workerId,jdbcType=INTEGER} where worker_id = #{workerId,jdbcType=INTEGER}
</update> </update>
</mapper> </mapper>