| @@ -481,39 +481,50 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return rentList; | |||
| } | |||
| public int[] computePrice(WxRentContract wxRentContract) { | |||
| //计算租金 | |||
| public int[] computePrice(String rentInfo) { | |||
| JSONArray rentInfoArray = JSONArray.parseArray(wxRentContract.getRentInfo()); | |||
| JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | |||
| int arraySize = rentInfoArray.size(); | |||
| List<int[]> priceList = new ArrayList<>(); | |||
| //第一年 | |||
| int[] priceArr = new int[arraySize]; | |||
| for (int i = 0; i < arraySize; i++) { | |||
| double priceSum = 0; | |||
| for (int j = i; j < arraySize; j++) { | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(j); | |||
| double price = rentInfoObject.getDoubleValue("price");//1000 2000 3000 | |||
| JSONArray adjustRatio = rentInfoObject.getJSONArray("adjustRatio");//[1000] | |||
| adjustRatio.set(0, 0); | |||
| int ratio = adjustRatio.getIntValue(j);//0 1000 | |||
| price = price + price * ratio / 10000.0;//1000 2000 3000 | |||
| priceSum = priceSum + price;//1000 2000 3000 | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | |||
| priceArr[i] = rentInfoObject.getIntValue("price"); | |||
| } | |||
| priceList.add(priceArr); | |||
| //大于一年 | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(0); | |||
| JSONArray adjustRatio = rentInfoObject.getJSONArray("adjustRatio"); | |||
| int adjustRatioSize = adjustRatio.size(); | |||
| for (int i = 0; i < adjustRatioSize; i++) { | |||
| int[] priceArrs = new int[arraySize]; | |||
| for (int j = 0; j < arraySize; j++) { | |||
| rentInfoObject = rentInfoArray.getJSONObject(j); | |||
| adjustRatio = rentInfoObject.getJSONArray("adjustRatio"); | |||
| double price = priceList.get(i)[j] + priceList.get(i)[j] * adjustRatio.getIntValue(i) / 10000.0; | |||
| priceArrs[j] = new BigDecimal(price).setScale(0, RoundingMode.HALF_EVEN).intValue(); | |||
| } | |||
| priceArr[i] = new BigDecimal(priceSum).setScale(0, RoundingMode.HALF_EVEN).intValue();//6000 | |||
| priceList.add(priceArrs); | |||
| } | |||
| return priceArr; | |||
| int size = priceList.size(); | |||
| int[] priceArrs = new int[size]; | |||
| for (int i = 0; i < size; i++) { | |||
| int[] price = priceList.get(i); | |||
| int sum = 0; | |||
| for (int p : price) { | |||
| sum += p; | |||
| } | |||
| priceArrs[i] = sum; | |||
| } | |||
| return priceArrs; | |||
| } | |||
| public List<WxBillRent> buildRentMonth(WxMerchant wxMerchant, Long userId, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, Integer price,Integer isPreview) { | |||
| String adjustRatio = wxRentContract.getAdjustRatio(); | |||
| List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class); | |||
| integers.add(0, 0); | |||
| int size = integers.size(); | |||
| int[] priceArr = new int[size]; | |||
| priceArr[0] = price; | |||
| double priceD = price; | |||
| for (int i = 1; i < size; i++) { | |||
| priceD = priceD + priceD * integers.get(i) / 10000.0; | |||
| priceArr[i] = new BigDecimal(priceD).setScale(0, RoundingMode.HALF_EVEN).intValue(); | |||
| } | |||
| int[] priceArr = computePrice(wxRentContract.getRentInfo()); | |||
| int size = priceArr.length; | |||
| int month = 12; | |||
| int divide = lease / month; | |||
| int mod = lease % month; | |||