| @@ -162,7 +162,7 @@ public class ShiroConfig { | |||
| filterChainDefinitionMap.put("/logout", "authc"); | |||
| filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||
| // filterChainDefinitionMap.put("/**", "anon"); | |||
| filterChainDefinitionMap.put("/**", "anon"); | |||
| shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | |||
| @@ -46,12 +46,12 @@ public class BaseController { | |||
| }); | |||
| } | |||
| public MallUserInfo getUser(){ | |||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||
| // MallUserInfo user = new MallUserInfo(); | |||
| // user.setId(463627091581734912L); | |||
| // user.setName("富茂光谷测试版管理员"); | |||
| // user.setTenantId("1025"); | |||
| // user.setParentTenantId("1024"); | |||
| //MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||
| MallUserInfo user = new MallUserInfo(); | |||
| user.setId(321127266275430400L); | |||
| user.setName("富茂光谷测试版管理员"); | |||
| user.setTenantId("789"); | |||
| user.setParentTenantId(null); | |||
| return user; | |||
| } | |||
| @@ -18,3 +18,20 @@ ADD COLUMN `end_contract_time` datetime COMMENT '终止时间'; | |||
| ALTER TABLE `mallink`.`wx_rent_contract` | |||
| ADD COLUMN `bussiness_management_fee` bigint(12) COMMENT '商业管理费'; | |||
| ALTER TABLE `mallink`.`wx_rent_contract` | |||
| ADD COLUMN `bussiness_management_fee_ratio_way` int(1) COMMENT '商业管理费调整方式1按比例2按金额'; | |||
| ALTER TABLE `mallink`.`wx_rent_contract` | |||
| ADD COLUMN `bussiness_management_fee_ratio` JSON COMMENT '商业管理费调整比率' ; | |||
| ALTER TABLE `mallink`.`wx_rent_contract` | |||
| ADD COLUMN `operating_management_fee` bigint(12) COMMENT '营业管理费'; | |||
| ALTER TABLE `mallink`.`wx_rent_contract` | |||
| ADD COLUMN `operating_management_fee_ratio_way` int(1) COMMENT '营业管理费调整方式1按比例2按金额'; | |||
| ALTER TABLE `mallink`.`wx_rent_contract` | |||
| ADD COLUMN `operating_management_fee_ratio` JSON COMMENT '营业管理费调整比率' ; | |||
| @@ -402,6 +402,24 @@ public class WxRentContract extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private Integer flowHas; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商业管理费", name = "bussinessManagementFee") | |||
| private Long bussinessManagementFee; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商业管理费调整方式1按比例2按金额", name = "bussinessManagementFeeRatioWay") | |||
| private Integer bussinessManagementFeeRatioWay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商业管理费调整方式1按比例2按金额", name = "bussinessManagementFeeRatio") | |||
| private String bussinessManagementFeeRatio; | |||
| @io.swagger.annotations.ApiModelProperty(value = "营业管理费", name = "operatingManagementFee") | |||
| private Long operatingManagementFee; | |||
| @io.swagger.annotations.ApiModelProperty(value = "营业管理费调整方式1按比例2按金额", name = "operatingManagementFeeRatioWay") | |||
| private Integer operatingManagementFeeRatioWay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "营业管理费调整方式1按比例2按金额", name = "operatingManagementFeeRatio") | |||
| private String operatingManagementFeeRatio; | |||
| public void setAdjustPeriodHandle() { | |||
| if(EnumPriceUnit.D.getCode().equals(this.getPriceUnit()) && EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode().equals(adjustPeriod)){ | |||
| @@ -0,0 +1,339 @@ | |||
| package com.iformall.service.helper; | |||
| import java.math.BigDecimal; | |||
| import java.math.RoundingMode; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.enums.EnumMissTimeType; | |||
| import com.iformall.enums.EnumRentContractAdjustRatioWay; | |||
| import com.iformall.enums.EnumRentContractRentInputWay; | |||
| import com.iformall.enums.EnumRentContractType; | |||
| public class WxRentContractHelper { | |||
| //计算商业管理费 | |||
| public static long[] calcuteBussinessManagementFee(WxRentContract wxRentContract) { | |||
| return calcuteOtherCanAdjustFeeByArea(wxRentContract,wxRentContract.getBussinessManagementFee(),wxRentContract.getBussinessManagementFeeRatioWay(), | |||
| wxRentContract.getBussinessManagementFeeRatio(),"bussinessManagementFee","bussinessManagementFeeRatio"); | |||
| } | |||
| //计算营业管理费 | |||
| public static long[] calcuteOperatingManagementFee(WxRentContract wxRentContract) { | |||
| return calcuteOtherCanAdjustFeeByArea(wxRentContract,wxRentContract.getOperatingManagementFee(),wxRentContract.getOperatingManagementFeeRatioWay(), | |||
| wxRentContract.getOperatingManagementFeeRatio(),"operatingManagementFee","operatingManagementFeeRatio"); | |||
| } | |||
| //计算除租金外其他可调整费项(按面积计算) | |||
| private static long[] calcuteOtherCanAdjustFeeByArea(WxRentContract wxRentContract,Long fee,Integer ratioWay,String ratio,String feeField,String feeRatioField) { | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA.getCode()) || | |||
| wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | |||
| if (wxRentContract.getRentInputWay().equals(EnumRentContractRentInputWay.PART.getCode())) { | |||
| //第一年,根据面积来计算 | |||
| JSONArray rentInfoArray = JSONArray.parseArray(wxRentContract.getRentInfo()); | |||
| long[] priceArr = new long[rentInfoArray.size()]; | |||
| for (int i = 0; i < rentInfoArray.size(); i++) { | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | |||
| //商业管理费单价 | |||
| String priceStr = rentInfoObject.getString(feeField); | |||
| if (priceStr == null || priceStr.equalsIgnoreCase("NaN")) { | |||
| priceStr = "0"; | |||
| } | |||
| //租赁面积 | |||
| String rentArea = rentInfoObject.getString("rentPrice"); | |||
| if (rentArea == null || rentArea.equalsIgnoreCase("NaN")) { | |||
| rentArea = "0"; | |||
| } | |||
| priceArr[i] = new BigDecimal(priceStr).multiply(new BigDecimal(rentArea)).multiply(new BigDecimal(100)).longValue(); | |||
| } | |||
| List<long[]> priceList = computeRatioByShop(rentInfoArray,wxRentContract.getBussinessManagementFeeRatioWay(),priceArr,feeRatioField); | |||
| return calcuteRatioByPart(priceList, feeRatioField); | |||
| }else { | |||
| String rentArea = wxRentContract.getRentArea(); | |||
| if (rentArea == null || rentArea.equalsIgnoreCase("NaN")) { | |||
| rentArea = "0"; | |||
| } | |||
| Long ratioFirstYearPrice = new BigDecimal(fee).multiply(new BigDecimal(rentArea)).longValue(); | |||
| return calcuteRatioByJoin(ratioWay, ratio, ratioFirstYearPrice); | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| //计算年租金 | |||
| public static long[] calcuteRentPrice(WxRentContract wxRentContract) { | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA.getCode()) || | |||
| wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | |||
| if (wxRentContract.getRentInputWay().equals(EnumRentContractRentInputWay.PART.getCode())) { | |||
| //计算每年租金基数(按面积,分铺录入) | |||
| //第一年 | |||
| JSONArray rentInfoArray = JSONArray.parseArray(wxRentContract.getRentInfo()); | |||
| long[] priceArr = new long[rentInfoArray.size()]; | |||
| for (int i = 0; i < rentInfoArray.size(); i++) { | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | |||
| String priceStr = rentInfoObject.getString("price"); | |||
| if (priceStr == null || priceStr.equalsIgnoreCase("NaN")) { | |||
| priceStr = "0"; | |||
| } | |||
| priceArr[i] = new BigDecimal(priceStr).multiply(new BigDecimal(100)).longValue(); | |||
| } | |||
| List<long[]> priceList = computeRatioByShop(rentInfoArray,wxRentContract.getAdjustRatioWay(),priceArr,"adjustRatio"); | |||
| return calcuteRatioByPart(priceList, "adjustRatio"); | |||
| }else { | |||
| return calcuteRentPriceByJoin(wxRentContract); | |||
| } | |||
| } | |||
| return calcuteRentPriceByJoin(wxRentContract); | |||
| } | |||
| //计算每年租金基数(合铺录入) | |||
| private static long[] calcuteRentPriceByJoin(WxRentContract wxRentContract) { | |||
| String adjustRatio = wxRentContract.getAdjustRatio(); | |||
| List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class); | |||
| integers.add(0, 0); | |||
| int size = integers.size(); | |||
| long[] priceArrs = new long[size]; | |||
| priceArrs[0] = wxRentContract.getPrice(); | |||
| BigDecimal priceD = new BigDecimal(wxRentContract.getPrice()); | |||
| //联营保底营业额。 | |||
| String revenueYear = wxRentContract.getRevenueYear(); | |||
| List<Long> revenueYears = null; | |||
| if (!StringUtils.isBlank(revenueYear)) { | |||
| revenueYears = JSONArray.parseArray(revenueYear, Long.class); | |||
| }else { | |||
| revenueYears = new ArrayList<Long>(); | |||
| } | |||
| revenueYears.add(0,0L); | |||
| //联营扣点取高单独计算联营扣点调整。 | |||
| long[] 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(10000)); | |||
| priceD = priceD.add(divide); | |||
| priceArrs[i] = priceD.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | |||
| for (int i = 1; i < size; i++) { | |||
| priceD = priceD.add(new BigDecimal(integers.get(i))); | |||
| priceArrs[i] = priceD.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | |||
| for (int i = 1; i < size; i++) { | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | |||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| priceArrs[i] = new BigDecimal(integers.get(i)).multiply(new BigDecimal(12)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| priceArrs[i] = new BigDecimal(integers.get(i)).multiply(new BigDecimal(wxRentContract.getReceivePeriod())).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| } | |||
| priceArrs[i] = new BigDecimal(integers.get(i)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| }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)); | |||
| }else { | |||
| _p = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(10000)); | |||
| } | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | |||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| priceArrs[i] = _p.multiply(new BigDecimal(12)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| priceArrs[i] = _p.multiply(new BigDecimal(wxRentContract.getReceivePeriod())).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| } | |||
| priceArrs[i] = _p.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } | |||
| //租金和联营取高 | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | |||
| for (int i = 0 ; i < priceArrs.length; i ++) { | |||
| if (priceArrs[i] < revenuePriceArrs[i]) { | |||
| priceArrs[i] = revenuePriceArrs[i]; | |||
| } | |||
| } | |||
| } | |||
| return priceArrs; | |||
| } | |||
| //联营面积取高计算联营扣点调整。 | |||
| private static long[] calcuteRevenuePriceByRentAreaJoint(WxRentContract wxRentContract,List<Long> revenueYears,int size) { | |||
| //联营面积取高时,联营扣点调整比率设置 | |||
| long[] revenuePriceArrs = new long[size]; | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | |||
| long _revenuePriceD = wxRentContract.getRevenue()*wxRentContract.getPayRatio()/10000; | |||
| 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(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } 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(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } else if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | |||
| for (int i = 1; i < size; i++) { | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | |||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)).multiply(new BigDecimal(12)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)).multiply(new BigDecimal(wxRentContract.getReceivePeriod())).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| } | |||
| revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| }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)); | |||
| } | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | |||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| revenuePriceArrs[i] = _p.multiply(new BigDecimal(12)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| revenuePriceArrs[i] = _p.multiply(new BigDecimal(wxRentContract.getReceivePeriod())).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| } | |||
| revenuePriceArrs[i] = _p.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } | |||
| } | |||
| return revenuePriceArrs; | |||
| } | |||
| //合铺计算某项计费 | |||
| private static long[] calcuteRatioByJoin(Integer ratioWay,String ratio,Long ratioFirstYearPrice) { | |||
| List<Integer> integers = JSONArray.parseArray(ratio, Integer.class); | |||
| integers.add(0, 0); | |||
| int size = integers.size(); | |||
| long[] priceArrs = new long[size]; | |||
| priceArrs[0] = ratioFirstYearPrice; | |||
| BigDecimal priceD = new BigDecimal(ratioFirstYearPrice); | |||
| if (ratioWay.equals(EnumRentContractAdjustRatioWay.RATIO.getCode())) { | |||
| for (int i = 1; i < size; i++) { | |||
| BigDecimal divide = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(10000)); | |||
| priceD = priceD.add(divide); | |||
| priceArrs[i] = priceD.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } else if (ratioWay.equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | |||
| for (int i = 1; i < size; i++) { | |||
| priceD = priceD.add(new BigDecimal(integers.get(i))); | |||
| priceArrs[i] = priceD.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } else if (ratioWay.equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | |||
| for (int i = 1; i < size; i++) { | |||
| priceArrs[i] = new BigDecimal(integers.get(i)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| }else if (ratioWay.equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())){ | |||
| for (int i = 1; i < size; i++) { | |||
| BigDecimal _p = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(10000)); | |||
| priceArrs[i] = _p.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } | |||
| return priceArrs; | |||
| } | |||
| //分铺汇总计算某项计费 | |||
| private static long[] calcuteRatioByPart(List<long[]> priceList,String ratioKey){ | |||
| //通过rentInfo里面分别计算各商铺的金额 | |||
| long[] priceArrs = new long[priceList.size()]; | |||
| for (int i = 0; i < priceList.size(); i++) { | |||
| long[] priceInt = priceList.get(i); | |||
| long sum = 0; | |||
| for (long p : priceInt) { | |||
| sum += p; | |||
| } | |||
| priceArrs[i] = sum; | |||
| } | |||
| return priceArrs; | |||
| } | |||
| //计算某项金额,每年-每个店铺金额 | |||
| public static List<long[]> computeRatioByShop(JSONArray rentInfoArray, Integer ratioWayType,long[] firstYearPrces,String ratioKey) { | |||
| List<long[]> priceList = new ArrayList<>(); | |||
| priceList.add(firstYearPrces); //每个店铺每月租金 | |||
| //大于一年 | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(0); | |||
| JSONArray adjustRatio = rentInfoObject.getJSONArray(ratioKey);//[100,200] | |||
| return computeRatioFromRentInfo(priceList, rentInfoArray, ratioWayType, adjustRatio.size(), ratioKey); | |||
| } | |||
| //计算年调整后的某项计费 | |||
| private static List<long[]> computeRatioFromRentInfo(List<long[]> priceList,JSONArray rentInfoArray, Integer ratioWayType,int ratioYears,String ratioKey ) { | |||
| //循环多年的调整比例,如3年。[10,20,30] | |||
| for (int i = 0; i < ratioYears; i++) { | |||
| long[] priceArrs = new long[rentInfoArray.size()]; | |||
| //按每个商铺循环 | |||
| for (int j = 0; j < rentInfoArray.size(); j++) { | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(j); | |||
| JSONArray adjustRatio = rentInfoObject.getJSONArray(ratioKey); | |||
| if (ratioWayType.equals(EnumRentContractAdjustRatioWay.RATIO.getCode())) { | |||
| BigDecimal multiply = new BigDecimal(priceList.get(i)[j]).multiply(new BigDecimal(adjustRatio.getString(i)).divide(new BigDecimal(100))); | |||
| BigDecimal price = new BigDecimal(priceList.get(i)[j]).add(multiply); | |||
| priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| }else if (ratioWayType.equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | |||
| BigDecimal price = new BigDecimal(priceList.get(i)[j]).add(new BigDecimal(adjustRatio.getString(i)).multiply(new BigDecimal(100))); | |||
| priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| }else if (ratioWayType.equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())) { | |||
| BigDecimal price = new BigDecimal(adjustRatio.getString(i)).multiply(new BigDecimal(100)); | |||
| priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| }else if (ratioWayType.equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())) { | |||
| BigDecimal price = new BigDecimal(priceList.get(i)[j]).multiply(new BigDecimal(adjustRatio.getString(i)).divide(new BigDecimal(100))); | |||
| priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } | |||
| priceList.add(priceArrs); | |||
| } | |||
| return priceList; | |||
| } | |||
| } | |||
| @@ -19,6 +19,7 @@ import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.helper.WxRentContractHelper; | |||
| import com.iformall.utils.*; | |||
| import org.apache.commons.collections.map.HashedMap; | |||
| import org.apache.commons.compress.utils.Lists; | |||
| @@ -1016,269 +1017,17 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return rentList; | |||
| } | |||
| //计算租金,每年-每个店铺租金 | |||
| public List<long[]> computePrice(String rentInfo, WxRentContract wxRentContract) { | |||
| JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | |||
| int arraySize = rentInfoArray.size(); | |||
| List<long[]> priceList = new ArrayList<>(); | |||
| //第一年 | |||
| long[] priceArr = new long[arraySize]; | |||
| for (int i = 0; i < arraySize; i++) { | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | |||
| String priceStr = rentInfoObject.getString("price"); | |||
| if (priceStr == null || priceStr.equalsIgnoreCase("NaN")) { | |||
| priceStr = "0"; | |||
| } | |||
| priceArr[i] = new BigDecimal(priceStr).multiply(new BigDecimal(100)).longValue(); | |||
| } | |||
| priceList.add(priceArr); //每个店铺每月租金 | |||
| //大于一年 | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(0); | |||
| JSONArray adjustRatio = rentInfoObject.getJSONArray("adjustRatio");//[100,200] | |||
| int adjustRatioSize = adjustRatio.size(); | |||
| //判断年租金调整方式 | |||
| if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.RATIO.getCode())) { | |||
| for (int i = 0; i < adjustRatioSize; i++) { | |||
| long[] priceArrs = new long[arraySize]; | |||
| for (int j = 0; j < arraySize; j++) { | |||
| rentInfoObject = rentInfoArray.getJSONObject(j); | |||
| adjustRatio = rentInfoObject.getJSONArray("adjustRatio"); | |||
| BigDecimal multiply = new BigDecimal(priceList.get(i)[j]).multiply(new BigDecimal(adjustRatio.getString(i)).divide(new BigDecimal(100))); | |||
| BigDecimal price = new BigDecimal(priceList.get(i)[j]).add(multiply); | |||
| priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| priceList.add(priceArrs); | |||
| } | |||
| return priceList; | |||
| } | |||
| if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | |||
| for (int i = 0; i < adjustRatioSize; i++) { | |||
| long[] priceArrs = new long[arraySize]; | |||
| for (int j = 0; j < arraySize; j++) { | |||
| rentInfoObject = rentInfoArray.getJSONObject(j); | |||
| adjustRatio = rentInfoObject.getJSONArray("adjustRatio"); | |||
| BigDecimal price = new BigDecimal(priceList.get(i)[j]).add(new BigDecimal(adjustRatio.getString(i)).multiply(new BigDecimal(100))); | |||
| priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| priceList.add(priceArrs); | |||
| } | |||
| return priceList; | |||
| } | |||
| if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())) { | |||
| for (int i = 0; i < adjustRatioSize; i++) { | |||
| long[] priceArrs = new long[arraySize]; | |||
| for (int j = 0; j < arraySize; j++) { | |||
| rentInfoObject = rentInfoArray.getJSONObject(j); | |||
| adjustRatio = rentInfoObject.getJSONArray("adjustRatio"); | |||
| BigDecimal price = new BigDecimal(adjustRatio.getString(i)).multiply(new BigDecimal(100)); | |||
| priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| priceList.add(priceArrs); | |||
| } | |||
| } | |||
| if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())) { | |||
| for (int i = 0; i < adjustRatioSize; i++) { | |||
| long[] priceArrs = new long[arraySize]; | |||
| for (int j = 0; j < arraySize; j++) { | |||
| rentInfoObject = rentInfoArray.getJSONObject(j); | |||
| adjustRatio = rentInfoObject.getJSONArray("adjustRatio"); | |||
| BigDecimal price = new BigDecimal(priceList.get(i)[j]).multiply(new BigDecimal(adjustRatio.getString(i)).divide(new BigDecimal(100))); | |||
| priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| priceList.add(priceArrs); | |||
| } | |||
| } | |||
| return priceList; | |||
| } | |||
| public List<WxBillRent> buildRentMonth(Long userId, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview, boolean saveDb) { | |||
| int size = 0; | |||
| long[] priceArrs = null; | |||
| List<Map<String, Object>> shopInfos = new ArrayList<>(); | |||
| 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_COUNT.getCode())) { | |||
| String rentInfo = wxRentContract.getRentInfo(); | |||
| JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | |||
| List<long[]> priceList = computePrice(rentInfo, wxRentContract); | |||
| size = priceList.size(); | |||
| priceArrs = new long[size]; | |||
| for (int i = 0; i < size; i++) { | |||
| long[] priceInt = priceList.get(i); | |||
| long sum = 0; | |||
| for (long p : priceInt) { | |||
| sum += p; | |||
| } | |||
| priceArrs[i] = sum; | |||
| } | |||
| for (int i = 0; i < size; i++) { | |||
| Map<String, Object> shopInfo = new HashMap<>(); | |||
| long[] ints = priceList.get(i); | |||
| for (int j = 0; j < ints.length; j++) { | |||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(j); | |||
| String s = new BigDecimal(ints[j]).divide(new BigDecimal(100)).toPlainString(); | |||
| shopInfo.put(rentInfoObject.getString("shopNumber"), s); | |||
| } | |||
| shopInfos.add(shopInfo); | |||
| } | |||
| } else { | |||
| String adjustRatio = wxRentContract.getAdjustRatio(); | |||
| List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class); | |||
| integers.add(0, 0); | |||
| size = integers.size(); | |||
| priceArrs = new long[size]; | |||
| priceArrs[0] = price; | |||
| BigDecimal priceD = new BigDecimal(price); | |||
| //联营保底营业额。 | |||
| String revenueYear = wxRentContract.getRevenueYear(); | |||
| List<Long> revenueYears = null; | |||
| if (!StringUtils.isBlank(revenueYear)) { | |||
| revenueYears = JSONArray.parseArray(revenueYear, Long.class); | |||
| }else { | |||
| revenueYears = new ArrayList<Long>(); | |||
| } | |||
| revenueYears.add(0,0L); | |||
| //联营面积取高时,联营扣点调整比率设置 | |||
| long[] revenuePriceArrs = new long[size]; | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | |||
| long _revenuePriceD = wxRentContract.getRevenue()*wxRentContract.getPayRatio()/10000; | |||
| 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(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } 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(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } else if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | |||
| for (int i = 1; i < size; i++) { | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | |||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)).multiply(new BigDecimal(12)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)).multiply(new BigDecimal(wxRentContract.getReceivePeriod())).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| } | |||
| revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| }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)); | |||
| } | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | |||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| revenuePriceArrs[i] = _p.multiply(new BigDecimal(12)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| revenuePriceArrs[i] = _p.multiply(new BigDecimal(wxRentContract.getReceivePeriod())).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| } | |||
| revenuePriceArrs[i] = _p.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } | |||
| } | |||
| 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(10000)); | |||
| priceD = priceD.add(divide); | |||
| priceArrs[i] = priceD.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | |||
| for (int i = 1; i < size; i++) { | |||
| priceD = priceD.add(new BigDecimal(integers.get(i))); | |||
| priceArrs[i] = priceD.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | |||
| for (int i = 1; i < size; i++) { | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | |||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| priceArrs[i] = new BigDecimal(integers.get(i)).multiply(new BigDecimal(12)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| priceArrs[i] = new BigDecimal(integers.get(i)).multiply(new BigDecimal(wxRentContract.getReceivePeriod())).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| } | |||
| priceArrs[i] = new BigDecimal(integers.get(i)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| }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)); | |||
| }else { | |||
| _p = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(10000)); | |||
| } | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | |||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| priceArrs[i] = _p.multiply(new BigDecimal(12)).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| priceArrs[i] = _p.multiply(new BigDecimal(wxRentContract.getReceivePeriod())).setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| continue; | |||
| } | |||
| } | |||
| priceArrs[i] = _p.setScale(0, RoundingMode.HALF_EVEN).longValue(); | |||
| } | |||
| } | |||
| //租金和联营取高 | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | |||
| for (int i = 0 ; i < priceArrs.length; i ++) { | |||
| if (priceArrs[i] < revenuePriceArrs[i]) { | |||
| priceArrs[i] = revenuePriceArrs[i]; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| //计算租金每年的计费基数 | |||
| long[] priceArrs = WxRentContractHelper.calcuteRentPrice(wxRentContract); | |||
| //计算商业管理费 | |||
| long[] bussinessManagerPriceArrs = WxRentContractHelper.calcuteBussinessManagementFee(wxRentContract); | |||
| //计算运营管理费 | |||
| long[] operationManagerPriceArrs = WxRentContractHelper.calcuteOperatingManagementFee(wxRentContract); | |||
| int month = 12; | |||
| // int divide = lease / month; | |||
| // int mod = lease % month; | |||
| // int[] leaseArr = new int[size]; | |||
| // for (int i = 0; i < divide; i++) { | |||
| // leaseArr[i] = month; | |||
| // } | |||
| // if (mod > 0) { | |||
| // leaseArr[divide] = mod; | |||
| // } | |||
| int billcount = 0; | |||
| List<WxBillRent> resultList = new ArrayList<>(); | |||
| @@ -1304,7 +1053,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| String shopInfoStr = getShopInfoStr(wxRentContract); | |||
| Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr,saveDb); | |||
| Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs,bussinessManagerPriceArrs,operationManagerPriceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr,saveDb); | |||
| List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList"); | |||
| resultList.addAll(billRentList); | |||
| return resultList; | |||
| @@ -1404,7 +1153,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| String shopInfoStr = getShopInfoStr(wxRentContract); | |||
| Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr,saveDb); | |||
| Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs,null,null, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr,saveDb); | |||
| List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList"); | |||
| resultList.addAll(billRentList); | |||
| return resultList; | |||
| @@ -1437,7 +1186,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| if(wxRentContract.getRentInputWay().equals(EnumRentContractRentInputWay.PART.getCode())){ | |||
| String rentInfo = wxRentContract.getRentInfo(); | |||
| JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | |||
| long[] priceList = computePrice(rentInfo, wxRentContract).get(0); | |||
| long[] priceList = WxRentContractHelper.computePrice(rentInfo, wxRentContract).get(0); | |||
| long sum = Arrays.stream(priceList).sum(); | |||
| int size = rentInfoArray.size(); | |||
| for (int i = 0;i < size;i++) { | |||
| @@ -1548,7 +1297,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return calendar.getTime(); | |||
| } | |||
| public Map<String, Object> buildRent(int receivePeriod, long[] priceArrs, List<Date> yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) { | |||
| public Map<String, Object> buildRent(int receivePeriod, long[] priceArrs,long[] bussinessManagerPriceArrs,long[] operationManagerPriceArrs, List<Date> yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) { | |||
| WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxRentContract); | |||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |||
| Map<String,Object> resultMap = new HashedMap(); | |||
| @@ -1581,6 +1330,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| long needpay = 0; | |||
| boolean flag = false; | |||
| Long bmpricePre = null; | |||
| Long bmPrce = null; | |||
| Long ompricePre = null; | |||
| Long omPrce = null; | |||
| //此处逻辑处理这一年和下一年交接那一期账单。 | |||
| if(yearList.size() > 1) { | |||
| if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { | |||
| @@ -1589,32 +1342,37 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| //logger.info("=====billTimeVo.getStartDate():"+sd.format(billTimeVo.getStartDate())+" endDate:"+sd.format(endDate)); | |||
| index++; | |||
| if (null != bussinessManagerPriceArrs && null != operationManagerPriceArrs) { | |||
| bmpricePre = bussinessManagerPriceArrs[index-1]; | |||
| bmPrce = bussinessManagerPriceArrs[index]; | |||
| ompricePre = operationManagerPriceArrs[index-1]; | |||
| omPrce = operationManagerPriceArrs[index]; | |||
| } | |||
| //如果是计算账单金额&cross 拆分日期进行计算 | |||
| if(billTimeVo.getEndDate().after(endDate)) { | |||
| long needpayFront = 0; | |||
| long needpayAfter = 0; | |||
| //同一天,算一天 | |||
| if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){ | |||
| needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false); | |||
| needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],bmpricePre,ompricePre,billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false); | |||
| }else{ | |||
| if(billTimeVo.getStartDate().before(endDate)){ | |||
| if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(wxRentContract.getType()) && EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | |||
| //设置跳点率为年周期 price不变 | |||
| needpayFront = priceArrs[index - 1]; | |||
| }else { | |||
| needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false); | |||
| needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false); | |||
| needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1],bmpricePre,ompricePre, billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false); | |||
| needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index],bmPrce,omPrce, endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false); | |||
| } | |||
| }else{ | |||
| //如果是按自然月,则这一年和下一年交叉部分需要重新计算 | |||
| if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { | |||
| Date currentYearRentDate = getCurrentYearRentDate(endDate,wxRentContract.getRentalStartDate()); | |||
| needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1], endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true); | |||
| needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index], currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true); | |||
| needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1],bmpricePre,ompricePre, endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true); | |||
| needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index],bmPrce,omPrce, currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true); | |||
| }else { | |||
| //按账单日 | |||
| needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod,false,false); | |||
| needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index],bmPrce,omPrce, billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod,false,false); | |||
| } | |||
| } | |||
| } | |||
| @@ -1634,7 +1392,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| //计算金额 | |||
| if(!flag){ | |||
| needpay = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false); | |||
| needpay = getNeedPayMoney(wxRentContract, priceArrs[index],bmPrce,omPrce, billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false); | |||
| } | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| @@ -1645,7 +1403,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| wxBillRent.setStarttime(billTimeVo.getStartDate()); | |||
| wxBillRent.setEndtime(billTimeVo.getEndDate()); | |||
| wxBillRent.setReceiveDate(billTimeVo.getReceiveDate()); | |||
| ```11111111 | |||
| wxBillRent.setContractNeedPay(needpay); | |||
| wxBillRent.setRentPriceInfo(getRentPriceInfo(wxRentContract,needpay)); | |||
| wxBillRent.setNeedPay(needpay); | |||
| @@ -1687,7 +1445,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return resultMap; | |||
| } | |||
| public long getNeedPayMoney(WxRentContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod,boolean part,boolean monthCalDay){ | |||
| public long getNeedPayMoney(WxRentContract wxRentContract,long price,long bussinessManageFee,long operatingManageFee,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod,boolean part,boolean monthCalDay){ | |||
| long needpay; | |||
| //按日 | |||
| if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ | |||
| @@ -2901,7 +2659,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| adjustRatioList.add(adjustRatioStr.toString()); | |||
| } | |||
| List<long[]> priceList = computePrice(rentInfo, wxRentContract); | |||
| List<long[]> priceList = WxRentContractHelper.computePrice(rentInfo, wxRentContract); | |||
| int size = priceList.size(); | |||
| priceArrs = new long[size]; | |||
| for (int i = 0; i < size; i++) { | |||
| @@ -117,6 +117,13 @@ | |||
| <result column="bus_discount_time" property="busDiscountTime"/> | |||
| <result column="end_contract_time" jdbcType="TIMESTAMP" property="endContractTime"/> | |||
| <result column="bussiness_management_fee" jdbcType="INTEGER" property="bussinessManagementFee"/> | |||
| <result column="bussiness_management_fee_ratio_way" jdbcType="INTEGER" property="bussinessManagementFeeRatioWay"/> | |||
| <result column="bussiness_management_fee_ratio" jdbcType="VARCHAR" property="bussinessManagementFeeRatio"/> | |||
| <result column="operating_management_fee" jdbcType="INTEGER" property="operatingManagementFee"/> | |||
| <result column="operating_management_fee_ratio_way" jdbcType="INTEGER" property="operatingManagementFeeRatioWay"/> | |||
| <result column="operating_management_fee_ratio" jdbcType="VARCHAR" property="operatingManagementFeeRatio"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| @@ -132,7 +139,9 @@ | |||
| `start_date`,`end_date`,`shop_name`,`from_id`,`end_contract_time`, | |||
| `apply_status`,`bank_name`,`rent_shop_type`,`fix_start_date`,`fix_end_date`, | |||
| `business_type`,`rent_info`, `file_names`,price_unit,rent_price,other_rent_price_info,`subject_name`,rent_start_type, | |||
| `rent_input_way`,`adjust_ratio_way`,`operation_type`,late_pay_ratio,late_pay_day,bus_discount_ratio,bus_discount_time | |||
| `rent_input_way`,`adjust_ratio_way`,`operation_type`,late_pay_ratio,late_pay_day,bus_discount_ratio,bus_discount_time, | |||
| bussiness_management_fee,bussiness_management_fee_ratio_way,bussiness_management_fee_ratio, | |||
| operating_management_fee,operating_management_fee_ratio_way,operating_management_fee_ratio | |||
| </sql> | |||
| @@ -499,7 +508,9 @@ | |||
| rc.`start_date`,rc.`end_date`,rc.`shop_name`,rc.`from_id`,`rc.end_contract_time`, | |||
| rc.`apply_status`,rc.`bank_name`,rc.`rent_shop_type`,rc.`fix_start_date`,rc.`fix_end_date`, | |||
| rc.`business_type`,rc.`rent_info`, rc.`file_names`,rc.price_unit,rent_price,rc.other_rent_price_info,rc.`subject_name`,rc.rent_start_type, | |||
| rc.`rent_input_way`,rc.`adjust_ratio_way`,rc.`operation_type`,rc.late_pay_ratio,rc.late_pay_day,rc.bus_discount_ratio,rc.bus_discount_time | |||
| rc.`rent_input_way`,rc.`adjust_ratio_way`,rc.`operation_type`,rc.late_pay_ratio,rc.late_pay_day,rc.bus_discount_ratio,rc.bus_discount_time, | |||
| rc.bussiness_management_fee,rc.bussiness_management_fee_ratio_way,rc.bussiness_management_fee_ratio, | |||
| rc.operating_management_fee,rc.operating_management_fee_ratio_way,rc.operating_management_fee_ratio | |||
| from wx_shop s | |||
| left join wx_merchant_shop ms on ms.shop_id=s.id and ms.is_del=0 | |||
| left join wx_merchant m on ms.merchant_id=m.id | |||
| @@ -524,7 +535,9 @@ | |||
| rc.`start_date`,rc.`end_date`,rc.`shop_name`,rc.`from_id`,rc.`end_contract_time`, | |||
| rc.`apply_status`,rc.`bank_name`,rc.`rent_shop_type`,rc.`fix_start_date`,rc.`fix_end_date`, | |||
| rc.`business_type`,rc.`rent_info`, rc.`file_names`,rc.price_unit,rent_price,rc.other_rent_price_info,rc.`subject_name`,rc.rent_start_type, | |||
| rc.`rent_input_way`,rc.`adjust_ratio_way`,rc.`operation_type`,rc.late_pay_ratio,rc.late_pay_day,rc.bus_discount_ratio,rc.bus_discount_time | |||
| rc.`rent_input_way`,rc.`adjust_ratio_way`,rc.`operation_type`,rc.late_pay_ratio,rc.late_pay_day,rc.bus_discount_ratio,rc.bus_discount_time, | |||
| rc.bussiness_management_fee,rc.bussiness_management_fee_ratio_way,rc.bussiness_management_fee_ratio, | |||
| rc.operating_management_fee,rc.operating_management_fee_ratio_way,rc.operating_management_fee_ratio | |||
| from wx_rent_contract rc | |||
| where rc.is_del = 0 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||