소스 검색

提交 批次新增信息

qh 2 년 전
부모
커밋
7c56f05bae

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

@@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.business.dto.BatchOrderSavaDto;
 import org.jeecg.modules.business.dto.BookingOrderSaveDto;
 import org.jeecg.modules.business.entity.BusRoomBookingOrders;
 import org.jeecg.modules.business.service.IBusRoomBookingOrdersService;
@@ -92,7 +93,19 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	public Result<String> add(@RequestBody BookingOrderSaveDto busRoomBookingOrders) {
 		return Result.OK("预定成功",busRoomBookingOrdersService.bookingOrderSave(busRoomBookingOrders));
 	}
-	
+	 /**
+	  *   添加批次订单
+	  *
+	  * @param batchOrderSavaDto
+	  * @return
+	  */
+	 @AutoLog(value = "酒店预定订单-添加批次订单")
+	 @ApiOperation(value="酒店预定订单-添加批次订单", notes="酒店预定订单-添加批次订单")
+	 //@RequiresPermissions("business:bus_room_booking_orders:add")
+	 @PostMapping(value = "/add-batch")
+	 public Result<String> addBatchOrder(@RequestBody BatchOrderSavaDto batchOrderSavaDto) {
+		 return Result.OK("预定成功",busRoomBookingOrdersService.batchOrderSave(batchOrderSavaDto));
+	 }
 	/**
 	 *  编辑
 	 *

+ 5 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/dto/BatchOrderSavaDto.java

@@ -11,9 +11,13 @@ import java.util.List;
 @Data
 public class BatchOrderSavaDto {
     @ApiModelProperty(value = "批次订单信息")
-    private BusBookingBatch batchInfo;
+    private BusBookingBatch orderInfo;
     @ApiModelProperty(value = "散客预定 走这个,关联的房间id")
     private List<BookingLayoutRoomsDto> roomIds;
     @ApiModelProperty(value = "房型每天价格 ,1 散客预定 每天房价传入这个必传")
     private List<BusBookingLayoutDayPrice> layoutDayPrices;
+    // 联系人名称
+    private String contactName;
+    // 联系人电话
+    private String phone;
 }

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

@@ -131,6 +131,8 @@ public class BusBookingBatch implements Serializable {
     private String customerSource;
     private Integer bookingType;
     private String bookingDicWay;
+    private Date createTime;
+    private String createUser;
 
 
 

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.business.service;
 
+import org.jeecg.modules.business.dto.BatchOrderSavaDto;
 import org.jeecg.modules.business.dto.BookingOrderSaveDto;
 import org.jeecg.modules.business.entity.BusRoomBookingOrders;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -25,4 +26,6 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
     Boolean setOrderStatus(BusRoomBookingOrders entity);
 
     BatchOrderEditVo batchOrderDetail(String batchId);
+
+    String batchOrderSave(BatchOrderSavaDto item);
 }

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.TokenUtils;
+import org.jeecg.modules.business.dto.BatchOrderSavaDto;
 import org.jeecg.modules.business.dto.BookingBatchRoomsDto;
 import org.jeecg.modules.business.dto.BookingOrderSaveDto;
 import org.jeecg.modules.business.entity.*;
@@ -558,6 +559,141 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         return result;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public String batchOrderSave(BatchOrderSavaDto item) {
+        LoginUser user = TokenUtils.getAuthUser();
+        if(item == null || item.getOrderInfo() == null || item.getOrderInfo().getBookingOrdersId() == null) throw
+            new JeecgBootException("参数错误");
+        BusRoomBookingOrders orignOrder = getById(item.getOrderInfo().getBookingOrdersId());
+        if(orignOrder == null) throw
+            new JeecgBootException("关联订单信息不存在");
+        item.getOrderInfo().setCreateTime(new Date());
+        item.getOrderInfo().setCreateUser(user.getId());
+
+        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())
+            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("钟点房计费项目不能为空");
+        }
+
+
+        // 【添加客人信息 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())
+                    .eq("phone",item.getPhone()));
+            if(customer == null) {
+                // save customer
+                BusCustomer newCustomer = new BusCustomer();
+                newCustomer.setCreateTime(new Date());
+                newCustomer.setCreateUser(user.getId());
+                newCustomer.setHotelId(user.getRelTenantIds());
+                newCustomer.setTenantId(user.getRelTenantIds());
+                newCustomer.setName(item.getContactName());
+                newCustomer.setPhone(item.getPhone());
+                newCustomer.setCertType(1); // 身份证
+                customerService.save(newCustomer);
+                item.getOrderInfo().setContactId(newCustomer.getId());
+            } else {
+                item.getOrderInfo().setContactId(customer.getId());
+            }
+        } else throw new JeecgBootException("客人信息不能为空");
+
+        // 【添加客人信息 end】
+
+
+        BookingBatchRoomsDto c = new BookingBatchRoomsDto();
+
+        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());
+//        setBatchOrderInfo(item.getOrderInfo(),c);
+//        BusBookingBatch batchItem = copyBatchToBase(c);
+        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(2);
+            } else {
+                bookingRoomItem.setRoomStatus(1);
+            }
+            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);
+        // 以上处理批次关联的房间
+
+        //批次中处理每天房型价格 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->{
+            long roomCount = c.getRoomIds().stream().filter(e->e.getLayoutId().equals(g.getRoomLayoutId())).count();
+            if(roomCount > 0 ) {
+                g.setBookingOrderId(item.getOrderInfo().getId());
+                g.setBookingType(BookingOrdersType.TEAM.getKey());
+                g.setBatchId(batchItem.getId());
+            }
+        });
+        List<String> lList = c.getRoomIds().stream().map(a->a.getLayoutId()).collect(Collectors.toList());
+        dayPriceService.saveBatch(c.getLayoutDayPrices().stream().filter(x->lList.contains(x.getRoomLayoutId())).collect(Collectors.toList()));
+        //批次中处理每天房型价格 End
+
+        return batchItem.getBatchNo();
+    }
+
 
     private BusBookingBatch copyBatchToBase(BookingBatchRoomsDto data) {
         BusBookingBatch batch = new BookingBatchRoomsDto();