From 01f918105c1017e50d86a4e072a304ec8b022c90 Mon Sep 17 00:00:00 2001 From: xhxu Date: Mon, 22 Mar 2021 16:33:05 +0800 Subject: [PATCH] rent --- .../impl/WxRentContractServiceImpl.java | 93 ++++++++++++++++++- .../mapper/WxBillOtherDepositMapper.xml | 6 +- 2 files changed, 94 insertions(+), 5 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 705d1abb4..013d6d894 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -1054,9 +1054,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { int size = 0; long[] priceArrs = null; List> shopInfos = new ArrayList<>(); - if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode()) && + if (//wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode()) && wxRentContract.getRentInputWay().equals(EnumRentContractRentInputWay.PART.getCode()) && - !wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { + !wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode()) && + !wxRentContract.getType().equals(EnumRentContractType.RENT_BY_COUNT.getCode())) { String rentInfo = wxRentContract.getRentInfo(); JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); List priceList = computePrice(rentInfo, wxRentContract); @@ -1175,6 +1176,92 @@ public class WxRentContractServiceImpl implements WxRentContractService { return shopInfoStr; } + private String getRentPriceInfo(WxRentContract wxRentContract, long contractNeedPay){ + long rentPrice = 0l, siteMoney = 0l, facilityMoney = 0l, administratorMoney = 0l; + if(!wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode()) && + !wxRentContract.getType().equals(EnumRentContractType.RENT_BY_COUNT.getCode())){ + if(wxRentContract.getRentInputWay().equals(EnumRentContractRentInputWay.PART.getCode())){ + String rentInfo = wxRentContract.getRentInfo(); + JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); + long[] priceList = computePrice(rentInfo, wxRentContract).get(0); + long sum = Arrays.stream(priceList).sum(); + int size = rentInfoArray.size(); + for (int i = 0;i < size;) { + BigDecimal a=new BigDecimal(0),b=new BigDecimal(0),c=new BigDecimal(0),d=new BigDecimal(0); + JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); + + String rentPrice1 = rentInfoObject.getString("rentPrice"); + if(StringUtils.isNotBlank(rentPrice1)){ + a = new BigDecimal(rentPrice1); + } + JSONObject otherRentPriceInfo = rentInfoObject.getJSONObject("otherRentPriceInfo"); + if(otherRentPriceInfo != null ){ + String siteMoney1 = otherRentPriceInfo.getString("siteMoney"); + if(StringUtils.isNotBlank(siteMoney1)){ + b = new BigDecimal(siteMoney1); + } + String facilityMoney1 = otherRentPriceInfo.getString("facilityMoney"); + if(StringUtils.isNotBlank(facilityMoney1)){ + c = new BigDecimal(facilityMoney1); + } + String administratorMoney1 = otherRentPriceInfo.getString("administratorMoney"); + if(StringUtils.isNotBlank(administratorMoney1)){ + d = new BigDecimal(administratorMoney1); + } + } + + rentPrice += new BigDecimal(contractNeedPay).multiply(new BigDecimal(priceList[i])).divide(new BigDecimal(sum)) + .multiply(a).divide(a.add(b).add(c).add(d)).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); + siteMoney += new BigDecimal(contractNeedPay).multiply(new BigDecimal(priceList[i])).divide(new BigDecimal(sum)) + .multiply(b).divide(a.add(b).add(c).add(d)).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); + facilityMoney += new BigDecimal(contractNeedPay).multiply(new BigDecimal(priceList[i])).divide(new BigDecimal(sum)) + .multiply(c).divide(a.add(b).add(c).add(d)).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); + administratorMoney += new BigDecimal(contractNeedPay).multiply(new BigDecimal(priceList[i])).divide(new BigDecimal(sum)) + .multiply(d).divide(a.add(b).add(c).add(d)).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); + + } + + }else{ + BigDecimal a=new BigDecimal(0),b=new BigDecimal(0),c=new BigDecimal(0),d=new BigDecimal(0); + String rentPrice1 = wxRentContract.getRentPrice(); + if(StringUtils.isNotBlank(rentPrice1)){ + a = new BigDecimal(rentPrice1).divide(new BigDecimal(100)); + } + String otherRentPriceInfo1 = wxRentContract.getOtherRentPriceInfo(); + if(StringUtils.isNotBlank(otherRentPriceInfo1)){ + JSONObject jsonObject = JSONObject.parseObject(otherRentPriceInfo1); + String siteMoney1 = jsonObject.getString("siteMoney"); + if(StringUtils.isNotBlank(siteMoney1)){ + b = new BigDecimal(siteMoney1); + } + String facilityMoney1 = jsonObject.getString("facilityMoney"); + if(StringUtils.isNotBlank(facilityMoney1)){ + c = new BigDecimal(facilityMoney1); + } + String administratorMoney1 = jsonObject.getString("administratorMoney"); + if(StringUtils.isNotBlank(administratorMoney1)){ + d = new BigDecimal(administratorMoney1); + } + } + rentPrice = new BigDecimal(contractNeedPay).multiply(a).divide(a.add(b).add(c).add(d)).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); + siteMoney = new BigDecimal(contractNeedPay).multiply(b).divide(a.add(b).add(c).add(d)).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); + facilityMoney = new BigDecimal(contractNeedPay).multiply(c).divide(a.add(b).add(c).add(d)).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); + administratorMoney = new BigDecimal(contractNeedPay).multiply(d).divide(a.add(b).add(c).add(d)).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); + + } + }else{ + rentPrice = contractNeedPay; + } + + + Map resultMap = new HashedMap(); + resultMap.put("rentPrice",new BigDecimal(rentPrice).divide(new BigDecimal(100)).toString()); + resultMap.put("siteMoney",new BigDecimal(siteMoney).divide(new BigDecimal(100)).toString()); + resultMap.put("facilityMoney",new BigDecimal(facilityMoney).divide(new BigDecimal(100)).toString()); + resultMap.put("administratorMoney",new BigDecimal(administratorMoney).divide(new BigDecimal(100)).toString()); + return resultMap.toString(); + } + public Map buildRent(int receivePeriod, long[] priceArrs, List yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) { WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxRentContract); @@ -1265,6 +1352,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { wxBillRent.setEndtime(billTimeVo.getEndDate()); wxBillRent.setReceiveDate(billTimeVo.getReceiveDate()); + wxBillRent.setContractNeedPay(needpay); + wxBillRent.setRentPriceInfo(getRentPriceInfo(wxRentContract,needpay)); wxBillRent.setNeedPay(needpay); wxBillRent.setOwe(needpay); wxBillRent.setReceivePay(needpay); diff --git a/mallinkService/src/main/resources/mapper/WxBillOtherDepositMapper.xml b/mallinkService/src/main/resources/mapper/WxBillOtherDepositMapper.xml index 928bcd575..58ac8fd14 100644 --- a/mallinkService/src/main/resources/mapper/WxBillOtherDepositMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillOtherDepositMapper.xml @@ -17,6 +17,7 @@ + @@ -34,7 +35,7 @@ `id`,`tenant_id`,`parent_tenant_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`, - `owe`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`name`,`comments`, + `owe`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`shop_name`,`updatetime`,`name`,`comments`, `rent_shop_type`,`return_price`,`pay_way`,`starttime`,`endtime`,freeze,service_charge_pay @@ -84,10 +85,9 @@