From 49d61595e2fbd6f73f5cc6f1fa89de4b3cc2892b Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Wed, 11 Jan 2023 00:45:02 +0800 Subject: [PATCH] fix bug --- .../com/iformall/schedule/ContractSchedule.java | 13 +++++++++++++ .../resources/mapper/WxPropertyContractMapper.xml | 2 +- .../main/resources/mapper/WxRentContractMapper.xml | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/ContractSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/ContractSchedule.java index a788e8269..144810580 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/ContractSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/ContractSchedule.java @@ -13,6 +13,8 @@ import com.iformall.mapper.WxMallMapper; import com.iformall.mq.MqBaseProducer; import com.iformall.service.WxPropertyContractService; import com.iformall.service.WxRentContractService; +import com.iformall.utils.DateUtils; + import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,6 +23,7 @@ import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -144,10 +147,15 @@ public class ContractSchedule { @Scheduled(cron = "0 5 0 * * ?") public void notifyRentContractOutDate() { List wxMalls = wxMallMapper.findList(null); + Date date = new Date(); for (WxMall wxMall : wxMalls) { //物业合同 List contractList = wxRentContractService.findToOutDateContracts(wxMall); for (WxRentContract rent:contractList) { + Date endDate = DateUtils.stringToDate(DateUtils.getTimeBefore(rent.getOutDateNotifyDays(),rent.getRentalEndDate()), DateUtils.DATE_TIME_PATTERN); + if (endDate.after(date)) { + continue; + } try { WxMsgRecord msgRecord = new WxMsgRecord(); msgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); @@ -174,10 +182,15 @@ public class ContractSchedule { @Scheduled(cron = "0 5 0 * * ?") public void notifyPropertyContractOutDate() { List wxMalls = wxMallMapper.findList(null); + Date date = new Date(); for (WxMall wxMall : wxMalls) { //物业合同 List contractList = wxPropertyContractService.findToOutDateContracts(wxMall); for (WxPropertyContract rent:contractList) { + Date endDate = DateUtils.stringToDate(DateUtils.getTimeBefore(rent.getOutDateNotifyDays(),rent.getRentalEndDate()), DateUtils.DATE_TIME_PATTERN); + if (endDate.after(date)) { + continue; + } try { WxMsgRecord msgRecord = new WxMsgRecord(); msgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); diff --git a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml index d6aeb8426..2b40efc2d 100644 --- a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml @@ -72,7 +72,7 @@ and `price` = #{price} and `rental_start_date` = #{rentalStartDate} and `rental_end_date` = #{rentalEndDate} - and (out_date_notify_phone is not null and out_date_notify_phone != '' and DATE_SUB(rental_end_date, INTERVAL out_date_notify_days DAY) <= NOW()) + and out_date_notify_phone is not null and out_date_notify_phone != '' and and out_date_notify_days is not null and out_date_notify_days > 0 and rental_end_date <= NOW() and `sign_date` = #{signDate} and `receive_period` = #{receivePeriod} diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 1e26d38c6..48aff48f7 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -156,7 +156,7 @@ and `price` = #{price} and `rental_start_date` = #{rentalStartDate} and `rental_end_date` = #{rentalEndDate} - and (out_date_notify_phone is not null and out_date_notify_phone != '' and DATE_SUB(rental_end_date, INTERVAL out_date_notify_days DAY) <= NOW()) + and out_date_notify_phone is not null and out_date_notify_phone != '' and out_date_notify_days is not null and out_date_notify_days > 0 and rental_end_date <= NOW() and `sign_date` = #{signDate} and `receive_period` = #{receivePeriod}