| @@ -207,7 +207,7 @@ public class WxRentContractController extends WxContractBaseController { | |||||
| MallUserInfo user = getUser(); | MallUserInfo user = getUser(); | ||||
| wxRentContract.updateTenantInfo(user); | wxRentContract.updateTenantInfo(user); | ||||
| wxRentContract.setAdjustPeriodHandle(); | wxRentContract.setAdjustPeriodHandle(); | ||||
| wxRentContract.setRentPriceHandle(); | |||||
| //wxRentContract.setRentPriceHandle(); | |||||
| Date oldDate = wxRentContract.getRentalStartDate(); | Date oldDate = wxRentContract.getRentalStartDate(); | ||||
| if(wxRentContract.getRentStartType()!=null &&wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | if(wxRentContract.getRentStartType()!=null &&wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | ||||
| wxRentContract.setRentalStartDate(wxRentContract.getStartDate()); | wxRentContract.setRentalStartDate(wxRentContract.getStartDate()); | ||||
| @@ -230,7 +230,7 @@ public class WxRentContractController extends WxContractBaseController { | |||||
| MallUserInfo user = getUser(); | MallUserInfo user = getUser(); | ||||
| wxRentContract.updateTenantInfo(user); | wxRentContract.updateTenantInfo(user); | ||||
| wxRentContract.setAdjustPeriodHandle(); | wxRentContract.setAdjustPeriodHandle(); | ||||
| wxRentContract.setRentPriceHandle(); | |||||
| //wxRentContract.setRentPriceHandle(); | |||||
| Date oldDate = wxRentContract.getRentalStartDate(); | Date oldDate = wxRentContract.getRentalStartDate(); | ||||
| if(wxRentContract.getRentStartType()!=null && wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | if(wxRentContract.getRentStartType()!=null && wxRentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | ||||
| wxRentContract.setRentalStartDate(wxRentContract.getStartDate()); | wxRentContract.setRentalStartDate(wxRentContract.getStartDate()); | ||||
| @@ -277,7 +277,7 @@ public class WxRentContractController extends WxContractBaseController { | |||||
| MallUserInfo user = getUser(); | MallUserInfo user = getUser(); | ||||
| rentContract.updateTenantInfo(user); | rentContract.updateTenantInfo(user); | ||||
| rentContract.setAdjustPeriodHandle(); | rentContract.setAdjustPeriodHandle(); | ||||
| rentContract.setRentPriceHandle(); | |||||
| //rentContract.setRentPriceHandle(); | |||||
| Date oldDate = rentContract.getRentalStartDate(); | Date oldDate = rentContract.getRentalStartDate(); | ||||
| if(rentContract.getRentStartType()!=null && rentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | if(rentContract.getRentStartType()!=null && rentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | ||||
| rentContract.setRentalStartDate(rentContract.getStartDate()); | rentContract.setRentalStartDate(rentContract.getStartDate()); | ||||
| @@ -165,27 +165,27 @@ public class WxSettleMerchantController extends BaseController { | |||||
| if (null == rpage || null == rpage.getList() || rpage.getList().size() <= 0 ) { | if (null == rpage || null == rpage.getList() || rpage.getList().size() <= 0 ) { | ||||
| return new ResultData(Result.ERROR,"租金合同无对应账单"); | return new ResultData(Result.ERROR,"租金合同无对应账单"); | ||||
| } | } | ||||
| Long all = 0L; | |||||
| BigDecimal all = new BigDecimal(0); | |||||
| List<WxBillRent> blist = rpage.getList(); | List<WxBillRent> blist = rpage.getList(); | ||||
| for (int i = 0 ; i < blist.size() ; i ++) { | for (int i = 0 ; i < blist.size() ; i ++) { | ||||
| WxBillRent r = blist.get(i); | WxBillRent r = blist.get(i); | ||||
| Long _np = 0L; | |||||
| BigDecimal _np = new BigDecimal(0); | |||||
| if (null != r.getNeedPay()) { | if (null != r.getNeedPay()) { | ||||
| _np = r.getNeedPay(); | |||||
| _np = new BigDecimal(r.getNeedPay()); | |||||
| } | } | ||||
| Long _bmf = 0L; | |||||
| BigDecimal _bmf = new BigDecimal(0); | |||||
| if (null != r.getBussinessManageFeeNeedPay()) { | if (null != r.getBussinessManageFeeNeedPay()) { | ||||
| _bmf = r.getBussinessManageFeeNeedPay(); | |||||
| _bmf = new BigDecimal(r.getBussinessManageFeeNeedPay()); | |||||
| } | } | ||||
| Long _omf = 0L; | |||||
| BigDecimal _omf = new BigDecimal(0); | |||||
| if (null != r.getOperatingManageFeeNeedPay()) { | if (null != r.getOperatingManageFeeNeedPay()) { | ||||
| _omf = r.getOperatingManageFeeNeedPay(); | |||||
| _omf = new BigDecimal(r.getOperatingManageFeeNeedPay()); | |||||
| } | } | ||||
| all = all + _np + _bmf + _omf; | |||||
| all = all.add(_np).add(_bmf).add(_omf); | |||||
| } | } | ||||
| Map retMap = new HashMap(); | Map retMap = new HashMap(); | ||||
| retMap.put("rent", rent); | retMap.put("rent", rent); | ||||
| retMap.put("money", new BigDecimal(all).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP)); | |||||
| retMap.put("money", all.toPlainString()); | |||||
| return new ResultData(retMap); | return new ResultData(retMap); | ||||
| } | } | ||||
| @@ -16,7 +16,7 @@ ALTER TABLE wx_bill_rent MODIFY COLUMN `revenue` VARCHAR(30); | |||||
| ALTER TABLE wx_bill_rent MODIFY COLUMN `late_pay_price` VARCHAR(30); | ALTER TABLE wx_bill_rent MODIFY COLUMN `late_pay_price` VARCHAR(30); | ||||
| ALTER TABLE wx_bill_rent MODIFY COLUMN `join_rent_price` VARCHAR(30); | ALTER TABLE wx_bill_rent MODIFY COLUMN `join_rent_price` VARCHAR(30); | ||||
| ALTER TABLE wx_bill_rent MODIFY COLUMN `service_charge_pay` VARCHAR(30); | ALTER TABLE wx_bill_rent MODIFY COLUMN `service_charge_pay` VARCHAR(30); | ||||
| ALTER TABLE wx_bill_rent MODIFY COLUMN `service_charge_pay` VARCHAR(30); | |||||
| ALTER TABLE wx_bill_rent MODIFY COLUMN `contract_need_pay` VARCHAR(30); | |||||
| ALTER TABLE wx_bill_rent_deposit MODIFY COLUMN `receive_pay` VARCHAR(30); | ALTER TABLE wx_bill_rent_deposit MODIFY COLUMN `receive_pay` VARCHAR(30); | ||||
| @@ -96,11 +96,12 @@ public class WxBillRent extends TenantEntity { | |||||
| private Integer isDel; | private Integer isDel; | ||||
| @io.swagger.annotations.ApiModelProperty(value="原合同应收金额",name="contractNeedPay") | @io.swagger.annotations.ApiModelProperty(value="原合同应收金额",name="contractNeedPay") | ||||
| private Long contractNeedPay; | |||||
| @Excel(name = "原合同应收金额(元)", width = 20, orderNum = "6") | @Excel(name = "原合同应收金额(元)", width = 20, orderNum = "6") | ||||
| @TableField(exist = false) | |||||
| private String contractNeedPayStr; | |||||
| private String contractNeedPay; | |||||
| // @TableField(exist = false) | |||||
| // private String contractNeedPayStr; | |||||
| // public String getContractNeedPayStr() { | // public String getContractNeedPayStr() { | ||||
| // return new BigDecimal(contractNeedPay == null ? 0 : contractNeedPay).divide(new BigDecimal(100)).toPlainString(); | // return new BigDecimal(contractNeedPay == null ? 0 : contractNeedPay).divide(new BigDecimal(100)).toPlainString(); | ||||
| @@ -351,8 +351,8 @@ public class WxRentContract extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "审批时带的物业合同编号,租金+物业时用", name = "propertyId") | @io.swagger.annotations.ApiModelProperty(value = "审批时带的物业合同编号,租金+物业时用", name = "propertyId") | ||||
| private Long propertyId; | private Long propertyId; | ||||
| // @io.swagger.annotations.ApiModelProperty(value = "租金信息", name = "rentInfo") | |||||
| // private String rentInfo; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "租金信息", name = "rentInfo") | |||||
| private String rentInfo; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "上传文件名", name = "fileNames") | @io.swagger.annotations.ApiModelProperty(value = "上传文件名", name = "fileNames") | ||||
| private String fileNames; | private String fileNames; | ||||
| @@ -62,7 +62,7 @@ public class WxRentContractHelper { | |||||
| if (rentArea == null || rentArea.equalsIgnoreCase("NaN")) { | if (rentArea == null || rentArea.equalsIgnoreCase("NaN")) { | ||||
| rentArea = "0"; | rentArea = "0"; | ||||
| } | } | ||||
| priceArr[i] = new BigDecimal(priceStr).multiply(new BigDecimal(rentArea)).toPlainString(); | |||||
| priceArr[i] = new BigDecimal(priceStr).multiply(new BigDecimal(rentArea)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| List<String[]> priceList = computeRatioByShop(wxRentContract.getDecimalSize(),rentInfoArray,wxRentContract.getBussinessManagementFeeRatioWay(),priceArr,feeRatioField); | List<String[]> priceList = computeRatioByShop(wxRentContract.getDecimalSize(),rentInfoArray,wxRentContract.getBussinessManagementFeeRatioWay(),priceArr,feeRatioField); | ||||
| @@ -79,7 +79,7 @@ public class WxRentContractHelper { | |||||
| if (rentArea == null || rentArea.equalsIgnoreCase("NaN")) { | if (rentArea == null || rentArea.equalsIgnoreCase("NaN")) { | ||||
| rentArea = "0"; | rentArea = "0"; | ||||
| } | } | ||||
| String ratioFirstYearPrice = new BigDecimal(fee).multiply(new BigDecimal(rentArea)).toPlainString(); | |||||
| String ratioFirstYearPrice = new BigDecimal(fee).multiply(new BigDecimal(rentArea)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| return calcuteRatioByJoin(wxRentContract.getDecimalSize(),ratioWay, ratio, ratioFirstYearPrice); | return calcuteRatioByJoin(wxRentContract.getDecimalSize(),ratioWay, ratio, ratioFirstYearPrice); | ||||
| } | } | ||||
| } | } | ||||
| @@ -145,28 +145,28 @@ public class WxRentContractHelper { | |||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| BigDecimal divide = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(10000)); | BigDecimal divide = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(10000)); | ||||
| priceD = priceD.add(divide); | priceD = priceD.add(divide); | ||||
| priceArrs[i] = priceD.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[i] = priceD.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | } else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | ||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| priceD = priceD.add(new BigDecimal(integers.get(i))); | priceD = priceD.add(new BigDecimal(integers.get(i))); | ||||
| priceArrs[i] = priceD.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[i] = priceD.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | } else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | ||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | ||||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | ||||
| priceArrs[i] = new BigDecimal(integers.get(i)).multiply(new BigDecimal(12)) | priceArrs[i] = new BigDecimal(integers.get(i)).multiply(new BigDecimal(12)) | ||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| continue; | continue; | ||||
| } | } | ||||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | ||||
| priceArrs[i] = new BigDecimal(integers.get(i)).multiply(new BigDecimal(wxRentContract.getReceivePeriod())) | priceArrs[i] = new BigDecimal(integers.get(i)).multiply(new BigDecimal(wxRentContract.getReceivePeriod())) | ||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| priceArrs[i] = new BigDecimal(integers.get(i)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[i] = new BigDecimal(integers.get(i)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| }else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())){ | }else if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())){ | ||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| @@ -179,16 +179,16 @@ public class WxRentContractHelper { | |||||
| } | } | ||||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | ||||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | ||||
| priceArrs[i] = _p.multiply(new BigDecimal(12)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[i] = _p.multiply(new BigDecimal(12)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| continue; | continue; | ||||
| } | } | ||||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | ||||
| priceArrs[i] = _p.multiply(new BigDecimal(wxRentContract.getReceivePeriod())) | priceArrs[i] = _p.multiply(new BigDecimal(wxRentContract.getReceivePeriod())) | ||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| priceArrs[i] = _p.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[i] = _p.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -210,7 +210,7 @@ public class WxRentContractHelper { | |||||
| String[] revenuePriceArrs = new String[size]; | String[] revenuePriceArrs = new String[size]; | ||||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode())) { | ||||
| String _revenuePriceD = new BigDecimal(wxRentContract.getRevenue()).multiply(new BigDecimal(wxRentContract.getPayRatio())) | String _revenuePriceD = new BigDecimal(wxRentContract.getRevenue()).multiply(new BigDecimal(wxRentContract.getPayRatio())) | ||||
| .divide(new BigDecimal(100)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| .divide(new BigDecimal(100)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| revenuePriceArrs[0] = _revenuePriceD; | revenuePriceArrs[0] = _revenuePriceD; | ||||
| BigDecimal revenuePriceD = new BigDecimal(_revenuePriceD); | BigDecimal revenuePriceD = new BigDecimal(_revenuePriceD); | ||||
| //联营扣点调整比率 | //联营扣点调整比率 | ||||
| @@ -230,31 +230,31 @@ public class WxRentContractHelper { | |||||
| BigDecimal _p = new BigDecimal(revenueYears.get(i)).multiply(new BigDecimal(revenueRationSets.get(i))).divide(new BigDecimal(10000)); | BigDecimal _p = new BigDecimal(revenueYears.get(i)).multiply(new BigDecimal(revenueRationSets.get(i))).divide(new BigDecimal(10000)); | ||||
| revenuePriceD = revenuePriceD.add(_p); | revenuePriceD = revenuePriceD.add(_p); | ||||
| } | } | ||||
| revenuePriceArrs[i] = revenuePriceD.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| revenuePriceArrs[i] = revenuePriceD.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } else if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | } else if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | ||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| if (revenueYears.size() == size && revenueRationSets.size() == size) { | if (revenueYears.size() == size && revenueRationSets.size() == size) { | ||||
| revenuePriceD = revenuePriceD.add(new BigDecimal(revenueRationSets.get(i))); | revenuePriceD = revenuePriceD.add(new BigDecimal(revenueRationSets.get(i))); | ||||
| } | } | ||||
| revenuePriceArrs[i] = revenuePriceD.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| revenuePriceArrs[i] = revenuePriceD.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } else if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | } else if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | ||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | ||||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | ||||
| revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)).multiply(new BigDecimal(12)) | revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)).multiply(new BigDecimal(12)) | ||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| continue; | continue; | ||||
| } | } | ||||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | ||||
| revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)).multiply(new BigDecimal(wxRentContract.getReceivePeriod())) | revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)).multiply(new BigDecimal(wxRentContract.getReceivePeriod())) | ||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)) | revenuePriceArrs[i] = new BigDecimal(revenueRationSets.get(i)) | ||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| }else if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())){ | }else if (wxRentContract.getRevenueRatioWay().equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())){ | ||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| @@ -265,16 +265,16 @@ public class WxRentContractHelper { | |||||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { | ||||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | ||||
| revenuePriceArrs[i] = _p.multiply(new BigDecimal(12)) | revenuePriceArrs[i] = _p.multiply(new BigDecimal(12)) | ||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| continue; | continue; | ||||
| } | } | ||||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | ||||
| revenuePriceArrs[i] = _p.multiply(new BigDecimal(wxRentContract.getReceivePeriod())) | revenuePriceArrs[i] = _p.multiply(new BigDecimal(wxRentContract.getReceivePeriod())) | ||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| revenuePriceArrs[i] = _p.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString(); | |||||
| revenuePriceArrs[i] = _p.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -295,21 +295,21 @@ public class WxRentContractHelper { | |||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| BigDecimal divide = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(100)); | BigDecimal divide = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(100)); | ||||
| priceD = priceD.add(divide); | priceD = priceD.add(divide); | ||||
| priceArrs[i] = priceD.setScale(decimalSize, RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[i] = priceD.setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } else if (ratioWay.equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | } else if (ratioWay.equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | ||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| priceD = priceD.add(new BigDecimal(integers.get(i))); | priceD = priceD.add(new BigDecimal(integers.get(i))); | ||||
| priceArrs[i] = priceD.setScale(decimalSize, RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[i] = priceD.setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } else if (ratioWay.equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | } else if (ratioWay.equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())){ | ||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| priceArrs[i] = new BigDecimal(integers.get(i)).setScale(decimalSize, RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[i] = new BigDecimal(integers.get(i)).setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| }else if (ratioWay.equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())){ | }else if (ratioWay.equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())){ | ||||
| for (int i = 1; i < size; i++) { | for (int i = 1; i < size; i++) { | ||||
| BigDecimal _p = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(100)); | BigDecimal _p = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(100)); | ||||
| priceArrs[i] = _p.setScale(decimalSize, RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[i] = _p.setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } | } | ||||
| return priceArrs; | return priceArrs; | ||||
| @@ -356,16 +356,16 @@ public class WxRentContractHelper { | |||||
| if (ratioWayType.equals(EnumRentContractAdjustRatioWay.RATIO.getCode())) { | 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 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); | BigDecimal price = new BigDecimal(priceList.get(i)[j]).add(multiply); | ||||
| priceArrs[j] = price.setScale(decimalSize, RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[j] = price.setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | |||||
| }else if (ratioWayType.equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) { | }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))); | BigDecimal price = new BigDecimal(priceList.get(i)[j]).add(new BigDecimal(adjustRatio.getString(i)).multiply(new BigDecimal(100))); | ||||
| priceArrs[j] = price.setScale(decimalSize, RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[j] = price.setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | |||||
| }else if (ratioWayType.equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())) { | }else if (ratioWayType.equals(EnumRentContractAdjustRatioWay.CUSTOM.getCode())) { | ||||
| BigDecimal price = new BigDecimal(adjustRatio.getString(i)).multiply(new BigDecimal(100)); | BigDecimal price = new BigDecimal(adjustRatio.getString(i)).multiply(new BigDecimal(100)); | ||||
| priceArrs[j] = price.setScale(decimalSize, RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[j] = price.setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | |||||
| }else if (ratioWayType.equals(EnumRentContractAdjustRatioWay.FIX_RATIO.getCode())) { | }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))); | BigDecimal price = new BigDecimal(priceList.get(i)[j]).multiply(new BigDecimal(adjustRatio.getString(i)).divide(new BigDecimal(100))); | ||||
| priceArrs[j] = price.setScale(decimalSize, RoundingMode.HALF_EVEN).toPlainString(); | |||||
| priceArrs[j] = price.setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } | } | ||||
| priceList.add(priceArrs); | priceList.add(priceArrs); | ||||
| @@ -374,31 +374,31 @@ public class WxRentContractHelper { | |||||
| } | } | ||||
| //查询月账单需要支付的金额 | //查询月账单需要支付的金额 | ||||
| public static long getNeedPayMoney(WxRentContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod,boolean part,boolean monthCalDay){ | |||||
| long needpay; | |||||
| public static String getNeedPayMoney(WxRentContract wxRentContract,String price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod,boolean part,boolean monthCalDay){ | |||||
| String needpay; | |||||
| //按日 | //按日 | ||||
| if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ | if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ | ||||
| Double priceD = new Double(price); | |||||
| double needpayD = WxRentContractHelper.getNeedPay(0,priceD,startDate,endDate); | |||||
| BigDecimal priceD = new BigDecimal(price); | |||||
| String needpayD = WxRentContractHelper.getNeedPay(wxRentContract.getDecimalSize(),new BigDecimal(0),priceD,startDate,endDate); | |||||
| //取整 | //取整 | ||||
| //needpay = new Double(needpayD).longValue(); | //needpay = new Double(needpayD).longValue(); | ||||
| //四舍五入 | //四舍五入 | ||||
| needpay = new BigDecimal(needpayD).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| needpay = new BigDecimal(needpayD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| }else{ | }else{ | ||||
| Double priceD = new Double(price); | |||||
| BigDecimal priceD = new BigDecimal(price); | |||||
| if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(wxRentContract.getType())) { | if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(wxRentContract.getType())) { | ||||
| //设置跳点率为年周期 price不变 | //设置跳点率为年周期 price不变 | ||||
| if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | if (EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { | ||||
| return priceD.longValue(); | |||||
| return priceD.toPlainString(); | |||||
| } | } | ||||
| //年或者设置跳点率为年周期 除12 | //年或者设置跳点率为年周期 除12 | ||||
| if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | if (EnumMissTimeType.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())) { | ||||
| priceD = new Double(price) / 12; | |||||
| priceD = new BigDecimal(price).divide(new BigDecimal(12),wxRentContract.getDecimalSize(),RoundingMode.HALF_UP).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP); | |||||
| } | } | ||||
| }else{ | }else{ | ||||
| //年 除12 | //年 除12 | ||||
| if(EnumPriceUnit.Y.getCode().equals(wxRentContract.getPriceUnit())){ | if(EnumPriceUnit.Y.getCode().equals(wxRentContract.getPriceUnit())){ | ||||
| priceD = new Double(price)/12; | |||||
| priceD = new BigDecimal(price).divide(new BigDecimal(12),wxRentContract.getDecimalSize(),RoundingMode.HALF_UP).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP); | |||||
| } | } | ||||
| } | } | ||||
| @@ -406,7 +406,7 @@ public class WxRentContractHelper { | |||||
| //生成金额直接计算 | //生成金额直接计算 | ||||
| if(!saveDb){ | if(!saveDb){ | ||||
| //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,part)).longValue(); | //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,part)).longValue(); | ||||
| needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,part)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| needpay = new BigDecimal(getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,part)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| return needpay; | return needpay; | ||||
| } | } | ||||
| @@ -421,20 +421,22 @@ public class WxRentContractHelper { | |||||
| instance.add(Calendar.DATE, -1); | instance.add(Calendar.DATE, -1); | ||||
| if(sd.format(instance.getTime()).equals(sd.format(endDate))){ | if(sd.format(instance.getTime()).equals(sd.format(endDate))){ | ||||
| int months = WxRentContractHelper.getMonths(sdM.format(startDate)+"-01",sdM.format(DateUtils.getDaySet(endDate,Calendar.DATE,1))+"-01"); | int months = WxRentContractHelper.getMonths(sdM.format(startDate)+"-01",sdM.format(DateUtils.getDaySet(endDate,Calendar.DATE,1))+"-01"); | ||||
| needpay = new Double(months * priceD).longValue(); | |||||
| needpay = new BigDecimal(months).multiply(priceD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| }else{ | }else{ | ||||
| //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); | //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); | ||||
| needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| needpay = new BigDecimal(getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false)) | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| }else if(i == 0){//第一期 | }else if(i == 0){//第一期 | ||||
| if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ | if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ | ||||
| if(isFirstDay(startDate)){ | if(isFirstDay(startDate)){ | ||||
| int months = WxRentContractHelper.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); | int months = WxRentContractHelper.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); | ||||
| months++; | months++; | ||||
| needpay = new Double(months * priceD).longValue(); | |||||
| needpay = new BigDecimal(months).multiply(priceD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| }else{ | }else{ | ||||
| //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); | //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); | ||||
| needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| needpay = new BigDecimal(getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false)) | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| }else{ | }else{ | ||||
| if(isFirstDay(startDate)){ | if(isFirstDay(startDate)){ | ||||
| @@ -442,10 +444,11 @@ public class WxRentContractHelper { | |||||
| if(isFirstDay(startDate)){ | if(isFirstDay(startDate)){ | ||||
| months++; | months++; | ||||
| } | } | ||||
| needpay = new Double(months * priceD).longValue(); | |||||
| needpay = new BigDecimal(months).multiply(priceD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| }else{ | }else{ | ||||
| //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); | //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); | ||||
| needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| needpay = new BigDecimal(getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false)) | |||||
| .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } | } | ||||
| }else{//中间 | }else{//中间 | ||||
| @@ -456,9 +459,10 @@ public class WxRentContractHelper { | |||||
| //如果当月费用需要按天计算 | //如果当月费用需要按天计算 | ||||
| if (monthCalDay) { | if (monthCalDay) { | ||||
| //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); | //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); | ||||
| needpay = new BigDecimal(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).setScale(0, BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| needpay = new BigDecimal(getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false)) | |||||
| .setScale(wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP).toPlainString(); | |||||
| }else { | }else { | ||||
| needpay = new Double(months * priceD).longValue(); | |||||
| needpay = new BigDecimal(months).multiply(priceD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -481,17 +485,17 @@ public class WxRentContractHelper { | |||||
| * @param end | * @param end | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| public static double getMonthNeedPay(Double price,Date start,Date end,int dayType,int receivePeriod,boolean part){ | |||||
| public static String getMonthNeedPay(Integer decimalSize,BigDecimal price,Date start,Date end,int dayType,int receivePeriod,boolean part){ | |||||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | ||||
| SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); | SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); | ||||
| SimpleDateFormat sdD = new SimpleDateFormat("d"); | SimpleDateFormat sdD = new SimpleDateFormat("d"); | ||||
| Double total = new Double(0); | |||||
| BigDecimal total = new BigDecimal(0); | |||||
| int[] diff; | int[] diff; | ||||
| //同一天 | //同一天 | ||||
| if(sd.format(start).equals(sd.format(end))){ | if(sd.format(start).equals(sd.format(end))){ | ||||
| int dayCount = DateUtils.getMonthDayCount(start); | int dayCount = DateUtils.getMonthDayCount(start); | ||||
| return 1 * (price/dayCount); | |||||
| return price.divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP).toPlainString(); | |||||
| } | } | ||||
| //同月 | //同月 | ||||
| @@ -499,8 +503,8 @@ public class WxRentContractHelper { | |||||
| diff = DateUtils.getDiff(start,end); | diff = DateUtils.getDiff(start,end); | ||||
| int dayCount = DateUtils.getMonthDayCount(start); | int dayCount = DateUtils.getMonthDayCount(start); | ||||
| total += (diff[1]+1) * (price/dayCount); | |||||
| return total; | |||||
| total = total.add(new BigDecimal((diff[1]+1)).multiply(price).divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP)); | |||||
| return total.toPlainString(); | |||||
| } | } | ||||
| //判断是否满足整月 | //判断是否满足整月 | ||||
| @@ -523,25 +527,25 @@ public class WxRentContractHelper { | |||||
| if(isFullMonth){ | if(isFullMonth){ | ||||
| int months = getMonths(sdM.format(start)+"-01",sdM.format(DateUtils.getDaySet(end,Calendar.DATE,1))+"-01"); | int months = getMonths(sdM.format(start)+"-01",sdM.format(DateUtils.getDaySet(end,Calendar.DATE,1))+"-01"); | ||||
| return (months) * price; | |||||
| return new BigDecimal(months).multiply(price).setScale(decimalSize, RoundingMode.HALF_UP).toPlainString(); | |||||
| } | } | ||||
| //第一个月 | //第一个月 | ||||
| Date lastMonthDay = DateUtils.getLastDayForMonth(start); | Date lastMonthDay = DateUtils.getLastDayForMonth(start); | ||||
| diff = DateUtils.getDiff(start,lastMonthDay); | diff = DateUtils.getDiff(start,lastMonthDay); | ||||
| int dayCount = DateUtils.getMonthDayCount(start); | int dayCount = DateUtils.getMonthDayCount(start); | ||||
| total += (diff[1]+1) * (price/dayCount); | |||||
| total = total.add(new BigDecimal((diff[1]+1)).multiply(price).divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP)); | |||||
| //中间月份 | //中间月份 | ||||
| Date newStartDate = DateUtils.getDaySet(lastMonthDay,Calendar.DATE,1); | Date newStartDate = DateUtils.getDaySet(lastMonthDay,Calendar.DATE,1); | ||||
| int months = getMonths(sdM.format(newStartDate)+"-01",sdM.format(end)+"-01"); | int months = getMonths(sdM.format(newStartDate)+"-01",sdM.format(end)+"-01"); | ||||
| total += months * price; | |||||
| total = total.add(new BigDecimal(months).multiply(price)); | |||||
| //最后一个月 | //最后一个月 | ||||
| diff = DateUtils.getDiff(DateUtils.getFirstDayForCurrMonth(end),end); | diff = DateUtils.getDiff(DateUtils.getFirstDayForCurrMonth(end),end); | ||||
| dayCount = DateUtils.getMonthDayCount(end); | dayCount = DateUtils.getMonthDayCount(end); | ||||
| total += (diff[1]+1) * (price/dayCount); | |||||
| return total; | |||||
| total = total.add(new BigDecimal((diff[1]+1)).multiply(price).divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP)); | |||||
| return total.toPlainString(); | |||||
| } | } | ||||
| public static int getMonths(String startStr,String endStr){ | public static int getMonths(String startStr,String endStr){ | ||||
| @@ -559,40 +563,40 @@ public class WxRentContractHelper { | |||||
| * @param end | * @param end | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| public static double getNeedPay(long monthPrice,Double dayPrice,Date start,Date end){ | |||||
| public static String getNeedPay(Integer decimalSize,BigDecimal monthPrice,BigDecimal dayPrice,Date start,Date end){ | |||||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | ||||
| SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); | SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); | ||||
| Double total; | |||||
| BigDecimal total; | |||||
| int[] diff; | int[] diff; | ||||
| int dayCount = DateUtils.getMonthDayCount(start); | int dayCount = DateUtils.getMonthDayCount(start); | ||||
| double price; | |||||
| if(monthPrice > 0){ | |||||
| price = (double) monthPrice/dayCount; | |||||
| BigDecimal price; | |||||
| if(monthPrice.compareTo(new BigDecimal(0)) > 0){ | |||||
| price = monthPrice.divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP); | |||||
| }else{ | }else{ | ||||
| price = dayPrice; | price = dayPrice; | ||||
| } | } | ||||
| //同一天 | //同一天 | ||||
| if(sd.format(start).equals(sd.format(end))){ | if(sd.format(start).equals(sd.format(end))){ | ||||
| return 1 * price; //算1天 | |||||
| return price.toPlainString(); //算1天 | |||||
| } | } | ||||
| //同月 | //同月 | ||||
| if(sdM.format(start).equals(sdM.format(end))){ | if(sdM.format(start).equals(sdM.format(end))){ | ||||
| diff = DateUtils.getDiff(start,end); | diff = DateUtils.getDiff(start,end); | ||||
| return (diff[1]+1) * price; | |||||
| return new BigDecimal((diff[1]+1)).multiply(price).setScale(decimalSize, BigDecimal.ROUND_HALF_UP).toPlainString(); | |||||
| } | } | ||||
| Date currEnd = DateUtils.getLastDayForMonth(start); | Date currEnd = DateUtils.getLastDayForMonth(start); | ||||
| diff = DateUtils.getDiff(start,currEnd); | diff = DateUtils.getDiff(start,currEnd); | ||||
| total = (diff[1]+1) * price; | |||||
| total = new BigDecimal((diff[1]+1)).multiply(price).setScale(decimalSize, BigDecimal.ROUND_HALF_UP); | |||||
| int warnCount = 0; | int warnCount = 0; | ||||
| while (true){ | while (true){ | ||||
| Date monthStartDate = DateUtils.getDaySet(currEnd,Calendar.DATE,1); | Date monthStartDate = DateUtils.getDaySet(currEnd,Calendar.DATE,1); | ||||
| dayCount = DateUtils.getMonthDayCount(monthStartDate); | dayCount = DateUtils.getMonthDayCount(monthStartDate); | ||||
| if(monthPrice > 0){ | |||||
| price = (double) monthPrice/dayCount; | |||||
| if(monthPrice.compareTo(new BigDecimal(0)) > 0){ | |||||
| price = monthPrice.divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP); | |||||
| }else{ | }else{ | ||||
| price = dayPrice; | price = dayPrice; | ||||
| } | } | ||||
| @@ -600,12 +604,12 @@ public class WxRentContractHelper { | |||||
| //最后一个月 | //最后一个月 | ||||
| if(sdM.format(monthStartDate).equals(sdM.format(end))){ | if(sdM.format(monthStartDate).equals(sdM.format(end))){ | ||||
| diff = DateUtils.getDiff(monthStartDate,end); | diff = DateUtils.getDiff(monthStartDate,end); | ||||
| total += price * (diff[1]+1); | |||||
| total = total.add(price.multiply(new BigDecimal((diff[1]+1))).setScale(decimalSize, BigDecimal.ROUND_HALF_UP)); | |||||
| break; | break; | ||||
| }else{ | }else{ | ||||
| currEnd = DateUtils.getLastDayForMonth(monthStartDate); | currEnd = DateUtils.getLastDayForMonth(monthStartDate); | ||||
| diff = DateUtils.getDiff(monthStartDate,currEnd); | diff = DateUtils.getDiff(monthStartDate,currEnd); | ||||
| total += price * (diff[1]+1); | |||||
| total = total.add(price.multiply(new BigDecimal((diff[1]+1))).setScale(decimalSize, BigDecimal.ROUND_HALF_UP)); | |||||
| } | } | ||||
| //预警 | //预警 | ||||
| @@ -616,7 +620,7 @@ public class WxRentContractHelper { | |||||
| } | } | ||||
| warnCount ++; | warnCount ++; | ||||
| } | } | ||||
| return total; | |||||
| return total.setScale(decimalSize, BigDecimal.ROUND_HALF_UP).toPlainString(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -780,7 +780,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||||
| wxBillDeposit.setPayDate(date); | wxBillDeposit.setPayDate(date); | ||||
| Long owe = (Long) bill.get("owe"); | Long owe = (Long) bill.get("owe"); | ||||
| wxBillDeposit.setPay(wxBillDeposit.getPay() + owe); | wxBillDeposit.setPay(wxBillDeposit.getPay() + owe); | ||||
| wxBillDeposit.setOwe(0L); | |||||
| wxBillDeposit.setOwe("0"); | |||||
| wxBillDeposit.setStatus(EnumBillDailyStatus.PAID.getCode()); | wxBillDeposit.setStatus(EnumBillDailyStatus.PAID.getCode()); | ||||
| wxBillDeposit.setPayDate(date); | wxBillDeposit.setPayDate(date); | ||||
| wxBillDeposit.setUpdatetime(date); | wxBillDeposit.setUpdatetime(date); | ||||
| @@ -825,7 +825,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||||
| wxBillRent.setPayDate(date); | wxBillRent.setPayDate(date); | ||||
| Long owe = (Long) bill.get("owe"); | Long owe = (Long) bill.get("owe"); | ||||
| wxBillRent.setPay(wxBillRent.getPay() + owe); | wxBillRent.setPay(wxBillRent.getPay() + owe); | ||||
| wxBillRent.setOwe(0L); | |||||
| wxBillRent.setOwe("0"); | |||||
| wxBillRent.setStatus(EnumBillDailyStatus.PAID.getCode()); | wxBillRent.setStatus(EnumBillDailyStatus.PAID.getCode()); | ||||
| wxBillRent.setPayDate(date); | wxBillRent.setPayDate(date); | ||||
| wxBillRent.setUpdatetime(date); | wxBillRent.setUpdatetime(date); | ||||
| @@ -1153,238 +1153,238 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||||
| @Override | @Override | ||||
| public ResultData updateReceivePay(WxBillAll wxBillAll, MallUserInfo user,boolean forcePaid) { | public ResultData updateReceivePay(WxBillAll wxBillAll, MallUserInfo user,boolean forcePaid) { | ||||
| Integer billType = wxBillAll.getBillTypeValue(); | |||||
| Long oldPrice = wxBillAll.getOldPrice(); | |||||
| Long newPrice = wxBillAll.getNewPrice(); | |||||
| Long oldLatePrice = wxBillAll.getOldLatePrice(); | |||||
| Long newLatePrice = wxBillAll.getNewLatePrice(); | |||||
| Long id = wxBillAll.getId(); | |||||
| Date updateDate = new Date(); | |||||
| if (billType.equals(EnumBillTypeParam.RENT.getCode())) { | |||||
| WxBillRent dbBill = wxBillRentMapper.selectById(id); | |||||
| WxBillRent wxBillRent = new WxBillRent(); | |||||
| wxBillRent.setId(id); | |||||
| wxBillRent.setUpdatetime(updateDate); | |||||
| if (forcePaid) { | |||||
| wxBillRent.setReceivePay(dbBill.getPay()); | |||||
| wxBillRent.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| wxBillRent.setOwe(0L); | |||||
| wxBillRentMapper.updateById(wxBillRent); | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, dbBill.getPay(), dbBill.getPay(), user); | |||||
| }else { | |||||
| if (oldLatePrice != null) { | |||||
| wxBillRent.setLatePayPrice(newLatePrice); | |||||
| wxBillRent.setOwe(dbBill.getReceivePay() + dbBill.getServiceChargePay() + newLatePrice - dbBill.getPay()); | |||||
| wxBillRentMapper.updateById(wxBillRent); | |||||
| addBillAction(EnumBillAction.UPDATE_LATE_PAY_MONEY, id, oldLatePrice, newLatePrice, user); | |||||
| } else { | |||||
| //租赁账单更新 | |||||
| wxBillRent.setReceivePay(newPrice); | |||||
| long latePayPrice = dbBill.getLatePayPrice() == null ? 0 : dbBill.getLatePayPrice(); | |||||
| wxBillRent.setOwe(newPrice + dbBill.getServiceChargePay() + latePayPrice - dbBill.getPay()); | |||||
| if (newPrice.equals(dbBill.getPay())) { | |||||
| wxBillRent.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| } | |||||
| wxBillRentMapper.updateById(wxBillRent); | |||||
| //账单日志 | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| } | |||||
| } | |||||
| } else if (billType.equals(EnumBillTypeParam.RENT_DEPOSIT.getCode())) { | |||||
| WxBillDeposit dbBill = wxBillDepositMapper.selectById(id); | |||||
| if (dbBill != null) { | |||||
| WxBillDeposit wxBillDeposit = new WxBillDeposit(); | |||||
| wxBillDeposit.setId(id); | |||||
| Long billDepositOldPrce = oldPrice; | |||||
| Long billDepositNewPrce = newPrice; | |||||
| //租赁押金账单更新 | |||||
| if (forcePaid) { | |||||
| wxBillDeposit.setReceivePay(dbBill.getPay()); | |||||
| wxBillDeposit.setOwe(0L); | |||||
| wxBillDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| billDepositOldPrce = dbBill.getPay(); | |||||
| billDepositNewPrce = dbBill.getPay(); | |||||
| }else { | |||||
| wxBillDeposit.setReceivePay(newPrice); | |||||
| wxBillDeposit.setOwe(newPrice - dbBill.getPay()); | |||||
| if (newPrice.equals(dbBill.getPay())) { | |||||
| wxBillDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| } | |||||
| wxBillDeposit.setUpdatetime(updateDate); | |||||
| } | |||||
| wxBillDepositMapper.updateById(wxBillDeposit); | |||||
| //账单日志 | |||||
| addBillAction(EnumBillAction.DEPOSIT_MODIFY, id, billDepositOldPrce, billDepositNewPrce, user); | |||||
| } | |||||
| WxBillPropertyDeposit propertyDeposit = wxBillPropertyDepositMapper.selectById(id); | |||||
| if (propertyDeposit != null) { | |||||
| //物业押金账单更新 | |||||
| WxBillPropertyDeposit wxBillPropertyDeposit = new WxBillPropertyDeposit(); | |||||
| wxBillPropertyDeposit.setId(id); | |||||
| Long billPropertyDepositOldPrce = oldPrice; | |||||
| Long billPropertyDepositNewPrce = newPrice; | |||||
| if (forcePaid) { | |||||
| wxBillPropertyDeposit.setReceivePay(propertyDeposit.getPay()); | |||||
| wxBillPropertyDeposit.setOwe(0L); | |||||
| wxBillPropertyDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| billPropertyDepositOldPrce = propertyDeposit.getPay(); | |||||
| billPropertyDepositNewPrce = propertyDeposit.getPay(); | |||||
| }else { | |||||
| wxBillPropertyDeposit.setReceivePay(newPrice); | |||||
| wxBillPropertyDeposit.setOwe(newPrice - propertyDeposit.getPay()); | |||||
| if (newPrice.equals(propertyDeposit.getPay())) { | |||||
| wxBillPropertyDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| } | |||||
| } | |||||
| wxBillPropertyDeposit.setUpdatetime(updateDate); | |||||
| wxBillPropertyDepositMapper.updateById(wxBillPropertyDeposit); | |||||
| //账单日志 | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, billPropertyDepositOldPrce, billPropertyDepositNewPrce, user); | |||||
| } | |||||
| } else if (billType.equals(EnumBillTypeParam.PROPERTY.getCode())) { | |||||
| WxBillProperty dbBill = wxBillPropertyMapper.selectById(id); | |||||
| //物业账单更新 | |||||
| WxBillProperty wxBillProperty = new WxBillProperty(); | |||||
| wxBillProperty.setId(id); | |||||
| wxBillProperty.setUpdatetime(updateDate); | |||||
| if (forcePaid) { | |||||
| wxBillProperty.setReceivePay(dbBill.getPay()); | |||||
| wxBillProperty.setOwe(0L); | |||||
| wxBillProperty.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| wxBillPropertyMapper.updateById(wxBillProperty); | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, dbBill.getPay(), dbBill.getPay(), user); | |||||
| }else { | |||||
| if (oldLatePrice != null) { | |||||
| wxBillProperty.setLatePayPrice(newLatePrice); | |||||
| wxBillProperty.setOwe(dbBill.getReceivePay() + dbBill.getServiceChargePay() + newLatePrice - dbBill.getPay()); | |||||
| wxBillPropertyMapper.updateById(wxBillProperty); | |||||
| addBillAction(EnumBillAction.UPDATE_LATE_PAY_MONEY, id, oldLatePrice, newLatePrice, user); | |||||
| } else { | |||||
| wxBillProperty.setReceivePay(newPrice); | |||||
| long latePayPrice = dbBill.getLatePayPrice() == null ? 0 : dbBill.getLatePayPrice(); | |||||
| wxBillProperty.setOwe(newPrice + dbBill.getServiceChargePay() + latePayPrice - dbBill.getPay()); | |||||
| if (newPrice.equals(dbBill.getPay())) { | |||||
| wxBillProperty.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| } | |||||
| wxBillPropertyMapper.updateById(wxBillProperty); | |||||
| //账单日志 | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| } | |||||
| } | |||||
| } else if (billType.equals(EnumBillTypeParam.PROPERTY_DEPOSIT.getCode())) { | |||||
| WxBillPropertyDeposit dbBill = wxBillPropertyDepositMapper.selectById(id); | |||||
| //物业押金账单更新 | |||||
| WxBillPropertyDeposit wxBillPropertyDeposit = new WxBillPropertyDeposit(); | |||||
| wxBillPropertyDeposit.setId(id); | |||||
| Long billPropertyDepositOldPrce = oldPrice; | |||||
| Long billPropertyDepositNewPrce = newPrice; | |||||
| if (forcePaid) { | |||||
| wxBillPropertyDeposit.setReceivePay(dbBill.getPay()); | |||||
| wxBillPropertyDeposit.setOwe(0L); | |||||
| wxBillPropertyDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| billPropertyDepositOldPrce = dbBill.getPay(); | |||||
| billPropertyDepositNewPrce = dbBill.getPay(); | |||||
| }else { | |||||
| wxBillPropertyDeposit.setReceivePay(newPrice); | |||||
| wxBillPropertyDeposit.setOwe(newPrice - dbBill.getPay()); | |||||
| if (newPrice.equals(dbBill.getPay())) { | |||||
| wxBillPropertyDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| } | |||||
| } | |||||
| wxBillPropertyDeposit.setUpdatetime(updateDate); | |||||
| wxBillPropertyDepositMapper.updateById(wxBillPropertyDeposit); | |||||
| //账单日志 | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, billPropertyDepositOldPrce, billPropertyDepositNewPrce, user); | |||||
| } else if (billType.equals(EnumBillTypeParam.WATER.getCode())) { | |||||
| //水费账单更新 | |||||
| updateDailyBill(id, newPrice, updateDate,forcePaid); | |||||
| //账单日志 | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| } else if (billType.equals(EnumBillTypeParam.POWER.getCode())) { | |||||
| //电费账单更新 | |||||
| updateDailyBill(id, newPrice, updateDate,forcePaid); | |||||
| //账单日志 | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| } else if (billType.equals(EnumBillTypeParam.AIR_CONDITIONING.getCode())) { | |||||
| //空调费账单更新 | |||||
| updateDailyBill(id, newPrice, updateDate,forcePaid); | |||||
| //账单日志 | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| } else if (billType.equals(EnumBillTypeParam.ROUTINE.getCode())) { | |||||
| WxBillOther dbBill = wxBillOtherMapper.selectById(id); | |||||
| //其他费用账单更新 | |||||
| WxBillOther wxBillOther = new WxBillOther(); | |||||
| wxBillOther.setId(id); | |||||
| if (forcePaid) { | |||||
| wxBillOther.setReceivePay(dbBill.getPay()); | |||||
| wxBillOther.setOwe(0L); | |||||
| wxBillOther.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| }else { | |||||
| wxBillOther.setReceivePay(newPrice); | |||||
| wxBillOther.setOwe(newPrice + dbBill.getServiceChargePay() - dbBill.getPay()); | |||||
| if (newPrice.equals(dbBill.getPay())) { | |||||
| wxBillOther.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| } | |||||
| } | |||||
| wxBillOther.setUpdatetime(updateDate); | |||||
| wxBillOtherMapper.updateById(wxBillOther); | |||||
| //账单日志 | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| } else if (billType.equals(EnumBillTypeParam.ATHER_DEPOSIT.getCode())) { | |||||
| WxBillOtherDeposit dbBill = wxBillOtherDepositMapper.selectById(id); | |||||
| //其他押金账单更新 | |||||
| WxBillOtherDeposit wxBillOtherDeposit = new WxBillOtherDeposit(); | |||||
| wxBillOtherDeposit.setId(id); | |||||
| if (forcePaid) { | |||||
| wxBillOtherDeposit.setReceivePay(dbBill.getPay()); | |||||
| wxBillOtherDeposit.setOwe(0L); | |||||
| wxBillOtherDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| }else { | |||||
| wxBillOtherDeposit.setReceivePay(newPrice); | |||||
| wxBillOtherDeposit.setOwe(newPrice + dbBill.getServiceChargePay() - dbBill.getPay()); | |||||
| if (newPrice.equals(dbBill.getPay())) { | |||||
| wxBillOtherDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| } | |||||
| } | |||||
| wxBillOtherDeposit.setUpdatetime(updateDate); | |||||
| wxBillOtherDepositMapper.updateById(wxBillOtherDeposit); | |||||
| //账单日志 | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| }if (billType.equals(EnumBillTypeParam.RENT_BUSSINESS_MANAGE.getCode()) || billType.equals(EnumBillTypeParam.RENT_OPERATING_MANAGE.getCode())) { | |||||
| WxBillRentManage dbBill = wxBillRentManageMapper.selectById(id); | |||||
| WxBillRentManage wxBillRent = new WxBillRentManage(); | |||||
| wxBillRent.setId(id); | |||||
| wxBillRent.setUpdatetime(updateDate); | |||||
| if (forcePaid) { | |||||
| wxBillRent.setReceivePay(dbBill.getPay()); | |||||
| wxBillRent.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| wxBillRent.setOwe(0L); | |||||
| wxBillRentManageMapper.updateById(wxBillRent); | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, dbBill.getPay(), dbBill.getPay(), user); | |||||
| }else { | |||||
| if (oldLatePrice != null) { | |||||
| wxBillRent.setLatePayPrice(newLatePrice); | |||||
| wxBillRent.setOwe(dbBill.getReceivePay() + dbBill.getServiceChargePay() + newLatePrice - dbBill.getPay()); | |||||
| wxBillRentManageMapper.updateById(wxBillRent); | |||||
| addBillAction(EnumBillAction.UPDATE_LATE_PAY_MONEY, id, oldLatePrice, newLatePrice, user); | |||||
| } else { | |||||
| //租赁账单更新 | |||||
| wxBillRent.setReceivePay(newPrice); | |||||
| long latePayPrice = dbBill.getLatePayPrice() == null ? 0 : dbBill.getLatePayPrice(); | |||||
| wxBillRent.setOwe(newPrice + dbBill.getServiceChargePay() + latePayPrice - dbBill.getPay()); | |||||
| if (newPrice.equals(dbBill.getPay())) { | |||||
| wxBillRent.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| } | |||||
| wxBillRentManageMapper.updateById(wxBillRent); | |||||
| //账单日志 | |||||
| addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| } | |||||
| } | |||||
| } else { | |||||
| logger.info("未找到账单类型"); | |||||
| } | |||||
| // Integer billType = wxBillAll.getBillTypeValue(); | |||||
| // Long oldPrice = wxBillAll.getOldPrice(); | |||||
| // Long newPrice = wxBillAll.getNewPrice(); | |||||
| // Long oldLatePrice = wxBillAll.getOldLatePrice(); | |||||
| // Long newLatePrice = wxBillAll.getNewLatePrice(); | |||||
| // Long id = wxBillAll.getId(); | |||||
| // Date updateDate = new Date(); | |||||
| // if (billType.equals(EnumBillTypeParam.RENT.getCode())) { | |||||
| // WxBillRent dbBill = wxBillRentMapper.selectById(id); | |||||
| // WxBillRent wxBillRent = new WxBillRent(); | |||||
| // wxBillRent.setId(id); | |||||
| // wxBillRent.setUpdatetime(updateDate); | |||||
| // if (forcePaid) { | |||||
| // wxBillRent.setReceivePay(dbBill.getPay()); | |||||
| // wxBillRent.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // wxBillRent.setOwe("0"); | |||||
| // wxBillRentMapper.updateById(wxBillRent); | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, dbBill.getPay(), dbBill.getPay(), user); | |||||
| // }else { | |||||
| // if (oldLatePrice != null) { | |||||
| // wxBillRent.setLatePayPrice(newLatePrice); | |||||
| // wxBillRent.setOwe(dbBill.getReceivePay() + dbBill.getServiceChargePay() + newLatePrice - dbBill.getPay()); | |||||
| // wxBillRentMapper.updateById(wxBillRent); | |||||
| // addBillAction(EnumBillAction.UPDATE_LATE_PAY_MONEY, id, oldLatePrice, newLatePrice, user); | |||||
| // } else { | |||||
| // //租赁账单更新 | |||||
| // wxBillRent.setReceivePay(newPrice); | |||||
| // long latePayPrice = dbBill.getLatePayPrice() == null ? 0 : dbBill.getLatePayPrice(); | |||||
| // wxBillRent.setOwe(newPrice + dbBill.getServiceChargePay() + latePayPrice - dbBill.getPay()); | |||||
| // if (newPrice.equals(dbBill.getPay())) { | |||||
| // wxBillRent.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // } | |||||
| // wxBillRentMapper.updateById(wxBillRent); | |||||
| // //账单日志 | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| // } | |||||
| // } | |||||
| // } else if (billType.equals(EnumBillTypeParam.RENT_DEPOSIT.getCode())) { | |||||
| // WxBillDeposit dbBill = wxBillDepositMapper.selectById(id); | |||||
| // if (dbBill != null) { | |||||
| // WxBillDeposit wxBillDeposit = new WxBillDeposit(); | |||||
| // wxBillDeposit.setId(id); | |||||
| // Long billDepositOldPrce = oldPrice; | |||||
| // Long billDepositNewPrce = newPrice; | |||||
| // //租赁押金账单更新 | |||||
| // if (forcePaid) { | |||||
| // wxBillDeposit.setReceivePay(dbBill.getPay()); | |||||
| // wxBillDeposit.setOwe(0L); | |||||
| // wxBillDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // billDepositOldPrce = dbBill.getPay(); | |||||
| // billDepositNewPrce = dbBill.getPay(); | |||||
| // }else { | |||||
| // wxBillDeposit.setReceivePay(newPrice); | |||||
| // wxBillDeposit.setOwe(newPrice - dbBill.getPay()); | |||||
| // if (newPrice.equals(dbBill.getPay())) { | |||||
| // wxBillDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // } | |||||
| // wxBillDeposit.setUpdatetime(updateDate); | |||||
| // } | |||||
| // wxBillDepositMapper.updateById(wxBillDeposit); | |||||
| // //账单日志 | |||||
| // addBillAction(EnumBillAction.DEPOSIT_MODIFY, id, billDepositOldPrce, billDepositNewPrce, user); | |||||
| // } | |||||
| // | |||||
| // WxBillPropertyDeposit propertyDeposit = wxBillPropertyDepositMapper.selectById(id); | |||||
| // if (propertyDeposit != null) { | |||||
| // //物业押金账单更新 | |||||
| // WxBillPropertyDeposit wxBillPropertyDeposit = new WxBillPropertyDeposit(); | |||||
| // wxBillPropertyDeposit.setId(id); | |||||
| // Long billPropertyDepositOldPrce = oldPrice; | |||||
| // Long billPropertyDepositNewPrce = newPrice; | |||||
| // if (forcePaid) { | |||||
| // wxBillPropertyDeposit.setReceivePay(propertyDeposit.getPay()); | |||||
| // wxBillPropertyDeposit.setOwe(0L); | |||||
| // wxBillPropertyDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // billPropertyDepositOldPrce = propertyDeposit.getPay(); | |||||
| // billPropertyDepositNewPrce = propertyDeposit.getPay(); | |||||
| // }else { | |||||
| // wxBillPropertyDeposit.setReceivePay(newPrice); | |||||
| // wxBillPropertyDeposit.setOwe(newPrice - propertyDeposit.getPay()); | |||||
| // if (newPrice.equals(propertyDeposit.getPay())) { | |||||
| // wxBillPropertyDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // } | |||||
| // } | |||||
| // wxBillPropertyDeposit.setUpdatetime(updateDate); | |||||
| // wxBillPropertyDepositMapper.updateById(wxBillPropertyDeposit); | |||||
| // //账单日志 | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, billPropertyDepositOldPrce, billPropertyDepositNewPrce, user); | |||||
| // } | |||||
| // } else if (billType.equals(EnumBillTypeParam.PROPERTY.getCode())) { | |||||
| // WxBillProperty dbBill = wxBillPropertyMapper.selectById(id); | |||||
| // //物业账单更新 | |||||
| // WxBillProperty wxBillProperty = new WxBillProperty(); | |||||
| // wxBillProperty.setId(id); | |||||
| // wxBillProperty.setUpdatetime(updateDate); | |||||
| // if (forcePaid) { | |||||
| // wxBillProperty.setReceivePay(dbBill.getPay()); | |||||
| // wxBillProperty.setOwe(0L); | |||||
| // wxBillProperty.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // wxBillPropertyMapper.updateById(wxBillProperty); | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, dbBill.getPay(), dbBill.getPay(), user); | |||||
| // }else { | |||||
| // if (oldLatePrice != null) { | |||||
| // wxBillProperty.setLatePayPrice(newLatePrice); | |||||
| // wxBillProperty.setOwe(dbBill.getReceivePay() + dbBill.getServiceChargePay() + newLatePrice - dbBill.getPay()); | |||||
| // wxBillPropertyMapper.updateById(wxBillProperty); | |||||
| // addBillAction(EnumBillAction.UPDATE_LATE_PAY_MONEY, id, oldLatePrice, newLatePrice, user); | |||||
| // } else { | |||||
| // wxBillProperty.setReceivePay(newPrice); | |||||
| // long latePayPrice = dbBill.getLatePayPrice() == null ? 0 : dbBill.getLatePayPrice(); | |||||
| // wxBillProperty.setOwe(newPrice + dbBill.getServiceChargePay() + latePayPrice - dbBill.getPay()); | |||||
| // if (newPrice.equals(dbBill.getPay())) { | |||||
| // wxBillProperty.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // } | |||||
| // wxBillPropertyMapper.updateById(wxBillProperty); | |||||
| // //账单日志 | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| // } | |||||
| // } | |||||
| // } else if (billType.equals(EnumBillTypeParam.PROPERTY_DEPOSIT.getCode())) { | |||||
| // WxBillPropertyDeposit dbBill = wxBillPropertyDepositMapper.selectById(id); | |||||
| // //物业押金账单更新 | |||||
| // WxBillPropertyDeposit wxBillPropertyDeposit = new WxBillPropertyDeposit(); | |||||
| // wxBillPropertyDeposit.setId(id); | |||||
| // Long billPropertyDepositOldPrce = oldPrice; | |||||
| // Long billPropertyDepositNewPrce = newPrice; | |||||
| // if (forcePaid) { | |||||
| // wxBillPropertyDeposit.setReceivePay(dbBill.getPay()); | |||||
| // wxBillPropertyDeposit.setOwe(0L); | |||||
| // wxBillPropertyDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // billPropertyDepositOldPrce = dbBill.getPay(); | |||||
| // billPropertyDepositNewPrce = dbBill.getPay(); | |||||
| // }else { | |||||
| // wxBillPropertyDeposit.setReceivePay(newPrice); | |||||
| // wxBillPropertyDeposit.setOwe(newPrice - dbBill.getPay()); | |||||
| // if (newPrice.equals(dbBill.getPay())) { | |||||
| // wxBillPropertyDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // } | |||||
| // } | |||||
| // wxBillPropertyDeposit.setUpdatetime(updateDate); | |||||
| // wxBillPropertyDepositMapper.updateById(wxBillPropertyDeposit); | |||||
| // //账单日志 | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, billPropertyDepositOldPrce, billPropertyDepositNewPrce, user); | |||||
| // | |||||
| // } else if (billType.equals(EnumBillTypeParam.WATER.getCode())) { | |||||
| // //水费账单更新 | |||||
| // updateDailyBill(id, newPrice, updateDate,forcePaid); | |||||
| // //账单日志 | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| // } else if (billType.equals(EnumBillTypeParam.POWER.getCode())) { | |||||
| // //电费账单更新 | |||||
| // updateDailyBill(id, newPrice, updateDate,forcePaid); | |||||
| // //账单日志 | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| // } else if (billType.equals(EnumBillTypeParam.AIR_CONDITIONING.getCode())) { | |||||
| // //空调费账单更新 | |||||
| // updateDailyBill(id, newPrice, updateDate,forcePaid); | |||||
| // //账单日志 | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| // } else if (billType.equals(EnumBillTypeParam.ROUTINE.getCode())) { | |||||
| // WxBillOther dbBill = wxBillOtherMapper.selectById(id); | |||||
| // //其他费用账单更新 | |||||
| // WxBillOther wxBillOther = new WxBillOther(); | |||||
| // wxBillOther.setId(id); | |||||
| // if (forcePaid) { | |||||
| // wxBillOther.setReceivePay(dbBill.getPay()); | |||||
| // wxBillOther.setOwe(0L); | |||||
| // wxBillOther.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // }else { | |||||
| // wxBillOther.setReceivePay(newPrice); | |||||
| // wxBillOther.setOwe(newPrice + dbBill.getServiceChargePay() - dbBill.getPay()); | |||||
| // if (newPrice.equals(dbBill.getPay())) { | |||||
| // wxBillOther.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // } | |||||
| // } | |||||
| // wxBillOther.setUpdatetime(updateDate); | |||||
| // wxBillOtherMapper.updateById(wxBillOther); | |||||
| // //账单日志 | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| // } else if (billType.equals(EnumBillTypeParam.ATHER_DEPOSIT.getCode())) { | |||||
| // WxBillOtherDeposit dbBill = wxBillOtherDepositMapper.selectById(id); | |||||
| // //其他押金账单更新 | |||||
| // WxBillOtherDeposit wxBillOtherDeposit = new WxBillOtherDeposit(); | |||||
| // wxBillOtherDeposit.setId(id); | |||||
| // if (forcePaid) { | |||||
| // wxBillOtherDeposit.setReceivePay(dbBill.getPay()); | |||||
| // wxBillOtherDeposit.setOwe(0L); | |||||
| // wxBillOtherDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // }else { | |||||
| // wxBillOtherDeposit.setReceivePay(newPrice); | |||||
| // wxBillOtherDeposit.setOwe(newPrice + dbBill.getServiceChargePay() - dbBill.getPay()); | |||||
| // if (newPrice.equals(dbBill.getPay())) { | |||||
| // wxBillOtherDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // } | |||||
| // } | |||||
| // wxBillOtherDeposit.setUpdatetime(updateDate); | |||||
| // wxBillOtherDepositMapper.updateById(wxBillOtherDeposit); | |||||
| // //账单日志 | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| // }if (billType.equals(EnumBillTypeParam.RENT_BUSSINESS_MANAGE.getCode()) || billType.equals(EnumBillTypeParam.RENT_OPERATING_MANAGE.getCode())) { | |||||
| // WxBillRentManage dbBill = wxBillRentManageMapper.selectById(id); | |||||
| // WxBillRentManage wxBillRent = new WxBillRentManage(); | |||||
| // wxBillRent.setId(id); | |||||
| // wxBillRent.setUpdatetime(updateDate); | |||||
| // if (forcePaid) { | |||||
| // wxBillRent.setReceivePay(dbBill.getPay()); | |||||
| // wxBillRent.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // wxBillRent.setOwe(0L); | |||||
| // wxBillRentManageMapper.updateById(wxBillRent); | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, dbBill.getPay(), dbBill.getPay(), user); | |||||
| // }else { | |||||
| // if (oldLatePrice != null) { | |||||
| // wxBillRent.setLatePayPrice(newLatePrice); | |||||
| // wxBillRent.setOwe(dbBill.getReceivePay() + dbBill.getServiceChargePay() + newLatePrice - dbBill.getPay()); | |||||
| // wxBillRentManageMapper.updateById(wxBillRent); | |||||
| // addBillAction(EnumBillAction.UPDATE_LATE_PAY_MONEY, id, oldLatePrice, newLatePrice, user); | |||||
| // } else { | |||||
| // //租赁账单更新 | |||||
| // wxBillRent.setReceivePay(newPrice); | |||||
| // long latePayPrice = dbBill.getLatePayPrice() == null ? 0 : dbBill.getLatePayPrice(); | |||||
| // wxBillRent.setOwe(newPrice + dbBill.getServiceChargePay() + latePayPrice - dbBill.getPay()); | |||||
| // if (newPrice.equals(dbBill.getPay())) { | |||||
| // wxBillRent.setStatus(EnumBillRentStatus.PAID.getCode()); | |||||
| // } | |||||
| // wxBillRentManageMapper.updateById(wxBillRent); | |||||
| // //账单日志 | |||||
| // addBillAction(EnumBillAction.UPDATE_BILL, id, oldPrice, newPrice, user); | |||||
| // } | |||||
| // } | |||||
| // } else { | |||||
| // logger.info("未找到账单类型"); | |||||
| // } | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -1775,68 +1775,68 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||||
| @Override | @Override | ||||
| public void importBill(String importKey, WxBillExcelTemplate bill, MallUserInfo user) { | public void importBill(String importKey, WxBillExcelTemplate bill, MallUserInfo user) { | ||||
| //租金 | |||||
| Integer billType = bill.getBillType(); | |||||
| if (billType.equals(EnumBillExcelTemplate.SHOP_RENT.getCode()) || billType.equals(EnumBillExcelTemplate.POINT_RENT.getCode())) { | |||||
| WxBillRent rentQuery = new WxBillRent(); | |||||
| rentQuery.updateTenantInfo(user); | |||||
| rentQuery.setMerchantId(bill.getMerchantId()); | |||||
| rentQuery.setStarttime(bill.getStarttime()); | |||||
| rentQuery.setEndtime(bill.getEndtime()); | |||||
| if (billType.equals(EnumBillExcelTemplate.SHOP_RENT.getCode())) { | |||||
| rentQuery.setRentShopType(EnumRentShopType.SHOP.getCode()); | |||||
| } else { | |||||
| rentQuery.setRentShopType(EnumRentShopType.POINT.getCode()); | |||||
| } | |||||
| rentQuery.setIsPreview(EnumIsPreview.NO.getCode()); | |||||
| WxBillRent rent = wxBillRentMapper.selectBillOne(rentQuery); | |||||
| if (rent != null && !rent.getStatus().equals(EnumBillRentStatus.PAID.getCode())) { | |||||
| long pay = new BigDecimal(bill.getPayStr()).multiply(new BigDecimal(100)).longValueExact(); | |||||
| WxBillRent expiredDayAndStatus = getExpiredDayAndStatus(bill.getReceiveDate(), bill.getPayDate(), rent.getOwe(), pay, true); | |||||
| rent.setExpiredDay(expiredDayAndStatus.getExpiredDay()); | |||||
| rent.setStatus(expiredDayAndStatus.getStatus()); | |||||
| rent.setPay(rent.getPay() + pay); | |||||
| rent.setOwe(rent.getOwe() - pay); | |||||
| rent.setPayDate(bill.getPayDate()); | |||||
| rent.setReceiveDate(bill.getReceiveDate()); | |||||
| wxBillRentMapper.updateById(rent); | |||||
| if (pay > 0) { | |||||
| addActionImport(rent.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr()); | |||||
| } | |||||
| } | |||||
| } else if (billType.equals(EnumBillExcelTemplate.SHOP_PROPERTY.getCode()) || billType.equals(EnumBillExcelTemplate.POINT_PROPERTY.getCode())) { | |||||
| WxBillProperty propertyQuery = new WxBillProperty(); | |||||
| propertyQuery.updateTenantInfo(user); | |||||
| propertyQuery.setMerchantId(bill.getMerchantId()); | |||||
| propertyQuery.setStarttime(bill.getStarttime()); | |||||
| propertyQuery.setEndtime(bill.getEndtime()); | |||||
| if (billType.equals(EnumBillExcelTemplate.SHOP_PROPERTY.getCode())) { | |||||
| propertyQuery.setRentShopType(EnumRentShopType.SHOP.getCode()); | |||||
| } else { | |||||
| propertyQuery.setRentShopType(EnumRentShopType.POINT.getCode()); | |||||
| } | |||||
| propertyQuery.setIsPreview(EnumIsPreview.NO.getCode()); | |||||
| WxBillProperty property = wxBillPropertyMapper.selectBillOne(propertyQuery); | |||||
| if (property != null && !property.getStatus().equals(EnumBillRentStatus.PAID.getCode())) { | |||||
| long pay = new BigDecimal(bill.getPayStr()).multiply(new BigDecimal(100)).longValueExact(); | |||||
| WxBillRent expiredDayAndStatus = getExpiredDayAndStatus(bill.getReceiveDate(), bill.getPayDate(), property.getOwe(), pay, true); | |||||
| property.setExpiredDay(expiredDayAndStatus.getExpiredDay()); | |||||
| property.setStatus(expiredDayAndStatus.getStatus()); | |||||
| property.setPay(property.getPay() + pay); | |||||
| property.setOwe(property.getOwe() - pay); | |||||
| property.setPayDate(bill.getPayDate()); | |||||
| property.setReceiveDate(bill.getReceiveDate()); | |||||
| wxBillPropertyMapper.updateById(property); | |||||
| if (pay > 0) { | |||||
| addActionImport(property.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr()); | |||||
| } | |||||
| } | |||||
| } else { | |||||
| logger.error("账单导入失败"); | |||||
| } | |||||
| //记数 | |||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||||
| // //租金 | |||||
| // Integer billType = bill.getBillType(); | |||||
| // if (billType.equals(EnumBillExcelTemplate.SHOP_RENT.getCode()) || billType.equals(EnumBillExcelTemplate.POINT_RENT.getCode())) { | |||||
| // WxBillRent rentQuery = new WxBillRent(); | |||||
| // rentQuery.updateTenantInfo(user); | |||||
| // rentQuery.setMerchantId(bill.getMerchantId()); | |||||
| // rentQuery.setStarttime(bill.getStarttime()); | |||||
| // rentQuery.setEndtime(bill.getEndtime()); | |||||
| // if (billType.equals(EnumBillExcelTemplate.SHOP_RENT.getCode())) { | |||||
| // rentQuery.setRentShopType(EnumRentShopType.SHOP.getCode()); | |||||
| // } else { | |||||
| // rentQuery.setRentShopType(EnumRentShopType.POINT.getCode()); | |||||
| // } | |||||
| // rentQuery.setIsPreview(EnumIsPreview.NO.getCode()); | |||||
| // WxBillRent rent = wxBillRentMapper.selectBillOne(rentQuery); | |||||
| // if (rent != null && !rent.getStatus().equals(EnumBillRentStatus.PAID.getCode())) { | |||||
| // long pay = new BigDecimal(bill.getPayStr()).multiply(new BigDecimal(100)).longValueExact(); | |||||
| // WxBillRent expiredDayAndStatus = getExpiredDayAndStatus(bill.getReceiveDate(), bill.getPayDate(), rent.getOwe(), pay, true); | |||||
| // rent.setExpiredDay(expiredDayAndStatus.getExpiredDay()); | |||||
| // rent.setStatus(expiredDayAndStatus.getStatus()); | |||||
| // rent.setPay(rent.getPay() + pay); | |||||
| // rent.setOwe(rent.getOwe() - pay); | |||||
| // rent.setPayDate(bill.getPayDate()); | |||||
| // rent.setReceiveDate(bill.getReceiveDate()); | |||||
| // wxBillRentMapper.updateById(rent); | |||||
| // if (pay > 0) { | |||||
| // addActionImport(rent.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr()); | |||||
| // } | |||||
| // } | |||||
| // } else if (billType.equals(EnumBillExcelTemplate.SHOP_PROPERTY.getCode()) || billType.equals(EnumBillExcelTemplate.POINT_PROPERTY.getCode())) { | |||||
| // WxBillProperty propertyQuery = new WxBillProperty(); | |||||
| // propertyQuery.updateTenantInfo(user); | |||||
| // propertyQuery.setMerchantId(bill.getMerchantId()); | |||||
| // propertyQuery.setStarttime(bill.getStarttime()); | |||||
| // propertyQuery.setEndtime(bill.getEndtime()); | |||||
| // if (billType.equals(EnumBillExcelTemplate.SHOP_PROPERTY.getCode())) { | |||||
| // propertyQuery.setRentShopType(EnumRentShopType.SHOP.getCode()); | |||||
| // } else { | |||||
| // propertyQuery.setRentShopType(EnumRentShopType.POINT.getCode()); | |||||
| // } | |||||
| // propertyQuery.setIsPreview(EnumIsPreview.NO.getCode()); | |||||
| // WxBillProperty property = wxBillPropertyMapper.selectBillOne(propertyQuery); | |||||
| // if (property != null && !property.getStatus().equals(EnumBillRentStatus.PAID.getCode())) { | |||||
| // long pay = new BigDecimal(bill.getPayStr()).multiply(new BigDecimal(100)).longValueExact(); | |||||
| // WxBillRent expiredDayAndStatus = getExpiredDayAndStatus(bill.getReceiveDate(), bill.getPayDate(), property.getOwe(), pay, true); | |||||
| // property.setExpiredDay(expiredDayAndStatus.getExpiredDay()); | |||||
| // property.setStatus(expiredDayAndStatus.getStatus()); | |||||
| // property.setPay(property.getPay() + pay); | |||||
| // property.setOwe(property.getOwe() - pay); | |||||
| // property.setPayDate(bill.getPayDate()); | |||||
| // property.setReceiveDate(bill.getReceiveDate()); | |||||
| // wxBillPropertyMapper.updateById(property); | |||||
| // if (pay > 0) { | |||||
| // addActionImport(property.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr()); | |||||
| // } | |||||
| // } | |||||
| // } else { | |||||
| // logger.error("账单导入失败"); | |||||
| // } | |||||
| // //记数 | |||||
| // stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| // stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||||
| } | } | ||||
| public void addActionImport(Long billId, String payWay, Date payDate, MallUserInfo user, String pay) { | public void addActionImport(Long billId, String payWay, Date payDate, MallUserInfo user, String pay) { | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| @@ -64,16 +65,16 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { | |||||
| @Override | @Override | ||||
| public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillDeposit deposit) { | public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillDeposit deposit) { | ||||
| if (deposit.getReceivePay() != null) { | if (deposit.getReceivePay() != null) { | ||||
| Long receivePayB = deposit.getReceivePay(); | |||||
| String receivePayB = deposit.getReceivePay(); | |||||
| BigDecimal servicePay; | BigDecimal servicePay; | ||||
| if (deposit.getServiceChargePay() != null) { | if (deposit.getServiceChargePay() != null) { | ||||
| servicePay = new BigDecimal(deposit.getServiceChargePay()); | servicePay = new BigDecimal(deposit.getServiceChargePay()); | ||||
| } else { | } else { | ||||
| servicePay = new BigDecimal(receivePayB).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); | |||||
| servicePay = new BigDecimal(receivePayB).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 10, BigDecimal.ROUND_HALF_UP); | |||||
| } | } | ||||
| Long realReceivePay = servicePay.longValue() + receivePayB; | |||||
| deposit.setRealReceivePay(realReceivePay); | |||||
| deposit.setServiceChargePay(servicePay.intValue()); | |||||
| BigDecimal realReceivePay = servicePay.add(new BigDecimal(receivePayB)); | |||||
| deposit.setRealReceivePay(realReceivePay.toPlainString()); | |||||
| deposit.setServiceChargePay(servicePay.toPlainString()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -126,9 +127,9 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { | |||||
| @Override | @Override | ||||
| public ResultData saveOrUpdate(WxBillDeposit record, MallUserInfo user) { | public ResultData saveOrUpdate(WxBillDeposit record, MallUserInfo user) { | ||||
| int receivepay = record.getReceivePay() == null ? 0 : record.getReceivePay().intValue(); | |||||
| int pay = record.getPay()==null?0:record.getPay().intValue(); | |||||
| if(pay>receivepay){ | |||||
| String receivepay = StringUtils.isBlank(record.getReceivePay()) ? "0" : record.getReceivePay(); | |||||
| String pay = StringUtils.isBlank(record.getPay()) ? "0":record.getPay(); | |||||
| if(new BigDecimal(pay).compareTo(new BigDecimal(receivepay)) > 0){ | |||||
| return new ResultData(ErrorCode.BILL_PAY_ERROR.getCode(), "实收金额不能大于实际应收金额"); | return new ResultData(ErrorCode.BILL_PAY_ERROR.getCode(), "实收金额不能大于实际应收金额"); | ||||
| } | } | ||||
| Date date = new Date(); | Date date = new Date(); | ||||
| @@ -138,7 +139,7 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { | |||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| record.setCreatetime(date); | record.setCreatetime(date); | ||||
| record.setUpdatetime(date); | record.setUpdatetime(date); | ||||
| record.setOwe(record.getReceivePay() - record.getPay()); | |||||
| record.setOwe(new BigDecimal(receivepay).subtract(new BigDecimal(pay)).toPlainString()); | |||||
| record.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | record.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | ||||
| try { | try { | ||||
| wxBillDepositMapper.insert(record); | wxBillDepositMapper.insert(record); | ||||
| @@ -153,10 +154,10 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { | |||||
| if(wxBillDeposit==null){ | if(wxBillDeposit==null){ | ||||
| return new ResultData(ErrorCode.BILL_RENT_DEPOSIT_IS_NOT_FOUND); | return new ResultData(ErrorCode.BILL_RENT_DEPOSIT_IS_NOT_FOUND); | ||||
| } | } | ||||
| Long addpay = wxBillDeposit.getPay(); | |||||
| String addpay = wxBillDeposit.getPay(); | |||||
| wxBillDeposit.setPay(record.getPay()); | wxBillDeposit.setPay(record.getPay()); | ||||
| wxBillDeposit.setReceivePay(record.getReceivePay()); | wxBillDeposit.setReceivePay(record.getReceivePay()); | ||||
| wxBillDeposit.setOwe(record.getReceivePay() - record.getPay()); | |||||
| wxBillDeposit.setOwe(new BigDecimal(receivepay).subtract(new BigDecimal(pay)).toPlainString()); | |||||
| if (record.getPay().equals(record.getReceivePay())) { | if (record.getPay().equals(record.getReceivePay())) { | ||||
| wxBillDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | wxBillDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | ||||
| Date receiveDate = wxBillDeposit.getReceiveDate(); | Date receiveDate = wxBillDeposit.getReceiveDate(); | ||||
| @@ -175,24 +176,24 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { | |||||
| logger.error("更新租赁押金账单失败,e:" + e.getMessage()); | logger.error("更新租赁押金账单失败,e:" + e.getMessage()); | ||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | ||||
| } | } | ||||
| //日志 | |||||
| WxBillAction wxBillAction = new WxBillAction(); | |||||
| wxBillAction.setBillId(wxBillDeposit.getId()); | |||||
| String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | |||||
| String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | |||||
| wxBillAction.setDetails(message + price + "元"); | |||||
| wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); | |||||
| wxBillAction.setUserId(user.getId()); | |||||
| wxBillAction.setUserName(user.getName()); | |||||
| wxBillAction.setPhone(user.getPhone()); | |||||
| wxBillAction.updateTenantInfo(user); | |||||
| wxBillAction.setPayDate(wxBillDeposit.getPayDate()); | |||||
| try { | |||||
| wxBillActionService.save(wxBillAction); | |||||
| } catch (Exception e) { | |||||
| logger.error("添加租赁押金账单行为日志,e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| // //日志 | |||||
| // WxBillAction wxBillAction = new WxBillAction(); | |||||
| // wxBillAction.setBillId(wxBillDeposit.getId()); | |||||
| // String message = EnumBillPayWay.getEnum(record.getPayWay()).getMessage(); | |||||
| // String price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | |||||
| // wxBillAction.setDetails(message + price + "元"); | |||||
| // wxBillAction.setAction(EnumBillAction.OFFLINE_PAY.getCode()); | |||||
| // wxBillAction.setUserId(user.getId()); | |||||
| // wxBillAction.setUserName(user.getName()); | |||||
| // wxBillAction.setPhone(user.getPhone()); | |||||
| // wxBillAction.updateTenantInfo(user); | |||||
| // wxBillAction.setPayDate(wxBillDeposit.getPayDate()); | |||||
| // try { | |||||
| // wxBillActionService.save(wxBillAction); | |||||
| // } catch (Exception e) { | |||||
| // logger.error("添加租赁押金账单行为日志,e:" + e.getMessage()); | |||||
| // throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| // } | |||||
| return new ResultData(Result.SUCCESS, "更新租赁押金账单成功", wxBillDeposit); | return new ResultData(Result.SUCCESS, "更新租赁押金账单成功", wxBillDeposit); | ||||
| } | } | ||||
| } | } | ||||
| @@ -268,7 +269,7 @@ public class WxBillDepositServiceImpl implements WxBillDepositService { | |||||
| return new ResultData(ErrorCode.BILL_RENT_DEPOSIT_IS_NOT_FOUND); | return new ResultData(ErrorCode.BILL_RENT_DEPOSIT_IS_NOT_FOUND); | ||||
| } | } | ||||
| wxBillDeposit.setReceivePay(record.getReceivePay()); | wxBillDeposit.setReceivePay(record.getReceivePay()); | ||||
| wxBillDeposit.setOwe(record.getReceivePay() - record.getPay()); | |||||
| wxBillDeposit.setOwe(new BigDecimal(record.getReceivePay()).subtract(new BigDecimal(record.getPay())).toPlainString()); | |||||
| wxBillDeposit.setUpdatetime(new Date()); | wxBillDeposit.setUpdatetime(new Date()); | ||||
| try { | try { | ||||
| wxBillDepositMapper.updateById(wxBillDeposit); | wxBillDepositMapper.updateById(wxBillDeposit); | ||||
| @@ -153,9 +153,9 @@ public class WxBillRentManageServiceImpl implements WxBillRentManageService { | |||||
| @Override | @Override | ||||
| public ResultData saveOrUpdate(WxBillRentManage record, MallUserInfo user) { | public ResultData saveOrUpdate(WxBillRentManage record, MallUserInfo user) { | ||||
| int receivepay = record.getRealReceivePay() == null ? 0 : record.getRealReceivePay().intValue(); | |||||
| int pay = record.getPay()==null?0:record.getPay().intValue(); | |||||
| if(pay>receivepay){ | |||||
| String receivepay = StringUtils.isBlank(record.getRealReceivePay()) ? "0" : record.getRealReceivePay(); | |||||
| String pay = StringUtils.isBlank(record.getPay()) ? "0" : record.getPay(); | |||||
| if(new BigDecimal(pay).compareTo(new BigDecimal(receivepay)) > 0 ){ | |||||
| return new ResultData(ErrorCode.BILL_PAY_ERROR.getCode(), "实收金额不能大于实际应收总金额"); | return new ResultData(ErrorCode.BILL_PAY_ERROR.getCode(), "实收金额不能大于实际应收总金额"); | ||||
| } | } | ||||
| Date date = new Date(); | Date date = new Date(); | ||||
| @@ -164,7 +164,7 @@ public class WxBillRentManageServiceImpl implements WxBillRentManageService { | |||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| record.setCreatetime(date); | record.setCreatetime(date); | ||||
| record.setUpdatetime(date); | record.setUpdatetime(date); | ||||
| record.setOwe(record.getReceivePay()-record.getPay()); | |||||
| record.setOwe(new BigDecimal(receivepay).subtract(new BigDecimal(pay)).toPlainString()); | |||||
| record.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | record.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | ||||
| try { | try { | ||||
| wxBillRentManageMapper.insert(record); | wxBillRentManageMapper.insert(record); | ||||
| @@ -183,18 +183,18 @@ public class WxBillRentManageServiceImpl implements WxBillRentManageService { | |||||
| String price = ""; | String price = ""; | ||||
| String message =""; | String message =""; | ||||
| if(record.getServiceChargePayUpdate() != null){ | if(record.getServiceChargePayUpdate() != null){ | ||||
| Double l = Double.valueOf(record.getServiceChargePayUpdate())*100; | |||||
| wxBillRent.setServiceChargePay(l.intValue()); | |||||
| long latePayPrice = wxBillRent.getLatePayPrice() == null ? 0 : wxBillRent.getLatePayPrice(); | |||||
| wxBillRent.setOwe(wxBillRent.getReceivePay() + latePayPrice + wxBillRent.getServiceChargePay() - wxBillRent.getPay()); | |||||
| wxBillRent.setServiceChargePay(record.getServiceChargePayUpdate()); | |||||
| String latePayPrice = StringUtils.isBlank(wxBillRent.getLatePayPrice()) ? "0" : wxBillRent.getLatePayPrice(); | |||||
| wxBillRent.setOwe(new BigDecimal(wxBillRent.getReceivePay()).add(new BigDecimal(latePayPrice)).add(new BigDecimal(wxBillRent.getServiceChargePay())) | |||||
| .subtract(new BigDecimal(wxBillRent.getPay())).toPlainString()); | |||||
| }else{ | }else{ | ||||
| Long addpay = wxBillRent.getPay(); | |||||
| String addpay = wxBillRent.getPay(); | |||||
| wxBillRent.setLatePayRatio(record.getLatePayRatio()); | wxBillRent.setLatePayRatio(record.getLatePayRatio()); | ||||
| wxBillRent.setLatePayTime(record.getLatePayTime()); | wxBillRent.setLatePayTime(record.getLatePayTime()); | ||||
| wxBillRent.setLatePayStatus(record.getLatePayStatus()); | wxBillRent.setLatePayStatus(record.getLatePayStatus()); | ||||
| wxBillRent.setPay(record.getPay()); | wxBillRent.setPay(record.getPay()); | ||||
| wxBillRent.setReceivePay(record.getReceivePay()); | wxBillRent.setReceivePay(record.getReceivePay()); | ||||
| wxBillRent.setOwe(record.getRealReceivePay() - record.getPay()); | |||||
| wxBillRent.setOwe(new BigDecimal(receivepay).subtract(new BigDecimal(pay)).toPlainString()); | |||||
| if (record.getPay().equals(record.getRealReceivePay())) { | if (record.getPay().equals(record.getRealReceivePay())) { | ||||
| wxBillRent.setStatus(EnumBillRentStatus.PAID.getCode()); | wxBillRent.setStatus(EnumBillRentStatus.PAID.getCode()); | ||||
| Date payDate = record.getPayDate(); | Date payDate = record.getPayDate(); | ||||
| @@ -208,7 +208,7 @@ public class WxBillRentManageServiceImpl implements WxBillRentManageService { | |||||
| wxBillRent.setPayDate(record.getPayDate()); | wxBillRent.setPayDate(record.getPayDate()); | ||||
| wxBillRent.setUpdatetime(date); | wxBillRent.setUpdatetime(date); | ||||
| wxBillRent.setPayWay(record.getPayWay()); | wxBillRent.setPayWay(record.getPayWay()); | ||||
| price = new BigDecimal(record.getPay() - addpay).divide(new BigDecimal(100)).toPlainString(); | |||||
| price = new BigDecimal(record.getPay()).subtract(new BigDecimal(addpay)).toPlainString(); | |||||
| } | } | ||||
| try { | try { | ||||
| @@ -251,7 +251,7 @@ public class WxBillRentManageServiceImpl implements WxBillRentManageService { | |||||
| record.updateTenantInfo(tenantEntity); | record.updateTenantInfo(tenantEntity); | ||||
| PageInfo<WxBillRentManage> page = getBillRentManageList(1, 1, record, wxPayAccountBill); | PageInfo<WxBillRentManage> page = getBillRentManageList(1, 1, record, wxPayAccountBill); | ||||
| WxBillRentManage rentManage = page.getList().get(0); | WxBillRentManage rentManage = page.getList().get(0); | ||||
| rentManage.setOwe(rentManage.getRealReceivePay() - rentManage.getPay()); | |||||
| rentManage.setOwe(new BigDecimal(rentManage.getRealReceivePay()).subtract(new BigDecimal(rentManage.getPay())).toPlainString()); | |||||
| return rentManage; | return rentManage; | ||||
| } | } | ||||
| @@ -265,21 +265,21 @@ public class WxBillRentManageServiceImpl implements WxBillRentManageService { | |||||
| public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillRentManage rent) { | public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillRentManage rent) { | ||||
| if (rent.getReceivePay() != null) { | if (rent.getReceivePay() != null) { | ||||
| if (rent.getLatePayPrice() == null) { | if (rent.getLatePayPrice() == null) { | ||||
| rent.setLatePayPrice(0L); | |||||
| rent.setLatePayPrice("0"); | |||||
| } | } | ||||
| BigDecimal servicePay; | BigDecimal servicePay; | ||||
| if (rent.getServiceChargePay() != null) { | if (rent.getServiceChargePay() != null) { | ||||
| servicePay = new BigDecimal(rent.getServiceChargePay()); | servicePay = new BigDecimal(rent.getServiceChargePay()); | ||||
| } else { | } else { | ||||
| servicePay = new BigDecimal(rent.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); | |||||
| servicePay = new BigDecimal(rent.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 10, BigDecimal.ROUND_HALF_UP); | |||||
| } | } | ||||
| Long realReceivePay = servicePay.longValue() + rent.getLatePayPrice() + rent.getReceivePay(); | |||||
| rent.setRealReceivePay(realReceivePay); | |||||
| rent.setServiceChargePay(servicePay.intValue()); | |||||
| BigDecimal realReceivePay = servicePay.add(new BigDecimal(rent.getLatePayPrice()).add(new BigDecimal(rent.getReceivePay()))); | |||||
| rent.setRealReceivePay(realReceivePay.toPlainString()); | |||||
| rent.setServiceChargePay(servicePay.toPlainString()); | |||||
| if (!rent.getStatus().equals(EnumBillRentStatus.NOT_PAID.getCode())) { | if (!rent.getStatus().equals(EnumBillRentStatus.NOT_PAID.getCode())) { | ||||
| rent.setOwe(0L); | |||||
| rent.setOwe("0"); | |||||
| } else { | } else { | ||||
| rent.setOwe(realReceivePay - rent.getPay()); | |||||
| rent.setOwe(realReceivePay.subtract(new BigDecimal(rent.getPay())).toPlainString()); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -288,8 +288,8 @@ public class WxBillRentManageServiceImpl implements WxBillRentManageService { | |||||
| public ResultData updateLatePayMoney(WxBillRentManage record, MallUserInfo user) { | public ResultData updateLatePayMoney(WxBillRentManage record, MallUserInfo user) { | ||||
| WxBillRentManage rent = wxBillRentManageMapper.selectById(record.getId()); | WxBillRentManage rent = wxBillRentManageMapper.selectById(record.getId()); | ||||
| if(record.getLatePayMoneyUpdate() != null) { | if(record.getLatePayMoneyUpdate() != null) { | ||||
| rent.setLatePayPrice(Long.parseLong(record.getLatePayMoneyUpdate()) * 100); | |||||
| rent.setOwe(rent.getReceivePay() + rent.getLatePayPrice() + rent.getServiceChargePay() - rent.getPay()); | |||||
| rent.setLatePayPrice(record.getLatePayMoneyUpdate()); | |||||
| rent.setOwe(new BigDecimal(rent.getReceivePay()).add(new BigDecimal(rent.getLatePayPrice())).add(new BigDecimal(rent.getServiceChargePay())).subtract(new BigDecimal(rent.getPay())).toPlainString()); | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| WxBillAction billAction = new WxBillAction(); | WxBillAction billAction = new WxBillAction(); | ||||
| billAction.setId(idWorker.nextId()); | billAction.setId(idWorker.nextId()); | ||||
| @@ -76,7 +76,7 @@ public class WxBillRentServiceImpl implements WxBillRentService { | |||||
| public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillRent rent) { | public void computeTotalMoney(WxPayAccountBill wxPayAccountBill, WxBillRent rent) { | ||||
| if (rent.getReceivePay() != null) { | if (rent.getReceivePay() != null) { | ||||
| if (rent.getLatePayPrice() == null) { | if (rent.getLatePayPrice() == null) { | ||||
| rent.setLatePayPrice(0L); | |||||
| rent.setLatePayPrice("0"); | |||||
| } | } | ||||
| BigDecimal servicePay; | BigDecimal servicePay; | ||||
| if (rent.getServiceChargePay() != null) { | if (rent.getServiceChargePay() != null) { | ||||
| @@ -165,9 +165,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| //init rentPrice | //init rentPrice | ||||
| if(StringUtils.isNotBlank(wxRentContract.getRentPrice())){ | |||||
| wxRentContract.setRentPrice(Double.parseDouble(wxRentContract.getRentPrice())/100 + ""); | |||||
| } | |||||
| //if(StringUtils.isNotBlank(wxRentContract.getRentPrice())){ | |||||
| //wxRentContract.setRentPrice(Double.parseDouble(wxRentContract.getRentPrice())/100 + ""); | |||||
| //} | |||||
| //init 租赁单价 | //init 租赁单价 | ||||
| String rentInfo = wxRentContract.getRentInfo(); | String rentInfo = wxRentContract.getRentInfo(); | ||||
| @@ -177,13 +177,13 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| //查询rent_info 包括shopId | //查询rent_info 包括shopId | ||||
| for (int i = 0; i < size; i++) { | for (int i = 0; i < size; i++) { | ||||
| JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); | ||||
| Double rentPrice = rentInfoObject.getDouble("rentPrice"); | |||||
| BigDecimal rentPrice = rentInfoObject.getBigDecimal("rentPrice"); | |||||
| //wxRentContract.setShopId(rentInfoObject.getLong("shopId")); | //wxRentContract.setShopId(rentInfoObject.getLong("shopId")); | ||||
| String price = wxRentContract.getPrice(); | String price = wxRentContract.getPrice(); | ||||
| if(rentPrice == null){ | if(rentPrice == null){ | ||||
| if(StringUtils.isNotBlank(wxRentContract.getRentArea()) && !"0".equals(wxRentContract.getRentArea()) && !"0.00".equals(wxRentContract.getRentArea()) && !"0.0".equals(wxRentContract.getRentArea()) ) { | if(StringUtils.isNotBlank(wxRentContract.getRentArea()) && !"0".equals(wxRentContract.getRentArea()) && !"0.00".equals(wxRentContract.getRentArea()) && !"0.0".equals(wxRentContract.getRentArea()) ) { | ||||
| Double rentArea = Double.parseDouble(wxRentContract.getRentArea()); | Double rentArea = Double.parseDouble(wxRentContract.getRentArea()); | ||||
| rentPrice = new BigDecimal(price).divide(new BigDecimal(rentArea)).setScale(wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP).doubleValue(); | |||||
| rentPrice = new BigDecimal(price).divide(new BigDecimal(rentArea),wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||||
| rentInfoObject.put("rentPrice", rentPrice); | rentInfoObject.put("rentPrice", rentPrice); | ||||
| } | } | ||||
| } | } | ||||
| @@ -194,8 +194,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| if(StringUtils.isNotBlank(wxRentContract.getRentArea()) && !"0".equals(wxRentContract.getRentArea()) && !"0.00".equals(wxRentContract.getRentArea()) && !"0.0".equals(wxRentContract.getRentArea()) ) { | if(StringUtils.isNotBlank(wxRentContract.getRentArea()) && !"0".equals(wxRentContract.getRentArea()) && !"0.00".equals(wxRentContract.getRentArea()) && !"0.0".equals(wxRentContract.getRentArea()) ) { | ||||
| String price = wxRentContract.getPrice(); | String price = wxRentContract.getPrice(); | ||||
| Double rentArea = Double.parseDouble(wxRentContract.getRentArea()); | Double rentArea = Double.parseDouble(wxRentContract.getRentArea()); | ||||
| Double rentPrice = new BigDecimal(price).divide(new BigDecimal(rentArea)).setScale(wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP).doubleValue(); | |||||
| if(rentPrice > 0){ | |||||
| BigDecimal rentPrice = new BigDecimal(price).divide(new BigDecimal(rentArea),wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||||
| if(rentPrice.compareTo(new BigDecimal(0)) > 0){ | |||||
| wxRentContract.setRentPrice(rentPrice.toString()); | wxRentContract.setRentPrice(rentPrice.toString()); | ||||
| }else{ | }else{ | ||||
| wxRentContract.setRentPrice("0"); | wxRentContract.setRentPrice("0"); | ||||
| @@ -740,7 +740,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| bill.setShopId(shopIds.get(0)); | bill.setShopId(shopIds.get(0)); | ||||
| } | } | ||||
| setManageExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod()); | setManageExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod()); | ||||
| if (bill.getReceivePay().equals(0L)) { | |||||
| if (bill.getReceivePay().equals("0")) { | |||||
| bill.setStatus(EnumBillRentStatus.PAID.getCode()); | bill.setStatus(EnumBillRentStatus.PAID.getCode()); | ||||
| bill.setPayDate(date); | bill.setPayDate(date); | ||||
| } | } | ||||
| @@ -1295,19 +1295,22 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| return shopInfoStr; | return shopInfoStr; | ||||
| } | } | ||||
| private String getRentPriceInfo(WxRentContract wxRentContract, long contractNeedPay){ | |||||
| if(contractNeedPay == 0l){ | |||||
| private String getRentPriceInfo(WxRentContract wxRentContract, BigDecimal contractNeedPay){ | |||||
| if(contractNeedPay.compareTo(new BigDecimal(0)) == 0){ | |||||
| return null; | return null; | ||||
| } | } | ||||
| long rentPrice = 0l, siteMoney = 0l, facilityMoney = 0l, administratorMoney = 0l,managementMoney = 0l; | |||||
| BigDecimal rentPrice = new BigDecimal(0), siteMoney = new BigDecimal(0), facilityMoney = new BigDecimal(0), administratorMoney = new BigDecimal(0),managementMoney = new BigDecimal(0); | |||||
| if(!wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode()) && | if(!wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode()) && | ||||
| !wxRentContract.getType().equals(EnumRentContractType.RENT_BY_COUNT.getCode()) | !wxRentContract.getType().equals(EnumRentContractType.RENT_BY_COUNT.getCode()) | ||||
| && !wxRentContract.getType().equals(EnumRentContractType.RENT_BY_CUSTOMIZE.getCode())){ | && !wxRentContract.getType().equals(EnumRentContractType.RENT_BY_CUSTOMIZE.getCode())){ | ||||
| if(wxRentContract.getRentInputWay().equals(EnumRentContractRentInputWay.PART.getCode())){ | if(wxRentContract.getRentInputWay().equals(EnumRentContractRentInputWay.PART.getCode())){ | ||||
| String rentInfo = wxRentContract.getRentInfo(); | String rentInfo = wxRentContract.getRentInfo(); | ||||
| JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | ||||
| long[] priceList = WxRentContractHelper.computeRentPriceByShop(wxRentContract).get(0); | |||||
| long sum = Arrays.stream(priceList).sum(); | |||||
| String[] priceList = WxRentContractHelper.computeRentPriceByShop(wxRentContract).get(0); | |||||
| BigDecimal sum = new BigDecimal(0); | |||||
| for (int i = 0 ; i < priceList.length ; i++) { | |||||
| sum = sum.add(new BigDecimal(priceList[i])); | |||||
| } | |||||
| int size = rentInfoArray.size(); | int size = rentInfoArray.size(); | ||||
| for (int i = 0;i < size;i++) { | for (int i = 0;i < size;i++) { | ||||
| BigDecimal a=new BigDecimal(0),b=new BigDecimal(0),c=new BigDecimal(0),d=new BigDecimal(0),e=new BigDecimal(0); | BigDecimal a=new BigDecimal(0),b=new BigDecimal(0),c=new BigDecimal(0),d=new BigDecimal(0),e=new BigDecimal(0); | ||||
| @@ -1343,23 +1346,24 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| } | } | ||||
| rentPrice += new BigDecimal(contractNeedPay).multiply(new BigDecimal(priceList[i])).divide(new BigDecimal(sum),2,BigDecimal.ROUND_HALF_UP) | |||||
| .multiply(a).divide(a.add(b).add(c).add(d).add(e),2,BigDecimal.ROUND_HALF_UP).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| siteMoney += new BigDecimal(contractNeedPay).multiply(new BigDecimal(priceList[i])).divide(new BigDecimal(sum),2,BigDecimal.ROUND_HALF_UP) | |||||
| .multiply(b).divide(a.add(b).add(c).add(d).add(e),2,BigDecimal.ROUND_HALF_UP).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| facilityMoney += new BigDecimal(contractNeedPay).multiply(new BigDecimal(priceList[i])).divide(new BigDecimal(sum),2,BigDecimal.ROUND_HALF_UP) | |||||
| .multiply(c).divide(a.add(b).add(c).add(d).add(e),2,BigDecimal.ROUND_HALF_UP).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| administratorMoney += new BigDecimal(contractNeedPay).multiply(new BigDecimal(priceList[i])).divide(new BigDecimal(sum),2,BigDecimal.ROUND_HALF_UP) | |||||
| .multiply(d).divide(a.add(b).add(c).add(d).add(e),2,BigDecimal.ROUND_HALF_UP).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| managementMoney += new BigDecimal(contractNeedPay).multiply(new BigDecimal(priceList[i])).divide(new BigDecimal(sum),2,BigDecimal.ROUND_HALF_UP) | |||||
| .multiply(e).divide(a.add(b).add(c).add(d).add(e),2,BigDecimal.ROUND_HALF_UP).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| rentPrice =rentPrice.add(contractNeedPay.multiply(new BigDecimal(priceList[i])).divide(sum,wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP) | |||||
| .multiply(a).divide(a.add(b).add(c).add(d).add(e),wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP)); | |||||
| siteMoney =siteMoney.add(contractNeedPay.multiply(new BigDecimal(priceList[i])).divide(sum,wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP) | |||||
| .multiply(b).divide(a.add(b).add(c).add(d).add(e),wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP)); | |||||
| facilityMoney =facilityMoney.add(contractNeedPay.multiply(new BigDecimal(priceList[i])).divide(sum,wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP) | |||||
| .multiply(c).divide(a.add(b).add(c).add(d).add(e),wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP)); | |||||
| administratorMoney =administratorMoney.add(contractNeedPay.multiply(new BigDecimal(priceList[i])).divide(sum,wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP) | |||||
| .multiply(d).divide(a.add(b).add(c).add(d).add(e),wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP)); | |||||
| managementMoney =managementMoney.add(contractNeedPay.multiply(new BigDecimal(priceList[i])).divide(sum,wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP) | |||||
| .multiply(e).divide(a.add(b).add(c).add(d).add(e),wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP)); | |||||
| } | } | ||||
| }else{ | }else{ | ||||
| BigDecimal a=new BigDecimal(0),b=new BigDecimal(0),c=new BigDecimal(0),d=new BigDecimal(0),e=new BigDecimal(0); | BigDecimal a=new BigDecimal(0),b=new BigDecimal(0),c=new BigDecimal(0),d=new BigDecimal(0),e=new BigDecimal(0); | ||||
| String rentPrice1 = wxRentContract.getRentPrice(); | String rentPrice1 = wxRentContract.getRentPrice(); | ||||
| if(StringUtils.isNotBlank(rentPrice1)){ | if(StringUtils.isNotBlank(rentPrice1)){ | ||||
| a = new BigDecimal(rentPrice1).divide(new BigDecimal(100)); | |||||
| //a = new BigDecimal(rentPrice1).divide(new BigDecimal(100)); | |||||
| a = new BigDecimal(rentPrice1); | |||||
| } | } | ||||
| String otherRentPriceInfo1 = wxRentContract.getOtherRentPriceInfo(); | String otherRentPriceInfo1 = wxRentContract.getOtherRentPriceInfo(); | ||||
| if(StringUtils.isNotBlank(otherRentPriceInfo1)){ | if(StringUtils.isNotBlank(otherRentPriceInfo1)){ | ||||
| @@ -1384,11 +1388,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| e = new BigDecimal(managementMoney1); | e = new BigDecimal(managementMoney1); | ||||
| } | } | ||||
| } | } | ||||
| rentPrice = new BigDecimal(contractNeedPay).multiply(a).divide(a.add(b).add(c).add(d).add(e),2,BigDecimal.ROUND_HALF_UP).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| siteMoney = new BigDecimal(contractNeedPay).multiply(b).divide(a.add(b).add(c).add(d).add(e),2,BigDecimal.ROUND_HALF_UP).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| facilityMoney = new BigDecimal(contractNeedPay).multiply(c).divide(a.add(b).add(c).add(d).add(e),2,BigDecimal.ROUND_HALF_UP).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| administratorMoney = new BigDecimal(contractNeedPay).multiply(d).divide(a.add(b).add(c).add(d).add(e),2,BigDecimal.ROUND_HALF_UP).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| managementMoney = new BigDecimal(contractNeedPay).multiply(e).divide(a.add(b).add(c).add(d).add(e),2,BigDecimal.ROUND_HALF_UP).setScale(0,BigDecimal.ROUND_HALF_UP).longValue(); | |||||
| rentPrice = contractNeedPay.multiply(a).divide(a.add(b).add(c).add(d).add(e),wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); | |||||
| siteMoney = contractNeedPay.multiply(b).divide(a.add(b).add(c).add(d).add(e),wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); | |||||
| facilityMoney = contractNeedPay.multiply(c).divide(a.add(b).add(c).add(d).add(e),wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); | |||||
| administratorMoney = contractNeedPay.multiply(d).divide(a.add(b).add(c).add(d).add(e),wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); | |||||
| managementMoney = contractNeedPay.multiply(e).divide(a.add(b).add(c).add(d).add(e),wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP).setScale(wxRentContract.getDecimalSize(),BigDecimal.ROUND_HALF_UP); | |||||
| } | } | ||||
| }else{ | }else{ | ||||
| rentPrice = contractNeedPay; | rentPrice = contractNeedPay; | ||||
| @@ -1396,11 +1400,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| Map<String,String> resultMap = new HashedMap(); | Map<String,String> 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()); | |||||
| resultMap.put("managementMoney",new BigDecimal(managementMoney).divide(new BigDecimal(100)).toString()); | |||||
| resultMap.put("rentPrice",rentPrice.toString()); | |||||
| resultMap.put("siteMoney",siteMoney.toString()); | |||||
| resultMap.put("facilityMoney",facilityMoney.toString()); | |||||
| resultMap.put("administratorMoney",administratorMoney.toString()); | |||||
| resultMap.put("managementMoney",managementMoney.toString()); | |||||
| return JSON.toJSONString(resultMap); | return JSON.toJSONString(resultMap); | ||||
| } | } | ||||
| @@ -1448,11 +1452,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| for (int i = 0; i < billTimeVoList.size(); i++) { | for (int i = 0; i < billTimeVoList.size(); i++) { | ||||
| BillTimeVo billTimeVo = billTimeVoList.get(i); | BillTimeVo billTimeVo = billTimeVoList.get(i); | ||||
| //计算金额 | //计算金额 | ||||
| BigDecimal needpay = new BigDecimal(0); | |||||
| String needpay = "0"; | |||||
| //商业管理费 | //商业管理费 | ||||
| BigDecimal bussinessManageFeeNeedpay = new BigDecimal(0); | |||||
| String bussinessManageFeeNeedpay = "0"; | |||||
| //营业管理费 | //营业管理费 | ||||
| BigDecimal operatingManageFeeNeedpay = new BigDecimal(0); | |||||
| String operatingManageFeeNeedpay = "0"; | |||||
| boolean flag = false; | boolean flag = false; | ||||
| //此处逻辑处理这一年和下一年交接那一期账单。 | //此处逻辑处理这一年和下一年交接那一期账单。 | ||||
| @@ -1465,16 +1469,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| index++; | index++; | ||||
| //如果是计算账单金额&cross 拆分日期进行计算 | //如果是计算账单金额&cross 拆分日期进行计算 | ||||
| if(billTimeVo.getEndDate().after(endDate)) { | if(billTimeVo.getEndDate().after(endDate)) { | ||||
| long needpayFront = 0; | |||||
| long needpayAfter = 0; | |||||
| String needpayFront = "0"; | |||||
| String needpayAfter = "0"; | |||||
| //商业管理费 | //商业管理费 | ||||
| long bussinessManageFeeNeedpayFront = 0; | |||||
| long bussinessManageFeeNeedpayAfter = 0; | |||||
| String bussinessManageFeeNeedpayFront = "0"; | |||||
| String bussinessManageFeeNeedpayAfter = "0"; | |||||
| //营业管理费 | //营业管理费 | ||||
| long operatingManageFeeNeedpayFront = 0; | |||||
| long operatingManageFeeNeedpayAfter = 0; | |||||
| String operatingManageFeeNeedpayFront = "0"; | |||||
| String operatingManageFeeNeedpayAfter = "0"; | |||||
| //同一天,算一天 | //同一天,算一天 | ||||
| if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){ | if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){ | ||||
| @@ -1534,9 +1538,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| needpay = needpayFront+needpayAfter; | |||||
| bussinessManageFeeNeedpay = bussinessManageFeeNeedpayFront + bussinessManageFeeNeedpayAfter; | |||||
| operatingManageFeeNeedpay = operatingManageFeeNeedpayFront + operatingManageFeeNeedpayAfter; | |||||
| needpay = new BigDecimal(needpayFront).add(new BigDecimal(needpayAfter)).toPlainString(); | |||||
| bussinessManageFeeNeedpay = new BigDecimal(bussinessManageFeeNeedpayFront).add(new BigDecimal(bussinessManageFeeNeedpayAfter)).toPlainString(); | |||||
| operatingManageFeeNeedpay = new BigDecimal(operatingManageFeeNeedpayFront).add(new BigDecimal(operatingManageFeeNeedpayAfter)).toPlainString(); | |||||
| flag = true; | flag = true; | ||||
| } | } | ||||
| if(index >= yearList.size()-1){ | if(index >= yearList.size()-1){ | ||||
| @@ -1565,13 +1569,13 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| wxBillRent.setIsPreview(isPreview); | wxBillRent.setIsPreview(isPreview); | ||||
| wxBillRent.setId(idWorker.nextId()); | wxBillRent.setId(idWorker.nextId()); | ||||
| wxBillRent.setRentContractId(wxRentContract.getId()); | wxBillRent.setRentContractId(wxRentContract.getId()); | ||||
| wxBillRent.setPay(0L); | |||||
| wxBillRent.setPay("0"); | |||||
| wxBillRent.setStarttime(billTimeVo.getStartDate()); | wxBillRent.setStarttime(billTimeVo.getStartDate()); | ||||
| wxBillRent.setEndtime(billTimeVo.getEndDate()); | wxBillRent.setEndtime(billTimeVo.getEndDate()); | ||||
| wxBillRent.setReceiveDate(billTimeVo.getReceiveDate()); | wxBillRent.setReceiveDate(billTimeVo.getReceiveDate()); | ||||
| wxBillRent.setContractNeedPay(needpay); | wxBillRent.setContractNeedPay(needpay); | ||||
| wxBillRent.setRentPriceInfo(getRentPriceInfo(wxRentContract,needpay)); | |||||
| wxBillRent.setRentPriceInfo(getRentPriceInfo(wxRentContract,new BigDecimal(needpay))); | |||||
| wxBillRent.setNeedPay(needpay); | wxBillRent.setNeedPay(needpay); | ||||
| wxBillRent.setOwe(needpay); | wxBillRent.setOwe(needpay); | ||||
| wxBillRent.setReceivePay(needpay); | wxBillRent.setReceivePay(needpay); | ||||
| @@ -1582,7 +1586,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| //截止收租日在当前时间之前 | //截止收租日在当前时间之前 | ||||
| Date date = new Date(); | Date date = new Date(); | ||||
| setExpiredDay(wxBillRent,dayType,receivePeriod); | setExpiredDay(wxBillRent,dayType,receivePeriod); | ||||
| wxBillRent.setRevenue(0L); | |||||
| wxBillRent.setRevenue("0"); | |||||
| wxBillRent.updateTenantInfo(wxRentContract); | wxBillRent.updateTenantInfo(wxRentContract); | ||||
| wxBillRent.setMerchantId(wxRentContract.getMerchantId()); | wxBillRent.setMerchantId(wxRentContract.getMerchantId()); | ||||
| wxBillRent.setUserId(userId); | wxBillRent.setUserId(userId); | ||||
| @@ -1598,19 +1602,20 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| wxBillRent.setLatePayRatio(0); | wxBillRent.setLatePayRatio(0); | ||||
| //计算手续费 | //计算手续费 | ||||
| BigDecimal servicePay = new BigDecimal(wxBillRent.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); | |||||
| wxBillRent.setServiceChargePay(servicePay.intValue()); | |||||
| wxBillRent.setOwe(wxBillRent.getReceivePay() + wxBillRent.getServiceChargePay()); | |||||
| BigDecimal servicePay = new BigDecimal(wxBillRent.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())) | |||||
| .divide(new BigDecimal(10000), wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||||
| wxBillRent.setServiceChargePay(servicePay.toPlainString()); | |||||
| wxBillRent.setOwe(new BigDecimal(wxBillRent.getReceivePay()).add(new BigDecimal(wxBillRent.getServiceChargePay())).toPlainString()); | |||||
| resultList.add(wxBillRent); | resultList.add(wxBillRent); | ||||
| //商业管理费账单 | //商业管理费账单 | ||||
| if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0 && bussinessManageFeeNeedpay > 0) { | |||||
| manageList.add(setManageRent(wxBillRent,EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE,bussinessManageFeeNeedpay,wxPayAccountBill.getServiceChargeRate(),dayType,receivePeriod)); | |||||
| if (null != bussinessManagerPriceArrs && bussinessManagerPriceArrs.length > 0 && new BigDecimal(bussinessManageFeeNeedpay).compareTo(new BigDecimal(0)) > 0) { | |||||
| manageList.add(setManageRent(wxRentContract.getDecimalSize(),wxBillRent,EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE,bussinessManageFeeNeedpay,wxPayAccountBill.getServiceChargeRate(),dayType,receivePeriod)); | |||||
| } | } | ||||
| //营业管理费账单 | //营业管理费账单 | ||||
| if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0 && operatingManageFeeNeedpay > 0 ) { | |||||
| manageList.add(setManageRent(wxBillRent,EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE,operatingManageFeeNeedpay,wxPayAccountBill.getServiceChargeRate(),dayType,receivePeriod)); | |||||
| if (null != operationManagerPriceArrs && operationManagerPriceArrs.length > 0 && new BigDecimal(operatingManageFeeNeedpay).compareTo(new BigDecimal(0)) > 0 ) { | |||||
| manageList.add(setManageRent(wxRentContract.getDecimalSize(),wxBillRent,EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE,operatingManageFeeNeedpay,wxPayAccountBill.getServiceChargeRate(),dayType,receivePeriod)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1627,7 +1632,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| private WxBillRentManage setManageRent(WxBillRent wxBillRent,EnumRentContractManageFeeType feeType,Long needPay,Integer serviceChargeRate,int dayType,int receivePeriod) { | |||||
| private WxBillRentManage setManageRent(Integer decimalSize,WxBillRent wxBillRent,EnumRentContractManageFeeType feeType,String needPay,Integer serviceChargeRate,int dayType,int receivePeriod) { | |||||
| WxBillRentManage manage = new WxBillRentManage(); | WxBillRentManage manage = new WxBillRentManage(); | ||||
| manage.initByBillRent(wxBillRent); | manage.initByBillRent(wxBillRent); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| @@ -1638,9 +1643,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| manage.setOwe(needPay); | manage.setOwe(needPay); | ||||
| setManageExpiredDay(manage,dayType,receivePeriod); | setManageExpiredDay(manage,dayType,receivePeriod); | ||||
| //计算手续费 | //计算手续费 | ||||
| BigDecimal servicePay = new BigDecimal(needPay).multiply(new BigDecimal(serviceChargeRate)).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); | |||||
| manage.setServiceChargePay(servicePay.intValue()); | |||||
| manage.setOwe(needPay + manage.getServiceChargePay()); | |||||
| BigDecimal servicePay = new BigDecimal(needPay).multiply(new BigDecimal(serviceChargeRate)).divide(new BigDecimal(10000), decimalSize, BigDecimal.ROUND_HALF_UP); | |||||
| manage.setServiceChargePay(servicePay.toPlainString()); | |||||
| manage.setOwe(new BigDecimal(needPay).add(new BigDecimal(manage.getServiceChargePay())).toPlainString()); | |||||
| return manage; | return manage; | ||||
| } | } | ||||
| @@ -1949,7 +1954,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| //建立账单 | //建立账单 | ||||
| //自定义账单无单价,为能生成账单,设置该值 | //自定义账单无单价,为能生成账单,设置该值 | ||||
| if (EnumRentContractType.RENT_BY_CUSTOMIZE.getCode() == record.getType()) { | if (EnumRentContractType.RENT_BY_CUSTOMIZE.getCode() == record.getType()) { | ||||
| record.setPrice(1L); | |||||
| record.setPrice("0.01"); | |||||
| } | } | ||||
| if (record != null && | if (record != null && | ||||
| record.getMerchantId() != null && | record.getMerchantId() != null && | ||||
| @@ -1963,7 +1968,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| // WxMerchant wxMerchant = new WxMerchant(); | // WxMerchant wxMerchant = new WxMerchant(); | ||||
| // wxMerchant.setId(record.getMerchantId()); | // wxMerchant.setId(record.getMerchantId()); | ||||
| // wxMerchant.updateTenantInfo(record); | // wxMerchant.updateTenantInfo(record); | ||||
| if(record.getDeposit() > 0) { | |||||
| if(new BigDecimal(record.getDeposit()).compareTo(new BigDecimal(0)) > 0) { | |||||
| //押金 | //押金 | ||||
| buildDeposit( null, id); | buildDeposit( null, id); | ||||
| } | } | ||||
| @@ -2766,7 +2771,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| public void areaWay(WxRentContract wxRentContract, Map<String, Object> result, Integer lease, int extralease, int extracount, int paycount, int index, int count, BigDecimal rentPrice) { | public void areaWay(WxRentContract wxRentContract, Map<String, Object> result, Integer lease, int extralease, int extracount, int paycount, int index, int count, BigDecimal rentPrice) { | ||||
| long[] priceArrs = new long[]{}; | |||||
| String[] priceArrs = new String[]{}; | |||||
| List<String> adjustRatioList = new ArrayList<>(); | List<String> adjustRatioList = new ArrayList<>(); | ||||
| adjustRatioList.add(0, "0"); | adjustRatioList.add(0, "0"); | ||||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | ||||
| @@ -2784,16 +2789,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| adjustRatioList.add(adjustRatioStr.toString()); | adjustRatioList.add(adjustRatioStr.toString()); | ||||
| } | } | ||||
| List<long[]> priceList = WxRentContractHelper.computeRentPriceByShop(wxRentContract); | |||||
| List<String[]> priceList = WxRentContractHelper.computeRentPriceByShop(wxRentContract); | |||||
| int size = priceList.size(); | int size = priceList.size(); | ||||
| priceArrs = new long[size]; | |||||
| priceArrs = new String[size]; | |||||
| for (int i = 0; i < size; i++) { | for (int i = 0; i < size; i++) { | ||||
| long[] priceInt = priceList.get(i); | |||||
| long sum = 0; | |||||
| for (long p : priceInt) { | |||||
| sum += p; | |||||
| String[] priceInt = priceList.get(i); | |||||
| BigDecimal sum = new BigDecimal(0); | |||||
| for (String p : priceInt) { | |||||
| sum = sum.add(new BigDecimal(p)); | |||||
| } | } | ||||
| priceArrs[i] = sum; | |||||
| priceArrs[i] = sum.toPlainString(); | |||||
| } | } | ||||
| } else { | } else { | ||||
| String adjustRatio = wxRentContract.getAdjustRatio(); | String adjustRatio = wxRentContract.getAdjustRatio(); | ||||
| @@ -2832,15 +2837,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| result.put("rentalEndDateDay" + i, enddate.substring(8)); | result.put("rentalEndDateDay" + i, enddate.substring(8)); | ||||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | ||||
| rentPrice = new BigDecimal(priceArrs[i]).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN); | |||||
| rentPrice = new BigDecimal(priceArrs[i]).divide(new BigDecimal(100)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN); | |||||
| result.put("priceRentUpper" + i, PriceUtil.digitUppercase(rentPrice.doubleValue())); | result.put("priceRentUpper" + i, PriceUtil.digitUppercase(rentPrice.doubleValue())); | ||||
| result.put("priceRent" + i, rentPrice.doubleValue()); | |||||
| result.put("priceRent" + i, rentPrice.toPlainString()); | |||||
| result.put("adjustRatio" + i, adjustRatioList.get(i)); | result.put("adjustRatio" + i, adjustRatioList.get(i)); | ||||
| } else { | } else { | ||||
| rentPrice = rentPrice.multiply(new BigDecimal(adjustRatioList.get(i))) | rentPrice = rentPrice.multiply(new BigDecimal(adjustRatioList.get(i))) | ||||
| .add(rentPrice).setScale(2, RoundingMode.HALF_EVEN); | |||||
| .add(rentPrice).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN); | |||||
| result.put("priceRentUpper" + i, PriceUtil.digitUppercase(rentPrice.doubleValue())); | result.put("priceRentUpper" + i, PriceUtil.digitUppercase(rentPrice.doubleValue())); | ||||
| result.put("priceRent" + i, rentPrice.doubleValue()); | |||||
| result.put("priceRent" + i, rentPrice.toPlainString()); | |||||
| result.put("adjustRatio" + i, adjustRatioList.get(i)); | result.put("adjustRatio" + i, adjustRatioList.get(i)); | ||||
| } | } | ||||
| result.put("payRatio" + i, payRatioStr); | result.put("payRatio" + i, payRatioStr); | ||||
| @@ -2871,14 +2876,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| result.put("rentalEndDateDay" + count, enddate.substring(8)); | result.put("rentalEndDateDay" + count, enddate.substring(8)); | ||||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | ||||
| rentPrice = new BigDecimal(priceArrs[count]).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN); | |||||
| rentPrice = new BigDecimal(priceArrs[count]).divide(new BigDecimal(100)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN); | |||||
| result.put("priceRentUpper" + count, PriceUtil.digitUppercase(rentPrice.doubleValue())); | result.put("priceRentUpper" + count, PriceUtil.digitUppercase(rentPrice.doubleValue())); | ||||
| result.put("priceRent" + count, rentPrice.doubleValue()); | |||||
| result.put("priceRent" + count, rentPrice.toPlainString()); | |||||
| } else { | } else { | ||||
| rentPrice = rentPrice.multiply(new BigDecimal(adjustRatioList.get(count))) | rentPrice = rentPrice.multiply(new BigDecimal(adjustRatioList.get(count))) | ||||
| .add(rentPrice).setScale(2, RoundingMode.HALF_EVEN); | |||||
| .add(rentPrice).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN); | |||||
| result.put("priceRentUpper" + count, PriceUtil.digitUppercase(rentPrice.doubleValue())); | result.put("priceRentUpper" + count, PriceUtil.digitUppercase(rentPrice.doubleValue())); | ||||
| result.put("priceRent" + count, rentPrice.doubleValue()); | |||||
| result.put("priceRent" + count, rentPrice.toPlainString()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -3266,44 +3271,43 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| WxBillRent br = billList.get(j); | WxBillRent br = billList.get(j); | ||||
| try { | try { | ||||
| //判断账单是否跨月,如果跨月,需要按照每月来查询解单金额 | //判断账单是否跨月,如果跨月,需要按照每月来查询解单金额 | ||||
| int needPay = 0 ; | |||||
| BigDecimal needPay = new BigDecimal(0) ; | |||||
| int months = DateUtils.monthsBetween(br.getStarttime(), br.getEndtime()); | int months = DateUtils.monthsBetween(br.getStarttime(), br.getEndtime()); | ||||
| if ( months > 0 ) { | if ( months > 0 ) { | ||||
| for (int i = 0 ; i <= months ; i++ ) { | for (int i = 0 ; i <= months ; i++ ) { | ||||
| int _money = 0; | |||||
| BigDecimal _money = new BigDecimal(0); | |||||
| if (i == 0 ) { | if (i == 0 ) { | ||||
| _money = sumTradeDailyBySameMonthDay(bq, wxRentContract.getMerchantId(), br.getStarttime(), | |||||
| _money = sumTradeDailyBySameMonthDay(wxRentContract.getDecimalSize(),bq, wxRentContract.getMerchantId(), br.getStarttime(), | |||||
| DateUtils.getLastDayForMonth(br.getStarttime())); | DateUtils.getLastDayForMonth(br.getStarttime())); | ||||
| }else if (i == months){ | }else if (i == months){ | ||||
| _money = sumTradeDailyBySameMonthDay(bq, wxRentContract.getMerchantId(), | |||||
| _money = sumTradeDailyBySameMonthDay(wxRentContract.getDecimalSize(),bq, wxRentContract.getMerchantId(), | |||||
| DateUtils.getFirstDayForCurrMonth(DateUtils.getTimeAfterMonths(i,br.getStarttime())), | DateUtils.getFirstDayForCurrMonth(DateUtils.getTimeAfterMonths(i,br.getStarttime())), | ||||
| DateUtils.getDayEnd(DateUtils.getTimeAfterDays(-1, br.getEndtime()))); | DateUtils.getDayEnd(DateUtils.getTimeAfterDays(-1, br.getEndtime()))); | ||||
| }else { | }else { | ||||
| Date _date = DateUtils.getTimeAfterMonths(i,br.getStarttime()); | Date _date = DateUtils.getTimeAfterMonths(i,br.getStarttime()); | ||||
| _money = sumTradeDailyBySameMonthDay(bq, wxRentContract.getMerchantId(), | |||||
| _money = sumTradeDailyBySameMonthDay(wxRentContract.getDecimalSize(),bq, wxRentContract.getMerchantId(), | |||||
| DateUtils.getFirstDayForCurrMonth(_date), | DateUtils.getFirstDayForCurrMonth(_date), | ||||
| DateUtils.getLastDayForMonth(_date)); | DateUtils.getLastDayForMonth(_date)); | ||||
| } | } | ||||
| needPay = needPay + _money; | |||||
| needPay = needPay.add(_money); | |||||
| } | } | ||||
| }else { | }else { | ||||
| //同一个月 | //同一个月 | ||||
| //合同账单结束的时间是00:00:00,取日期要取前一天 | //合同账单结束的时间是00:00:00,取日期要取前一天 | ||||
| needPay = sumTradeDailyBySameMonthDay(bq, wxRentContract.getMerchantId(), | |||||
| needPay = sumTradeDailyBySameMonthDay(wxRentContract.getDecimalSize(),bq, wxRentContract.getMerchantId(), | |||||
| br.getStarttime(), DateUtils.getDayEnd(br.getEndtime())); | br.getStarttime(), DateUtils.getDayEnd(br.getEndtime())); | ||||
| } | } | ||||
| needPay = new BigDecimal(needPay).multiply(new BigDecimal(wxRentContract.getPayRatio())) | |||||
| .divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP).intValue(); | |||||
| Long oldNeedPay = br.getNeedPay(); | |||||
| if (needPay > br.getNeedPay()) { | |||||
| Long newPay = Long.parseLong(String.valueOf(needPay)); | |||||
| br.setNeedPay(newPay); | |||||
| br.setOwe(newPay); | |||||
| br.setReceivePay(newPay); | |||||
| needPay = needPay.multiply(new BigDecimal(wxRentContract.getPayRatio())) | |||||
| .divide(new BigDecimal(10000), wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||||
| String oldNeedPay = br.getNeedPay(); | |||||
| if (needPay.compareTo(new BigDecimal(br.getNeedPay())) > 0) { | |||||
| br.setNeedPay(needPay.toPlainString()); | |||||
| br.setOwe(needPay.toPlainString()); | |||||
| br.setReceivePay(needPay.toPlainString()); | |||||
| br.setUpdatetime(new Date()); | br.setUpdatetime(new Date()); | ||||
| BigDecimal servicePay = new BigDecimal(br.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); | |||||
| br.setServiceChargePay(servicePay.intValue()); | |||||
| br.setOwe(br.getReceivePay() + br.getServiceChargePay()); | |||||
| BigDecimal servicePay = new BigDecimal(br.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||||
| br.setServiceChargePay(servicePay.toPlainString()); | |||||
| br.setOwe(new BigDecimal(br.getReceivePay()).add(new BigDecimal(br.getServiceChargePay())).toPlainString()); | |||||
| br.setComments("原金额["+oldNeedPay+"(分)]小于解单金额["+needPay+"(分)],系统自动更新"); | br.setComments("原金额["+oldNeedPay+"(分)]小于解单金额["+needPay+"(分)],系统自动更新"); | ||||
| wxBillRentMapper.updateById(br); | wxBillRentMapper.updateById(br); | ||||
| } | } | ||||
| @@ -3314,7 +3318,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| } | } | ||||
| } | } | ||||
| private int sumTradeDailyBySameMonthDay(TenantEntity tenantEntity,Long merchantId,Date begin ,Date end) { | |||||
| private BigDecimal sumTradeDailyBySameMonthDay(Integer decimalSize,TenantEntity tenantEntity,Long merchantId,Date begin ,Date end) { | |||||
| //如果有按月的,则取按月来算 | //如果有按月的,则取按月来算 | ||||
| WxMerchantTradeDaily tdq = new WxMerchantTradeDaily(); | WxMerchantTradeDaily tdq = new WxMerchantTradeDaily(); | ||||
| tdq.updateTenantInfo(tenantEntity); | tdq.updateTenantInfo(tenantEntity); | ||||
| @@ -3328,7 +3332,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| Date _lastDay = DateUtils.getLastDayForMonth(begin); | Date _lastDay = DateUtils.getLastDayForMonth(begin); | ||||
| if (begin.equals(_fistDay) && end.equals(_lastDay)) { | if (begin.equals(_fistDay) && end.equals(_lastDay)) { | ||||
| //满月 | //满月 | ||||
| return monthSums; | |||||
| return new BigDecimal(monthSums); | |||||
| }else { | }else { | ||||
| //根据天数计算 | //根据天数计算 | ||||
| int monthDays = DateUtils.daysBetween(_fistDay, _lastDay)+1; | int monthDays = DateUtils.daysBetween(_fistDay, _lastDay)+1; | ||||
| @@ -3336,8 +3340,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| if (_days == 0) { | if (_days == 0) { | ||||
| _days = 1;//当天 | _days = 1;//当天 | ||||
| } | } | ||||
| BigDecimal servicePay = new BigDecimal(monthSums).multiply(new BigDecimal(_days)).divide(new BigDecimal(monthDays), 2, BigDecimal.ROUND_HALF_UP); | |||||
| return servicePay.intValue(); | |||||
| BigDecimal servicePay = new BigDecimal(monthSums).multiply(new BigDecimal(_days)).divide(new BigDecimal(monthDays), decimalSize, BigDecimal.ROUND_HALF_UP); | |||||
| return servicePay; | |||||
| } | } | ||||
| }else { | }else { | ||||
| WxMerchantTradeDaily tdq1 = new WxMerchantTradeDaily(); | WxMerchantTradeDaily tdq1 = new WxMerchantTradeDaily(); | ||||
| @@ -3347,7 +3351,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| tdq1.setStartTime(DateUtils.format(begin)); | tdq1.setStartTime(DateUtils.format(begin)); | ||||
| tdq1.setEndTime(DateUtils.format(end)); | tdq1.setEndTime(DateUtils.format(end)); | ||||
| String sumMoney = wxMerchantTradeDailyMapper.findSumMoney(tdq1); | String sumMoney = wxMerchantTradeDailyMapper.findSumMoney(tdq1); | ||||
| return Integer.parseInt(sumMoney); | |||||
| return new BigDecimal(sumMoney); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -161,6 +161,8 @@ public class PriceUtilV2 { | |||||
| BigDecimal a = new BigDecimal(10); | BigDecimal a = new BigDecimal(10); | ||||
| a = a.add(new BigDecimal(10)); | a = a.add(new BigDecimal(10)); | ||||
| System.out.println(a); | System.out.println(a); | ||||
| BigDecimal b = a.divide(new BigDecimal(3), 3, BigDecimal.ROUND_HALF_UP); | |||||
| System.out.println(b.toPlainString()); | |||||
| } | } | ||||
| @@ -18,7 +18,7 @@ | |||||
| <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/> | <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/> | ||||
| <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/> | <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/> | ||||
| <result column="is_del" jdbcType="INTEGER" property="isDel"/> | <result column="is_del" jdbcType="INTEGER" property="isDel"/> | ||||
| <result column="contract_need_pay" jdbcType="BIGINT" property="contractNeedPay"/> | |||||
| <result column="contract_need_pay" jdbcType="VARCHAR" property="contractNeedPay"/> | |||||
| <result column="rent_price_info" jdbcType="VARCHAR" property="rentPriceInfo"/> | <result column="rent_price_info" jdbcType="VARCHAR" property="rentPriceInfo"/> | ||||
| <result column="need_pay" jdbcType="VARCHAR" property="needPay"/> | <result column="need_pay" jdbcType="VARCHAR" property="needPay"/> | ||||
| <result column="bussiness_manage_fee_need_pay" jdbcType="VARCHAR" property="bussinessManageFeeNeedPay"/> | <result column="bussiness_manage_fee_need_pay" jdbcType="VARCHAR" property="bussinessManageFeeNeedPay"/> | ||||