|
|
@@ -29,10 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -62,6 +59,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
@Resource
|
|
|
private IBusLivingCustomerService livingCustomerService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IBusLivingLayoutDayPriceService livingLayoutDayPriceService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String bookingOrderSave(BookingOrderSaveDto item) {
|
|
|
@@ -171,19 +171,26 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
bookingRoomsService.saveBatch(bookingRooms);
|
|
|
|
|
|
// 处理预定每天的房型价格 Start
|
|
|
- if(item.getLayoutDayPrices() == null || item.getLayoutDayPrices().size() == 0)
|
|
|
- throw new JeecgBootException("参数错误,对应房型当天价格必传");
|
|
|
- if(item.getLayoutDayPrices().stream().anyMatch(o->o.getPrice()==null || o.getDayTime() == null || o.getRoomLayoutId() == null))
|
|
|
- throw new JeecgBootException("参数错误,请传入价格、日期、房型");
|
|
|
- item.getLayoutDayPrices().forEach(g->{
|
|
|
- long roomCount = item.getRoomIds().stream().filter(e->e.getLayoutId().equals(g.getRoomLayoutId())).count();
|
|
|
- if(roomCount > 0) {
|
|
|
- g.setBookingOrderId(item.getOrderInfo().getId());
|
|
|
- g.setBookingType(BookingOrdersType.NORMAL.getKey());
|
|
|
- }
|
|
|
- });
|
|
|
- List<String> lList = item.getRoomIds().stream().map(w->w.getLayoutId()).collect(Collectors.toList());
|
|
|
- dayPriceService.saveBatch(item.getLayoutDayPrices().stream().filter(l->lList.contains(l.getRoomLayoutId())).collect(Collectors.toList()));
|
|
|
+ if(item.getLivingRoomDayPrices() != null && item.getLivingRoomDayPrices().size() > 0) {
|
|
|
+ if(item.getLivingRoomDayPrices().stream().anyMatch(o->o.getPrice()==null || o.getDayTime() == null || o.getRoomLayoutId() == null || o.getRoomId() == null))
|
|
|
+ throw new JeecgBootException("参数错误,请传入价格、日期、房型");
|
|
|
+ // 入住之后在save
|
|
|
+ } else {
|
|
|
+ if(item.getLayoutDayPrices() == null || item.getLayoutDayPrices().size() == 0)
|
|
|
+ throw new JeecgBootException("参数错误,对应房型当天价格必传");
|
|
|
+ if(item.getLayoutDayPrices().stream().anyMatch(o->o.getPrice()==null || o.getDayTime() == null || o.getRoomLayoutId() == null))
|
|
|
+ throw new JeecgBootException("参数错误,请传入价格、日期、房型");
|
|
|
+ item.getLayoutDayPrices().forEach(g->{
|
|
|
+ long roomCount = item.getRoomIds().stream().filter(e->e.getLayoutId().equals(g.getRoomLayoutId())).count();
|
|
|
+ if(roomCount > 0) {
|
|
|
+ g.setBookingOrderId(item.getOrderInfo().getId());
|
|
|
+ g.setBookingType(BookingOrdersType.NORMAL.getKey());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<String> lList = item.getRoomIds().stream().map(w->w.getLayoutId()).collect(Collectors.toList());
|
|
|
+ dayPriceService.saveBatch(item.getLayoutDayPrices().stream().filter(l->lList.contains(l.getRoomLayoutId())).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
// 处理预定每天的房型价格 End
|
|
|
|
|
|
return item.getOrderInfo().getBookingOrdersNo();
|
|
|
@@ -766,7 +773,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Boolean bookingToLive(String bookingRoomId, List<BusLivingCustomer> customers) {
|
|
|
+ public String bookingToLive(String bookingRoomId, List<BusLivingCustomer> customers) {
|
|
|
BusBookingRooms bkRoom = bookingRoomsService.getById(bookingRoomId);
|
|
|
if(bkRoom == null) throw new JeecgBootException("关联房间不存在");
|
|
|
BusRoomBookingOrders bookingOrders = getById(bkRoom.getBookingOrdersId());
|
|
|
@@ -825,7 +832,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
//<editor-fold desc="todo:账单相关">
|
|
|
// TODO: 待做
|
|
|
//</editor-fold>
|
|
|
- return true;
|
|
|
+ return livingOrder.getId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -836,7 +843,15 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
BookingOrderEditVo bookingOrderVo = getBookingInfoById(null,bookingOrderNo);
|
|
|
// 散客取roomIds
|
|
|
if(bookingOrderVo.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.NORMAL.getKey())) {
|
|
|
- bookingRoomToLiving(livingData, bookingOrderVo.getRoomIds(), bookingOrderVo);
|
|
|
+ Map<String,String> roomOrderMap = bookingRoomToLiving(livingData, bookingOrderVo.getRoomIds(), bookingOrderVo);
|
|
|
+ livingData.getLivingRoomDayPrices().forEach(g->{
|
|
|
+ String livingOrderId = roomOrderMap.get(g.getRoomId());
|
|
|
+ if(livingOrderId != null && !livingOrderId.isEmpty()) {
|
|
|
+ g.setLivingOrderId(livingOrderId);
|
|
|
+ g.setLivingType(BookingOrdersType.NORMAL.getKey());
|
|
|
+ } else throw new JeecgBootException("房间订单错误");
|
|
|
+ });
|
|
|
+ livingLayoutDayPriceService.saveBatch(livingData.getLivingRoomDayPrices());
|
|
|
} else if(bookingOrderVo.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.TEAM.getKey())) {
|
|
|
bookingOrderVo.getBatchRooms().forEach(b->{
|
|
|
bookingRoomToLiving(livingData, b.getRoomIds(), bookingOrderVo);
|
|
|
@@ -846,14 +861,17 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private void bookingRoomToLiving(BookingOrderSaveDto livingData, List<ExtendBusBookingRoomsVo> roomIds, BookingOrderEditVo bookingOrderVo) {
|
|
|
+ private Map<String,String> bookingRoomToLiving(BookingOrderSaveDto livingData, List<ExtendBusBookingRoomsVo> roomIds, BookingOrderEditVo bookingOrderVo) {
|
|
|
+ Map<String,String> results = new HashMap<>();
|
|
|
roomIds.forEach(bkRoom-> {
|
|
|
if(livingData.getRoomIds().stream().filter(s->s.getRoomId().equals(bkRoom.getRoomId())).count() == 0)
|
|
|
throw new JeecgBootException("房间信息未找到");
|
|
|
List<BusLivingCustomer> customers = livingData.getRoomIds().stream().filter(s->s.getRoomId().equals(bkRoom.getRoomId())).findFirst().get().getLivingCustomers();
|
|
|
if(customers == null || customers.size() == 0) throw new JeecgBootException("请添加客户信息");
|
|
|
- bookingToLive(bkRoom.getId(), customers);
|
|
|
+ String livingOrderId = bookingToLive(bkRoom.getId(), customers);
|
|
|
+ results.put(bkRoom.getRoomId(),livingOrderId);
|
|
|
});
|
|
|
+ return results;
|
|
|
}
|
|
|
|
|
|
|