From a664b8892c02cab67d1f172f17f0c4d208b40abd Mon Sep 17 00:00:00 2001 From: gongbiao Date: Tue, 11 Jun 2019 18:09:05 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=A7=9F=E8=B5=81=E5=90=88=E5=90=8C][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][=E7=A7=9F=E8=B5=81=E5=BD=95=E5=85=A5?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E5=8F=8A=E5=B9=B4=E7=A7=9F=E9=87=91=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E6=96=B9=E5=BC=8F]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/domain/po/WxRentContract.java | 6 +++ .../enums/EnumRentContractAdjustRatioWay.java | 37 +++++++++++++++++ .../enums/EnumRentContractRentInputWay.java | 37 +++++++++++++++++ .../impl/WxRentContractServiceImpl.java | 41 +++++++++++++------ .../resources/mapper/WxRentContractMapper.xml | 11 +++-- 5 files changed, 116 insertions(+), 16 deletions(-) create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumRentContractAdjustRatioWay.java create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumRentContractRentInputWay.java diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java index 739ff60f1..47c51032a 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java @@ -220,6 +220,12 @@ public class WxRentContract extends BaseEntity { @io.swagger.annotations.ApiModelProperty(value = "1按租赁日生产2按计租日生成账单", name = "rentStartType") private Integer rentStartType; + @io.swagger.annotations.ApiModelProperty(value = "租金录入方式1合铺录入2分铺录入", name = "rent_input_way") + private Integer rentInputWay; + + @io.swagger.annotations.ApiModelProperty(value = "年租金调整方式1按比例2按金额", name = "adjust_ratio_way") + private Integer adjustRatioWay; + // public Integer getAdjustPeriod() { // if(EnumPriceUnit.D.getCode().equals(this.getPriceUnit()) && EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode().equals(adjustPeriod)){ // return EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode(); diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumRentContractAdjustRatioWay.java b/mallinkService/src/main/java/com/iformall/enums/EnumRentContractAdjustRatioWay.java new file mode 100644 index 000000000..c3ce1bcd1 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumRentContractAdjustRatioWay.java @@ -0,0 +1,37 @@ +package com.iformall.enums; + + +/** + * @author gongbiao + */ + +public enum EnumRentContractAdjustRatioWay { + + RATIO(1, "按比例"), + MONEY(2, "按金额"),; + + public static EnumRentContractAdjustRatioWay getEnum(Integer code) { + for (EnumRentContractAdjustRatioWay value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumRentContractAdjustRatioWay(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumRentContractRentInputWay.java b/mallinkService/src/main/java/com/iformall/enums/EnumRentContractRentInputWay.java new file mode 100644 index 000000000..083678f64 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumRentContractRentInputWay.java @@ -0,0 +1,37 @@ +package com.iformall.enums; + + +/** + * @author gongbiao + */ + +public enum EnumRentContractRentInputWay { + + WHOLE(1, "合铺录入"), + PART(2, "分铺录入"),; + + public static EnumRentContractRentInputWay getEnum(Integer code) { + for (EnumRentContractRentInputWay value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumRentContractRentInputWay(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} 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 c0db34182..27b74e22b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -761,7 +761,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { } //计算租金,每年-每个店铺租金 - public List computePrice(String rentInfo,Integer priceUnit) { + public List computePrice(String rentInfo, WxRentContract wxRentContract) { JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); int arraySize = rentInfoArray.size(); @@ -777,18 +777,32 @@ public class WxRentContractServiceImpl implements WxRentContractService { JSONObject rentInfoObject = rentInfoArray.getJSONObject(0); JSONArray adjustRatio = rentInfoObject.getJSONArray("adjustRatio"); int adjustRatioSize = adjustRatio.size(); - - 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(); + //判断年租金调整方式 + 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); + } + } else { + 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))); + priceArrs[j] = price.setScale(0, RoundingMode.HALF_EVEN).longValue(); + } + priceList.add(priceArrs); } - priceList.add(priceArrs); } + return priceList; } @@ -797,10 +811,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { long[] priceArrs = null; List> shopInfos = new ArrayList<>(); if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode()) && + wxRentContract.getRentInputWay().equals(EnumRentContractRentInputWay.PART.getCode()) && !wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { String rentInfo = wxRentContract.getRentInfo(); JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); - List priceList = computePrice(rentInfo,wxRentContract.getPriceUnit()); + List priceList = computePrice(rentInfo, wxRentContract); size = priceList.size(); priceArrs = new long[size]; for (int i = 0; i < size; i++) { @@ -1693,7 +1708,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { } adjustRatioList.add(adjustRatioStr.toString()); } - List priceList = computePrice(rentInfo,wxRentContract.getPriceUnit()); + List priceList = computePrice(rentInfo, wxRentContract); int size = priceList.size(); priceArrs = new long[size]; for (int i = 0; i < size; i++) { diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 089abc2d5..aa31e9a19 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -48,7 +48,10 @@ - + + + + @@ -58,7 +61,8 @@ `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio`, `start_date`,`end_date`, `apply_status`,`bank_name`,`rent_shop_type`,`fix_start_date`,`fix_end_date`, - `business_type`,`rent_info`, `file_names`,price_unit,rent_price,`subject_name`,rent_start_type + `business_type`,`rent_info`, `file_names`,price_unit,rent_price,`subject_name`,rent_start_type, + `rent_input_way`,`adjust_ratio_way` @@ -118,7 +122,8 @@ rc.start_date startDate,rc.end_date endDate,br.`name` brandName,rc.apply_status applyStatus,rc.bank_name bankName,rc.rent_shop_type rentShopType,rc.fix_start_date fixStartDate,rc.fix_end_date fixEndDate ,rc.business_type businessType,rc.adjust_period adjustPeriod,rc.rent_info rentInfo, rc.file_names - fileNames,rc.price_unit,rc.subject_name subjectName + fileNames,rc.price_unit,rc.subject_name subjectName,rc.`rent_input_way` rentInputWay,rc.`adjust_ratio_way` + adjustRatioWay from wx_rent_contract rc left join wx_shop s on rc.shop_id=s.id left join wx_mall_floor f on s.floor=f.id