| @@ -78,7 +78,6 @@ public class WxPropertyContractController extends BaseController { | |||
| return wxPropertyContractService.saveOrUpdate(propertyContract, user.getId(), user.getName()); | |||
| } | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "物业合同-修改") | |||
| public ResultData update(@RequestBody WxPropertyContract wxPropertyContract) { | |||
| @@ -209,13 +209,45 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| return wxBillPropertyMapper.findList(wxBillRent); | |||
| } | |||
| /** | |||
| * 重新生成账单(预账单调整) | |||
| */ | |||
| public void savePreviewBill(WxPropertyContract record){ | |||
| if(CollectionUtils.isEmpty(record.getPreviewBillRentList())){ | |||
| return; | |||
| } | |||
| wxBillPropertyMapper.deletePreviewBill(record); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| int count = 1; | |||
| for (WxBillProperty bill:record.getPreviewBillRentList()) { | |||
| bill.setId(idWorker.nextId()); | |||
| bill.setPropertyContractId(record.getId()); | |||
| bill.setCreatetime(new Date()); | |||
| bill.setTenantId(record.getTenantId()); | |||
| bill.setOwe(bill.getReceivePay()); | |||
| bill.setNeedPay(bill.getReceivePay()); | |||
| bill.setUpdatetime(new Date()); | |||
| bill.setRentShopType(record.getRentShopType()); | |||
| bill.setPeriod(count); | |||
| bill.setIsPreview(EnumIsPreview.YES.getCode()); | |||
| bill.setShopInfo(getShopInfoStr(record)); | |||
| bill.setRevenue(0l); | |||
| bill.setLatePayRatio(0); | |||
| bill.setPay(0l); | |||
| bill.setIsDel(0); | |||
| setExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod()); | |||
| count++; | |||
| } | |||
| wxBillPropertyMapper.insertBills(record.getPreviewBillRentList()); | |||
| } | |||
| @Override | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public ResultData saveOrUpdate(WxPropertyContract record, Long userId, String userName) { | |||
| // 保存调整金额(预账单调整) | |||
| boolean haspreview = false; | |||
| if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){ | |||
| wxBillPropertyMapper.updateBills(record.getPreviewBillRentList()); | |||
| savePreviewBill(record); | |||
| haspreview = true; | |||
| } | |||
| @@ -469,16 +501,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| wxBillDeposit.setUpdatetime(date); | |||
| wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| wxBillDeposit.setRentShopType(wxPropertyContract.getRentShopType()); | |||
| String rentInfo = wxPropertyContract.getRentInfo(); | |||
| Map<String, Object> shopInfo = new HashMap<>(); | |||
| if (rentInfo != null) { | |||
| JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | |||
| for (int i = 0, size = rentInfoArray.size(); i < size; i++) { | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | |||
| shopInfo.put(rentInfoObject.getString("shopNumber"), rentInfoObject.get("buildArea")); | |||
| } | |||
| } | |||
| wxBillDeposit.setShopInfo(JSONObject.toJSONString(shopInfo)); | |||
| wxBillDeposit.setShopInfo(getShopInfoStr(wxPropertyContract)); | |||
| try { | |||
| wxBillPropertyDepositMapper.insertSelective(wxBillDeposit); | |||
| } catch (Exception e) { | |||
| @@ -488,6 +511,19 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| } | |||
| } | |||
| public String getShopInfoStr(WxPropertyContract wxPropertyContract){ | |||
| String rentInfo = wxPropertyContract.getRentInfo(); | |||
| Map<String, Object> shopInfo = new HashMap<>(); | |||
| if (rentInfo != null) { | |||
| JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | |||
| for (int i = 0, size = rentInfoArray.size(); i < size; i++) { | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | |||
| shopInfo.put(rentInfoObject.getString("shopNumber"), rentInfoObject.get("buildArea")); | |||
| } | |||
| } | |||
| return JSONObject.toJSONString(shopInfo); | |||
| } | |||
| public List<WxBillProperty> buildRentMonth(WxMerchant wxMerchant, Long userId, WxPropertyContract wxPropertyContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview) { | |||
| String adjustRatio = wxPropertyContract.getAdjustRatio(); | |||
| String rentInfo = wxPropertyContract.getRentInfo(); | |||
| @@ -650,23 +686,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| //截止收租日在当前时间之前 | |||
| Date date = new Date(); | |||
| if (wxBillProperty.getReceiveDate().before(date)) { | |||
| long day = (wxBillProperty.getReceiveDate().getTime() - date.getTime()) / (24 * 60 * 60 * 1000); | |||
| wxBillProperty.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||
| wxBillProperty.setExpiredDay(day); | |||
| } else {//截止收租日在当前时间之后 | |||
| Calendar now = Calendar.getInstance(); | |||
| now.add(dayType, receivePeriod); | |||
| Date currenttime = now.getTime(); | |||
| //当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴 | |||
| if (currenttime.before(wxBillProperty.getReceiveDate())) { | |||
| wxBillProperty.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); | |||
| wxBillProperty.setExpiredDay(0L); | |||
| } else { | |||
| wxBillProperty.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| wxBillProperty.setExpiredDay(0L); | |||
| } | |||
| } | |||
| setExpiredDay(wxBillProperty,dayType,receivePeriod); | |||
| wxBillProperty.setTenantId(wxPropertyContract.getTenantId()); | |||
| wxBillProperty.setIsDel(0); | |||
| wxBillProperty.setMerchantId(wxPropertyContract.getMerchantId()); | |||
| @@ -691,6 +711,27 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| return resultMap; | |||
| } | |||
| public void setExpiredDay(WxBillProperty wxBillProperty,int dayType, int receivePeriod){ | |||
| Date date = new Date(); | |||
| if (wxBillProperty.getReceiveDate().before(date)) { | |||
| long day = (wxBillProperty.getReceiveDate().getTime() - date.getTime()) / (24 * 60 * 60 * 1000); | |||
| wxBillProperty.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||
| wxBillProperty.setExpiredDay(day); | |||
| } else {//截止收租日在当前时间之后 | |||
| Calendar now = Calendar.getInstance(); | |||
| now.add(dayType, receivePeriod); | |||
| Date currenttime = now.getTime(); | |||
| //当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴 | |||
| if (currenttime.before(wxBillProperty.getReceiveDate())) { | |||
| wxBillProperty.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); | |||
| wxBillProperty.setExpiredDay(0L); | |||
| } else { | |||
| wxBillProperty.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| wxBillProperty.setExpiredDay(0L); | |||
| } | |||
| } | |||
| } | |||
| public boolean isFirstDay(Date date){ | |||
| int dateInt = Integer.parseInt(new SimpleDateFormat("d").format(date)); | |||
| if(dateInt == 1){ | |||
| @@ -435,15 +435,46 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| } | |||
| // 保存调整金额(预账单调整) | |||
| if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){ | |||
| wxBillRentMapper.updateBills(record.getPreviewBillRentList()); | |||
| } | |||
| //保存调整金额(预账单调整) | |||
| savePreviewBill(record); | |||
| WxRentContract wxRentContract = (WxRentContract)resultData.data; | |||
| wxRentContract.setPreviewBillRentList(resultList); | |||
| return new ResultData(wxRentContract); | |||
| } | |||
| /** | |||
| * 重新生成账单(预账单调整) | |||
| */ | |||
| public void savePreviewBill(WxRentContract record){ | |||
| if(CollectionUtils.isEmpty(record.getPreviewBillRentList())){ | |||
| return; | |||
| } | |||
| wxBillRentMapper.deletePreviewBill(record); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| int count = 1; | |||
| for (WxBillRent bill:record.getPreviewBillRentList()) { | |||
| bill.setId(idWorker.nextId()); | |||
| bill.setRentContractId(record.getId()); | |||
| bill.setCreatetime(new Date()); | |||
| bill.setTenantId(record.getTenantId()); | |||
| bill.setOwe(bill.getReceivePay()); | |||
| bill.setNeedPay(bill.getReceivePay()); | |||
| bill.setUpdatetime(new Date()); | |||
| bill.setRentShopType(record.getRentShopType()); | |||
| bill.setPeriod(count); | |||
| bill.setIsPreview(EnumIsPreview.YES.getCode()); | |||
| bill.setShopInfo(getShopInfoStr(record)); | |||
| bill.setRevenue(0l); | |||
| bill.setLatePayRatio(0); | |||
| bill.setPay(0l); | |||
| bill.setIsDel(0); | |||
| setExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod()); | |||
| count++; | |||
| } | |||
| wxBillRentMapper.insertBills(record.getPreviewBillRentList()); | |||
| } | |||
| public ResultData getResultDataForUpdate(WxRentContract record, Long userId,int from,Date oldRentStartDate) { | |||
| //更新租赁合同信息 | |||
| WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(record.getId()); | |||
| @@ -919,6 +950,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| String shopInfoStr = getShopInfoStr(wxRentContract); | |||
| Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr); | |||
| List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList"); | |||
| resultList.addAll(billRentList); | |||
| return resultList; | |||
| } | |||
| public String getShopInfoStr(WxRentContract wxRentContract){ | |||
| String shopInfoStr = null; | |||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | |||
| String rentInfo = wxRentContract.getRentInfo(); | |||
| @@ -931,11 +970,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| shopInfoStr = JSONObject.toJSONString(shopInfoMap); | |||
| } | |||
| Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr); | |||
| List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList"); | |||
| resultList.addAll(billRentList); | |||
| return resultList; | |||
| return shopInfoStr; | |||
| } | |||
| public Map<String, Object> buildRent(int receivePeriod, long[] priceArrs, List<Date> yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr) { | |||
| @@ -1032,23 +1067,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| //截止收租日在当前时间之前 | |||
| Date date = new Date(); | |||
| if (wxBillRent.getReceiveDate().before(date)) { | |||
| long day = (wxBillRent.getReceiveDate().getTime() - date.getTime()) / (24 * 60 * 60 * 1000); | |||
| wxBillRent.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||
| wxBillRent.setExpiredDay(day); | |||
| } else {//截止收租日在当前时间之后 | |||
| Calendar now = Calendar.getInstance(); | |||
| now.add(dayType, receivePeriod); | |||
| Date currenttime = now.getTime(); | |||
| //当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴 | |||
| if (currenttime.before(wxBillRent.getReceiveDate())) { | |||
| wxBillRent.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); | |||
| wxBillRent.setExpiredDay(0L); | |||
| } else { | |||
| wxBillRent.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| wxBillRent.setExpiredDay(0L); | |||
| } | |||
| } | |||
| setExpiredDay(wxBillRent,dayType,receivePeriod); | |||
| wxBillRent.setRevenue(0L); | |||
| wxBillRent.setTenantId(wxRentContract.getTenantId()); | |||
| wxBillRent.setIsDel(0); | |||
| @@ -1073,6 +1092,28 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return resultMap; | |||
| } | |||
| public void setExpiredDay(WxBillRent wxBillRent,int dayType, int receivePeriod){ | |||
| //截止收租日在当前时间之前 | |||
| Date date = new Date(); | |||
| if (wxBillRent.getReceiveDate().before(date)) { | |||
| long day = (wxBillRent.getReceiveDate().getTime() - date.getTime()) / (24 * 60 * 60 * 1000); | |||
| wxBillRent.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||
| wxBillRent.setExpiredDay(day); | |||
| } else {//截止收租日在当前时间之后 | |||
| Calendar now = Calendar.getInstance(); | |||
| now.add(dayType, receivePeriod); | |||
| Date currenttime = now.getTime(); | |||
| //当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴 | |||
| if (currenttime.before(wxBillRent.getReceiveDate())) { | |||
| wxBillRent.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); | |||
| wxBillRent.setExpiredDay(0L); | |||
| } else { | |||
| wxBillRent.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| wxBillRent.setExpiredDay(0L); | |||
| } | |||
| } | |||
| } | |||
| public boolean isFirstDay(Date date){ | |||
| int dateInt = Integer.parseInt(new SimpleDateFormat("d").format(date)); | |||
| if(dateInt == 1){ | |||
| @@ -1298,7 +1339,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| public ResultData updateFile(WxRentContract record, Long userId,String userName,Date oldRentStartDate) { | |||
| // 保存调整金额(预账单调整) | |||
| if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){ | |||
| wxBillRentMapper.updateBills(record.getPreviewBillRentList()); | |||
| savePreviewBill(record); | |||
| } | |||
| ResultData resultData = getResultDataForUpdate(record, userId,0,oldRentStartDate); | |||
| if (resultData.code != Result.SUCCESS) { | |||