소스 검색

搞飞机

覃浩 2 년 전
부모
커밋
2253512011

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

@@ -1638,6 +1638,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         return  result;
         return  result;
     }
     }
 
 
+    @SneakyThrows
     @Override
     @Override
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
     public Boolean updateOrderInfo(Integer type, UpdateOrderInfoDto info){
     public Boolean updateOrderInfo(Integer type, UpdateOrderInfoDto info){
@@ -1781,19 +1782,36 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 roomsLivingOrderService.updateById(order);
                 roomsLivingOrderService.updateById(order);
                 return true;
                 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);
                 roomsLivingOrderService.updateById(order);
                 return true;
                 return true;
             }
             }
@@ -1825,6 +1843,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
     public Boolean updateOrderPrice(UpdateOrderPriceDto info) {
     public Boolean updateOrderPrice(UpdateOrderPriceDto info) {
         if(info.getLivingOrderId() == null || info.getLivingOrderId().isEmpty()) throw new JeecgBootException("参数错误");
         if(info.getLivingOrderId() == null || info.getLivingOrderId().isEmpty()) throw new JeecgBootException("参数错误");
         if(info.getDayPrices() == null || info.getDayPrices().size() == 0) 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-> {
         info.getDayPrices().forEach(s-> {
             if(new Date().getTime() < s.getDayTime().getTime()) return;
             if(new Date().getTime() < s.getDayTime().getTime()) return;
             if(s.getId() == null || s.getId().isEmpty()){
             if(s.getId() == null || s.getId().isEmpty()){