From 5fd338ec75b5e34b1a1ecc7948c67b148a1f53f7 Mon Sep 17 00:00:00 2001 From: xhxu Date: Sat, 21 Aug 2021 23:53:17 +0800 Subject: [PATCH] rent --- .../impl/WxRentContractServiceImpl.java | 104 +++++++++++------- .../java/com/iformall/utils/DateUtils.java | 12 ++ 2 files changed, 74 insertions(+), 42 deletions(-) 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 73c1730b3..24446300c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -1180,7 +1180,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { JSONObject jsonObject = array.getJSONObject(0); String increasingProportion = jsonObject.getString("increasingProportion"); if(StringUtils.isNotBlank(increasingProportion)){ - integers.add(Integer.parseInt(increasingProportion)); + int ratio = new BigDecimal(increasingProportion).multiply(new BigDecimal(100)).intValue(); + integers.add(ratio); + }else{ + integers.add(0); } } } @@ -1891,6 +1894,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { logger.info("获取租赁物业合同数据>>>>>>rentId:" + rentId +" >>>>propertyId:"+propertyId); Map result = new HashMap<>(); WxRentContract wxRentContract = wxRentContractMapper.selectById(rentId); + result.put("operationType", wxRentContract.getOperationType()); if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { JSONArray jsonArray = JSONArray.parseArray(wxRentContract.getRentInfo()); @@ -2213,22 +2217,25 @@ public class WxRentContractServiceImpl implements WxRentContractService { } //[{"progressivePay": "", "tempAdjustRatio": "2021-11-30 00:00:00", "incrementStartDate": "2021-11-29T16:00:00.000Z", "increasingProportion": "1.78"}] - //incrementStartDate - //tempAdjustRatio//租金递增起始日期 //increasingProportion//租金递增比例 //progressivePay//递增租赁单价 - String incrementStartDate = ""; - String tempAdjustRatio = ""; - String increasingProportion = ""; - String progressivePay = ""; + List> ratioList = new ArrayList<>(); if(StringUtils.isNotBlank(wxRentContract.getAdjustRatio())){ JSONArray array = JSONArray.parseArray(wxRentContract.getAdjustRatio()); if(array != null && array.size() > 0){ - JSONObject jsonObject = array.getJSONObject(0); - incrementStartDate = jsonObject.getString("incrementStartDate"); - tempAdjustRatio = jsonObject.getString("tempAdjustRatio"); - increasingProportion = jsonObject.getString("increasingProportion"); - progressivePay = jsonObject.getString("progressivePay"); + for(int i=0;i ratioMap = new HashMap<>(); + String afterYear = DateUtils.getAfterYear(wxRentContract.getStartDate(), i + 1); + String beforeAfterYear = DateUtils.getTimeBefore(1, afterYear); + ratioMap.put("incrementStartDate",afterYear); + ratioMap.put("beforeOneIncrementStartDate",beforeAfterYear); + ratioMap.put("increasingProportion",jsonObject.getString("increasingProportion")); + ratioMap.put("progressivePay",jsonObject.getString("progressivePay")); + ratioList.add(ratioMap); + } + } } } if(EnumRentContractType.RENT_BY_AREA.getCode().equals(type)){ @@ -2243,19 +2250,30 @@ public class WxRentContractServiceImpl implements WxRentContractService { .divide(new BigDecimal(100)) .setScale(2, RoundingMode.HALF_EVEN).doubleValue(); result.put("oneRentPrice",oneRentPrice); - //稍后详细计算 - result.put("oneRentalQuarterPrice1", priceRent*3); - result.put("oneRentalQuarterPriceUpper1", PriceUtil.digitUppercase(priceRent*3)); - - if(StringUtils.isNotBlank(incrementStartDate)){ - result.put("oneRentalEndDateYear1",incrementStartDate.substring(0,4)); - result.put("oneRentalEndDateMonth1",incrementStartDate.substring(5,7)); - result.put("oneRentalEndDateDay1",incrementStartDate.substring(8,10)); + WxBillRent wxBillRent = new WxBillRent(); + wxBillRent.setRentContractId(wxRentContract.getId()); + wxBillRent.setSortColumns(BaseEntity.SortField.Period_ASC); + List resultList = wxBillRentMapper.findList(wxBillRent); + //稍后详细计算(查询首期账单用于显示) + if(resultList != null && resultList.size() > 0){ + double oneRentalQuarterPrice1 = new BigDecimal(resultList.get(0).getReceivePay()) + .divide(new BigDecimal(100)) + .setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + result.put("oneRentalQuarterPrice1", oneRentalQuarterPrice1); + result.put("oneRentalQuarterPriceUpper1", PriceUtil.digitUppercase(oneRentalQuarterPrice1)); + } - result.put("oneRentalStartDateYear2",tempAdjustRatio.substring(0,4)); - result.put("oneRentalStartDateMonth2",tempAdjustRatio.substring(5,7)); - result.put("oneRentalStartDateDay2",tempAdjustRatio.substring(8,10)); + if(ratioList.size() > 0){ + String beforeOneIncrementStartDate = ratioList.get(0).get("beforeOneIncrementStartDate"); + result.put("oneRentalEndDateYear1",beforeOneIncrementStartDate.substring(0,4)); + result.put("oneRentalEndDateMonth1",beforeOneIncrementStartDate.substring(5,7)); + result.put("oneRentalEndDateDay1",beforeOneIncrementStartDate.substring(8,10)); + String incrementStartDate = ratioList.get(0).get("incrementStartDate"); + result.put("oneRentalStartDateYear2",incrementStartDate.substring(0,4)); + result.put("oneRentalStartDateMonth2",incrementStartDate.substring(5,7)); + result.put("oneRentalStartDateDay2",incrementStartDate.substring(8,10)); + String increasingProportion = ratioList.get(0).get("increasingProportion"); result.put("oneRentIncreasing2",increasingProportion); double priceRent2 = new BigDecimal(priceRent) .multiply(new BigDecimal(1).add(new BigDecimal(increasingProportion).divide(new BigDecimal(100)))) @@ -2277,15 +2295,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { .setScale(2, RoundingMode.HALF_EVEN).doubleValue(); result.put("twoPayRatio1",twoPayRatio1); result.put("twoPayDate",wxRentContract.getPayDate()); - if(StringUtils.isNotBlank(incrementStartDate)){ - result.put("twoRentalEndDateYear1",incrementStartDate.substring(0,4)); - result.put("twoRentalEndDateMonth1",incrementStartDate.substring(5,7)); - result.put("twoRentalEndDateDay1",incrementStartDate.substring(8,10)); - - - result.put("twoRentalStartDateYear2",tempAdjustRatio.substring(0,4)); - result.put("twoRentalStartDateMonth2",tempAdjustRatio.substring(5,7)); - result.put("twoRentalStartDateDay2",tempAdjustRatio.substring(8,10)); + if(ratioList.size() > 0){ + String beforeOneIncrementStartDate = ratioList.get(0).get("beforeOneIncrementStartDate"); + result.put("twoRentalEndDateYear1",beforeOneIncrementStartDate.substring(0,4)); + result.put("twoRentalEndDateMonth1",beforeOneIncrementStartDate.substring(5,7)); + result.put("twoRentalEndDateDay1",beforeOneIncrementStartDate.substring(8,10)); + String incrementStartDate = ratioList.get(0).get("incrementStartDate"); + result.put("twoRentalStartDateYear2",incrementStartDate.substring(0,4)); + result.put("twoRentalStartDateMonth2",incrementStartDate.substring(5,7)); + result.put("twoRentalStartDateDay2",incrementStartDate.substring(8,10)); + String increasingProportion = ratioList.get(0).get("increasingProportion"); result.put("twoRentIncreasing2",increasingProportion); Double twoPayRatio2 = new BigDecimal(twoPayRatio1) .add(new BigDecimal(increasingProportion)) @@ -2316,22 +2335,23 @@ public class WxRentContractServiceImpl implements WxRentContractService { result.put("threePayRatio1",threePayRatio1); result.put("threePayDate",wxRentContract.getPayDate()); - if(StringUtils.isNotBlank(incrementStartDate)){ - result.put("threeRentalEndDateYear1",incrementStartDate.substring(0,4)); - result.put("threeRentalEndDateMonth1",incrementStartDate.substring(5,7)); - result.put("threeRentalEndDateDay1",incrementStartDate.substring(8,10)); - - - result.put("threeRentalStartDateYear2",tempAdjustRatio.substring(0,4)); - result.put("threeRentalStartDateMonth2",tempAdjustRatio.substring(5,7)); - result.put("threeRentalStartDateDay2",tempAdjustRatio.substring(8,10)); + if(ratioList.size() > 0){ + String beforeOneIncrementStartDate = ratioList.get(0).get("beforeOneIncrementStartDate"); + result.put("threeRentalEndDateYear1",beforeOneIncrementStartDate.substring(0,4)); + result.put("threeRentalEndDateMonth1",beforeOneIncrementStartDate.substring(5,7)); + result.put("threeRentalEndDateDay1",beforeOneIncrementStartDate.substring(8,10)); + String incrementStartDate = ratioList.get(0).get("incrementStartDate"); + result.put("threeRentalStartDateYear2",incrementStartDate.substring(0,4)); + result.put("threeRentalStartDateMonth2",incrementStartDate.substring(5,7)); + result.put("threeRentalStartDateDay2",incrementStartDate.substring(8,10)); + String progressivePay = ratioList.get(0).get("progressivePay"); double threeProgressivePay2 = new BigDecimal(progressivePay) .multiply(new BigDecimal(wxRentContract.getRentArea())) .setScale(2, RoundingMode.HALF_EVEN).doubleValue(); result.put("threeProgressivePay2",threeProgressivePay2); result.put("threeProgressivePayUpper2",PriceUtil.digitUppercase(threeProgressivePay2)); - result.put("threeRentPrice2",progressivePay); + String increasingProportion = ratioList.get(0).get("increasingProportion"); result.put("threeRentIncreasing2",increasingProportion); }else{ diff --git a/mallinkService/src/main/java/com/iformall/utils/DateUtils.java b/mallinkService/src/main/java/com/iformall/utils/DateUtils.java index fdb9512b7..a1220150e 100755 --- a/mallinkService/src/main/java/com/iformall/utils/DateUtils.java +++ b/mallinkService/src/main/java/com/iformall/utils/DateUtils.java @@ -1393,4 +1393,16 @@ public class DateUtils { return isSameDate; } + /** + * 获取i年后的今天 + * @return + */ + public static String getAfterYear(Date date,int i){ + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Calendar cale = Calendar.getInstance(); + cale.setTime(date); + cale.add(Calendar.YEAR, i); + return format.format(cale.getTime()); + } + }