Forráskód Böngészése

预约订单
设置状态
删除

qh 2 éve
szülő
commit
63e7d4e8bf

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

@@ -135,7 +135,22 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 		busRoomBookingOrdersService.removeById(id);
 		return Result.OK("删除成功!");
 	}
-	
+
+	 /**
+	  *   设置状态
+	  *
+	  * @param order
+	  * @return
+	  */
+	 @AutoLog(value = "酒店预定订单-设置状态")
+	 @ApiOperation(value="酒店预定订单-设置状态", notes="酒店预定订单-设置状态")
+	 //@RequiresPermissions("business:bus_room_booking_orders:delete")
+	 @PostMapping(value = "/set-booking-status")
+	 public Result<String> delete(BusRoomBookingOrders order) {
+		 busRoomBookingOrdersService.setOrderStatus(order);
+		 return Result.OK("设置成功!");
+	 }
+
 	/**
 	 *  批量删除
 	 *

+ 53 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/enums/BookingStatusTypeEnum.java

@@ -0,0 +1,53 @@
+package org.jeecg.modules.business.enums;
+
+import org.jeecg.common.system.vo.DictModel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum BookingStatusTypeEnum {
+    NORMAL(1,"正常"),
+    CANCEL(2,"取消");
+
+    Integer key;
+
+    String title;
+
+    BookingStatusTypeEnum(Integer key, String title){
+        this.key = key;
+        this.title = title;
+    }
+    public Integer getKey() {
+        return key;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    /**
+     * 获取字典数据
+     * @return
+     */
+    public static List<DictModel> getDictList(){
+        List<DictModel> list = new ArrayList<>();
+        DictModel dictModel = null;
+        for(CouponsEventEnum e: CouponsEventEnum.values()){
+            dictModel = new DictModel();
+            dictModel.setValue(e.key.toString());
+            dictModel.setText(e.title);
+            list.add(dictModel);
+        }
+        return list;
+    }
+
+    public static BookingStatusTypeEnum val(Integer key){
+        for(BookingStatusTypeEnum bld: values()){
+            if(bld.key.equals(key)){
+                return bld;
+            }
+        }
+        return null;
+    }
+
+    }

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

@@ -18,4 +18,8 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
     BookingOrderEditVo getBookingInfoById(String orderId, String bookingNo);
 
     Boolean editBooking(BookingOrderEditVo param);
+
+    Boolean removeOrder(String id);
+
+    Boolean setOrderStatus(BusRoomBookingOrders entity);
 }

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

@@ -8,6 +8,7 @@ import org.jeecg.modules.business.dto.BookingBatchRoomsDto;
 import org.jeecg.modules.business.dto.BookingOrderSaveDto;
 import org.jeecg.modules.business.entity.*;
 import org.jeecg.modules.business.enums.BookingOrdersType;
+import org.jeecg.modules.business.enums.BookingStatusTypeEnum;
 import org.jeecg.modules.business.enums.CheckInTypeEnum;
 import org.jeecg.modules.business.enums.CustomerTypeEnum;
 import org.jeecg.modules.business.mapper.BusRoomBookingOrdersMapper;
@@ -167,10 +168,14 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             if(item.getLayoutDayPrices().stream().anyMatch(o->o.getPrice()==null || o.getDayTime() == null || o.getRoomLayoutId() == null))
                 throw new JeecgBootException("参数错误,请传入价格、日期、房型");
             item.getLayoutDayPrices().forEach(g->{
-                g.setBookingOrderId(item.getOrderInfo().getId());
-                g.setBookingType(BookingOrdersType.NORMAL.getKey());
+                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());
+                }
             });
-            dayPriceService.saveBatch(item.getLayoutDayPrices());
+            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();
@@ -233,11 +238,15 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 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());
+                    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());
+                    }
                 });
-                dayPriceService.saveBatch(c.getLayoutDayPrices());
+                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 item.getOrderInfo().getBookingOrdersNo();
@@ -418,7 +427,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 g.setBookingOrderId(item.getOrderInfo().getId());
                 g.setBookingType(BookingOrdersType.NORMAL.getKey());
             });
-            dayPriceService.saveBatch(item.getLayoutDayPrices());
+            List<String> layoutIds = item.getRoomIds().stream().map(v->v.getRoomLayoutId()).collect(Collectors.toList());
+            dayPriceService.saveBatch(item.getLayoutDayPrices().stream().filter(v->layoutIds.contains(v.getRoomLayoutId())).collect(Collectors.toList()));
             // 处理预定每天的房型价格 End
             return true;
             // 团队预定
@@ -484,11 +494,12 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 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());
+                        g.setBookingOrderId(item.getOrderInfo().getId());
+                        g.setBookingType(BookingOrdersType.TEAM.getKey());
+                        g.setBatchId(batchItem.getId());
                 });
-                dayPriceService.saveBatch(c.getLayoutDayPrices());
+                List<String> layoutIds = c.getRoomIds().stream().map(v->v.getRoomLayoutId()).collect(Collectors.toList());
+                dayPriceService.saveBatch(c.getLayoutDayPrices().stream().filter(p->layoutIds.contains(p.getRoomLayoutId())).collect(Collectors.toList()));
                 //批次中处理每天房型价格 End
             });
             return true;
@@ -497,6 +508,31 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         }
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean removeOrder(String id) {
+        BusRoomBookingOrders order = getById(id);
+        if(order == null) throw
+             new JeecgBootException("订单不存在");
+        removeById(id);
+        bookingBatchService.remove(Wrappers.<BusBookingBatch>query().eq("booking_orders_id",order.getId()));
+        bookingRoomsService.remove(Wrappers.<BusBookingRooms>query().eq("booking_orders_id",order.getId()));
+        dayPriceService.remove(Wrappers.<BusBookingLayoutDayPrice>query().eq("booking_order_id",order.getId()));
+        return true;
+    }
+
+    @Override
+    public Boolean setOrderStatus(BusRoomBookingOrders entity) {
+        if(entity.getId() == null || entity.getBookingStatus() == null) throw new JeecgBootException("参数错误");
+        if(BookingStatusTypeEnum.val(entity.getBookingStatus()) == null) throw new JeecgBootException("状态错误");
+        BusRoomBookingOrders updateModel = new BusRoomBookingOrders();
+        updateModel.setId(entity.getId());
+        updateModel.setBookingStatus(entity.getBookingStatus());
+        updateById(updateModel);
+        return true;
+    }
+
+
     private BusBookingBatch copyBatchToBase(BookingBatchRoomsDto data) {
         BusBookingBatch batch = new BookingBatchRoomsDto();
         batch.setBatchNo(data.getBatchNo());