java110
2021-08-12 4dbf61c9189796ec46d39ac4b839cfc064e70411
service-fee/src/main/java/com/java110/fee/api/ApplyRoomDiscountApi.java
@@ -78,6 +78,14 @@
        Assert.hasKeyAndValue(reqJson, "startTime", "请求报文中未包含startTime");
        Assert.hasKeyAndValue(reqJson, "endTime", "请求报文中未包含endTime");
        Assert.hasKeyAndValue(reqJson, "applyType", "请求报文中未包含applyType");
        if (!StringUtil.isEmpty(reqJson.getString("startTime"))) {
            String startTime = reqJson.getString("startTime") + " 00:00:00";
            reqJson.put("startTime", startTime);
        }
        if (!StringUtil.isEmpty(reqJson.getString("endTime"))) {
            String endTime = reqJson.getString("endTime") + " 23:59:59";
            reqJson.put("endTime", endTime);
        }
        ApplyRoomDiscountPo applyRoomDiscountPo = BeanConvertUtil.covertBean(reqJson, ApplyRoomDiscountPo.class);
        ApplyRoomDiscountDto applyRoomDiscountDto = new ApplyRoomDiscountDto();
        applyRoomDiscountDto.setCommunityId(applyRoomDiscountPo.getCommunityId());
@@ -87,12 +95,16 @@
        //获取本次填写的开始时间
        Date startDate = simpleDateFormat.parse(applyRoomDiscountPo.getStartTime());
        if (applyRoomDiscountDtos.size() == 0) {
            //空置房优惠可用
            applyRoomDiscountPo.setInUse("0");
            return saveApplyRoomDiscountBMOImpl.save(applyRoomDiscountPo);
        } else if (applyRoomDiscountDtos.size() > 0) {
            //取出结束时间
            String endTime = applyRoomDiscountDtos.get(0).getEndTime();
            Date finishTime = simpleDateFormat.parse(endTime);
            if (startDate.getTime() - finishTime.getTime() >= 0) {
                //空置房优惠可用
                applyRoomDiscountPo.setInUse("0");
                return saveApplyRoomDiscountBMOImpl.save(applyRoomDiscountPo);
            } else {
                throw new UnsupportedOperationException("该时间段已经申请过空置房,请重新输入空置房申请开始和结束时间");