| @@ -1420,11 +1420,39 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| public Map<String, Object> getRentAndPropertyInfo(Long id) { | public Map<String, Object> getRentAndPropertyInfo(Long id) { | ||||
| logger.info("获取租赁物业合同数据>>>>>>id:" + id); | logger.info("获取租赁物业合同数据>>>>>>id:" + id); | ||||
| WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(id); | |||||
| WxShop record = new WxShop(); | |||||
| record.setId(wxRentContract.getShopId()); | |||||
| Map<String, Object> wxShop = wxShopMapper.findListMap(record).get(0); | |||||
| Map<String, Object> result = new HashMap<>(); | Map<String, Object> result = new HashMap<>(); | ||||
| WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(id); | |||||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | |||||
| JSONArray jsonArray = JSONArray.parseArray(wxRentContract.getRentInfo()); | |||||
| StringBuffer shopNumberStr = new StringBuffer(); | |||||
| StringBuffer floorNameStr = new StringBuffer(); | |||||
| StringBuffer buildingNameStr = new StringBuffer(); | |||||
| StringBuffer buildAreaStr = new StringBuffer(); | |||||
| StringBuffer operationAreaStr = new StringBuffer(); | |||||
| for (int i = 0, size = jsonArray.size(); i < size; i++) { | |||||
| JSONObject jsonObject = jsonArray.getJSONObject(i); | |||||
| shopNumberStr.append("[").append(jsonObject.getString("shopNumber")).append("]"); | |||||
| floorNameStr.append("[").append(jsonObject.getString("floor")).append("]"); | |||||
| buildingNameStr.append("[").append(jsonObject.getString("building")).append("]"); | |||||
| buildAreaStr.append("[").append(jsonObject.getString("buildArea")).append("]"); | |||||
| operationAreaStr.append("[").append(jsonObject.getString("operationArea")).append("]"); | |||||
| } | |||||
| result.put("shopNumber", shopNumberStr); | |||||
| result.put("floorName", floorNameStr); | |||||
| result.put("buildingName", buildingNameStr); | |||||
| result.put("buildArea", buildAreaStr); | |||||
| result.put("operationArea", operationAreaStr); | |||||
| } else { | |||||
| WxShop record = new WxShop(); | |||||
| record.setId(wxRentContract.getShopId()); | |||||
| Map<String, Object> wxShop = wxShopMapper.findListMap(record).get(0); | |||||
| //店铺信息 | |||||
| result.put("shopNumber", wxShop.get("shopNumber")); | |||||
| result.put("floorName", wxShop.get("floor")); | |||||
| result.put("buildingName", wxShop.get("building")); | |||||
| result.put("buildArea", wxShop.get("buildArea")); | |||||
| result.put("operationArea", wxShop.get("operationArea")); | |||||
| } | |||||
| //MALL信息 | //MALL信息 | ||||
| WxMall wxMall = new WxMall(); | WxMall wxMall = new WxMall(); | ||||
| wxMall.setTenantId(wxRentContract.getTenantId()); | wxMall.setTenantId(wxRentContract.getTenantId()); | ||||
| @@ -1435,12 +1463,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| //经营业态 | //经营业态 | ||||
| WxBusiness wxBusiness = wxBusinessMapper.selectByPrimaryKey(wxRentContract.getBusinessId()); | WxBusiness wxBusiness = wxBusinessMapper.selectByPrimaryKey(wxRentContract.getBusinessId()); | ||||
| result.put("business", wxBusiness.getTitle()); | result.put("business", wxBusiness.getTitle()); | ||||
| //店铺信息 | |||||
| result.put("shopNumber", wxShop.get("shopNumber")); | |||||
| result.put("floorName", wxShop.get("floor")); | |||||
| result.put("buildingName", wxShop.get("building")); | |||||
| result.put("buildArea", wxShop.get("buildArea")); | |||||
| result.put("operationArea", wxShop.get("operationArea")); | |||||
| //商户信息 | //商户信息 | ||||
| WxMerchant merchant = wxMerchantService.getById(wxRentContract.getMerchantId()); | WxMerchant merchant = wxMerchantService.getById(wxRentContract.getMerchantId()); | ||||
| if (merchant != null) { | if (merchant != null) { | ||||
| @@ -1524,15 +1547,20 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| int index = 10 - paycount; | int index = 10 - paycount; | ||||
| int count = paycount - 1; | int count = paycount - 1; | ||||
| BigDecimal rentPrice = new BigDecimal(priceRent); | BigDecimal rentPrice = new BigDecimal(priceRent); | ||||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA.getCode())) { | |||||
| areaWay(wxRentContract, result, lease, 0, extralease, extracount, paycount, index, count, rentPrice); | |||||
| } else { | |||||
| if (!wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | |||||
| //保底 | //保底 | ||||
| double revenue = new BigDecimal(wxRentContract.getRevenue()) | |||||
| .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); | |||||
| result.put("revenue", revenue); | |||||
| result.put("revenueUpper", digitUppercase(revenue)); | |||||
| ratioWay(wxRentContract, result, lease, 0, extralease, extracount, paycount, index, count, rentPrice); | |||||
| if (wxRentContract.getRevenue() != null) { | |||||
| double revenue = new BigDecimal(wxRentContract.getRevenue()) | |||||
| .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); | |||||
| result.put("revenue", revenue); | |||||
| result.put("revenueUpper", digitUppercase(revenue)); | |||||
| } else { | |||||
| result.put("revenue", 0); | |||||
| result.put("revenueUpper", digitUppercase(0)); | |||||
| } | |||||
| areaWay(wxRentContract, result, lease, extralease, extracount, paycount, index, count, rentPrice); | |||||
| } else { | |||||
| ratioWay(wxRentContract, result, lease, extralease, extracount, paycount, index, count, rentPrice); | |||||
| } | } | ||||
| //物业合同信息 | //物业合同信息 | ||||
| WxPropertyContract propertyContract = new WxPropertyContract(); | WxPropertyContract propertyContract = new WxPropertyContract(); | ||||
| @@ -1625,9 +1653,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| return result; | return result; | ||||
| } | } | ||||
| public void ratioWay(WxRentContract wxRentContract, Map<String, Object> result, Integer lease, double adjustRatio, int extralease, int extracount, int paycount, int index, int count, BigDecimal rentPrice) { | |||||
| double payRatio = wxRentContract.getPayRatio() != null ? wxRentContract.getPayRatio() / 100.0 : 0; | |||||
| public void ratioWay(WxRentContract wxRentContract, Map<String, Object> result, Integer lease, int extralease, int extracount, int paycount, int index, int count, BigDecimal rentPrice) { | |||||
| String adjustRatio = wxRentContract.getAdjustRatio(); | |||||
| List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class); | |||||
| integers.add(0, 0); | |||||
| //常规租期 | //常规租期 | ||||
| for (int i = 0; i <= count; i++) { | for (int i = 0; i <= count; i++) { | ||||
| //开始时间 | //开始时间 | ||||
| @@ -1651,7 +1680,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| result.put("rentalEndDateYear" + i, enddate.substring(0, 4)); | result.put("rentalEndDateYear" + i, enddate.substring(0, 4)); | ||||
| result.put("rentalEndDateMonth" + i, enddate.substring(5, 7)); | result.put("rentalEndDateMonth" + i, enddate.substring(5, 7)); | ||||
| result.put("rentalEndDateDay" + i, enddate.substring(8)); | result.put("rentalEndDateDay" + i, enddate.substring(8)); | ||||
| result.put("adjustRatio" + i, wxRentContract.getAdjustRatio()); | |||||
| String ratio = new BigDecimal(integers.get(i)).divide(new BigDecimal(100)).toPlainString(); | |||||
| result.put("adjustRatio" + i, ratio); | |||||
| result.put("adjustPeriod" + i, wxRentContract.getAdjustPeriod()); | result.put("adjustPeriod" + i, wxRentContract.getAdjustPeriod()); | ||||
| result.put("payRatio" + i, wxRentContract.getPayRatio()); | result.put("payRatio" + i, wxRentContract.getPayRatio()); | ||||
| @@ -1685,7 +1715,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| //无数据租期 | //无数据租期 | ||||
| for (int i = paycount; i <= index; i++) { | |||||
| for (int i = paycount; i <= 10; i++) { | |||||
| result.put("rentalStartDate" + i, "/"); | result.put("rentalStartDate" + i, "/"); | ||||
| result.put("rentalStartDateYear" + i, "/"); | result.put("rentalStartDateYear" + i, "/"); | ||||
| result.put("rentalStartDateMonth" + i, "/"); | result.put("rentalStartDateMonth" + i, "/"); | ||||
| @@ -1700,7 +1730,50 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| } | } | ||||
| public void areaWay(WxRentContract wxRentContract, Map<String, Object> result, Integer lease, double adjustRatio, int extralease, int extracount, int paycount, int index, int count, BigDecimal rentPrice) { | |||||
| public void areaWay(WxRentContract wxRentContract, Map<String, Object> result, Integer lease, int extralease, int extracount, int paycount, int index, int count, BigDecimal rentPrice) { | |||||
| int[] priceArrs = new int[]{}; | |||||
| List<String> adjustRatioList = new ArrayList<>(); | |||||
| adjustRatioList.add(0, "0"); | |||||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | |||||
| String rentInfo = wxRentContract.getRentInfo(); | |||||
| JSONArray objects = JSONArray.parseArray(rentInfo); | |||||
| JSONObject jsonObject = objects.getJSONObject(0); | |||||
| JSONArray adjustRatio = jsonObject.getJSONArray("adjustRatio"); | |||||
| for (int i = 0, size = adjustRatio.size(); i < size; i++) { | |||||
| StringBuffer adjustRatioStr = new StringBuffer(); | |||||
| for (int j = 0, shopSize = objects.size(); j < shopSize; j++) { | |||||
| JSONObject shopObject = objects.getJSONObject(j); | |||||
| JSONArray adjustRatioArr = shopObject.getJSONArray("adjustRatio"); | |||||
| String shopNumber = shopObject.getString("shopNumber"); | |||||
| double ratioStr = new BigDecimal(adjustRatioArr.getIntValue(i)).divide(new BigDecimal(100)).doubleValue(); | |||||
| adjustRatioStr.append(shopNumber).append("[").append(ratioStr).append("]"); | |||||
| } | |||||
| adjustRatioList.add(adjustRatioStr.toString()); | |||||
| } | |||||
| List<int[]> priceList = computePrice(rentInfo); | |||||
| int size = priceList.size(); | |||||
| priceArrs = new int[size]; | |||||
| for (int i = 0; i < size; i++) { | |||||
| int[] priceInt = priceList.get(i); | |||||
| int sum = 0; | |||||
| for (int p : priceInt) { | |||||
| sum += p; | |||||
| } | |||||
| priceArrs[i] = sum; | |||||
| } | |||||
| } else { | |||||
| String adjustRatio = wxRentContract.getAdjustRatio(); | |||||
| List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class); | |||||
| for (int i = 0, size = integers.size(); i < size; i++) { | |||||
| double ratioStr = new BigDecimal(integers.get(i)).divide(new BigDecimal(100)).doubleValue(); | |||||
| adjustRatioList.add(String.valueOf(ratioStr)); | |||||
| } | |||||
| } | |||||
| String payRatioStr = "0"; | |||||
| if (wxRentContract.getPayRatio() != null) { | |||||
| payRatioStr = new BigDecimal(wxRentContract.getPayRatio()).divide(new BigDecimal(100)).toPlainString(); | |||||
| } | |||||
| //常规租期 | //常规租期 | ||||
| for (int i = 0; i <= count; i++) { | for (int i = 0; i <= count; i++) { | ||||
| //开始时间 | //开始时间 | ||||
| @@ -1724,13 +1797,21 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| result.put("rentalEndDateYear" + i, enddate.substring(0, 4)); | result.put("rentalEndDateYear" + i, enddate.substring(0, 4)); | ||||
| result.put("rentalEndDateMonth" + i, enddate.substring(5, 7)); | result.put("rentalEndDateMonth" + i, enddate.substring(5, 7)); | ||||
| result.put("rentalEndDateDay" + i, enddate.substring(8)); | result.put("rentalEndDateDay" + i, enddate.substring(8)); | ||||
| if (i > 0) { | |||||
| rentPrice = rentPrice.multiply(new BigDecimal(adjustRatio)) | |||||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | |||||
| rentPrice = new BigDecimal(priceArrs[i]).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN); | |||||
| result.put("priceRentUpper" + i, digitUppercase(rentPrice.doubleValue())); | |||||
| result.put("priceRent" + i, rentPrice.doubleValue()); | |||||
| result.put("adjustRatio" + i, adjustRatioList.get(i)); | |||||
| } else { | |||||
| rentPrice = rentPrice.multiply(new BigDecimal(adjustRatioList.get(i))) | |||||
| .add(rentPrice).setScale(2, RoundingMode.HALF_EVEN); | .add(rentPrice).setScale(2, RoundingMode.HALF_EVEN); | ||||
| result.put("priceRentUpper" + i, digitUppercase(rentPrice.doubleValue())); | result.put("priceRentUpper" + i, digitUppercase(rentPrice.doubleValue())); | ||||
| result.put("priceRent" + i, rentPrice.doubleValue()); | result.put("priceRent" + i, rentPrice.doubleValue()); | ||||
| result.put("adjustRatio" + i, adjustRatioList.get(i)); | |||||
| } | } | ||||
| result.put("adjustRatio" + i, wxRentContract.getAdjustRatio()); | |||||
| result.put("payRatio" + i, payRatioStr); | |||||
| result.put("adjustPeriod" + i, wxRentContract.getAdjustPeriod()); | |||||
| } | } | ||||
| if (extracount > 0) { | if (extracount > 0) { | ||||
| //额外租期 | //额外租期 | ||||
| @@ -1756,15 +1837,20 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| result.put("rentalEndDateMonth" + count, enddate.substring(5, 7)); | result.put("rentalEndDateMonth" + count, enddate.substring(5, 7)); | ||||
| result.put("rentalEndDateDay" + count, enddate.substring(8)); | result.put("rentalEndDateDay" + count, enddate.substring(8)); | ||||
| rentPrice = rentPrice.multiply(new BigDecimal(adjustRatio)) | |||||
| .add(rentPrice).setScale(2, RoundingMode.HALF_EVEN); | |||||
| result.put("priceRentUpper" + count, digitUppercase(rentPrice.doubleValue())); | |||||
| result.put("priceRent" + count, rentPrice.doubleValue()); | |||||
| result.put("adjustRatio" + count, wxRentContract.getAdjustRatio()); | |||||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | |||||
| rentPrice = new BigDecimal(priceArrs[count]).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN); | |||||
| result.put("priceRentUpper" + count, digitUppercase(rentPrice.doubleValue())); | |||||
| result.put("priceRent" + count, rentPrice.doubleValue()); | |||||
| } else { | |||||
| rentPrice = rentPrice.multiply(new BigDecimal(adjustRatioList.get(count))) | |||||
| .add(rentPrice).setScale(2, RoundingMode.HALF_EVEN); | |||||
| result.put("priceRentUpper" + count, digitUppercase(rentPrice.doubleValue())); | |||||
| result.put("priceRent" + count, rentPrice.doubleValue()); | |||||
| } | |||||
| } | } | ||||
| //无数据租期 | //无数据租期 | ||||
| for (int i = paycount; i <= index; i++) { | |||||
| for (int i = paycount; i <= 10; i++) { | |||||
| result.put("rentalStartDate" + i, "/"); | result.put("rentalStartDate" + i, "/"); | ||||
| result.put("rentalStartDateYear" + i, "/"); | result.put("rentalStartDateYear" + i, "/"); | ||||
| result.put("rentalStartDateMonth" + i, "/"); | result.put("rentalStartDateMonth" + i, "/"); | ||||
| @@ -1776,6 +1862,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| result.put("priceRentUpper" + i, "/"); | result.put("priceRentUpper" + i, "/"); | ||||
| result.put("priceRent" + i, "/"); | result.put("priceRent" + i, "/"); | ||||
| result.put("adjustRatio" + i, "/"); | result.put("adjustRatio" + i, "/"); | ||||
| result.put("payRatio" + i, "/"); | |||||
| result.put("adjustPeriod" + i, "/"); | |||||
| } | } | ||||
| } | } | ||||