Przeglądaj źródła

fixbug & 优化逻辑

qh 2 lat temu
rodzic
commit
843210c30f

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

@@ -89,7 +89,6 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	//@RequiresPermissions("business:bus_room_booking_orders:add")
 	@PostMapping(value = "/add")
 	public Result<String> add(@RequestBody BookingOrderSaveDto busRoomBookingOrders) {
-
 		return Result.OK("预定成功",busRoomBookingOrdersService.bookingOrderSave(busRoomBookingOrders));
 	}
 	

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

@@ -4,14 +4,13 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
-import javax.validation.constraints.NotNull;
-
 @Data
 @ApiModel(value="预定房间和房型参数", description="预定房间和房型参数")
 public class BookingLayoutRoomsDto {
     @ApiModelProperty(value = "房型ID")
-    @NotNull(message = "房型必传")
     private String layoutId;
     @ApiModelProperty(value = "房间id,传入null/不传,表示未排房")
     private String roomId;
+    @ApiModelProperty(value = "是否主房")
+    private Boolean isMain;
 }

+ 9 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/BusBookingRooms.java

@@ -56,5 +56,14 @@ public class BusBookingRooms implements Serializable {
     @Excel(name = "layoutId房型id", width = 15)
     @ApiModelProperty(value = "layoutId房型id")
     private String roomLayoutId;
+    /**房间状态,1:未排房,2:已排房,3:已入住,4:已退房*/
+    @Excel(name = "房间状态,1:未排房,2:已排房,3:已入住,4:已退房", width = 15)
+    @ApiModelProperty(value = "房间状态,1:未排房,2:已排房,3:已入住,4:已退房")
+    private Integer roomStatus;
+    /**是否主房*/
+    @Excel(name = "是否主房", width = 15)
+    @ApiModelProperty(value = "是否主房")
+    private Boolean isMain;
+
 
 }

+ 14 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/BusBookingRoomsMapper.java

@@ -3,8 +3,10 @@ package org.jeecg.modules.business.mapper;
 import java.util.List;
 
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.jeecg.modules.business.entity.BusBookingRooms;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.business.vo.ExtendBusBookingRoomsVo;
 
 /**
  * @Description: 预定订单关联房间
@@ -13,5 +15,16 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @Version: V1.0
  */
 public interface BusBookingRoomsMapper extends BaseMapper<BusBookingRooms> {
-
+    @Select("SELECT\n" +
+            "\tr.*,\n" +
+            "\tl.`name` AS layoutName, \n" +
+            "\trm.`name` as roomName \n" +
+            "FROM\n" +
+            "\tbus_booking_rooms r \n" +
+            "\tINNER JOIN ces_room_layout l ON r.room_layout_id = l.id \n" +
+            "\tINNER JOIN ces_rooms rm ON r.room_id = rm.id \n" +
+            "WHERE\n" +
+            "\tr.booking_orders_id = #{bookingId} and\n" +
+            "\tr.booking_type=#{sType}")
+    List<ExtendBusBookingRoomsVo> bookingRooms(String bookingId, Integer sType);
 }

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

@@ -1,7 +1,11 @@
 package org.jeecg.modules.business.service;
 
+import org.apache.ibatis.annotations.Select;
 import org.jeecg.modules.business.entity.BusBookingRooms;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.business.vo.ExtendBusBookingRoomsVo;
+
+import java.util.List;
 
 /**
  * @Description: 预定订单关联房间
@@ -11,4 +15,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IBusBookingRoomsService extends IService<BusBookingRooms> {
 
+    List<ExtendBusBookingRoomsVo> bookingRooms(String bookingId, Integer type);
+
 }

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

@@ -3,10 +3,13 @@ package org.jeecg.modules.business.service.impl;
 import org.jeecg.modules.business.entity.BusBookingRooms;
 import org.jeecg.modules.business.mapper.BusBookingRoomsMapper;
 import org.jeecg.modules.business.service.IBusBookingRoomsService;
+import org.jeecg.modules.business.vo.ExtendBusBookingRoomsVo;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import java.util.List;
+
 /**
  * @Description: 预定订单关联房间
  * @Author: jeecg-boot
@@ -16,4 +19,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @Service
 public class BusBookingRoomsServiceImpl extends ServiceImpl<BusBookingRoomsMapper, BusBookingRooms> implements IBusBookingRoomsService {
 
+    @Override
+    public List<ExtendBusBookingRoomsVo> bookingRooms(String bookingId,Integer type) {
+        return baseMapper.bookingRooms(bookingId,type);
+    }
 }

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

@@ -16,6 +16,7 @@ import org.jeecg.modules.business.service.IBusCustomerService;
 import org.jeecg.modules.business.service.IBusRoomBookingOrdersService;
 import org.jeecg.modules.business.vo.BookingBatchRoomsVo;
 import org.jeecg.modules.business.vo.BookingOrderEditVo;
+import org.jeecg.modules.business.vo.ExtendBusBookingRoomsVo;
 import org.jeecg.modules.rooms.service.CesRoomsServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -134,14 +135,30 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             String bookingId = item.getOrderInfo().getId();
             // todo 判定是否有安排冲突的房间
             List<BusBookingRooms> bookingRooms = new ArrayList<>();
+            long mainCount = item.getRoomIds().stream().filter(t->t.getIsMain()!=null&&t.getIsMain()).count();
+
             item.getRoomIds().forEach(c->{
+
                 BusBookingRooms bookingRoomsItem = new BusBookingRooms();
                 bookingRoomsItem.setBookingOrdersId(bookingId);
+                if(c.getRoomId() != null && !c.getRoomId().isEmpty()){
+                    bookingRoomsItem.setRoomStatus(1);
+                } else {
+                    bookingRoomsItem.setRoomStatus(2);
+                }
+                if(mainCount != 1) {
+                    bookingRoomsItem.setIsMain(false);
+                } else {
+                    bookingRoomsItem.setIsMain(c.getIsMain());
+                }
                 bookingRoomsItem.setRoomId(c.getRoomId());
                 bookingRoomsItem.setRoomLayoutId(c.getLayoutId());
                 bookingRoomsItem.setBookingType(1);
                 bookingRooms.add(bookingRoomsItem);
             });
+            if(mainCount != 1) {
+                bookingRooms.get(0).setIsMain(true);
+            }
             bookingRoomsService.saveBatch(bookingRooms);
 
             // 处理预定每天的房型价格 Start
@@ -156,9 +173,6 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             dayPriceService.saveBatch(item.getLayoutDayPrices());
             // 处理预定每天的房型价格 End
 
-
-
-
             return item.getOrderInfo().getBookingOrdersNo();
             // 团队预定
         } else if(item.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.TEAM.getKey())) {
@@ -187,15 +201,29 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 BusBookingBatch batchItem = copyBatchToBase(c);
                 bookingBatchService.save(batchItem);
                 List<BusBookingRooms> batchBookingRooms = new ArrayList<>();
+                long mainCount = c.getRoomIds().stream().filter(t->t.getIsMain()!=null&&t.getIsMain()).count();
                 c.getRoomIds().forEach(s-> {
                     BusBookingRooms bookingRoomItem = new BusBookingRooms();
                     bookingRoomItem.setRoomId(s.getRoomId());
                     bookingRoomItem.setRoomLayoutId(s.getLayoutId());
+                    if(s.getRoomId() != null && !s.getRoomId().isEmpty()){
+                        bookingRoomItem.setRoomStatus(1);
+                    } else {
+                        bookingRoomItem.setRoomStatus(2);
+                    }
+                    if(mainCount != 1) {
+                        bookingRoomItem.setIsMain(false);
+                    } else {
+                        bookingRoomItem.setIsMain(s.getIsMain());
+                    }
                     bookingRoomItem.setBookingType(2);
                     bookingRoomItem.setBookingBatchId(batchItem.getId());
                     bookingRoomItem.setBookingOrdersId(item.getOrderInfo().getId());
                     batchBookingRooms.add(bookingRoomItem);
                 });
+                if(mainCount != 1) {
+                    batchBookingRooms.get(0).setIsMain(true);
+                }
                 bookingRoomsService.saveBatch(batchBookingRooms);
                 // 以上处理批次关联的房间
 
@@ -235,9 +263,13 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         orderId = orderInfo.getId();
         BookingOrderEditVo result = new BookingOrderEditVo();
         if(orderInfo.getBookingOrdersType().equals(BookingOrdersType.NORMAL.getKey())) {
-            List<BusBookingRooms> bookingRooms = bookingRoomsService.list(Wrappers.<BusBookingRooms>query()
-            .eq("booking_orders_id",orderId)
-            .eq("booking_type",BookingOrdersType.NORMAL.getKey()));
+            List<ExtendBusBookingRoomsVo> bookingRooms = bookingRoomsService.bookingRooms(orderId,BookingOrdersType.NORMAL.getKey());
+            List<BusBookingLayoutDayPrice> layoutDayPrices = dayPriceService.list(Wrappers.<BusBookingLayoutDayPrice>query()
+            .eq("booking_order_id",orderId));
+            bookingRooms.forEach(s->{
+                List<BusBookingLayoutDayPrice> findLayoutPrice = layoutDayPrices.stream().filter(a->a.getRoomLayoutId().equals(s.getRoomLayoutId())).collect(Collectors.toList());
+                s.setLayoutDayPrices(findLayoutPrice);
+            });
             result.setRoomIds(bookingRooms);
         } else if(orderInfo.getBookingOrdersType().equals(BookingOrdersType.TEAM.getKey())) {
             List<BusBookingBatch> batches = bookingBatchService.list(Wrappers.<BusBookingBatch>query().eq("booking_orders_id",orderId));
@@ -246,15 +278,18 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 batchesVo.add(copyBaseToBatch(s));
             });
 
-            List<BusBookingRooms> batchRooms = bookingRoomsService.list(Wrappers.<BusBookingRooms>query()
-            .eq("booking_orders_id",orderId).eq("booking_type",BookingOrdersType.TEAM.getKey()));
+            List<ExtendBusBookingRoomsVo> batchRooms = bookingRoomsService.bookingRooms(orderId,BookingOrdersType.TEAM.getKey());
             List<BusBookingLayoutDayPrice> layoutDayPrices = dayPriceService.list(Wrappers.<BusBookingLayoutDayPrice>query()
             .eq("booking_order_id",orderId)
             .eq("booking_type",BookingOrdersType.TEAM.getKey()));
             batchesVo.forEach(s->{
-                List<BusBookingRooms> findRooms = batchRooms.stream().filter(a->a.getBookingBatchId().equals(s.getId())).collect(Collectors.toList());
+                List<ExtendBusBookingRoomsVo> findRooms = batchRooms.stream().filter(a->a.getBookingBatchId().equals(s.getId())).collect(Collectors.toList());
                 List<BusBookingLayoutDayPrice> findDayPrice = layoutDayPrices.stream().filter(a->a.getBatchId().equals(s.getId())).collect(Collectors.toList());
-                s.setLayoutDayPrices(findDayPrice);
+                findRooms.forEach(f->{
+                    List<BusBookingLayoutDayPrice> batchPriceOfLayout = findDayPrice.stream().filter(i->i.getRoomLayoutId().equals(f.getRoomLayoutId())).collect(Collectors.toList());
+                    f.setLayoutDayPrices(batchPriceOfLayout);
+                });
+//                s.setLayoutDayPrices(findDayPrice);
                 s.setRoomIds(findRooms);
             });
             result.setBatchRooms(batchesVo);
@@ -348,7 +383,30 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             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()));
-
+            List<BusBookingRooms> bookingRooms = new ArrayList<>();
+            long mainCount = item.getRoomIds().stream().filter(t->t.getIsMain()!=null&&t.getIsMain()).count();
+            item.getRoomIds().forEach(c->{
+                BusBookingRooms bookingRoomsItem = new BusBookingRooms();
+                bookingRoomsItem.setBookingOrdersId(bookingId);
+                if(c.getRoomId() != null && !c.getRoomId().isEmpty()){
+                    bookingRoomsItem.setRoomStatus(1);
+                } else {
+                    bookingRoomsItem.setRoomStatus(2);
+                }
+                if(mainCount != 1) {
+                    bookingRoomsItem.setIsMain(false);
+                } else {
+                    bookingRoomsItem.setIsMain(c.getIsMain());
+                }
+                bookingRoomsItem.setRoomId(c.getRoomId());
+                bookingRoomsItem.setRoomLayoutId(c.getRoomLayoutId());
+                bookingRoomsItem.setBookingType(1);
+                bookingRooms.add(bookingRoomsItem);
+            });
+            if(mainCount != 1) {
+                bookingRooms.get(0).setIsMain(true);
+            }
+            bookingRoomsService.saveBatch(bookingRooms);
             // 处理预定每天的房型价格 Start
             if(item.getLayoutDayPrices() == null || item.getLayoutDayPrices().size() == 0)
                 throw new JeecgBootException("参数错误,对应房型当天价格必传");
@@ -393,15 +451,29 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 BusBookingBatch batchItem = c;
                 bookingBatchService.save(batchItem);
                 List<BusBookingRooms> batchBookingRooms = new ArrayList<>();
+                long mainCount = c.getRoomIds().stream().filter(t->t.getIsMain()!=null&&t.getIsMain()).count();
                 c.getRoomIds().forEach(s-> {
                     BusBookingRooms bookingRoomItem = new BusBookingRooms();
                     bookingRoomItem.setRoomId(s.getRoomId());
+                    if(s.getRoomId() != null && !s.getRoomId().isEmpty()){
+                        bookingRoomItem.setRoomStatus(1); // 未排房
+                    } else {
+                        bookingRoomItem.setRoomStatus(2); // 已排房
+                    }
+                    if(mainCount != 1) {
+                        bookingRoomItem.setIsMain(false);
+                    } else {
+                        bookingRoomItem.setIsMain(s.getIsMain());
+                    }
                     bookingRoomItem.setRoomLayoutId(s.getRoomLayoutId());
                     bookingRoomItem.setBookingType(2);
                     bookingRoomItem.setBookingBatchId(batchItem.getId());
                     bookingRoomItem.setBookingOrdersId(item.getOrderInfo().getId());
                     batchBookingRooms.add(bookingRoomItem);
                 });
+                if(mainCount != 1) {
+                    batchBookingRooms.get(0).setIsMain(true);
+                }
                 bookingRoomsService.saveBatch(batchBookingRooms);
                 // 以上处理批次关联的房间
 

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

@@ -13,7 +13,7 @@ import java.util.List;
 @Data
 public class BookingBatchRoomsVo  extends BusBookingBatch {
     @TableField(exist = false)
-    private List<BusBookingRooms> roomIds;
+    private List<ExtendBusBookingRoomsVo> roomIds;
     @ApiModelProperty(value = "房型每天价格 ,1 散客预定 每天房价传入这个必传")
     @TableField(exist = false)
     private List<BusBookingLayoutDayPrice> layoutDayPrices;

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

@@ -17,7 +17,7 @@ public class BookingOrderEditVo {
      *散客预定 走这个
      **/
     @ApiModelProperty(value = "散客预定 走这个,关联的房间id")
-    private List<BusBookingRooms> roomIds;
+    private List<ExtendBusBookingRoomsVo> roomIds;
     @ApiModelProperty(value = "房型每天价格 ,1 散客预定 每天房价传入这个必传")
     private List<BusBookingLayoutDayPrice> layoutDayPrices;
     @ApiModelProperty(value = "如果是团队预定,关联房间ID和房型每天价格 走这个参数")

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

@@ -0,0 +1,15 @@
+package org.jeecg.modules.business.vo;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+import org.jeecg.modules.business.entity.BusBookingLayoutDayPrice;
+import org.jeecg.modules.business.entity.BusBookingRooms;
+
+import java.util.List;
+
+@Data
+public class ExtendBusBookingRoomsVo extends BusBookingRooms {
+    private String layoutName;
+    private String roomName;
+    private List<BusBookingLayoutDayPrice> layoutDayPrices;
+}