From fdceaf48a248db9e8ff97b97f0ae6804519984a6 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Tue, 25 Jun 2019 18:01:58 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=90=88=E5=90=8C][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=8A=B6=E6=80=81]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/schedule/ContractSchedule.java | 62 +++++++++++++++++++ .../service/WxPropertyContractService.java | 2 + .../service/WxRentContractService.java | 2 + .../service/impl/WxMerchantServiceImpl.java | 6 +- .../impl/WxPropertyContractServiceImpl.java | 9 ++- .../impl/WxRentContractServiceImpl.java | 7 ++- 6 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 mallinkSchedule/src/main/java/com/iformall/schedule/ContractSchedule.java diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/ContractSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/ContractSchedule.java new file mode 100644 index 000000000..68c196f94 --- /dev/null +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/ContractSchedule.java @@ -0,0 +1,62 @@ +package com.iformall.schedule; + +import com.iformall.domain.po.WxMall; +import com.iformall.domain.po.WxPropertyContract; +import com.iformall.domain.po.WxRentContract; +import com.iformall.mapper.WxMallMapper; +import com.iformall.service.WxPropertyContractService; +import com.iformall.service.WxRentContractService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author gongbiao + */ +@Component +public class ContractSchedule { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private WxRentContractService wxRentContractService; + + @Autowired + private WxPropertyContractService wxPropertyContractService; + + @Autowired + private WxMallMapper wxMallMapper; + + + /** + * 每天6点执行 + */ + @Scheduled(cron = "0 0 6 * * ?") + public void sendMsg() { + logger.info("合同状态更新开始"); + + List wxMalls = wxMallMapper.findList(null); + for (WxMall wxMall : wxMalls) { + String tenantId = wxMall.getTenantId(); + WxRentContract wxRentContract = new WxRentContract(); + wxRentContract.setTenantId(tenantId); + logger.info("租赁合同状态更新开始"); + wxRentContractService.updateStatus(wxRentContract); + logger.info("租赁合同状态更新结束"); + + WxPropertyContract wxPropertyContract = new WxPropertyContract(); + wxPropertyContract.setTenantId(tenantId); + logger.info("物业合同状态更新开始"); + wxPropertyContractService.updateStatus(wxPropertyContract); + logger.info("物业合同状态更新结束"); + } + logger.info("合同状态更新结束"); + + } + + +} \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java b/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java index c73d99534..0c3c09852 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java @@ -70,4 +70,6 @@ public interface WxPropertyContractService { void updatePropertyPreviewBill(WxPropertyContract record); List getWxBillPropertyPreview(Long id); + + Map updateStatus(WxPropertyContract record); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java index bc034c83b..b8348c372 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java @@ -91,4 +91,6 @@ public interface WxRentContractService { void endContract(WxRentContract wxRentContract); void updatePropertyPreviewBill(WxRentContract record); + + Map updateStatus(WxRentContract record); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index 4dddfcf98..452902ddf 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -401,7 +401,11 @@ public class WxMerchantServiceImpl implements WxMerchantService { } wxRentContract.setMerchantId(merchantId); wxRentContract.setUpdatetime(new Date()); - wxRentContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()); + if (wxRentContract.getRentalStartDate().before(new Date())) { + wxRentContract.setStatus(EnumRentContractStatus.RENT_PAID.getCode()); + } else { + wxRentContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()); + } wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract); //预览账单改为正式,并写入商户id(租赁合同需要绑定商户才变成已签约) WxBillRent billRent = new WxBillRent(); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java index dfbffaa21..52a1c0df6 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -398,13 +398,17 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService if (id == null) { return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); } + WxPropertyContract record = wxPropertyContractMapper.selectByPrimaryKey(id); //更新合同状态为签约 WxPropertyContract wxPropertyContract = new WxPropertyContract(); wxPropertyContract.setId(id); - wxPropertyContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()); + if (record.getRentalStartDate().before(new Date())) { + wxPropertyContract.setStatus(EnumRentContractStatus.RENT_PAID.getCode()); + } else { + wxPropertyContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()); + } wxPropertyContractMapper.updateByPrimaryKeySelective(wxPropertyContract); //建立账单 - WxPropertyContract record = wxPropertyContractMapper.selectByPrimaryKey(id); if (record.getMerchantId() != null && record.getReceivePeriod() != null && record.getPrice() > 0) { //预览账单改为正式,并写入商户id @@ -877,6 +881,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService return new ResultData(false); } + @Override public Map updateStatus(WxPropertyContract record) { Map resultData = new HashMap(); WxPropertyContract wxPropertyContract = new WxPropertyContract(); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 06be47e83..d1d7bf18a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -1208,6 +1208,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { return pageInfo; } + @Override public Map updateStatus(WxRentContract record) { Map resultData = new HashMap(); WxRentContract wxRentContract = new WxRentContract(); @@ -1340,7 +1341,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { //更新合同状态为签约 WxRentContract wxRentContract = new WxRentContract(); wxRentContract.setId(id); - wxRentContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()); + if (record.getRentalStartDate().before(new Date())) { + wxRentContract.setStatus(EnumRentContractStatus.RENT_PAID.getCode()); + } else { + wxRentContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()); + } wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract); //建立账单 if (record != null &&