Explorar o código

Merge branch 'master' of http://49.4.53.36:3000/hotel/hotel-saas-backend

WIN-B904R0U0NNS\Administrator %!s(int64=2) %!d(string=hai) anos
pai
achega
7a026f683d

+ 34 - 11
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusRoomBookingOrdersServiceImpl.java

@@ -419,7 +419,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                     }
                     BusRoomsLivingOrder order = opLvOrder.get();
                     List<BusLivingCustomer> currentLivingCustomers = livingCustomers.stream().filter(s->s.getLivingOrderId().equals(order.getId())).collect(Collectors.toList());
+                    List<BusLivingLayoutDayPrice> lvDayPrices = livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query().eq("living_order_id",order.getId()));
                     r.setLivingOrder(order);
+                    r.setLivingDayPrices(lvDayPrices);
                     r.setLivingCustomers(currentLivingCustomers);
                 }
             });
@@ -1638,6 +1640,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         return  result;
     }
 
+    @SneakyThrows
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean updateOrderInfo(Integer type, UpdateOrderInfoDto info){
@@ -1781,19 +1784,36 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 roomsLivingOrderService.updateById(order);
                 return true;
             }
-            if(info.getLiveType() != null && info.getLiveType().equals(2)){
-                if(info.getFangAnId() != null && !info.getFangAnId().isEmpty()) {
-                    CesHourRoomRule hourRoomRule = hourRoomRuleService.getById(info.getFangAnId());
-                    Integer timeMins = hourRoomRule.getAfterOpenRoom();// 分钟
-                    Date targetTime = DateUtils.formatAddDateMin(order.getArrivalTime(),timeMins);
-                    if(targetTime.getTime() > new Date().getTime()) throw new JeecgBootException("方案时间超时");
-                    order.setLivingType(2);
-                    order.setHourRoomId(info.getFangAnId());
 
-                } else throw new JeecgBootException("请选择时租房规则");
-                if(info.getPrices() != null && info.getPrices().getDayPrices().size() > 0) {
-                    updateOrderPrice(info.getPrices());
+            if(info.getLiveType() != null){
+                if(info.getPrices() == null || info.getPrices().getDayPrices().size() <= 0) {
+                    throw new JeecgBootException("请传入价格");
+                }
+                if(info.getLiveType().equals(2)) {
+                    if(info.getFangAnId() != null && !info.getFangAnId().isEmpty()) {
+                        CesHourRoomRule hourRoomRule = hourRoomRuleService.getById(info.getFangAnId());
+                        Integer timeMins = hourRoomRule.getAfterOpenRoom();// 分钟
+                        Date targetTime = DateUtils.formatAddDateMin(order.getArrivalTime(),timeMins);
+                        if(targetTime.getTime() < new Date().getTime()) throw new JeecgBootException("方案时间超时");
+                        order.setLivingType(2);
+                        order.setHourRoomId(info.getFangAnId());
+                        order.setDueOutTime(targetTime);
+                        updateOrderPrice(info.getPrices());
+                    } else throw new JeecgBootException("请选择时租房规则");
+
+                } else if(info.getLiveType().equals(1)) {
+                    CesAllDayPriceRule rule = allDayPriceRuleService.getOne(Wrappers.<CesAllDayPriceRule>query().eq("hotel_id",order.getHotelId()));
+                    String leaveTime = "13:00";
+                    if(rule == null || rule.getLeaveTime() == null) {
+                        leaveTime = rule.getLeaveTime();
+                    }
+                    String dateStr = DateUtils.formatAddDate(DateUtils.formatDate(new Date())+leaveTime,"yyyy-MM-dd HH:mm:ss",info.getPrices().getDayPrices().size());
+                    order.setDueOutTime(DateUtils.parseDatetime(dateStr));
                 }
+                updateOrderPrice(info.getPrices());
+                long dayCount = livingLayoutDayPriceService.count(Wrappers.<BusLivingLayoutDayPrice>query()
+                        .eq("living_order_id", order.getId()));
+                order.setDayCount((int)dayCount);
                 roomsLivingOrderService.updateById(order);
                 return true;
             }
@@ -1825,6 +1845,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
     public Boolean updateOrderPrice(UpdateOrderPriceDto info) {
         if(info.getLivingOrderId() == null || info.getLivingOrderId().isEmpty()) throw new JeecgBootException("参数错误");
         if(info.getDayPrices() == null || info.getDayPrices().size() == 0) throw new JeecgBootException("参数错误");
+        livingLayoutDayPriceService.remove(Wrappers.<BusLivingLayoutDayPrice>query()
+                .ge("day_time", DateUtils.formatDate(new Date()))
+                .eq("living_order_id",info.getLivingOrderId()));
         info.getDayPrices().forEach(s-> {
             if(new Date().getTime() < s.getDayTime().getTime()) return;
             if(s.getId() == null || s.getId().isEmpty()){

+ 1 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/vo/ExtendBusBookingRoomsVo.java

@@ -11,6 +11,7 @@ public class ExtendBusBookingRoomsVo extends BusBookingRooms {
     private String layoutName;
     private String roomName;
     private List<BusBookingLayoutDayPrice> layoutDayPrices;
+    private List<BusLivingLayoutDayPrice> livingDayPrices;
     private BusRoomsLivingOrder livingOrder;
     private List<BusLivingCustomer> livingCustomers;
 }