覃浩 2 роки тому
батько
коміт
b4d8e178e9

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

@@ -418,6 +418,23 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 		 return  Result.OK(service.riliFangTai(start,end,hotelId));
 	 }
 
+	 /**
+	  * 客历
+	  * @param type 1 入住订单查询->livingStatus | 2 bookingStatus
+	  * @param livingStatus -1 正常入住,1 已结账退房,2 先走未结,3 联房退房
+	  * @param bookingStatus 1 预定中 2 在住 3 已取消
+	  * @return
+	  */
+	 @ApiOperation(value="酒店预定订单-客历", notes="酒店预定订单-客历")
+	 @RequestMapping(value = "/keli-orders",method = RequestMethod.GET)
+	 public Result<IPage<KeLiItemVo>> keli(Page<KeLiItemVo> page, String keyw, Integer livingStatus,String hotelId,Integer type,Integer bookingStatus){
+	 	if(type == null) throw new JeecgBootException("参数错误");
+	 	if( type == 1 && livingStatus  == null ) throw new JeecgBootException("参数错误");
+	 	if(type == 2 && bookingStatus == null) throw new JeecgBootException("参数错误");
+	 	if(type == 1 ) return Result.OK(service.getLivingOrderKL(livingStatus,keyw,hotelId,page));
+	 	if(type == 2) return  Result.OK(service.getBookingOrderKL(bookingStatus,keyw,hotelId,page));
+	 	return  null;
+	 }
 
 
 

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

@@ -213,5 +213,8 @@ public class BusRoomsLivingOrder implements Serializable {
     @Excel(name = "酒店ID", width = 15)
     @ApiModelProperty(value = "酒店Id")
     private String hotelId;
+    @Excel(name = "是否联房退房 1 是,2否", width = 15)
+    @ApiModelProperty(value = "是否联房退房 1 是,2否")
+    private Integer isUnionSettled;
 
 }

+ 4 - 4
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/BusRoomBookingOrdersMapper.java

@@ -9,10 +9,7 @@ import org.jeecg.modules.business.dto.TodayBookingQueryDto;
 import org.jeecg.modules.business.entity.BusBookingRooms;
 import org.jeecg.modules.business.entity.BusRoomBookingOrders;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.jeecg.modules.business.vo.ForwardFangTaiQueryVo;
-import org.jeecg.modules.business.vo.LayoutRoomCountVo;
-import org.jeecg.modules.business.vo.RiLiFangTaiVo;
-import org.jeecg.modules.business.vo.RoomLivingQueryVo;
+import org.jeecg.modules.business.vo.*;
 import org.jeecg.modules.rooms.entity.CesRooms;
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -38,4 +35,7 @@ public interface BusRoomBookingOrdersMapper extends BaseMapper<BusRoomBookingOrd
     List<LayoutRoomCountVo> getLayoutRoomCount(String hotelId);
 
     List<RiLiFangTaiVo> getRiliFangTai(String start, String end,String hotelId);
+
+    IPage<KeLiItemVo> getKeLiLiving(IPage<KeLiItemVo> page, String hotelId,String keyw,Integer status);
+    IPage<KeLiItemVo> getKeBooking(IPage<KeLiItemVo> page, String hotelId,String keyw,Integer status);
 }

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

@@ -199,4 +199,104 @@ cus.id as customer_id,cus.`name` as customer_name,lo.arrival_time,lo.due_out_tim
         ) as t
         order by t.is_living, t.order_id desc
     </select>
+
+    <select id="getKeLiLiving" resultType="org.jeecg.modules.business.vo.KeLiItemVo">
+        select
+        o.id,
+        o.living_order_no as oder_no,
+        cus.`name` as customer_name,
+        cus.phone as customer_phone,
+        o.customer_type,
+        o.living_type as o_type,
+        l.`name` as layout_name,
+        concat(IFNULL(r.prefix,''),r.`name`) as room_name,
+        o.arrival_time,
+        o.due_out_time,
+        1 as is_living,
+        sum(if(fee.fee_type = 2 ,fee.money,0)) as yushou,
+        (
+            sum(if(fee.fee_type = 2 ,fee.money,0))
+            -
+            sum(if(fee.fee_type = 1,fee.money,0))
+        ) as yu_e
+
+        from bus_rooms_living_order o
+        inner join bus_customer cus
+        on o.contact_id = cus.id
+        inner join bus_order_fee fee
+        on fee.living_order_id = o.id
+        inner join bus_booking_rooms br
+        on br.id = o.booking_room_id
+        inner join ces_rooms r
+        on r.id = br.room_id
+        inner join ces_room_layout l
+        on l.id = r.layout_id
+        where o.hotel_id = #{hotelId}
+        <if test="status != 4">
+            and  o.settle_type = #{status}
+        </if>
+        <if test="status == 4">
+            -- 联防退房
+            and  (o.settle_type = 1 or o.settle_type = 2)
+            and is_union_settled = 1
+        </if>
+        <if test="keyw != null and keyw != ''" >
+            and (
+            cus.`name` like '%#{keyw}%' or cus.phone like '%#{keyw}%' or o.living_order_no like '%#{keyw}%'
+            )
+        </if>
+        GROUP BY o.id
+    </select>
+    <select id="getKeBooking" resultType="org.jeecg.modules.business.vo.KeLiItemVo" >
+        select
+        o.id,
+        l.id as layout_id,
+        o.booking_orders_no as order_no,
+        cus.`name` as customer_name,
+        cus.phone as customer_phone,
+        o.customer_type,
+        o.booking_type as o_type,
+        l.`name` as layout_name,
+        concat(IFNULL(r.prefix,''),r.`name`) as room_name,
+        o.arrival_time,
+        o.due_out_time,
+        0 as is_living,
+        0 as yushou,
+        0 as yu_e
+        from bus_room_booking_orders o
+        inner join bus_booking_rooms br
+        on o.id = br.booking_orders_id
+        and br.id
+        <if test="status == 1">
+            not
+        </if>
+         in (
+        select booking_room_id from bus_rooms_living_order
+        )
+        left join ces_rooms r
+        on r.id = br.room_id and r.hotel_id = #{hotelId}
+        left join ces_room_layout l
+        on l.id = r.layout_id
+        inner join bus_customer cus
+        on cus.id = o.contact_id
+        where 1 = 1
+        <if test="status == 1 or status == 2">
+            and o.booking_status = 1
+        </if>
+        <if test="status == 3">
+            and o.booking_status = 2
+        </if>
+        <if test="status==1">
+            -- 预定中
+            and (
+            o.due_out_time >= now()
+            )
+        </if>
+        <if test="keyw != null and keyw != ''" >
+            and (
+            cus.`name` like '%#{keyw}%' or cus.phone like '%#{keyw}%' or o.booking_order_no like '%#{keyw}%'
+            )
+        </if>
+        GROUP BY o.id,r.id
+    </select>
 </mapper>

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

@@ -59,6 +59,8 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
     Boolean leaveNotSettle(String bookingOrderId, String livingOrderId);
 
     IPage<RoomLivingQueryVo> getLivingPageData(Integer status,String keyw, Page<RoomLivingQueryVo> page);
+    IPage<KeLiItemVo> getLivingOrderKL(Integer status,String keyw,String hotelId, Page<KeLiItemVo> page);
+    IPage<KeLiItemVo> getBookingOrderKL(Integer status,String keyw,String hotelId, Page<KeLiItemVo> page);
     Boolean setLivingOrderFee(List<BusOrderFee> fees,String livingOrderId,String hotelId);
     Boolean unionOrder(String roomId,String targetRoomId, String bookingOrderId, String hotelId);
     Boolean mergeOrder(String livingRoomId, List<String> livingOrderId);

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

@@ -198,10 +198,10 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             long mainCount = item.getRoomIds().stream().filter(t->t.getIsMain()!=null&&t.getIsMain()).count();
 
             item.getRoomIds().forEach(c->{
-                CesRooms room = roomsService.getById(c.getRoomId());
-                if(room == null) throw new JeecgBootException("房间不存在");
-                room.setBookingOrderId(bookingId);
-                roomsService.updateById(room);
+//                CesRooms room = roomsService.getById(c.getRoomId());
+//                if(room == null) throw new JeecgBootException("房间不存在");
+//                room.setBookingOrderId(bookingId);
+//                roomsService.updateById(room);
 
                 BusBookingRooms bookingRoomsItem = new BusBookingRooms();
                 bookingRoomsItem.setBookingOrdersId(bookingId);
@@ -1083,7 +1083,10 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             Optional<BusRoomsLivingOrder> opMainRoomOrder = livingOrders.stream().filter(s->s.getBookingRoomId().equals(mainRoom.getId())).findFirst();
             if(!opMainRoomOrder.isPresent()) throw new JeecgBootException("没有找到主房订单");
             BusRoomsLivingOrder mainRoomOrder = opMainRoomOrder.get();
-            livingOrders.forEach(s->s.setSettleType(SettleTypeEnum.SETTLE_LEAVE.getKey()));
+            livingOrders.forEach(s->{
+                s.setSettleType(SettleTypeEnum.SETTLE_LEAVE.getKey());
+                s.setIsUnionSettled(s.getId().equals(mainRoomOrder.getId())?0:1);
+            });
             roomsLivingOrderService.updateBatchById(livingOrders);
             if(livingOrders.size() > 0) {
                List<BusOrderFee> feeItems = getLivingOrderFee(bookingOrderId).stream().filter(
@@ -1244,6 +1247,30 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
     public IPage<RoomLivingQueryVo> getLivingPageData(Integer status,String keyw, Page<RoomLivingQueryVo> page) {
         return baseMapper.getPage(page,status,keyw);
     }
+    @Override
+    public IPage<KeLiItemVo> getLivingOrderKL(Integer status,String keyw,String hotelId, Page<KeLiItemVo> page) {
+        IPage<KeLiItemVo> pRes = baseMapper.getKeLiLiving(page,hotelId,keyw,status);
+        List<String> livingIds = pRes.getRecords().stream().map(s->s.getId()).collect(Collectors.toList());
+        List<BusLivingLayoutDayPrice> prices = livingIds.size() >0? livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
+        .in("living_order_id",livingIds)) : new ArrayList<>();
+        pRes.getRecords().forEach(s->{
+            List<BusLivingLayoutDayPrice> orderDayPrice = prices.stream().filter(a->a.getLivingOrderId().equals(s.getId())).collect(Collectors.toList());
+            s.setLivingDayPrices(orderDayPrice);
+        });
+        return pRes;
+    }
+    @Override
+    public IPage<KeLiItemVo> getBookingOrderKL(Integer status,String keyw,String hotelId, Page<KeLiItemVo> page) {
+        IPage<KeLiItemVo> pRes = baseMapper.getKeBooking(page,hotelId,keyw,status);
+        List<String> livingIds = pRes.getRecords().stream().map(s->s.getId()).collect(Collectors.toList());
+        List<BusBookingLayoutDayPrice> prices = livingIds.size() >0? dayPriceService.list(Wrappers.<BusBookingLayoutDayPrice>query()
+                .in("booking_order_id",livingIds)) : new ArrayList<>();
+        pRes.getRecords().forEach(s->{
+            List<BusBookingLayoutDayPrice> orderDayPrice = prices.stream().filter(a->a.getBookingOrderId().equals(s.getId()) && a.getRoomLayoutId().equals(s.getLayoutId())).collect(Collectors.toList());
+            s.setBookingDayPrices(orderDayPrice);
+        });
+        return pRes;
+    }
 
     @Override
     @Transactional(rollbackFor = Exception.class)

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

@@ -0,0 +1,29 @@
+package org.jeecg.modules.business.vo;
+
+import lombok.Data;
+import org.jeecg.modules.business.entity.BusBookingLayoutDayPrice;
+import org.jeecg.modules.business.entity.BusLivingLayoutDayPrice;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class KeLiItemVo {
+    private String id;
+    private String layoutId;
+    private String orderNo;
+    private String customerName;
+    private String customerPhone;
+    private Integer customerType;
+    private Integer oType;
+    private String layoutName;
+    private String roomName;
+    private Date arrivalTime;
+    private Date dueOutTime;
+    private Integer isLiving;
+    private BigDecimal yushou;
+    private BigDecimal yuE;
+    private List<BusLivingLayoutDayPrice> livingDayPrices;
+    private List<BusBookingLayoutDayPrice> bookingDayPrices;
+}