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 977bb296b..24fc9cb28 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -285,51 +285,58 @@ public class WxRentContractServiceImpl implements WxRentContractService { wxBillRent.setIsPreview(EnumIsPreview.YES.getCode()); List resultList = wxBillRentMapper.findList(wxBillRent); - boolean change = false; - if(CollectionUtils.isEmpty(resultList)){ - change = true; - }else if(record.getAdjustPeriod().intValue() != dbRent.getAdjustPeriod().intValue()){ - change = true; + ResultData resultData = null; + if (dbRent.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { + // 更新 + resultData = getResultDataForUpdate(record, userId); + //删除预账单,重新生成 + wxBillRentMapper.deletePreviewBill(record); + resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode()); }else{ - if(record.getReceivePeriod() != null && record.getLease()!=null && record.getPrice()!= null) { - if (record.getType().equals(EnumRentContractType.RENT_BY_AREA.getCode())) { - if (!record.getReceivePeriod().equals(dbRent.getReceivePeriod()) - || !record.getLease().equals(dbRent.getLease()) - || !record.getType().equals(dbRent.getType()) - || !record.getPrice().equals(dbRent.getPrice()) - || !record.getAdjustRatio().replaceAll("\\s*","").equals(dbRent.getAdjustRatio().replaceAll("\\s*","")) - ) { - change = true; - } - } else if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { - if (!record.getReceivePeriod().equals(dbRent.getReceivePeriod()) - || !record.getLease().equals(dbRent.getLease()) - || !record.getType().equals(dbRent.getType()) - || !record.getRevenue().equals(dbRent.getRevenue()) - || !record.getPayRatio().equals(dbRent.getPayRatio()) - ) { - change = true; - } - } else if (record.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { - if (!record.getReceivePeriod().equals(dbRent.getReceivePeriod()) - || !record.getLease().equals(dbRent.getLease()) - || !record.getType().equals(dbRent.getType()) - || !record.getPrice().equals(dbRent.getPrice()) - || !record.getPayRatio().equals(dbRent.getPayRatio()) - ) { - change = true; + boolean change = false; + if (CollectionUtils.isEmpty(resultList)) { + change = true; + } else if (record.getAdjustPeriod().intValue() != dbRent.getAdjustPeriod().intValue()) { + change = true; + } else { + if (record.getReceivePeriod() != null && record.getLease() != null && record.getPrice() != null) { + if (record.getType().equals(EnumRentContractType.RENT_BY_AREA.getCode())) { + if (!record.getReceivePeriod().equals(dbRent.getReceivePeriod()) + || !record.getLease().equals(dbRent.getLease()) + || !record.getType().equals(dbRent.getType()) + || !record.getPrice().equals(dbRent.getPrice()) + || !record.getAdjustRatio().replaceAll("\\s*", "").equals(dbRent.getAdjustRatio().replaceAll("\\s*", "")) + ) { + change = true; + } + } else if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { + if (!record.getReceivePeriod().equals(dbRent.getReceivePeriod()) + || !record.getLease().equals(dbRent.getLease()) + || !record.getType().equals(dbRent.getType()) + || !record.getRevenue().equals(dbRent.getRevenue()) + || !record.getPayRatio().equals(dbRent.getPayRatio()) + ) { + change = true; + } + } else if (record.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { + if (!record.getReceivePeriod().equals(dbRent.getReceivePeriod()) + || !record.getLease().equals(dbRent.getLease()) + || !record.getType().equals(dbRent.getType()) + || !record.getPrice().equals(dbRent.getPrice()) + || !record.getPayRatio().equals(dbRent.getPayRatio()) + ) { + change = true; + } } } } - } - - // 更新 - ResultData resultData = getResultDataForUpdate(record, userId); - - //有改变,删除预账单,重新生成 - if(change) { - wxBillRentMapper.deletePreviewBill(record); - resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode()); + // 更新 + resultData = getResultDataForUpdate(record, userId); + //有改变,删除预账单,重新生成 + if (change) { + wxBillRentMapper.deletePreviewBill(record); + resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode()); + } } //启动审批流 @@ -408,7 +415,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { WxRentContract wxRentContractQuery = new WxRentContract(); wxRentContractQuery.setTenantId(record.getTenantId()); wxRentContractQuery.setShopId(rentInfoObject.getLong("shopId")); - int count = wxRentContractMapper.selectRentContractCountByShopId(wxRentContract); + int count = wxRentContractMapper.selectRentContractCountByShopId(wxRentContractQuery); if (count > 0) { String shopNumber = rentInfoObject.getString("shopNumber"); return new ResultData(ErrorCode.SHOP_IS_RENT.getCode(), "店铺 " + shopNumber + " 已出租"); @@ -556,7 +563,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { int[] priceArr = new int[arraySize]; for (int i = 0; i < arraySize; i++) { JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); - priceArr[i] = rentInfoObject.getIntValue("price"); + priceArr[i] = new BigDecimal(rentInfoObject.getIntValue("price")).multiply(new BigDecimal(100)).intValue(); } priceList.add(priceArr); //大于一年 @@ -569,8 +576,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { 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(); + BigDecimal multiply = new BigDecimal(priceList.get(i)[j]).multiply(new BigDecimal(adjustRatio.getIntValue(i)).divide(new BigDecimal(100))); + BigDecimal price = new BigDecimal(priceList.get(i)[j]).add(multiply); + priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).intValue(); } priceList.add(priceArrs); } @@ -1599,67 +1607,4 @@ public class WxRentContractServiceImpl implements WxRentContractService { wxRentContractMapper.updateApplyStatus(wxRentContract); } - - public static void main(String[] args) { - JSONArray rentInfoArray = JSONArray.parseArray("[{shopId:0,shopNumber:0,price:1000,adjustRatio:[1100,1100]},{shopId:1,shopNumber:1,price:2000,adjustRatio:[1200,1200]},{shopId:2,shopNumber:2,price:3000,adjustRatio:[1300,1300]}]"); - int arraySize = rentInfoArray.size(); - List priceList = new ArrayList<>(); - //第一年 - int[] priceArr = new int[arraySize]; - for (int i = 0; i < arraySize; i++) { - 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(); - } - priceList.add(priceArrs); - } - 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; - } - - - List> shopInfos = new ArrayList<>(); - for (int i = 0; i < size; i++) { - Map shopInfo = new HashMap<>(); - int[] ints = priceList.get(i); - for (int j = 0; j < ints.length; j++) { - rentInfoObject = rentInfoArray.getJSONObject(j); - shopInfo.put(rentInfoObject.getString("shopNumber"), ints[j]); - } - shopInfos.add(shopInfo); - } - - System.out.println(shopInfos); - //System.out.println(Arrays.toString(priceArr)); -// Calendar a = Calendar.getInstance(); -// a.set(Calendar.DATE, 1); -// a.roll(Calendar.DATE, -1); -// int maxDate = a.get(Calendar.DATE); -// System.out.println(maxDate); -// a.clear(); -// a.setTime(new Date()); -// System.out.println(a.get(Calendar.DAY_OF_MONTH)); - - } - } diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 6c450ee10..7cc7b0323 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -225,7 +225,7 @@