| | |
| | | import com.java110.utils.exception.ListenerExecuteException; |
| | | import com.java110.utils.util.*; |
| | | import com.java110.vo.ResultVo; |
| | | import com.java110.vo.api.fee.ApiFeeDataVo; |
| | | import com.java110.vo.api.fee.ApiFeeVo; |
| | | import com.java110.vo.api.feeConfig.ApiFeeConfigDataVo; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | |
| | | Integer.parseInt(feeDto.getDecimalPlace()) |
| | | ) |
| | | ); |
| | | |
| | | if (!StringUtil.isEmpty(custEndTime)) { |
| | | Date date = DateUtil.getDateFromStringB(custEndTime); |
| | | computeFeeSMOImpl.dealRentRateCustEndTime(feeDto, date); |
| | |
| | | //去掉多余0 |
| | | feeDto.setSquarePrice(Double.parseDouble(feeDto.getSquarePrice()) + ""); |
| | | feeDto.setAdditionalAmount(Double.parseDouble(feeDto.getAdditionalAmount()) + ""); |
| | | return ResultVo.createResponseEntity(feeDto); |
| | | ApiFeeDataVo apiFeeDataVo = BeanConvertUtil.covertBeanList(feeDtos, ApiFeeDataVo.class).get(0); |
| | | apiFeeDataVo.setStartTime(apiFeeDataVo.getStartTime() == null ? null : apiFeeDataVo.getStartTime().split(" ")[0]); |
| | | apiFeeDataVo.setEndTime(apiFeeDataVo.getEndTime() == null ? null : apiFeeDataVo.getEndTime().split(" ")[0]); |
| | | apiFeeDataVo.setMaxEndTime(apiFeeDataVo.getMaxEndTime() == null ? null : apiFeeDataVo.getMaxEndTime().split(" ")[0]); |
| | | apiFeeDataVo.setDeadlineTime(apiFeeDataVo.getDeadlineTime() == null ? null : apiFeeDataVo.getDeadlineTime().split(" ")[0]); |
| | | if (cycel != null && !"105".equals(cycel)) { // 修正字符串比较方式 |
| | | Date date = feeDto.getEndTime(); |
| | | if (date != null) { // 增加空值检查 |
| | | LocalDateTime localDateTime; |
| | | |
| | | // 处理 java.sql.Date 不支持 toInstant() 的问题 |
| | | if (date instanceof java.sql.Date) { |
| | | // 对于 sql.Date,先转换为 LocalDate 再转为 LocalDateTime |
| | | LocalDate localDate = ((java.sql.Date) date).toLocalDate(); |
| | | localDateTime = localDate.atStartOfDay(); |
| | | } else { |
| | | // 对于 util.Date,正常转换 |
| | | localDateTime = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()); |
| | | } |
| | | |
| | | try { |
| | | // 增加x个月 |
| | | int monthsToAdd = Integer.parseInt(cycel); |
| | | LocalDateTime newLocalDateTime = localDateTime.plusMonths(monthsToAdd).minusDays(1); |
| | | |
| | | // 转换回Date |
| | | Date newDate = Date.from(newLocalDateTime.atZone(ZoneId.systemDefault()).toInstant()); |
| | | apiFeeDataVo.setPayStartDate(feeDto.getEndTime()); |
| | | apiFeeDataVo.setPayEndDate(newDate); |
| | | } catch (NumberFormatException e) { |
| | | // 处理cycel无法转换为整数的异常 |
| | | // 可以根据实际需求记录日志或抛出自定义异常 |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else{ |
| | | apiFeeDataVo.setPayStartDate(DateUtil.getDateFromStringB(feeDto.getCustomStartTime())); |
| | | // 获取原始日期 |
| | | Date originalDate = DateUtil.getDateFromStringB(feeDto.getCustomEndTime()); |
| | | if (originalDate != null) { |
| | | // 创建Calendar实例并设置日期 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(originalDate); |
| | | |
| | | // 减一天 |
| | | calendar.add(Calendar.DAY_OF_MONTH, -1); |
| | | |
| | | // 获取处理后的日期 |
| | | Date dateMinusOneDay = calendar.getTime(); |
| | | apiFeeDataVo.setPayEndDate(dateMinusOneDay); |
| | | } |
| | | } |
| | | return ResultVo.createResponseEntity(apiFeeDataVo); |
| | | } |
| | | |
| | | @Override |