Selaa lähdekoodia

预约单 完善
预约单详情获取
预约单编辑

qh 2 vuotta sitten
vanhempi
commit
3538d9fcca

+ 2 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusRoomBookingOrdersController.java

@@ -100,9 +100,8 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	@ApiOperation(value="酒店预定订单-编辑", notes="酒店预定订单-编辑")
 	//@RequiresPermissions("business:bus_room_booking_orders:edit")
 	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
-	public Result<String> edit(@RequestBody BusRoomBookingOrders busRoomBookingOrders) {
-		busRoomBookingOrdersService.updateById(busRoomBookingOrders);
-		return Result.OK("编辑成功!");
+	public Result<Boolean> edit(@RequestBody BookingOrderEditVo busRoomBookingOrders) {
+		return Result.OK(busRoomBookingOrdersService.editBooking(busRoomBookingOrders));
 	}
 
 	 /**

+ 2 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusRoomBookingOrdersService.java

@@ -16,4 +16,6 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
     String bookingOrderSave(BookingOrderSaveDto item);
 
     BookingOrderEditVo getBookingInfoById(String orderId);
+
+    Boolean editBooking(BookingOrderEditVo param);
 }

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

@@ -89,6 +89,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             if(item.getOrderInfo().getHourRoomId() == null || item.getOrderInfo().getHourRoomId().isEmpty())
                 throw new JeecgBootException("钟点房计费项目不能为空");
         }
+
+        if(item.getOrderInfo().getBookingOrdersType() == null)
+            throw new JeecgBootException("参数错误");
         // 散客预定
         if(item.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.NORMAL.getKey())) {
             if(item.getOrderInfo().getArrivalTime() == null || item.getOrderInfo().getDueOutTime() == null)
@@ -231,6 +234,144 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         return result;
     }
 
+    /**
+     * 修改预约单
+     * @param item
+     * @return
+     */
+    @Override
+    public Boolean editBooking(BookingOrderEditVo item) {
+        BusRoomBookingOrders order = getById(item.getOrderInfo().getId());
+        if(order == null) throw new JeecgBootException("预约单不存在");
+
+        if(item.getOrderInfo().getCustomerSource() == null || item.getOrderInfo().getCustomerSource().isEmpty())
+            throw new JeecgBootException("客人来源不能为空");
+        if(item.getOrderInfo().getCustomerType() == null)
+            throw new JeecgBootException("客人类型不能为空");
+        if(CustomerTypeEnum.val(item.getOrderInfo().getCustomerType()) == null)
+            throw new JeecgBootException("客人类型不正确");
+        if(item.getOrderInfo().getCustomerType().equals(CustomerTypeEnum.VIP.getKey())
+                && (item.getOrderInfo().getVipCustomerId() == null || item.getOrderInfo().getVipCustomerId().isEmpty()))
+            throw new JeecgBootException("客人类型为会员时,请选择会员");
+        if(item.getOrderInfo().getCustomerType().equals(CustomerTypeEnum.PROTOCOL.getKey())
+                && (item.getOrderInfo().getContactId() == null || item.getOrderInfo().getContactId().isEmpty()
+                || item.getOrderInfo().getContractTeamProtocolId() == null || item.getOrderInfo().getContractTeamProtocolId().isEmpty()
+        )
+        )
+            throw new JeecgBootException("客人类型为协议单位时,请选择协议单位和相关协议");
+        if(item.getOrderInfo().getCustomerType().equals(CustomerTypeEnum.PROXY.getKey())
+                && (item.getOrderInfo().getAgencyName() == null || item.getOrderInfo().getAgencyName().isEmpty())
+        )
+            throw new JeecgBootException("客人类型为中介时,请填写中介信息");
+        // 钟点房判断,计费项目判定
+        if(item.getOrderInfo().getBookingType().equals(CheckInTypeEnum.HOUR_TIME.getKey())) {
+            if(item.getOrderInfo().getHourRoomId() == null || item.getOrderInfo().getHourRoomId().isEmpty())
+                throw new JeecgBootException("钟点房计费项目不能为空");
+        }
+        // 散客预定
+        if(item.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.NORMAL.getKey())) {
+            if(item.getOrderInfo().getArrivalTime() == null || item.getOrderInfo().getDueOutTime() == null)
+                throw new JeecgBootException("预抵时间和预离时间不能为空");
+            if(item.getOrderInfo().getArrivalTime().getTime() < new Date().getTime())
+                throw new JeecgBootException("预抵时间不能小于当前时间");
+            if(item.getOrderInfo().getArrivalTime().getTime() >= item.getOrderInfo().getDueOutTime().getTime())
+                throw new JeecgBootException("预抵时间不能大于或者等于预离时间");
+            // 非钟点房判定
+            if(!item.getOrderInfo().getBookingType().equals(CheckInTypeEnum.HOUR_TIME.getKey())) {
+                if(item.getOrderInfo().getDayCount() == null || item.getOrderInfo().getDayCount() <= 0)
+                    throw new JeecgBootException("入住天数不能小于0");
+
+            }
+
+            if(item.getRoomIds() == null || item.getRoomIds().size() == 0)
+                throw new JeecgBootException("请选择预定房间");
+            item.getOrderInfo().setCreateTime(order.getCreateTime());
+            item.getOrderInfo().setCreateUser(order.getCreateUser());
+            item.getOrderInfo().setUpdateTime(new Date());
+            LoginUser user = TokenUtils.getAuthUser();
+            item.getOrderInfo().setUpdateUser(user.getId());
+            updateById(item.getOrderInfo());
+            String bookingId = item.getOrderInfo().getId();
+            // todo 判定是否有安排冲突的房间
+            bookingRoomsService.remove(Wrappers.<BusBookingRooms>query().eq("booking_orders_id", item.getOrderInfo().getId()));
+            bookingBatchService.remove(Wrappers.<BusBookingBatch>query().eq("booking_orders_id",item.getOrderInfo().getId()));
+            dayPriceService.remove(Wrappers.<BusBookingLayoutDayPrice>query().eq("booking_order_id",item.getOrderInfo().getId()));
+
+            // 处理预定每天的房型价格 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->{
+                g.setId(null);
+                g.setBookingOrderId(item.getOrderInfo().getId());
+                g.setBookingType(BookingOrdersType.NORMAL.getKey());
+            });
+            dayPriceService.saveBatch(item.getLayoutDayPrices());
+            // 处理预定每天的房型价格 End
+            return true;
+            // 团队预定
+        } else if(item.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.TEAM.getKey())) {
+            if(item.getOrderInfo().getTeamName() == null || item.getOrderInfo().getTeamName().isEmpty())
+                throw new JeecgBootException("请填写团队名称");
+            if(item.getBatchRooms() == null || item.getBatchRooms().size() == 0)
+                throw  new JeecgBootException("请添加批次信息");
+            updateById(item.getOrderInfo());
+            bookingRoomsService.remove(Wrappers.<BusBookingRooms>query().eq("booking_orders_id", item.getOrderInfo().getId()));
+            bookingBatchService.remove(Wrappers.<BusBookingBatch>query().eq("booking_orders_id",item.getOrderInfo().getId()));
+            dayPriceService.remove(Wrappers.<BusBookingLayoutDayPrice>query().eq("booking_order_id",item.getOrderInfo().getId()));
+            item.getBatchRooms().forEach(c->{
+                c.setId(null);
+                if(c.getArrivalTime() == null || c.getDueOutTime() == null)
+                    throw new JeecgBootException("预抵时间和预离时间不能为空");
+                if(c.getArrivalTime().getTime() < new Date().getTime())
+                    throw new JeecgBootException("预抵时间不能小于当前时间");
+                if(c.getArrivalTime().getTime() >= c.getDueOutTime().getTime())
+                    throw new JeecgBootException("预抵时间不能大于或者等于预离时间");
+                // 非钟点房判定
+                if(!item.getOrderInfo().getBookingType().equals(CheckInTypeEnum.HOUR_TIME.getKey())) {
+                    if(c.getDayCount() == null || c.getDayCount() <= 0)
+                        throw new JeecgBootException("入住天数不能小于0");
+                }
+                if(c.getRoomIds() == null || c.getRoomIds().size() == 0)
+                    throw new JeecgBootException("请选择批次房间");
+                SimpleDateFormat sdfPc = new SimpleDateFormat("yyyyMMddHHmmssSSS");
+                c.setBatchNo("YDPC"+sdfPc.format(System.currentTimeMillis()));
+                c.setBookingOrdersId(item.getOrderInfo().getId());
+                BusBookingBatch batchItem = c;
+                bookingBatchService.save(batchItem);
+                List<BusBookingRooms> batchBookingRooms = new ArrayList<>();
+                c.getRoomIds().forEach(s-> {
+                    BusBookingRooms bookingRoomItem = new BusBookingRooms();
+                    bookingRoomItem.setRoomId(s.getRoomId());
+                    bookingRoomItem.setRoomLayoutId(s.getRoomLayoutId());
+                    bookingRoomItem.setBookingType(2);
+                    bookingRoomItem.setBookingBatchId(batchItem.getId());
+                    bookingRoomItem.setBookingOrdersId(item.getOrderInfo().getId());
+                    batchBookingRooms.add(bookingRoomItem);
+                });
+                bookingRoomsService.saveBatch(batchBookingRooms);
+                // 以上处理批次关联的房间
+
+                //批次中处理每天房型价格 Start
+                if(c.getLayoutDayPrices() == null || c.getLayoutDayPrices().size() == 0)
+                    throw new JeecgBootException("参数错误,批次中对应房型当天价格必传");
+                if(c.getLayoutDayPrices().stream().anyMatch(o->o.getPrice()==null || o.getDayTime() == null || o.getRoomLayoutId() == null))
+                    throw new JeecgBootException("参数错误,批次中请传入价格、日期、房型");
+                c.getLayoutDayPrices().forEach(g->{
+                    g.setBookingOrderId(item.getOrderInfo().getId());
+                    g.setBookingType(BookingOrdersType.TEAM.getKey());
+                    g.setBatchId(batchItem.getId());
+                });
+                dayPriceService.saveBatch(c.getLayoutDayPrices());
+                //批次中处理每天房型价格 End
+            });
+            return true;
+        } else { // not exist type
+            throw new JeecgBootException("参数错误");
+        }
+    }
+
     private BusBookingBatch copyBatchToBase(BookingBatchRoomsDto data) {
         BusBookingBatch batch = new BookingBatchRoomsDto();
         batch.setBatchNo(data.getBatchNo());