| @@ -131,12 +131,14 @@ public class WxAgileContractController extends WxContractBaseController { | |||
| return new ResultData(Result.ERROR,"请选择店铺"); | |||
| } | |||
| Map<Long,ShopValidAreaVo> map = null; | |||
| List<Long> ignoreIds = new ArrayList<Long>(); | |||
| ignoreIds.add(wxRentContract.getId()); | |||
| if (null != wxRentContract.getCalcuteIsProperty() | |||
| && EnumYesOrNo.YES.getCode().intValue() == wxRentContract.getCalcuteIsProperty().intValue()) { | |||
| map = this.calcuteShopValidArea(wxRentContract, wxRentContract.getId(), wxRentContract.getRentalStartDate(), wxRentContract.getRentalEndDate(), | |||
| map = this.calcuteShopValidArea(wxRentContract, ignoreIds, wxRentContract.getRentalStartDate(), wxRentContract.getRentalEndDate(), | |||
| wxRentContract.getCalcuteShopIds(), null, false); | |||
| }else { | |||
| map = this.calcuteShopValidArea(wxRentContract, wxRentContract.getId(), wxRentContract.getRentalStartDate(), wxRentContract.getRentalEndDate(), | |||
| map = this.calcuteShopValidArea(wxRentContract, ignoreIds, wxRentContract.getRentalStartDate(), wxRentContract.getRentalEndDate(), | |||
| wxRentContract.getCalcuteShopIds(), null, true); | |||
| } | |||
| return new ResultData(map); | |||
| @@ -98,7 +98,7 @@ public class WxContractBaseController extends BaseController{ | |||
| } | |||
| } | |||
| protected Map<Long,ShopValidAreaVo> calcuteShopValidArea(TenantEntity tenantEntity,Long contractId,Date contractStartDate,Date contractEndDate, | |||
| protected Map<Long,ShopValidAreaVo> calcuteShopValidArea(TenantEntity tenantEntity,List<Long> ignoreContractIds,Date contractStartDate,Date contractEndDate, | |||
| List<Long> shopIdList,Map<Long, BigDecimal> rentAreaMap,boolean isRent) { | |||
| //判断店铺是否还有有效的面积 | |||
| Map<Long,ShopValidAreaVo> shopValidAreaMap = new HashMap<Long,ShopValidAreaVo>(); | |||
| @@ -129,10 +129,10 @@ public class WxContractBaseController extends BaseController{ | |||
| List<Long> contractIds = wxAgileContractService.findShopContractIds(tenantEntity, sidlist); | |||
| //查询是否有跟当前合同时间有冲突的合同 | |||
| if (null != contractIds) { | |||
| if (null != contractId) { | |||
| contractIds.remove(contractId); | |||
| if (null != ignoreContractIds && ignoreContractIds.size() > 0 ) { | |||
| contractIds.removeAll(ignoreContractIds); | |||
| } | |||
| if (contractIds.size() > 0) { | |||
| if (null != contractIds && contractIds.size() > 0) { | |||
| List<Long> usedContractIds = null; | |||
| List<Integer> statusList = new ArrayList<Integer>(); | |||
| statusList.add(EnumRentContractStatus.DRAFT.getCode()); | |||
| @@ -165,10 +165,10 @@ public class WxContractBaseController extends BaseController{ | |||
| return shopValidAreaMap; | |||
| } | |||
| private void contractValidShop(TenantEntity tenantEntity,Long contractId,Date contractStartDate,Date contractEndDate, | |||
| private void contractValidShop(TenantEntity tenantEntity,List<Long> ignoreContractIds,Date contractStartDate,Date contractEndDate, | |||
| List<Long> rentShopIdList,Map<Long, BigDecimal> rentAreaMap,boolean isRent) throws Exception { | |||
| //判断店铺是否还有有效的面积 | |||
| Map<Long,ShopValidAreaVo> shopVliadAreaMap = calcuteShopValidArea(tenantEntity, contractId, contractStartDate, contractEndDate, rentShopIdList, rentAreaMap, isRent); | |||
| Map<Long,ShopValidAreaVo> shopVliadAreaMap = calcuteShopValidArea(tenantEntity, ignoreContractIds, contractStartDate, contractEndDate, rentShopIdList, rentAreaMap, isRent); | |||
| if (null != shopVliadAreaMap) { | |||
| for (Iterator<Long> it = shopVliadAreaMap.keySet().iterator(); it.hasNext();) { | |||
| Long shopId = it.next(); | |||
| @@ -195,12 +195,16 @@ public class WxContractBaseController extends BaseController{ | |||
| //如果是影子数据修改,则要排除源合同 | |||
| if (rentContract.isYingZiContract()) { | |||
| contractValidShop(rentContract,rentContract.getOrginId(),rentContract.getRentalStartDate(),rentContract.getRentalEndDate(),rentContract.shopIdsByRentInfo(), | |||
| List<Long> ignoreIds = new ArrayList<Long>(); | |||
| ignoreIds.add(rentContract.getOrginId()); | |||
| ignoreIds.add(rentContract.getId()); | |||
| contractValidShop(rentContract,ignoreIds,rentContract.getRentalStartDate(),rentContract.getRentalEndDate(),rentContract.shopIdsByRentInfo(), | |||
| rentContract.getRentShopArea(),true); | |||
| }else { | |||
| contractValidShop(rentContract,rentContract.getId(),rentContract.getRentalStartDate(),rentContract.getRentalEndDate(),rentContract.shopIdsByRentInfo(), | |||
| List<Long> ignoreIds = new ArrayList<Long>(); | |||
| ignoreIds.add(rentContract.getId()); | |||
| contractValidShop(rentContract,ignoreIds,rentContract.getRentalStartDate(),rentContract.getRentalEndDate(),rentContract.shopIdsByRentInfo(), | |||
| rentContract.getRentShopArea(),true); | |||
| } | |||
| } | |||
| } | |||
| @@ -124,22 +124,22 @@ public class WxRentContractController extends WxContractBaseController { | |||
| return new ResultData(); | |||
| } | |||
| /** | |||
| * 设置定时终止时间 | |||
| * @return | |||
| */ | |||
| @PostMapping("setEndContractTime") | |||
| @SystemControllerLog(description = "租赁合同-设置定时终止合同时间") | |||
| public ResultData setEndContractTime(@RequestBody WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::endContract"); | |||
| WxRentContract contract = wxRentContractMapper.selectById(wxRentContract.getId()); | |||
| if (contract == null) { | |||
| return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); | |||
| } | |||
| contract.setEndContractTime(wxRentContract.getEndContractTime()); | |||
| wxRentContractService.setEndContractTime(contract); | |||
| return new ResultData(); | |||
| } | |||
| // /** | |||
| // * 设置定时终止时间 | |||
| // * @return | |||
| // */ | |||
| // @PostMapping("setEndContractTime") | |||
| // @SystemControllerLog(description = "租赁合同-设置定时终止合同时间") | |||
| // public ResultData setEndContractTime(@RequestBody WxRentContract wxRentContract) { | |||
| // logger.debug("[" + getIpAddr() + "] WxRentContractController::endContract"); | |||
| // WxRentContract contract = wxRentContractMapper.selectById(wxRentContract.getId()); | |||
| // if (contract == null) { | |||
| // return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); | |||
| // } | |||
| // contract.setEndContractTime(wxRentContract.getEndContractTime()); | |||
| // wxRentContractService.setEndContractTime(contract); | |||
| // return new ResultData(); | |||
| // } | |||
| @RequestMapping("/download") | |||
| @@ -82,27 +82,27 @@ public class ContractSchedule { | |||
| // log.info("合同状态更新结束"); | |||
| // } | |||
| /** | |||
| * 凌晨5分,定时终止租金合同 | |||
| */ | |||
| @Async | |||
| @Scheduled(cron = "0 5 0 * * ?") | |||
| public void endContract() { | |||
| List<WxMall> wxMalls = wxMallMapper.findList(null); | |||
| for (WxMall wxMall : wxMalls) { | |||
| //租金合同 | |||
| WxRentContract record = new WxRentContract(); | |||
| record.updateTenantInfo(wxMall); | |||
| List<WxRentContract> contractList = wxRentContractService.findToEndContractList(record); | |||
| for (WxRentContract rent:contractList) { | |||
| try { | |||
| wxRentContractService.endContract(rent,null); | |||
| }catch(Exception e) { | |||
| log.error("rentcontract outDate error.",e); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| // /** | |||
| // * 凌晨5分,定时终止租金合同 | |||
| // */ | |||
| // @Async | |||
| // @Scheduled(cron = "0 5 0 * * ?") | |||
| // public void endContract() { | |||
| // List<WxMall> wxMalls = wxMallMapper.findList(null); | |||
| // for (WxMall wxMall : wxMalls) { | |||
| // //租金合同 | |||
| // WxRentContract record = new WxRentContract(); | |||
| // record.updateTenantInfo(wxMall); | |||
| // List<WxRentContract> contractList = wxRentContractService.findToEndContractList(record); | |||
| // for (WxRentContract rent:contractList) { | |||
| // try { | |||
| // wxRentContractService.endContract(rent,null); | |||
| // }catch(Exception e) { | |||
| // log.error("rentcontract outDate error.",e); | |||
| // } | |||
| // } | |||
| // } | |||
| // } | |||
| // /** | |||
| // * 凌晨5分,定时过期提醒租金合同到期 | |||
| @@ -1254,7 +1254,7 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||
| } | |||
| @Override | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void renewalAgile(WxRentContract rentContract,MallUserInfo user) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| Long newContractId = idWorker.nextId(); | |||
| @@ -371,7 +371,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| } | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| @Override | |||
| public ResultData endContract(WxRentContract wxRentContract,MallUserInfo userInfo) { | |||
| @@ -384,19 +384,17 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| contract.setUpdateBy(userInfo.getId()); | |||
| contract.setEndContractTime(wxRentContract.getEndContractTime()); | |||
| wxRentContractMapper.updateById(contract); | |||
| //删除影子合同 | |||
| WxRentContract yingziContract = wxAgileContractService.findYingZiContract(contract.getId(),contract); | |||
| if (null != yingziContract) { | |||
| wxAgileContractService.deleteContract(yingziContract.getId(), yingziContract); | |||
| } | |||
| //租赁账单失效 | |||
| wxBillAllHelper.rentContractStop(wxRentContract,userInfo); | |||
| // WxBillRent wxBillRent = new WxBillRent(); | |||
| // wxBillRent.setRentContractId(wxRentContract.getId()); | |||
| // wxBillRent.updateTenantInfo(wxRentContract); | |||
| // wxBillRentMapper.updateInvalidStatus(wxBillRent); | |||
| return new ResultData(Result.SUCCESS,"终止成功"); | |||
| //解绑商户和商铺关系 | |||
| // WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId()); | |||
| // if(rentContract != null && rentContract.getMerchantId() != null){ | |||
| // wxMerchantService.disable(rentContract.getMerchantId()); | |||
| // } | |||
| } | |||
| @Transactional(rollbackFor = {Exception.class}) | |||