Browse Source

添加免费订单数量接口

liu 1 year ago
parent
commit
f171106bb2

+ 5 - 1
src/main/java/com/template/api/HouseOrderAPI.java

@@ -16,7 +16,7 @@ public interface HouseOrderAPI {
 
     @GetMapping("/houseOrderPrice")
     @ApiOperation(value = "订单金额", notes = "订单金额", httpMethod = "GET")
-    CommonResult getHouseOrderPrice(int houseOrderNumber, String userId, String houseId, String liveTime, String leaveTime);
+    CommonResult getHouseOrderPrice(int houseOrderNumber, String userId, String houseId, String liveTime, String leaveTime,Integer source);
 
 
     @PostMapping("/establishOrder")
@@ -144,5 +144,9 @@ public interface HouseOrderAPI {
     @ApiOperation(value = "订单管理-已支付未入住", notes = "订单管理-已支付未入住", httpMethod = "POST")
     CommonResult payNotCheckIn(@RequestBody CancelDto cancelDto);
 
+    @GetMapping("/remainFree")
+    @ApiOperation(value = "免费订单数量", notes = "免费订单数量", httpMethod = "GET")
+    CommonResult remainFree(@RequestParam String userId,@RequestParam String liveTime,@RequestParam String leaveTime);
+
 }
 

+ 2 - 2
src/main/java/com/template/controller/ClassScheduleController.java

@@ -336,8 +336,8 @@ public class ClassScheduleController implements ClassScheduleAPI {
         LocalDate date = LocalDate.now();
         String chineseDayOfWeek = date.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINA);
         String week = "";
-        if (chineseDayOfWeek.equals("星期")) {
-            week = "5";
+        if (chineseDayOfWeek.equals("星期")) {
+            week = "3";
         }
         DateTimeFormatter dateTimeFormatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDate localDate = date.minusDays(Integer.valueOf(week) - 1);

+ 182 - 16
src/main/java/com/template/controller/HouseOrderController.java

@@ -58,9 +58,12 @@ import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.security.Signature;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
+import java.time.format.TextStyle;
+import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -155,8 +158,11 @@ public class HouseOrderController implements HouseOrderAPI {
     @Autowired
     BlacklistSettingService blacklistSettingService;
 
+    @Autowired
+    ApplicationProcedureTemporaryService applicationProcedureTemporaryService;
+
     @Override
-    public CommonResult getHouseOrderPrice(int houseOrderNumber, String userId, String houseId, String liveTime, String leaveTime) {
+    public CommonResult getHouseOrderPrice(int houseOrderNumber, String userId, String houseId, String liveTime, String leaveTime,Integer source) {
         if (ObjectUtils.isEmpty(userId) && ObjectUtils.isEmpty(houseId) && ObjectUtils.isEmpty(leaveTime) && ObjectUtils.isEmpty(leaveTime) && ObjectUtils.isEmpty(houseOrderNumber) && houseOrderNumber <= 0) {
             return CommonResult.fail();
         }
@@ -174,7 +180,7 @@ public class HouseOrderController implements HouseOrderAPI {
 //            establishOrderDto.setReserveLiveTime(reserveLeaveTime);
         }
 //        计算总金额
-        BigDecimal totalPrice = houseOrderService.getHouseOrderPrice(houseOrderNumber, userId, houseId, liveTime, leaveTime);
+        BigDecimal totalPrice = houseOrderService.getHouseOrderPrice(houseOrderNumber, userId, houseId, liveTime, leaveTime,source);
 
         return CommonResult.ok(totalPrice);
 
@@ -187,14 +193,20 @@ public class HouseOrderController implements HouseOrderAPI {
         if (ObjectUtils.isEmpty(establishOrderDto)) {
             return CommonResult.fail();
         }
+        //        判断传过来的时间和当前时间比较
+        DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
 //        需判断当前用户是能定这时间段的房
         String reserveLiveTime = establishOrderDto.getReserveLiveTime();
         String reserveLeaveTime = establishOrderDto.getReserveLeaveTime();
+        Integer source = establishOrderDto.getSource();
+
 
 //        判断课表,临时人员
 
 
+
+
         String userId = establishOrderDto.getUserId();
 
         String houseId = establishOrderDto.getHouseId();
@@ -229,8 +241,7 @@ public class HouseOrderController implements HouseOrderAPI {
 //        String reserveLiveTime = establishOrderDto.getReserveLiveTime();
 //        String reserveLeaveTime = establishOrderDto.getReserveLeaveTime();
 
-        //        判断传过来的时间和当前时间比较
-        DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
         LocalDateTime now = LocalDateTime.now();
         LocalDateTime date = LocalDateTime.parse(reserveLiveTime, dateTimeFormatter1);
         if (now.isAfter(date)) {
@@ -258,7 +269,7 @@ public class HouseOrderController implements HouseOrderAPI {
         HouseOrder houseOrder = new HouseOrder();
 
 //        计算总金额
-        BigDecimal totalPrice = houseOrderService.getHouseOrderPrice(establishOrderDto.getHouseOrderNumber(), userId, houseId, establishOrderDto.getReserveLiveTime(), establishOrderDto.getReserveLeaveTime());
+        BigDecimal totalPrice = houseOrderService.getHouseOrderPrice(establishOrderDto.getHouseOrderNumber(), userId, houseId, establishOrderDto.getReserveLiveTime(), establishOrderDto.getReserveLeaveTime(),source);
 
         BigDecimal payPrice = establishOrderDto.getPayPrice();
 //        返回的结果是int类型,-1表示小于,0是等于,1是大于。
@@ -328,6 +339,8 @@ public class HouseOrderController implements HouseOrderAPI {
         String timeOut = now.plusMinutes(15).format(dateTimeFormatter1);
         houseOrder.setTimeOut(timeOut);
 
+        houseOrder.setSource(source);
+
 //    单价   全日房  价格单价=总价/房间数/天数
 //       钟点房  价格单价=总价/房间数
         Integer roomType = house.getRoomType();
@@ -623,7 +636,7 @@ public class HouseOrderController implements HouseOrderAPI {
     }
 
     @Override
-    public CommonResult pageList(int adminId, int page, int size, String keyWord, String houseType, String orderStatus, String payPriceStartTime, String payPriceEndTime, String refundStartTime, String refundEndTime, String cancelStartTime, String cancelEndTime, String liveStartTime, String liveEndTime, String leaveStartTime, String leaveEndTime,String houseId,Integer keyType,Integer giveBack,Integer buildingId,Integer orgId) {
+    public CommonResult pageList(int adminId, int page, int size, String keyWord, String houseType, String orderStatus, String payPriceStartTime, String payPriceEndTime, String refundStartTime, String refundEndTime, String cancelStartTime, String cancelEndTime, String liveStartTime, String liveEndTime, String leaveStartTime, String leaveEndTime, String houseId, Integer keyType, Integer giveBack, Integer buildingId, Integer orgId) {
 //        PermissionSetting permissionSetting = permissionSettingService.getById(adminId);
 //        if (ObjectUtils.isEmpty(permissionSetting)) {
 //            return CommonResult.fail("非法进入");
@@ -642,7 +655,7 @@ public class HouseOrderController implements HouseOrderAPI {
             size = 10;
         }
 
-        PageUtils<HouseOrderPageListVo> pageList = houseOrderService.pageList(page, size, keyWord, houseType, orderStatus, payPriceStartTime, payPriceEndTime, refundStartTime, refundEndTime, cancelStartTime, cancelEndTime, liveStartTime, liveEndTime, leaveStartTime, leaveEndTime,houseId,keyType,giveBack,buildingId,orgId);
+        PageUtils<HouseOrderPageListVo> pageList = houseOrderService.pageList(page, size, keyWord, houseType, orderStatus, payPriceStartTime, payPriceEndTime, refundStartTime, refundEndTime, cancelStartTime, cancelEndTime, liveStartTime, liveEndTime, leaveStartTime, leaveEndTime, houseId, keyType, giveBack, buildingId, orgId);
         List<HouseOrderPageListVo> list = pageList.getList();
         for (int i = 0; i < list.size(); i++) {
             HouseOrderPageListVo houseOrderPageListVo = list.get(i);
@@ -1484,7 +1497,7 @@ public class HouseOrderController implements HouseOrderAPI {
     }
 
     @Override
-    public void queryExport(HttpServletResponse response, int adminId, String keyWord, String houseType, String orderStatus, String payPriceStartTime, String payPriceEndTime, String refundStartTime, String refundEndTime, String cancelStartTime, String cancelEndTime, String liveStartTime, String liveEndTime, String leaveStartTime, String leaveEndTime,String houseId,Integer keyType,Integer giveBack,Integer buildingId,Integer orgId) {
+    public void queryExport(HttpServletResponse response, int adminId, String keyWord, String houseType, String orderStatus, String payPriceStartTime, String payPriceEndTime, String refundStartTime, String refundEndTime, String cancelStartTime, String cancelEndTime, String liveStartTime, String liveEndTime, String leaveStartTime, String leaveEndTime, String houseId, Integer keyType, Integer giveBack, Integer buildingId, Integer orgId) {
 //        PermissionSetting permissionSetting = permissionSettingService.getById(adminId);
 //        if (ObjectUtils.isEmpty(permissionSetting)) {
 //            return CommonResult.fail("非法进入");
@@ -1495,7 +1508,7 @@ public class HouseOrderController implements HouseOrderAPI {
 //            return CommonResult.fail("此账号暂无该权限");
 //        }
 
-        List<QueryExportVo> vos = houseOrderService.queryExport(keyWord, houseType, orderStatus, payPriceStartTime, payPriceEndTime, refundStartTime, refundEndTime, cancelStartTime, cancelEndTime, liveStartTime, liveEndTime, leaveStartTime, leaveEndTime,houseId,keyType,giveBack,buildingId,orgId);
+        List<QueryExportVo> vos = houseOrderService.queryExport(keyWord, houseType, orderStatus, payPriceStartTime, payPriceEndTime, refundStartTime, refundEndTime, cancelStartTime, cancelEndTime, liveStartTime, liveEndTime, leaveStartTime, leaveEndTime, houseId, keyType, giveBack, buildingId, orgId);
 
         //        导出
         Workbook workbook = new XSSFWorkbook();
@@ -3323,6 +3336,159 @@ public class HouseOrderController implements HouseOrderAPI {
         }
     }
 
+    @Override
+    public CommonResult remainFree(String userId, String liveTime, String leaveTime) {
+
+        Users users = usersService.getById(userId);
+        if (ObjectUtils.isEmpty(users)) {
+            return CommonResult.fail("参数异常");
+        }
+        DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalDateTime stateTime = LocalDateTime.parse(liveTime, dateTimeFormatter1);
+        LocalDateTime endTime = LocalDateTime.parse(leaveTime, dateTimeFormatter1);
+        long day = stateTime.until(endTime, ChronoUnit.DAYS);
+
+        if (day>2) {
+            return CommonResult.fail("超过限制的时间段");
+        }
+
+
+        ArrayList<RemainFreeVo> vos = new ArrayList<>();
+        RemainFreeVo vo = new RemainFreeVo();
+        vo.setName("课表值班预定");
+        vo.setSource(1);
+        RemainFreeVo vo1 = new RemainFreeVo();
+        vo1.setName("流程预定");
+        vo1.setSource(2);
+
+        //        先判断是否在黑名单中
+        LambdaQueryWrapper<Blacklist> wrapperB=new LambdaQueryWrapper<>();
+        wrapperB.eq(Blacklist::getReserveUserId,userId);
+        Blacklist one = blacklistService.getOne(wrapperB);
+        if (ObjectUtils.isNotEmpty(one)) {
+            vo.setCount(0);
+            vos.add(vo);
+            vo1.setCount(0);
+            vos.add(vo1);
+            return CommonResult.fail("您本月预订成功后未入住次数已达到上限,已被加入黑名单,无法免费入住。");
+        }
+
+
+//        获取课表
+
+
+        LocalDate state = stateTime.toLocalDate();
+        LocalDate end = endTime.toLocalDate();
+
+
+
+        //        获取预定时间的开始星期和结束星期
+        String chineseDayOfWeek = state.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINA);
+        Integer week = 0;
+        if ("星期一".equals(chineseDayOfWeek)) {
+            week = 1;
+        } else if ("星期二".equals(chineseDayOfWeek)) {
+            week = 2;
+        } else if ("星期三".equals(chineseDayOfWeek)) {
+            week = 3;
+        } else if ("星期四".equals(chineseDayOfWeek)) {
+            week = 4;
+        } else if ("星期五".equals(chineseDayOfWeek)) {
+            week = 5;
+        } else if ("星期六".equals(chineseDayOfWeek)) {
+            week = 6;
+        } else {
+            week = 7;
+        }
+        DateTimeFormatter dateTimeFormatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDate localDate = state.minusDays(week - 1);
+        String stateTimeXq = localDate.format(dateTimeFormatter2);
+        LocalDate localEnd = localDate.plusDays(6);
+        String endTimeXq = localEnd.format(dateTimeFormatter2);
+//        查询该星期是否满足有2天的订单
+        LambdaQueryWrapper<HouseOrder> wrapperHO = new LambdaQueryWrapper<>();
+        wrapperHO.between(HouseOrder::getReserveLiveTime, stateTimeXq, endTimeXq)
+                .eq(HouseOrder::getReserveUserId, userId)
+                .eq(HouseOrder::getSource, 1)
+                .eq(HouseOrder::getPayPrice, 0)
+                .in(HouseOrder::getOrderStatus, "1,2,3,4,8");
+        List<HouseOrder> orderList = houseOrderService.list(wrapperHO);
+
+        long dayDiff = 0;
+
+        for (HouseOrder houseOrder : orderList) {
+            String reserveLiveTime = houseOrder.getReserveLiveTime();
+            String reserveLeaveTime = houseOrder.getReserveLeaveTime();
+            LocalDateTime stateTime2 = LocalDateTime.parse(reserveLiveTime, dateTimeFormatter1);
+            LocalDateTime endTime2 = LocalDateTime.parse(reserveLeaveTime, dateTimeFormatter1);
+            //   计算2个时间差
+            long until = stateTime2.until(endTime2, ChronoUnit.DAYS);
+            dayDiff = dayDiff + until;
+        }
+
+        //   计算2个时间差
+        long until = state.until(end, ChronoUnit.DAYS);
+
+        Integer count = 1;
+        if (dayDiff + until >= 2) {
+            count=0;
+        } else {
+            for (int i = 0; i < until; i++) {
+                LocalDateTime dateTime1 = stateTime.plusDays(i);
+                LocalDateTime startS = dateTime1.withHour(0).withMinute(0).withSecond(0);
+                LocalDateTime endS = dateTime1.withHour(23).withMinute(59).withSecond(59);
+                LambdaQueryWrapper<ClassSchedule> wrapperCS = new LambdaQueryWrapper<>();
+                wrapperCS.eq(ClassSchedule::getJsgh, users.getCardNumber())
+                        .between(ClassSchedule::getDateTime, startS, endS);
+                List<ClassSchedule> scheduleList = classScheduleService.list(wrapperCS);
+
+//            只要有一天是空的就不是免费
+                if (ObjectUtils.isEmpty(scheduleList)) {
+                    count = 0;
+                    break;
+                } else {
+                    //        有课表就查询是否已经有该订单了
+                    List<HouseOrder> list = houseOrderService.getDate(dateTime1, userId, 1);
+                    if (ObjectUtils.isNotEmpty(list)) {
+                        count = 0;
+                        break;
+                    }
+                }
+
+            }
+        }
+        vo.setCount(count);
+
+        vos.add(vo);
+
+//        获取流程
+        List<ApplicationProcedureTemporary> aptList=applicationProcedureTemporaryService.getApt(state,end,userId);
+        if (ObjectUtils.isEmpty(aptList)) {
+            vo1.setCount(0);
+        }else {
+            ApplicationProcedureTemporary applicationProcedureTemporary = aptList.get(0);
+            String houseCount = applicationProcedureTemporary.getHouseCount();
+            String startTime = applicationProcedureTemporary.getStartTime();
+            String endTime1 = applicationProcedureTemporary.getEndTime();
+//            计算开始到结束时间有多少订单
+            LambdaQueryWrapper<HouseOrder> wrapper=new LambdaQueryWrapper<>();
+            wrapper.eq(HouseOrder::getReserveUserId,userId)
+                            .eq(HouseOrder::getSource,2)
+                    .between(HouseOrder::getReserveLiveTime,startTime,endTime1)
+                    .eq(HouseOrder::getPayPrice, 0)
+                    .in(HouseOrder::getOrderStatus, "1,2,3,4,8");
+            List<HouseOrder> list = houseOrderService.list(wrapper);
+            Integer count2 = Integer.valueOf(houseCount);
+            count2=count2-list.size();
+            vo1.setCount(count2);
+
+        }
+        vos.add(vo1);
+
+        return CommonResult.ok(vos);
+    }
+
 
     public static void main(String[] args) throws Exception {
 //        获取签名
@@ -3609,18 +3775,18 @@ public class HouseOrderController implements HouseOrderAPI {
     @Scheduled(cron = "0 0 13 * * ? ")
 //    @Scheduled(cron = "0 0/1 * * * ?")
     @Transactional(rollbackFor = Exception.class)
-    public void getBlacklist(){
+    public void getBlacklist() {
 //        获取预离时间是当天的待入住,已支付订单
         LocalDateTime startTime = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
         LocalDateTime endTime = startTime.withHour(23).withMinute(59).withSecond(59);
 
-        LambdaQueryWrapper<HouseOrder> wrapper=new LambdaQueryWrapper<>();
-        wrapper.in(HouseOrder::getOrderStatus,2,3)
-                .between(HouseOrder::getReserveLeaveTime,startTime,endTime)
-                .eq(HouseOrder::getPayPrice,0);
+        LambdaQueryWrapper<HouseOrder> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(HouseOrder::getOrderStatus, 2, 3)
+                .between(HouseOrder::getReserveLeaveTime, startTime, endTime)
+                .eq(HouseOrder::getPayPrice, 0);
         List<HouseOrder> list = houseOrderService.list(wrapper);
 
-        if (list.size()>.0) {
+        if (list.size() > .0) {
             ArrayList<BlacklistOrder> blacklistOrders = new ArrayList<>();
 
             for (HouseOrder houseOrder : list) {
@@ -3679,7 +3845,7 @@ public class HouseOrderController implements HouseOrderAPI {
                         blacklistService.saveOrUpdateBatch(blacklists);
                     }
                 }
-            }catch (Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
             }
 

+ 1 - 1
src/main/java/com/template/controller/UnlockingAdminController.java

@@ -105,7 +105,7 @@ public class UnlockingAdminController implements UnlockingAdminControllerAPI {
 
             unlockingAdmin = passwordIssController.savePassWord(keyPassWordDto);
             if (ObjectUtils.isEmpty(unlockingAdmin)) {
-                return CommonResult.fail("该密码已存在,请更换");
+                return CommonResult.fail("参数异常");
             }
 
             unlockingAdmin.setName(byId.getName());

+ 3 - 0
src/main/java/com/template/mapper/ApplicationProcedureTemporaryMapper.java

@@ -9,6 +9,7 @@ import com.template.model.vo.ApplicationProcedureTemporaryVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.List;
 
@@ -37,4 +38,6 @@ public interface ApplicationProcedureTemporaryMapper extends BaseMapper<Applicat
     IPage<ApplicationProcedureTemporaryVo> pageAppletList(Page<ApplicationProcedureTemporaryVo> pageVo,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("status") String status);
 
     IPage<ApplicationProcedureTemporaryVo> parentAppletPageList(Page<ApplicationProcedureTemporaryVo> pageVo, @Param("startTime") String startTime,@Param("endTime") String endTime,@Param("status") String status);
+
+    List<ApplicationProcedureTemporary> getApt(@Param("state") LocalDate state,@Param("end") LocalDate end,@Param("userId") String userId);
 }

+ 1 - 1
src/main/java/com/template/mapper/ClassScheduleMapper.java

@@ -8,7 +8,6 @@ import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Component;
 
 import java.time.LocalDate;
-import java.util.List;
 
 /**
  * <p>
@@ -26,4 +25,5 @@ public interface ClassScheduleMapper extends BaseMapper<ClassSchedule> {
 
     @Delete("delete from class_schedule where  remark =#{remark} ")
     int removeByRemark(String remark);
+
 }

+ 1 - 1
src/main/java/com/template/mapper/HouseOrderMapper.java

@@ -42,5 +42,5 @@ public interface HouseOrderMapper extends BaseMapper<HouseOrder> {
 
     List<String> payHouseOrderUser(@Param("start") LocalDateTime start,@Param("end") LocalDateTime end);
 
-    List<HouseOrder> getDate(@Param("dateTime") LocalDateTime dateTime, @Param("userId") String userId);
+    List<HouseOrder> getDate(@Param("dateTime") LocalDateTime dateTime, @Param("userId") String userId,@Param("source") Integer source);
 }

+ 2 - 3
src/main/java/com/template/model/dto/EstablishOrderDto.java

@@ -1,11 +1,8 @@
 package com.template.model.dto;
 
-import com.template.model.pojo.HouseOrder;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.math.BigDecimal;
-import java.util.Date;
 
 @Data
 public class EstablishOrderDto {
@@ -27,5 +24,7 @@ public class EstablishOrderDto {
     private String reservePhone;
 //    预定人姓名
     private String reserveName;
+//   免费订单来源
+    private Integer source;
 
 }

+ 3 - 0
src/main/java/com/template/model/pojo/HouseOrder.java

@@ -130,6 +130,9 @@ public class HouseOrder implements Serializable {
     @ApiModelProperty(value = "备注")
     private String remark;
 
+    @ApiModelProperty(value = "免费订单来源,1.课表,2.流程管理")
+    private Integer source;
+
     @ApiModelProperty(value = "创建时间")
     @TableField(fill = FieldFill.INSERT)
     private String createTime;

+ 10 - 0
src/main/java/com/template/model/vo/RemainFreeVo.java

@@ -0,0 +1,10 @@
+package com.template.model.vo;
+
+import lombok.Data;
+
+@Data
+public class RemainFreeVo {
+    private String name;
+    private Integer count;
+    private Integer source;
+}

+ 3 - 0
src/main/java/com/template/services/ApplicationProcedureTemporaryService.java

@@ -6,6 +6,7 @@ import com.template.model.result.PageUtils;
 import com.template.model.vo.ApplicationProcedureTemporaryRecordVo;
 import com.template.model.vo.ApplicationProcedureTemporaryVo;
 
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.List;
 
@@ -33,4 +34,6 @@ public interface ApplicationProcedureTemporaryService extends IService<Applicati
     PageUtils<ApplicationProcedureTemporaryVo> pageAppletList(String startTime, String endTime, String status, int page, int size);
 
     PageUtils<ApplicationProcedureTemporaryVo> parentAppletPageList(String startTime, String endTime, String status, int page, int size);
+
+    List<ApplicationProcedureTemporary> getApt(LocalDate state, LocalDate end, String userId);
 }

+ 2 - 1
src/main/java/com/template/services/ClassScheduleService.java

@@ -5,7 +5,6 @@ import com.template.model.pojo.ClassSchedule;
 import com.template.model.vo.ClassListVo;
 
 import java.time.LocalDate;
-import java.util.List;
 
 /**
  * <p>
@@ -20,4 +19,6 @@ public interface ClassScheduleService extends IService<ClassSchedule> {
     ClassListVo  classList(LocalDate localDate, String teacherName);
 
     int removeByRemark(String remark);
+
+
 }

+ 2 - 1
src/main/java/com/template/services/HouseOrderService.java

@@ -27,7 +27,7 @@ public interface HouseOrderService extends IService<HouseOrder> {
      * @param leaveTime
      * @return
      */
-    BigDecimal getHouseOrderPrice(int houseOrderNumber, String userId, String houseId, String liveTime, String leaveTime);
+    BigDecimal getHouseOrderPrice(int houseOrderNumber, String userId, String houseId, String liveTime, String leaveTime,Integer source);
 
     /**
      * 管理端计算总金额
@@ -52,4 +52,5 @@ public interface HouseOrderService extends IService<HouseOrder> {
 
     List<String> payHouseOrderUser(LocalDateTime start, LocalDateTime end);
 
+    List<HouseOrder> getDate(LocalDateTime dateTime1, String userId,Integer source);
 }

+ 6 - 0
src/main/java/com/template/services/impl/ApplicationProcedureTemporaryServiceImpl.java

@@ -12,6 +12,7 @@ import com.template.services.ApplicationProcedureTemporaryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.List;
 
@@ -74,5 +75,10 @@ public class ApplicationProcedureTemporaryServiceImpl extends ServiceImpl<Applic
         return new PageUtils(result);
     }
 
+    @Override
+    public List<ApplicationProcedureTemporary> getApt(LocalDate state, LocalDate end, String userId) {
+        return applicationProcedureTemporaryMapper.getApt(state,end,userId);
+    }
+
 
 }

+ 4 - 3
src/main/java/com/template/services/impl/ClassScheduleServiceImpl.java

@@ -2,12 +2,11 @@ package com.template.services.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.template.mapper.ClassScheduleMapper;
-import com.template.model.pojo.HouseNumberState;
+import com.template.model.pojo.ClassSchedule;
 import com.template.model.vo.ClassListVo;
 import com.template.services.ClassScheduleService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.template.model.pojo.ClassSchedule;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -49,4 +48,6 @@ public class ClassScheduleServiceImpl extends ServiceImpl<ClassScheduleMapper, C
 
         return classScheduleMapper.removeByRemark(remark);
     }
+
+
 }

+ 84 - 98
src/main/java/com/template/services/impl/HouseOrderServiceImpl.java

@@ -33,7 +33,7 @@ import java.util.List;
  * @since 2023-11-21
  */
 @Service
-public class HouseOrderServiceImpl extends ServiceImpl<HouseOrderMapper, HouseOrder> implements HouseOrderService {
+public class HouseOrderServziceImpl extends ServiceImpl<HouseOrderMapper, HouseOrder> implements HouseOrderService {
 
     @Autowired
     HouseService houseService;
@@ -54,7 +54,7 @@ public class HouseOrderServiceImpl extends ServiceImpl<HouseOrderMapper, HouseOr
     ApplicationProcedureTemporaryService apts;
 
     @Override
-    public BigDecimal getHouseOrderPrice(int houseOrderNumber, String userId, String houseId, String liveTime, String leaveTime) {
+    public BigDecimal getHouseOrderPrice(int houseOrderNumber, String userId, String houseId, String liveTime, String leaveTime,Integer source) {
 
         House house = houseService.getById(houseId);
 
@@ -102,6 +102,9 @@ public class HouseOrderServiceImpl extends ServiceImpl<HouseOrderMapper, HouseOr
             BigDecimal totalPrice = roomPrice.multiply(new BigDecimal(houseOrderNumber));
             return totalPrice;
         }
+
+
+
         //   计算2个时间差
         long until = state.until(end, ChronoUnit.DAYS);
 
@@ -113,122 +116,100 @@ public class HouseOrderServiceImpl extends ServiceImpl<HouseOrderMapper, HouseOr
 
 
         BigDecimal totalPrice = new BigDecimal(0);
+
+        if (ObjectUtils.isNotEmpty(source)) {
+            if (source==1) {
+                return totalPrice;
+            }else if (source==2){
+                return totalPrice;
+            }
+        }
+
+
         for (int i = 0; i < until; i++) {
             LocalDate localDate1 = state.plusDays(i);
 
             LocalDateTime dateTime1 = stateTime.plusDays(i);
             List<HousePrice> housePrices1 = housePriceService.getDatePrice(localDate1, houseId);
 
-            if ("4".equals(department)) {
-                LocalDateTime startS = dateTime1.withHour(0).withMinute(0).withSecond(0);
-                LocalDateTime endS = dateTime1.withHour(23).withMinute(59).withSecond(59);
-                LambdaQueryWrapper<ClassSchedule> wrapperCS = new LambdaQueryWrapper<>();
-                wrapperCS.eq(ClassSchedule::getJsgh, users.getCardNumber())
-                        .between(ClassSchedule::getDateTime, startS, endS);
-                List<ClassSchedule> scheduleList = classScheduleService.list(wrapperCS);
-
-                if (ObjectUtils.isEmpty(scheduleList)) {
-                    if (ObjectUtils.isNotEmpty(housePrices1)) {
-                        HousePrice housePrice = housePrices1.get(housePrices1.size() - 1);
-                        BigDecimal price = housePrice.getPrice();
-                        totalPrice = totalPrice.add(price);
-                    } else {
-                        totalPrice = totalPrice.add(roomPrice);
-                    }
-                }else {
-//                    需要先判断当前时间是否已经有过订单,有的话则不免费
-//                        dateTime1
-                    List<HouseOrder> list = houseOrderMapper.getDate(dateTime1, userId);
-                    if (list.size() > 0) {
-                        if (ObjectUtils.isNotEmpty(housePrices1)) {
-                            HousePrice housePrice = housePrices1.get(housePrices1.size() - 1);
-                            BigDecimal price = housePrice.getPrice();
-                            totalPrice = totalPrice.add(price);
-                        } else {
-                            totalPrice = totalPrice.add(roomPrice);
-                        }
-                    }
-                }
-
-
-//                            for (HousePrice housePrice : housePrices1) {
-//                                String setDate = housePrice.getSetDate();
-//                                String[] split = setDate.split(",");
-//                                Date startDate = DateUtil.parseDateOnly(split[0]);
-//                                Date endDate = DateUtil.parseDateOnly(split[1]);
-//                                Date date1 = Date.from(localDate1.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
-//                                //      判断当前时间是否在[startTime, endTime]区间
-//                                assert startDate != null;
-//                                boolean effectiveDate = DateUtil.isEffectiveDate(date1, startDate, endDate);
-//                                if (effectiveDate) {
-//                                    BigDecimal price = housePrice.getPrice();
-//                                    totalPrice = totalPrice.add(price);
-//                                } else {
-//                                    totalPrice = totalPrice.add(roomPrice);
-//                                }
-//                            }
-
-
-
-        }else if ("7".equals(department)) {
-            List<ApplicationProcedureTemporary> list = apts.getDate(dateTime1, userId);
-            if (ObjectUtils.isNotEmpty(list)) {
-//                    当有临时表时需要判断是否已经有订单,有的话则原价
-                List<HouseOrder> list2 = houseOrderMapper.getDate(dateTime1, userId);
-                if (ObjectUtils.isNotEmpty(list2)) {
-                    if (ObjectUtils.isNotEmpty(housePrices1)) {
-                        HousePrice housePrice = housePrices1.get(housePrices1.size() - 1);
-                        BigDecimal price = housePrice.getPrice();
-                        totalPrice = totalPrice.add(price);
-                    } else {
-                        totalPrice = totalPrice.add(roomPrice);
-                    }
-                }
-            } else {
-                if (ObjectUtils.isNotEmpty(housePrices1)) {
-                    HousePrice housePrice = housePrices1.get(housePrices1.size() - 1);
-                    BigDecimal price = housePrice.getPrice();
-                    totalPrice = totalPrice.add(price);
-                } else {
-                    totalPrice = totalPrice.add(roomPrice);
-                }
-            }
-
-        } else {
-            if (ObjectUtils.isNotEmpty(housePrices1)) {
-                if (ObjectUtils.isNotEmpty(housePrices1)) {
-                    HousePrice housePrice = housePrices1.get(housePrices1.size() - 1);
-                    BigDecimal price = housePrice.getPrice();
-                    totalPrice = totalPrice.add(price);
-                }
-//                    for (HousePrice housePrice : housePrices1) {
-//                        String setDate = housePrice.getSetDate();
-//                        String[] split = setDate.split(",");
-//                        Date startDate = DateUtil.parseDateOnly(split[0]);
-//                        Date endDate = DateUtil.parseDateOnly(split[1]);
-//                        Date date1 = Date.from(localDate1.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
-//                        //      判断当前时间是否在[startTime, endTime]区间
-//                        assert startDate != null;
-//                        boolean effectiveDate = DateUtil.isEffectiveDate(date1, startDate, endDate);
-//                        if (effectiveDate) {
+//            if ("4".equals(department)) {
+//
+//                LocalDateTime startS = dateTime1.withHour(0).withMinute(0).withSecond(0);
+//                LocalDateTime endS = dateTime1.withHour(23).withMinute(59).withSecond(59);
+//                LambdaQueryWrapper<ClassSchedule> wrapperCS = new LambdaQueryWrapper<>();
+//                wrapperCS.eq(ClassSchedule::getJsgh, users.getCardNumber())
+//                        .between(ClassSchedule::getDateTime, startS, endS);
+//                List<ClassSchedule> scheduleList = classScheduleService.list(wrapperCS);
+//
+//                if (ObjectUtils.isEmpty(scheduleList)) {
+//                    if (ObjectUtils.isNotEmpty(housePrices1)) {
+//                        HousePrice housePrice = housePrices1.get(housePrices1.size() - 1);
+//                        BigDecimal price = housePrice.getPrice();
+//                        totalPrice = totalPrice.add(price);
+//                    } else {
+//                        totalPrice = totalPrice.add(roomPrice);
+//                    }
+//                }else {
+////                    需要先判断当前时间是否已经有过订单,有的话则不免费
+////                        dateTime1
+//                    List<HouseOrder> list = houseOrderMapper.getDate(dateTime1, userId,1);
+//                    if (list.size() > 0) {
+//                        if (ObjectUtils.isNotEmpty(housePrices1)) {
+//                            HousePrice housePrice = housePrices1.get(housePrices1.size() - 1);
 //                            BigDecimal price = housePrice.getPrice();
 //                            totalPrice = totalPrice.add(price);
 //                        } else {
 //                            totalPrice = totalPrice.add(roomPrice);
 //                        }
 //                    }
+//                }
+//
+//
+//
+//        }else if ("7".equals(department)) {
+//            List<ApplicationProcedureTemporary> list = apts.getDate(dateTime1, userId);
+//            if (ObjectUtils.isNotEmpty(list)) {
+////                    当有临时表时需要判断是否已经有订单,有的话则原价
+//                List<HouseOrder> list2 = houseOrderMapper.getDate(dateTime1, userId,2);
+//                if (ObjectUtils.isNotEmpty(list2)) {
+//                    if (ObjectUtils.isNotEmpty(housePrices1)) {
+//                        HousePrice housePrice = housePrices1.get(housePrices1.size() - 1);
+//                        BigDecimal price = housePrice.getPrice();
+//                        totalPrice = totalPrice.add(price);
+//                    } else {
+//                        totalPrice = totalPrice.add(roomPrice);
+//                    }
+//                }
+//            } else {
+//                if (ObjectUtils.isNotEmpty(housePrices1)) {
+//                    HousePrice housePrice = housePrices1.get(housePrices1.size() - 1);
+//                    BigDecimal price = housePrice.getPrice();
+//                    totalPrice = totalPrice.add(price);
+//                } else {
+//                    totalPrice = totalPrice.add(roomPrice);
+//                }
+//            }
+//
+//
+//
+//
+//        } else {
+            if (ObjectUtils.isNotEmpty(housePrices1)) {
+                if (ObjectUtils.isNotEmpty(housePrices1)) {
+                    HousePrice housePrice = housePrices1.get(housePrices1.size() - 1);
+                    BigDecimal price = housePrice.getPrice();
+                    totalPrice = totalPrice.add(price);
+                }
             } else {
                 totalPrice = totalPrice.add(roomPrice);
             }
-        }
 
 
-    }
 
+    }
 
-        return totalPrice.multiply(new
 
-    BigDecimal(houseOrderNumber));
+        return totalPrice.multiply(new BigDecimal(houseOrderNumber));
 }
 
     @Override
@@ -402,4 +383,9 @@ public class HouseOrderServiceImpl extends ServiceImpl<HouseOrderMapper, HouseOr
     public List<String> payHouseOrderUser(LocalDateTime start, LocalDateTime end) {
         return houseOrderMapper.payHouseOrderUser(start, end);
     }
+
+    @Override
+    public List<HouseOrder> getDate(LocalDateTime dateTime1, String userId,Integer source) {
+        return houseOrderMapper.getDate(dateTime1, userId,source);
+    }
 }

+ 11 - 0
src/main/resources/mapper/template/ApplicationProcedureTemporaryMapper.xml

@@ -307,5 +307,16 @@
         and FIND_IN_SET(ap.status,#{status})
         ORDER BY ap.submission_time DESC
     </select>
+    <select id="getApt" resultType="com.template.model.pojo.ApplicationProcedureTemporary">
+        SELECT
+            *
+        FROM
+            `application_procedure_temporary`
+        WHERE deleted=0
+          AND #{state} >= start_time
+          AND end_time >= #{end}
+          AND `status` =3
+          AND users_id=#{userId}
+    </select>
 
 </mapper>

+ 1 - 0
src/main/resources/mapper/template/ClassScheduleMapper.xml

@@ -17,4 +17,5 @@
         </where>
         GROUP BY date_time
     </select>
+
 </mapper>

+ 2 - 0
src/main/resources/mapper/template/HouseOrderMapper.xml

@@ -341,6 +341,8 @@
           AND reserve_user_id=#{userId}
           AND #{dateTime} >= reserve_live_time
           AND reserve_leave_time >= #{dateTime}
+          AND source=#{source}
+          AND pay_price=0
     </select>
 
 </mapper>