订单支付完成

This commit is contained in:
FreeeBird
2018-12-06 19:08:44 +08:00
parent fe8d5e521a
commit 7ebdc00b16
26 changed files with 272 additions and 602 deletions

View File

@@ -20,13 +20,20 @@ public class CheckInController {
this.checkInService = checkInService;
}
@RequestMapping(value = "/add")
public int addCheckIn(int peo_count, String persons, String ids){
/**
* 入住登记
* @param peo_count
* @param persons
* @param ids
* @return
*/
@RequestMapping(value = "/in")
public int addCheckIn(int orderId, int peo_count, String persons, String ids){
CheckIn checkIn = new CheckIn();
checkIn.setOrderId(orderId);
checkIn.setPeoCount(peo_count);
checkIn.setPersons(persons);
checkIn.setIds(ids);
checkIn.setCheckInTime(new Date());
return checkInService.insert(checkIn);
}
@@ -43,7 +50,7 @@ public class CheckInController {
return checkInService.update(checkIn);
}
@RequestMapping(value = "/checkOut")
@RequestMapping(value = "/out")
public int checkOut(String roomNumber){
return checkInService.updateByRoomNumber(roomNumber);
}

View File

@@ -105,8 +105,7 @@ public class OrderController {
*/
@RequestMapping(value = "/cancel")
public int cancelOrder(int orderId){
Order order = new Order(orderId,OrderStatus.WAS_CANCELED.getCode());
return orderService.update(order);
return orderService.cancelOrder(orderId);
}
/**

View File

@@ -52,6 +52,25 @@ public class UserController {
return userService.insertUser(user);
}
/**
* 用户添加
* @param username
* @param password
* @param name
* @param gender
* @param phone
* @param email
* @param address
* @param idcard
* @return
*/
@RequestMapping(method = RequestMethod.POST,value = "/add")
public int userAdd(String username,String password,String name,String gender,String phone,String email,String address,String idcard){
User user = new User(username,password,name,gender,phone,email,address,idcard);
return userService.addUser(user);
}
/**
* 更新用户信息
* @param userId

View File

@@ -12,6 +12,8 @@ public interface CheckInService {
int update(CheckIn checkIn);
int checkOut(String roomNumber);
int updateByRoomNumber(String roomNumber);
CheckIn selectById(int checkInId);

View File

@@ -18,6 +18,8 @@ public interface OrderService {
int payOrder(int orderId);
int cancelOrder(int orderId);
List<Order> selectByUserId(int userId);
List<Order> AllOrders();

View File

@@ -9,6 +9,8 @@ public interface UserService {
User selectById(int userId);
int addUser(User user);
int insertUser(User user);
int deleteUser(int userId);

View File

@@ -1,6 +1,7 @@
package cn.mafangui.hotel.service.impl;
import cn.mafangui.hotel.entity.CheckIn;
import cn.mafangui.hotel.entity.Room;
import cn.mafangui.hotel.mapper.CheckInMapper;
import cn.mafangui.hotel.service.CheckInService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +30,11 @@ public class CheckInServiceImpl implements CheckInService {
return checkInMapper.updateByPrimaryKeySelective(checkIn);
}
@Override
public int checkOut(String roomNumber) {
return 0;
}
@Override
public int updateByRoomNumber(String roomNumber) {
return checkInMapper.updateByRoomNumber(roomNumber);

View File

@@ -71,10 +71,6 @@ public class OrderServiceImpl implements OrderService {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return -2;
}
if (roomService.orderRoom(order.getRoomTypeId()) != 1){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return -1;
}
order.setOrderStatus(OrderStatus.PAID.getCode());
if (orderMapper.updateByPrimaryKeySelective(order) != 1){
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -83,6 +79,24 @@ public class OrderServiceImpl implements OrderService {
return 1;
}
/**
* 取消订单
* 1. 更改订单状态 -3
* 2. 修改房型余量(已付款)-2
* @param orderId
* @return
*/
@Override
public int cancelOrder(int orderId) {
Order order = orderMapper.selectByPrimaryKey(orderId);
if (order == null ) return -3;
order.setOrderStatus(OrderStatus.WAS_CANCELED.getCode());
if (roomTypeService.updateRest(order.getRoomTypeId(),1) != 1){
return -2;
}
return orderMapper.updateByPrimaryKeySelective(order);
}
@Override
public List<Order> selectByUserId(int userId) {
return orderMapper.selectByUserId(userId);

View File

@@ -47,7 +47,7 @@ public class RoomTypeServiceImpl implements RoomTypeService {
@Override
public int updateRest(int typeId, int num) {
RoomType rt =roomTypeMapper.selectByPrimaryKey(typeId);
if (rt.getRest() <= 0) return -1;
if (rt.getRest() <= 0 && num < 0) return -1;
rt.setRest(rt.getRest() + num);
return roomTypeMapper.updateByPrimaryKeySelective(rt);
}

View File

@@ -19,10 +19,15 @@ public class UserServiceImpl implements UserService {
}
@Override
public int insertUser(User user) {
public int addUser(User user) {
return userMapper.insertSelective(user);
}
@Override
public int insertUser(User user) {
return userMapper.insert(user);
}
@Override
public int deleteUser(int userId) {
return userMapper.deleteByPrimaryKey(userId);

File diff suppressed because one or more lines are too long

View File

@@ -2,13 +2,16 @@ server:
port: 8080
servlet:
context-path: "/hotel"
ssl:
key-store: classpath:mafangui.cn.jks
key-store-password: 98cy27738t8
key-store-type: JKS
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
url: jdbc:mysql://127.0.0.1:3306/hotel?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
password: 1997liyiyong
url: jdbc:mysql://localhost:3306/hotel?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
mybatis:
type-aliases-package: classpath*:cn.mafangui.hotel.entity
mapper-locations: classpath*:mybatis/mapper/*.xml

View File

@@ -2,12 +2,16 @@ server:
port: 8080
servlet:
context-path: "/hotel"
# ssl:
# key-store: classpath:mafangui.cn.jks
# key-store-password: 98cy27738t8
# key-store-type: JKS
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
url: jdbc:mysql://127.0.0.1:3306/hotel?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
username: muamua
password: muamua
url: jdbc:mysql://localhost:3306/hotel?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=true
mybatis:
type-aliases-package: classpath*:cn.mafangui.hotel.entity
mapper-locations: classpath*:mybatis/mapper/*.xml

View File

@@ -27,6 +27,11 @@
from order_info
where order_id = #{orderId,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from order_info
</select>
<select id="selectByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />