瀏覽代碼

入住房间每天价格,在入住时,传入每间房每天的价格数组

qh 2 年之前
父節點
當前提交
7d6912d3f8

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

@@ -255,7 +255,7 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	  */
 	 @ApiOperation(value="酒店预定订单-预约房间入住", notes="酒店预定订单-预约房间入住")
 	 @RequestMapping(value = "booking-to-live",method = RequestMethod.POST)
-	 public  Result<Boolean> bookingRoomToLive(String bookingRoomId, @RequestBody List<BusLivingCustomer> customers) {
+	 public  Result<String> bookingRoomToLive(String bookingRoomId, @RequestBody List<BusLivingCustomer> customers) {
 		 return  Result.OK("入住成功",service.bookingToLive(bookingRoomId, customers));
 	 }
 

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

@@ -3,6 +3,7 @@ package org.jeecg.modules.business.dto;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.jeecg.modules.business.entity.BusBookingLayoutDayPrice;
+import org.jeecg.modules.business.entity.BusLivingLayoutDayPrice;
 import org.jeecg.modules.business.entity.BusRoomBookingOrders;
 
 import java.util.List;
@@ -17,6 +18,8 @@ public class BookingOrderSaveDto  {
     private List<BookingLayoutRoomsDto> roomIds;
     @ApiModelProperty(value = "房型每天价格 ,1 散客预定 每天房价传入这个必传")
     private List<BusBookingLayoutDayPrice> layoutDayPrices;
+    @ApiModelProperty(value = "入住后房间每天价格 ,1 散客预定 每天房价传入这个必传")
+    private List<BusLivingLayoutDayPrice> livingRoomDayPrices;
     @ApiModelProperty(value = "如果是团队预定,关联房间ID和房型每天价格 走这个参数")
     private List<BookingBatchRoomsDto> batchRooms;
     // 联系人名称

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

@@ -0,0 +1,73 @@
+package org.jeecg.modules.business.entity;
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import lombok.Data;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecg.common.aspect.annotation.Dict;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * @Description: bus_living_layout_day_price
+ * @Author: jeecg-boot
+ * @Date:   2023-04-06
+ * @Version: V1.0
+ */
+@Data
+@TableName("bus_living_layout_day_price")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="bus_living_layout_day_price对象", description="bus_living_layout_day_price")
+public class BusLivingLayoutDayPrice implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	/**key*/
+	@TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "key")
+    private String id;
+	/**入住订单id*/
+	@Excel(name = "入住订单id", width = 15)
+    @ApiModelProperty(value = "入住订单id")
+    private String livingOrderId;
+	/**这个房价是那天的*/
+	@Excel(name = "这个房价是那天的", width = 15, format = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @ApiModelProperty(value = "这个房价是那天的")
+    private Date dayTime;
+	/**定义的价格是多少*/
+	@Excel(name = "定义的价格是多少", width = 15)
+    @ApiModelProperty(value = "定义的价格是多少")
+    private BigDecimal price;
+	/**1散客2团队*/
+	@Excel(name = "1散客2团队", width = 15)
+    @ApiModelProperty(value = "1散客2团队")
+    private Integer livingType;
+	/**团队类型下,关联的批次id*/
+	@Excel(name = "团队类型下,关联的批次id", width = 15)
+    @ApiModelProperty(value = "团队类型下,关联的批次id")
+    private String livingBatchId;
+	/**房型id*/
+	@Excel(name = "房型id", width = 15)
+    @ApiModelProperty(value = "房型id")
+    private String roomLayoutId;
+	/**房间id*/
+	@Excel(name = "房间id", width = 15)
+    @ApiModelProperty(value = "房间id")
+    private String roomId;
+	/**关联订单房间id*/
+	@Excel(name = "关联订单房间id", width = 15)
+    @ApiModelProperty(value = "关联订单房间id")
+    private String bookingRoomId;
+}

+ 17 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/BusLivingLayoutDayPriceMapper.java

@@ -0,0 +1,17 @@
+package org.jeecg.modules.business.mapper;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.business.entity.BusLivingLayoutDayPrice;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @Description: bus_living_layout_day_price
+ * @Author: jeecg-boot
+ * @Date:   2023-04-06
+ * @Version: V1.0
+ */
+public interface BusLivingLayoutDayPriceMapper extends BaseMapper<BusLivingLayoutDayPrice> {
+
+}

+ 5 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/BusLivingLayoutDayPriceMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.business.mapper.BusLivingLayoutDayPriceMapper">
+
+</mapper>

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

@@ -0,0 +1,14 @@
+package org.jeecg.modules.business.service;
+
+import org.jeecg.modules.business.entity.BusLivingLayoutDayPrice;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: bus_living_layout_day_price
+ * @Author: jeecg-boot
+ * @Date:   2023-04-06
+ * @Version: V1.0
+ */
+public interface IBusLivingLayoutDayPriceService extends IService<BusLivingLayoutDayPrice> {
+
+}

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

@@ -34,7 +34,7 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
     String batchOrderSave(BatchOrderSavaDto item);
 
     Boolean setBatchOrderStatus(BusBookingBatch batchOrder);
-    Boolean bookingToLive(String bookingRoomId, List<BusLivingCustomer> customers);
+    String bookingToLive(String bookingRoomId, List<BusLivingCustomer> customers);
 
     Boolean customerLiving(BookingOrderSaveDto livingData);
 }

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

@@ -0,0 +1,19 @@
+package org.jeecg.modules.business.service.impl;
+
+import org.jeecg.modules.business.entity.BusLivingLayoutDayPrice;
+import org.jeecg.modules.business.mapper.BusLivingLayoutDayPriceMapper;
+import org.jeecg.modules.business.service.IBusLivingLayoutDayPriceService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @Description: bus_living_layout_day_price
+ * @Author: jeecg-boot
+ * @Date:   2023-04-06
+ * @Version: V1.0
+ */
+@Service
+public class BusLivingLayoutDayPriceServiceImpl extends ServiceImpl<BusLivingLayoutDayPriceMapper, BusLivingLayoutDayPrice> implements IBusLivingLayoutDayPriceService {
+
+}

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

@@ -29,10 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -62,6 +59,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
     @Resource
     private IBusLivingCustomerService livingCustomerService;
 
+    @Resource
+    private IBusLivingLayoutDayPriceService livingLayoutDayPriceService;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String bookingOrderSave(BookingOrderSaveDto item) {
@@ -171,19 +171,26 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             bookingRoomsService.saveBatch(bookingRooms);
 
             // 处理预定每天的房型价格 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->{
-                long roomCount = item.getRoomIds().stream().filter(e->e.getLayoutId().equals(g.getRoomLayoutId())).count();
-                if(roomCount > 0) {
-                    g.setBookingOrderId(item.getOrderInfo().getId());
-                    g.setBookingType(BookingOrdersType.NORMAL.getKey());
-                }
-            });
-            List<String> lList = item.getRoomIds().stream().map(w->w.getLayoutId()).collect(Collectors.toList());
-            dayPriceService.saveBatch(item.getLayoutDayPrices().stream().filter(l->lList.contains(l.getRoomLayoutId())).collect(Collectors.toList()));
+            if(item.getLivingRoomDayPrices() != null && item.getLivingRoomDayPrices().size() > 0) {
+                if(item.getLivingRoomDayPrices().stream().anyMatch(o->o.getPrice()==null || o.getDayTime() == null || o.getRoomLayoutId() == null || o.getRoomId() == null))
+                    throw new JeecgBootException("参数错误,请传入价格、日期、房型");
+                // 入住之后在save
+            } else {
+                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->{
+                    long roomCount = item.getRoomIds().stream().filter(e->e.getLayoutId().equals(g.getRoomLayoutId())).count();
+                    if(roomCount > 0) {
+                        g.setBookingOrderId(item.getOrderInfo().getId());
+                        g.setBookingType(BookingOrdersType.NORMAL.getKey());
+                    }
+                });
+                List<String> lList = item.getRoomIds().stream().map(w->w.getLayoutId()).collect(Collectors.toList());
+                dayPriceService.saveBatch(item.getLayoutDayPrices().stream().filter(l->lList.contains(l.getRoomLayoutId())).collect(Collectors.toList()));
+            }
+
             // 处理预定每天的房型价格 End
 
             return item.getOrderInfo().getBookingOrdersNo();
@@ -766,7 +773,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean bookingToLive(String bookingRoomId, List<BusLivingCustomer> customers) {
+    public String bookingToLive(String bookingRoomId, List<BusLivingCustomer> customers) {
         BusBookingRooms bkRoom = bookingRoomsService.getById(bookingRoomId);
         if(bkRoom == null) throw  new JeecgBootException("关联房间不存在");
         BusRoomBookingOrders bookingOrders = getById(bkRoom.getBookingOrdersId());
@@ -825,7 +832,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         //<editor-fold desc="todo:账单相关">
         // TODO: 待做
         //</editor-fold>
-        return true;
+        return livingOrder.getId();
     }
 
     @Override
@@ -836,7 +843,15 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             BookingOrderEditVo bookingOrderVo =  getBookingInfoById(null,bookingOrderNo);
             // 散客取roomIds
             if(bookingOrderVo.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.NORMAL.getKey())) {
-                bookingRoomToLiving(livingData, bookingOrderVo.getRoomIds(), bookingOrderVo);
+                Map<String,String> roomOrderMap = bookingRoomToLiving(livingData, bookingOrderVo.getRoomIds(), bookingOrderVo);
+                livingData.getLivingRoomDayPrices().forEach(g->{
+                    String livingOrderId = roomOrderMap.get(g.getRoomId());
+                    if(livingOrderId != null && !livingOrderId.isEmpty()) {
+                        g.setLivingOrderId(livingOrderId);
+                        g.setLivingType(BookingOrdersType.NORMAL.getKey());
+                    } else throw new JeecgBootException("房间订单错误");
+                });
+                livingLayoutDayPriceService.saveBatch(livingData.getLivingRoomDayPrices());
             } else if(bookingOrderVo.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.TEAM.getKey())) {
                 bookingOrderVo.getBatchRooms().forEach(b->{
                     bookingRoomToLiving(livingData, b.getRoomIds(), bookingOrderVo);
@@ -846,14 +861,17 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         return true;
     }
 
-    private void bookingRoomToLiving(BookingOrderSaveDto livingData, List<ExtendBusBookingRoomsVo> roomIds, BookingOrderEditVo bookingOrderVo) {
+    private Map<String,String> bookingRoomToLiving(BookingOrderSaveDto livingData, List<ExtendBusBookingRoomsVo> roomIds, BookingOrderEditVo bookingOrderVo) {
+        Map<String,String> results = new HashMap<>();
         roomIds.forEach(bkRoom-> {
             if(livingData.getRoomIds().stream().filter(s->s.getRoomId().equals(bkRoom.getRoomId())).count() == 0)
                 throw new JeecgBootException("房间信息未找到");
             List<BusLivingCustomer> customers = livingData.getRoomIds().stream().filter(s->s.getRoomId().equals(bkRoom.getRoomId())).findFirst().get().getLivingCustomers();
             if(customers == null || customers.size() == 0) throw new JeecgBootException("请添加客户信息");
-            bookingToLive(bkRoom.getId(), customers);
+            String livingOrderId = bookingToLive(bkRoom.getId(), customers);
+            results.put(bkRoom.getRoomId(),livingOrderId);
         });
+        return results;
     }