|
@@ -4,16 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.common.util.TokenUtils;
|
|
import org.jeecg.common.util.TokenUtils;
|
|
|
import org.jeecg.modules.business.dto.BatchOrderSavaDto;
|
|
import org.jeecg.modules.business.dto.BatchOrderSavaDto;
|
|
|
import org.jeecg.modules.business.dto.BookingBatchRoomsDto;
|
|
import org.jeecg.modules.business.dto.BookingBatchRoomsDto;
|
|
|
import org.jeecg.modules.business.dto.BookingOrderSaveDto;
|
|
import org.jeecg.modules.business.dto.BookingOrderSaveDto;
|
|
|
import org.jeecg.modules.business.dto.TodayBookingQueryDto;
|
|
import org.jeecg.modules.business.dto.TodayBookingQueryDto;
|
|
|
import org.jeecg.modules.business.entity.*;
|
|
import org.jeecg.modules.business.entity.*;
|
|
|
-import org.jeecg.modules.business.enums.BookingOrdersType;
|
|
|
|
|
-import org.jeecg.modules.business.enums.BookingStatusTypeEnum;
|
|
|
|
|
-import org.jeecg.modules.business.enums.CheckInTypeEnum;
|
|
|
|
|
-import org.jeecg.modules.business.enums.CustomerTypeEnum;
|
|
|
|
|
|
|
+import org.jeecg.modules.business.enums.*;
|
|
|
import org.jeecg.modules.business.mapper.BusRoomBookingOrdersMapper;
|
|
import org.jeecg.modules.business.mapper.BusRoomBookingOrdersMapper;
|
|
|
import org.jeecg.modules.business.service.*;
|
|
import org.jeecg.modules.business.service.*;
|
|
|
import org.jeecg.modules.business.vo.BatchOrderEditVo;
|
|
import org.jeecg.modules.business.vo.BatchOrderEditVo;
|
|
@@ -33,6 +31,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -74,6 +73,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
@Resource
|
|
@Resource
|
|
|
private CesRoomsServiceImpl roomsService;
|
|
private CesRoomsServiceImpl roomsService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IBusOrderFeeService feeService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String bookingOrderSave(BookingOrderSaveDto item, Boolean isTeam) {
|
|
public String bookingOrderSave(BookingOrderSaveDto item, Boolean isTeam) {
|
|
@@ -987,19 +989,57 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
|
|
private Map<String,String> 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<>();
|
|
Map<String,String> results = new HashMap<>();
|
|
|
|
|
+
|
|
|
roomIds.forEach(bkRoom-> {
|
|
roomIds.forEach(bkRoom-> {
|
|
|
if(livingData.getRoomIds().stream().filter(s->s.getRoomId().equals(bkRoom.getRoomId())).count() == 0)
|
|
if(livingData.getRoomIds().stream().filter(s->s.getRoomId().equals(bkRoom.getRoomId())).count() == 0)
|
|
|
throw new JeecgBootException("房间信息未找到");
|
|
throw new JeecgBootException("房间信息未找到");
|
|
|
|
|
+
|
|
|
List<BusLivingCustomer> customers = livingData.getRoomIds().stream().filter(s->s.getRoomId().equals(bkRoom.getRoomId())).findFirst().get().getLivingCustomers();
|
|
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("请添加客户信息");
|
|
if(customers == null || customers.size() == 0) throw new JeecgBootException("请添加客户信息");
|
|
|
String livingOrderId = bookingToLive(bkRoom.getId(), customers);
|
|
String livingOrderId = bookingToLive(bkRoom.getId(), customers);
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 费用关联到主房
|
|
|
|
|
+ if(livingData.getOrderFees()!=null && livingData.getOrderFees().size() > 0 && bkRoom.getIsMain() !=null && bkRoom.getIsMain()) {
|
|
|
|
|
+ livingData.getOrderFees().forEach(s->{
|
|
|
|
|
+ s.setRoomId(bkRoom.getRoomId());
|
|
|
|
|
+ s.setLivingOrderId(livingOrderId);
|
|
|
|
|
+ s.setCreateTime(new Date());
|
|
|
|
|
+ s.setFeeType(2);// 收款
|
|
|
|
|
+ if(FeeSubjectType.val(s.getSubjectType()) == null) {
|
|
|
|
|
+ throw new JeecgBootException("收款项目不存在,请核对后操作");
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ feeService.saveBatch(livingData.getOrderFees());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 另外每个房间还要在入住时生成每日房费账单
|
|
|
|
|
+ BusOrderFee roomFee = new BusOrderFee();
|
|
|
|
|
+ roomFee.setRoomId(bkRoom.getRoomId());
|
|
|
|
|
+ roomFee.setLivingOrderId(livingOrderId);
|
|
|
|
|
+ roomFee.setFeeType(1); // 消费
|
|
|
|
|
+ BigDecimal dayRoomFee = currentDayFee(bkRoom.getLayoutDayPrices(),null);
|
|
|
|
|
+ if(dayRoomFee == null)
|
|
|
|
|
+ throw new JeecgBootException("未找到当日房价");
|
|
|
|
|
+ roomFee.setMoney(dayRoomFee); // 取当日房费的优惠价 其他时间要查询房价方案、每日房价,房型门市价按照规则去取
|
|
|
|
|
+ roomFee.setCreateTime(new Date());
|
|
|
|
|
+ roomFee.setDayTime(new Date());
|
|
|
|
|
+ feeService.save(roomFee);
|
|
|
results.put(bkRoom.getRoomId(),livingOrderId);
|
|
results.put(bkRoom.getRoomId(),livingOrderId);
|
|
|
});
|
|
});
|
|
|
return results;
|
|
return results;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private BigDecimal currentDayFee(List<BusBookingLayoutDayPrice> dayPrices, BigDecimal defaultPrice){
|
|
|
|
|
+ Optional<BusBookingLayoutDayPrice> opDayPrice = dayPrices.stream().filter(
|
|
|
|
|
+ s-> DateUtils.formatDate(s.getDayTime())
|
|
|
|
|
+ .equals(DateUtils.formatDate(new Date())
|
|
|
|
|
+ )).findFirst();
|
|
|
|
|
+ if(opDayPrice.isPresent()) {
|
|
|
|
|
+ return opDayPrice.get().getPrice();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return defaultPrice;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
private BusRoomsLivingOrder copyBookingToAcceptOrder(BusRoomBookingOrders bkOrder) {
|
|
private BusRoomsLivingOrder copyBookingToAcceptOrder(BusRoomBookingOrders bkOrder) {
|
|
|
BusRoomsLivingOrder livingOrder = new BusRoomsLivingOrder();
|
|
BusRoomsLivingOrder livingOrder = new BusRoomsLivingOrder();
|