qh hace 2 años
padre
commit
df11e55b7a

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

@@ -559,9 +559,20 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         return result;
     }
 
+    /**
+     * 修改或新增预定批次
+     * @param item
+     * @return
+     */
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String batchOrderSave(BatchOrderSavaDto item) {
+        boolean isUpdate = item.getOrderInfo().getId() != null && !item.getOrderInfo().getId().isEmpty();
+        BusBookingBatch batchInfo = item.getOrderInfo();
+        if(isUpdate){
+            if(batchInfo.getBatchNo() == null || batchInfo.getBatchNo().isEmpty())
+                throw new JeecgBootException("修改请传入BatchNo");
+        }
         LoginUser user = TokenUtils.getAuthUser();
         if(item == null || item.getOrderInfo() == null || item.getOrderInfo().getBookingOrdersId() == null) throw
             new JeecgBootException("参数错误");
@@ -571,8 +582,10 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         item.getOrderInfo().setCreateTime(new Date());
         item.getOrderInfo().setCreateUser(user.getId());
 
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
-        item.getOrderInfo().setBatchNo("YDPC"+sdf.format(System.currentTimeMillis()));
+        if(!isUpdate){
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
+            item.getOrderInfo().setBatchNo("YDPC"+sdf.format(System.currentTimeMillis()));
+        }
 //        if(item.getOrderInfo().getBookingType() == null)
 
         if(item.getOrderInfo().getCustomerSource() == null || item.getOrderInfo().getCustomerSource().isEmpty())
@@ -600,7 +613,12 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 throw new JeecgBootException("钟点房计费项目不能为空");
         }
 
-
+        // 如果是删除的话  先移除批次订单的关联房间和房型每天房价
+        // 删除这块,后续的所有与预定相关的信息均不能与 预定的关联子表进行主键关联
+        if(isUpdate) {
+            bookingRoomsService.remove(Wrappers.<BusBookingRooms>query().eq("booking_batch_id",batchInfo.getId()));
+            dayPriceService.remove(Wrappers.<BusBookingLayoutDayPrice>query().eq("batch_id",batchInfo.getId()));
+        }
         // 【添加客人信息 Start】
         if(item.getContactName() != null && !item.getContactName().isEmpty() && item.getPhone() != null && !item.getPhone().isEmpty()){
             BusCustomer customer = customerService.getOne(Wrappers.<BusCustomer>query().eq("name",item.getContactName())