| @@ -133,24 +133,16 @@ public class WxRentContractHelper { | |||
| //计算每年租金基数值(合铺录入),具体计算在合同创建时,会根据合同的PriceUnit来根据此基数来计算 | |||
| private static String[] calcuteRentPriceByJoin(WxRentContract wxRentContract) { | |||
| //租金的年调整 | |||
| String adjustRatio = wxRentContract.getAdjustRatio(); | |||
| List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class); | |||
| integers.add(0, 0); | |||
| int size = integers.size(); | |||
| String[] priceArrs = new String[size]; | |||
| //如果是联营扣点租金取高,是固定租金 | |||
| BigDecimal priceD = null; | |||
| if (null != wxRentContract.getRevenueFixedRentPrice() && | |||
| wxRentContract.getRevenueFixedRentPrice().intValue() == EnumYesOrNo.YES.getCode()) { | |||
| priceArrs[0] = wxRentContract.getRevenueRentPrice(); | |||
| priceD = new BigDecimal(wxRentContract.getRevenueRentPrice()); | |||
| }else { | |||
| priceArrs[0] = wxRentContract.getPrice(); | |||
| priceD = new BigDecimal(wxRentContract.getPrice()); | |||
| } | |||
| //BigDecimal priceD = new BigDecimal(wxRentContract.getPrice()); | |||
| priceArrs[0] = wxRentContract.getPrice(); | |||
| BigDecimal priceD = new BigDecimal(wxRentContract.getPrice()); | |||
| //联营扣点年调整。 | |||
| String revenueYear = wxRentContract.getRevenueRatioSet(); | |||
| List<Long> revenueYears = null; | |||
| @@ -162,107 +154,55 @@ public class WxRentContractHelper { | |||
| revenueYears.add(0,0L); | |||
| //联营扣点取高单独计算联营扣点调整。 | |||
| String[] revenuePriceArrs = calcuteRevenuePriceByRentAreaJoint(wxRentContract,revenueYears,size); | |||
| if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.RATIO.getCode())) { | |||
| for (int i = 1; i < size; i++) { | |||
| BigDecimal divide = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(100)); | |||
| //如果纯联营扣点,没有租金的年增长,用联营扣点的年增长;联营扣点取高时priceD已是最高值 | |||
| String _update = ""; | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode()) || wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | |||
| _update = String.valueOf(revenueYears.get(i)); | |||
| }else { | |||
| _update = String.valueOf(integers.get(i)); | |||
| } | |||
| BigDecimal divide = priceD.multiply(new BigDecimal(_update)).divide(new BigDecimal(100)); | |||
| priceD = priceD.add(divide); | |||
| priceArrs[i] = priceD.setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | |||
| } | |||
| } else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | |||
| for (int i = 1; i < size; i++) { | |||
| priceD = priceD.add(new BigDecimal(integers.get(i))); | |||
| String _update = ""; | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode()) || wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | |||
| _update = String.valueOf(revenueYears.get(i)); | |||
| }else { | |||
| _update = String.valueOf(integers.get(i)); | |||
| } | |||
| priceD = priceD.add(new BigDecimal(_update)); | |||
| priceArrs[i] = priceD.setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | |||
| } | |||
| } else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | |||
| for (int i = 1; i < size; i++) { | |||
| priceArrs[i] = new BigDecimal(integers.get(i)).setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | |||
| String _update = ""; | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode()) || wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | |||
| _update = String.valueOf(revenueYears.get(i)); | |||
| }else { | |||
| _update = String.valueOf(integers.get(i)); | |||
| } | |||
| priceArrs[i] = new BigDecimal(_update).setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | |||
| } | |||
| }else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())){ | |||
| for (int i = 1; i < size; i++) { | |||
| BigDecimal _p = null; | |||
| //联营扣点才乘保底营业额 | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode()) && revenueYears.size() == size) { | |||
| _p = new BigDecimal(revenueYears.get(i)).multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(10000)); | |||
| String _update = ""; | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode()) || wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | |||
| _update = String.valueOf(revenueYears.get(i)); | |||
| }else { | |||
| _p = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(100)); | |||
| _update = String.valueOf(integers.get(i)); | |||
| } | |||
| priceArrs[i] = _p.setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | |||
| priceArrs[i] = priceD.multiply(new BigDecimal(_update)).divide(new BigDecimal(100)).toPlainString(); | |||
| } | |||
| } | |||
| //租金和联营取高 | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | |||
| for (int i = 0 ; i < priceArrs.length; i ++) { | |||
| if (new BigDecimal(priceArrs[i]).compareTo(new BigDecimal(revenuePriceArrs[i])) < 0) { | |||
| priceArrs[i] = revenuePriceArrs[i]; | |||
| } | |||
| } | |||
| } | |||
| return priceArrs; | |||
| } | |||
| //联营面积取高计算联营扣点调整。 | |||
| private static String[] calcuteRevenuePriceByRentAreaJoint(WxRentContract wxRentContract,List<Long> revenueYears,int size) { | |||
| //联营面积取高时,联营扣点调整比率设置 | |||
| String[] revenuePriceArrs = new String[size]; | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | |||
| String _revenuePriceD = null; | |||
| if (null != wxRentContract.getRevenueFixedRentPrice() && wxRentContract.getRevenueFixedRentPrice().intValue() == EnumYesOrNo.YES.getCode().intValue()) { | |||
| _revenuePriceD = wxRentContract.getRevenueRentPrice(); | |||
| }else { | |||
| _revenuePriceD = new BigDecimal(wxRentContract.getRevenue()).multiply(new BigDecimal(wxRentContract.getPayRatio())) | |||
| .divide(new BigDecimal(10000)).setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | |||
| } | |||
| revenuePriceArrs[0] = _revenuePriceD; | |||
| BigDecimal revenuePriceD = new BigDecimal(_revenuePriceD); | |||
| //联营扣点调整比率 | |||
| String revenueRationSet = wxRentContract.getRevenueRatioSet(); | |||
| List<Long> revenueRationSets = null; | |||
| if (!StringUtils.isBlank(revenueRationSet)) { | |||
| revenueRationSets = JSONArray.parseArray(revenueRationSet, Long.class); | |||
| }else { | |||
| revenueRationSets = new ArrayList<Long>(); | |||
| } | |||
| revenueRationSets.add(0,0L); | |||
| if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.RATIO.getCode())) { | |||
| for (int i = 1; i < size; i++) { | |||
| //联营扣点算法 | |||
| if (revenueYears.size() == size && revenueRationSets.size() == size) { | |||
| BigDecimal _p = new BigDecimal(revenueYears.get(i)).multiply(new BigDecimal(revenueRationSets.get(i))).divide(new BigDecimal(10000)); | |||
| revenuePriceD = revenuePriceD.add(_p); | |||
| } | |||
| revenuePriceArrs[i] = revenuePriceD.setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | |||
| } | |||
| } else if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | |||
| for (int i = 1; i < size; i++) { | |||
| if (revenueYears.size() == size && revenueRationSets.size() == size) { | |||
| revenuePriceD = revenuePriceD.add(new BigDecimal(revenueRationSets.get(i))); | |||
| } | |||
| revenuePriceArrs[i] = revenuePriceD.setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | |||
| } | |||
| } else if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | |||
| for (int i = 1; i < size; i++) { | |||
| revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)) | |||
| .setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | |||
| } | |||
| }else if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())){ | |||
| for (int i = 1; i < size; i++) { | |||
| BigDecimal _p = new BigDecimal(0) ; | |||
| if (revenueYears.size() == size && revenueRationSets.size() == size) { | |||
| _p = new BigDecimal(revenueRationSets.get(i)).multiply(new BigDecimal(revenueYears.get(i))).divide(new BigDecimal(10000)); | |||
| } | |||
| revenuePriceArrs[i] = _p.setScale(Constant.default_long_decimal_size, RoundingMode.HALF_UP).toPlainString(); | |||
| } | |||
| } | |||
| } | |||
| return revenuePriceArrs; | |||
| return priceArrs; | |||
| } | |||
| //合铺计算某项计费 | |||
| private static String[] calcuteRatioByJoin(Integer decimalSize,Integer ratioWay,String ratio,String ratioFirstYearPrice) { | |||
| List<Integer> integers = JSONArray.parseArray(ratio, Integer.class); | |||