mirror of
https://github.com/FreeeBird/hotel.git
synced 2025-05-06 19:49:26 +08:00
入住登记完成
This commit is contained in:
parent
7ebdc00b16
commit
c1591ad821
@ -22,21 +22,33 @@ public class CheckInController {
|
||||
|
||||
/**
|
||||
* 入住登记
|
||||
* @param peo_count
|
||||
* @param peoCount
|
||||
* @param persons
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@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.setOrderId(orderId);
|
||||
checkIn.setPeoCount(peo_count);
|
||||
checkIn.setPeoCount(peoCount);
|
||||
checkIn.setPersons(persons);
|
||||
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")
|
||||
public int deleteCheckIn(int checkId){
|
||||
return checkInService.delete(checkId);
|
||||
@ -50,10 +62,7 @@ public class CheckInController {
|
||||
return checkInService.update(checkIn);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/out")
|
||||
public int checkOut(String roomNumber){
|
||||
return checkInService.updateByRoomNumber(roomNumber);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/withId")
|
||||
public CheckIn getById(int checkId){
|
||||
|
@ -159,4 +159,15 @@ public class OrderController {
|
||||
return orderService.selectById(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据姓名、预留手机号查找订单
|
||||
* 主要用于客户入住
|
||||
* @param name
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/withNameAndPhone")
|
||||
public Order getByNameAndPhone(String name,String phone){
|
||||
return orderService.selectByNameAndPhone(name,phone);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ public class CheckIn {
|
||||
|
||||
private Integer orderId;
|
||||
|
||||
private Integer roomId;
|
||||
|
||||
private String roomNumber;
|
||||
|
||||
private Integer peoCount;
|
||||
@ -55,6 +57,13 @@ public class CheckIn {
|
||||
this.roomNumber = roomNumber == null ? null : roomNumber.trim();
|
||||
}
|
||||
|
||||
public Integer getRoomId() {
|
||||
return roomId;
|
||||
}
|
||||
|
||||
public void setRoomId(Integer roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
public Integer getPeoCount() {
|
||||
return peoCount;
|
||||
@ -107,7 +116,8 @@ public class 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.peoCount = peoCount;
|
||||
this.persons = persons;
|
||||
@ -130,4 +140,4 @@ public class CheckIn {
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ public interface CheckInMapper {
|
||||
|
||||
CheckIn selectByPrimaryKey(Integer checkInId);
|
||||
|
||||
CheckIn selectByRoomNumber(String roomNumber);
|
||||
|
||||
int updateByRoomNumber(String roomNumber);
|
||||
|
||||
int updateByPrimaryKeySelective(CheckIn record);
|
||||
@ -23,4 +25,4 @@ public interface CheckInMapper {
|
||||
|
||||
List<CheckIn> selectAll();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ public interface OrderMapper {
|
||||
|
||||
Order selectByPrimaryKey(Integer orderId);
|
||||
|
||||
Order selectByNameAndPhone(Order record);
|
||||
|
||||
int updateByPrimaryKeySelective(Order record);
|
||||
|
||||
int updateByPrimaryKey(Order record);
|
||||
|
@ -15,6 +15,8 @@ public interface RoomMapper {
|
||||
|
||||
Room selectByPrimaryKey(Integer roomId);
|
||||
|
||||
Room selectByNumber(String roomNumber);
|
||||
|
||||
int updateByPrimaryKeySelective(Room record);
|
||||
|
||||
int updateByPrimaryKey(Room record);
|
||||
|
@ -8,6 +8,8 @@ public interface CheckInService {
|
||||
|
||||
int insert(CheckIn checkIn);
|
||||
|
||||
int checkIn(CheckIn checkIn);
|
||||
|
||||
int delete(int checkInId);
|
||||
|
||||
int update(CheckIn checkIn);
|
||||
|
@ -14,6 +14,8 @@ public interface OrderService {
|
||||
|
||||
Order selectById(Integer orderId);
|
||||
|
||||
Order selectByNameAndPhone(String name,String phone);
|
||||
|
||||
int update(Order record);
|
||||
|
||||
int payOrder(int orderId);
|
||||
|
@ -10,6 +10,7 @@ public interface RoomService {
|
||||
int delete(int roomId);
|
||||
int update(Room room);
|
||||
Room selectById(int roomId);
|
||||
Room selectByNumber(String roomNumber);
|
||||
List<Room> selectByStatus(int roomStatus);
|
||||
List<Room> selectByType(int typeId);
|
||||
List<Room> selectAll();
|
||||
|
@ -1,11 +1,18 @@
|
||||
package cn.mafangui.hotel.service.impl;
|
||||
|
||||
import cn.mafangui.hotel.entity.CheckIn;
|
||||
import cn.mafangui.hotel.entity.Order;
|
||||
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.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.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -13,13 +20,57 @@ import java.util.List;
|
||||
public class CheckInServiceImpl implements CheckInService {
|
||||
@Autowired
|
||||
private CheckInMapper checkInMapper;
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
@Autowired
|
||||
private RoomTypeService roomTypeService;
|
||||
@Autowired
|
||||
private RoomService roomService;
|
||||
|
||||
@Override
|
||||
public int insert(CheckIn 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
|
||||
public int delete(int checkInId) {
|
||||
return checkInMapper.deleteByPrimaryKey(checkInId);
|
||||
@ -30,10 +81,7 @@ public class CheckInServiceImpl implements CheckInService {
|
||||
return checkInMapper.updateByPrimaryKeySelective(checkIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkOut(String roomNumber) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int updateByRoomNumber(String roomNumber) {
|
||||
|
@ -47,6 +47,14 @@ public class OrderServiceImpl implements OrderService {
|
||||
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
|
||||
public int update(Order order) {
|
||||
return orderMapper.updateByPrimaryKeySelective(order);
|
||||
|
@ -35,6 +35,11 @@ public class RoomServiceImpl implements RoomService {
|
||||
return roomMapper.selectByPrimaryKey(roomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Room selectByNumber(String roomNumber) {
|
||||
return roomMapper.selectByNumber(roomNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Room> selectByStatus(int roomStatus) {
|
||||
return roomMapper.selectByStatus(roomStatus);
|
||||
@ -59,12 +64,19 @@ public class RoomServiceImpl implements RoomService {
|
||||
return roomMapper.updateByPrimaryKeySelective(room);
|
||||
}
|
||||
|
||||
/**
|
||||
* 房间入住
|
||||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int inRoom(int typeId) {
|
||||
Room room = roomMapper.randomSelectByTypeAndStatus(typeId,RoomStatus.ORDERED.getCode());
|
||||
if (room == null) return -1;
|
||||
Room room = roomMapper.randomSelectByTypeAndStatus(typeId,RoomStatus.AVAILABLE.getCode());
|
||||
System.out.println(room);
|
||||
room.setRoomStatus(RoomStatus.IN_USE.getCode());
|
||||
return roomMapper.updateByPrimaryKeySelective(room);
|
||||
if (roomMapper.updateByPrimaryKeySelective(room) <= 0)
|
||||
return -1;
|
||||
else return room.getRoomId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
24
src/main/resources/META-INF/MANIFEST.MF
Normal file
24
src/main/resources/META-INF/MANIFEST.MF
Normal 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
|
||||
|
BIN
src/main/resources/mafangui.cn.jks
Normal file
BIN
src/main/resources/mafangui.cn.jks
Normal file
Binary file not shown.
@ -18,11 +18,17 @@
|
||||
create_time, update_time
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from check_in
|
||||
where check_in_id = #{checkInId,jdbcType=INTEGER}
|
||||
</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
|
||||
<include refid="Base_Column_List" />
|
||||
@ -33,13 +39,13 @@
|
||||
where check_in_id = #{checkInId,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<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,
|
||||
ids, check_in_time, create_time,
|
||||
ids, check_in_time, create_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},
|
||||
#{ids,jdbcType=VARCHAR}, #{checkInTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
|
||||
#{ids,jdbcType=VARCHAR}, #{checkInTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
|
||||
#{updateTime,jdbcType=TIMESTAMP})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="cn.mafangui.hotel.entity.CheckIn">
|
||||
@ -145,4 +151,4 @@
|
||||
update_time = now()
|
||||
where check_in_id = #{checkInId,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
@ -32,6 +32,11 @@
|
||||
<include refid="Base_Column_List" />
|
||||
from order_info
|
||||
</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
|
||||
<include refid="Base_Column_List" />
|
||||
|
@ -23,6 +23,12 @@
|
||||
from room_info
|
||||
where room_id = #{roomId,jdbcType=INTEGER}
|
||||
</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
|
||||
<include refid="Base_Column_List" />
|
||||
|
@ -9,18 +9,17 @@
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="gender" jdbcType="CHAR" property="gender" />
|
||||
<result column="phone" jdbcType="VARCHAR" property="phone" />
|
||||
<result column="department" jdbcType="INTEGER" property="department" />
|
||||
<result column="email" jdbcType="VARCHAR" property="email" />
|
||||
<result column="address" jdbcType="VARCHAR" property="address" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
</resultMap>
|
||||
<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
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from worker_info
|
||||
where worker_id = #{workerId,jdbcType=INTEGER}
|
||||
@ -47,14 +46,14 @@
|
||||
where worker_id = #{workerId,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="cn.mafangui.hotel.entity.Worker">
|
||||
insert into worker_info (worker_id, role, username,
|
||||
password, name, gender,
|
||||
phone, department, email,
|
||||
insert into worker_info (worker_id, role, username,
|
||||
password, name, gender,
|
||||
phone,, email,
|
||||
address, create_time, update_time
|
||||
)
|
||||
values (#{workerId,jdbcType=INTEGER}, #{role,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR},
|
||||
#{password,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{gender,jdbcType=CHAR},
|
||||
#{phone,jdbcType=VARCHAR}, #{department,jdbcType=INTEGER}, #{email,jdbcType=VARCHAR},
|
||||
values (#{workerId,jdbcType=INTEGER}, #{role,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR},
|
||||
#{password,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{gender,jdbcType=CHAR},
|
||||
#{phone,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR},
|
||||
#{address,jdbcType=VARCHAR}, now(),now()
|
||||
)
|
||||
</insert>
|
||||
@ -82,9 +81,6 @@
|
||||
<if test="phone != null">
|
||||
phone,
|
||||
</if>
|
||||
<if test="department != null">
|
||||
department,
|
||||
</if>
|
||||
<if test="email != null">
|
||||
email,
|
||||
</if>
|
||||
@ -116,9 +112,6 @@
|
||||
<if test="phone != null">
|
||||
#{phone,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="department != null">
|
||||
#{department,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="email != null">
|
||||
#{email,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -150,9 +143,6 @@
|
||||
<if test="phone != null">
|
||||
phone = #{phone,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="department != null">
|
||||
department = #{department,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="email != null">
|
||||
email = #{email,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -170,10 +160,9 @@
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
gender = #{gender,jdbcType=CHAR},
|
||||
phone = #{phone,jdbcType=VARCHAR},
|
||||
department = #{department,jdbcType=INTEGER},
|
||||
email = #{email,jdbcType=VARCHAR},
|
||||
address = #{address,jdbcType=VARCHAR},
|
||||
where worker_id = #{workerId,jdbcType=INTEGER}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user