From cca9ff65985afe395fb0d922dc304804890fbd6a Mon Sep 17 00:00:00 2001 From: winter Date: Thu, 1 Aug 2024 16:36:44 +0800 Subject: [PATCH] fix --- .../WxPropertyContractController.java | 6 +++ .../contract/WxRentContractController.java | 6 +++ .../db/migration/V202408000000001.sql | 4 ++ .../domain/po/WxPropertyContract.java | 5 +++ .../iformall/domain/po/WxRentContract.java | 5 +++ .../enums/EnumRentDayPriceCalcute.java | 37 +++++++++++++++++ .../service/helper/WxRentContractHelper.java | 40 +++++++++++++------ .../impl/WxPropertyContractServiceImpl.java | 8 ++-- .../mapper/WxPropertyContractMapper.xml | 6 ++- .../resources/mapper/WxRentContractMapper.xml | 16 ++++++-- 10 files changed, 112 insertions(+), 21 deletions(-) create mode 100644 mallinkAdmin/src/main/resources/db/migration/V202408000000001.sql create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumRentDayPriceCalcute.java diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java index 15116d8db..124022f6e 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java @@ -260,6 +260,12 @@ public class WxPropertyContractController extends WxContractBaseController { if (null != wxPropertyContract.getFeeStandards() && wxPropertyContract.getFeeStandards().size() > 0 ) { wxPropertyContract.setFeesStandardsInfo(JSON.toJSONString(wxPropertyContract.getFeeStandards())); } + if (null == wxPropertyContract.getDayPriceCalcute()){ + wxPropertyContract.setDayPriceCalcute(EnumRentDayPriceCalcute.REAL_DAYS.getCode()); + } + if (wxPropertyContract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode().intValue() && null == wxPropertyContract.getMonthAverageDays()) { + return new ResultData(Result.ERROR,"请填写月平均天数"); + } return wxPropertyContractService.updateMoney(wxPropertyContract, user, user.getName(),false); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java index 316de7c8d..1adfe73ca 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -226,6 +226,12 @@ public class WxRentContractController extends WxContractBaseController { } wxRentContract.setRentShopType(null); wxRentContract.setOperationType(null); + if (null == wxRentContract.getDayPriceCalcute()){ + wxRentContract.setDayPriceCalcute(EnumRentDayPriceCalcute.REAL_DAYS.getCode()); + } + if (wxRentContract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode().intValue() && null == wxRentContract.getMonthAverageDays()) { + return new ResultData(Result.ERROR,"请填写月平均天数"); + } return wxRentContractService.update(wxRentContract, user,user.getName(),EnumFromType.OTHER.getCode(),oldDate,false); } diff --git a/mallinkAdmin/src/main/resources/db/migration/V202408000000001.sql b/mallinkAdmin/src/main/resources/db/migration/V202408000000001.sql new file mode 100644 index 000000000..bfdc75530 --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V202408000000001.sql @@ -0,0 +1,4 @@ +ALTER TABLE wx_rent_contract ADD COLUMN day_price_calcute INT(1) NOT NULL DEFAULT 1 COMMENT '每天价格计算规则'; +ALTER TABLE wx_rent_contract ADD COLUMN month_average_days INT(2) COMMENT '每月平均天数'; +ALTER TABLE wx_property_contract ADD COLUMN day_price_calcute INT(1) NOT NULL DEFAULT 1 COMMENT '每天价格计算规则'; +ALTER TABLE wx_property_contract ADD COLUMN month_average_days INT(2) COMMENT '每月平均天数'; \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java index 043ff5e71..465b39cc8 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java @@ -176,6 +176,11 @@ public class WxPropertyContract extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "上传文件名", name = "fileNames") private String fileNames; + + @io.swagger.annotations.ApiModelProperty(value = "每天价格计算规则EnumRentDayPriceCalcute", name = "dayPriceCalcute") + private Integer dayPriceCalcute; + @io.swagger.annotations.ApiModelProperty(value = "每月平均天数", name = "monthAverageDays") + private Integer monthAverageDays; @TableField(exist = false) private String building; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java index 3c3e80509..7e0ec2c46 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java @@ -399,6 +399,11 @@ public class WxRentContract extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "操作类型1区分租赁物业2合并租赁物业3金茂", name = "operationType") private Integer operationType; + + @io.swagger.annotations.ApiModelProperty(value = "每天价格计算规则EnumRentDayPriceCalcute", name = "dayPriceCalcute") + private Integer dayPriceCalcute; + @io.swagger.annotations.ApiModelProperty(value = "每月平均天数", name = "monthAverageDays") + private Integer monthAverageDays; @io.swagger.annotations.ApiModelProperty(value = "滞纳金费率", name = "latePayRatio") private String latePayRatio; diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumRentDayPriceCalcute.java b/mallinkService/src/main/java/com/iformall/enums/EnumRentDayPriceCalcute.java new file mode 100644 index 000000000..03c332e5b --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumRentDayPriceCalcute.java @@ -0,0 +1,37 @@ +package com.iformall.enums; + +/** + */ +public enum EnumRentDayPriceCalcute { + + + REAL_DAYS(1, "按每月真实天数"), + AVERAGE_DAYS(2, "按每月平均天数(手写)"), + ; + + public static EnumRentDayPriceCalcute getEnum(Integer code) { + for (EnumRentDayPriceCalcute value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumRentDayPriceCalcute(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} + diff --git a/mallinkService/src/main/java/com/iformall/service/helper/WxRentContractHelper.java b/mallinkService/src/main/java/com/iformall/service/helper/WxRentContractHelper.java index 6b61de1fb..18e5473bd 100644 --- a/mallinkService/src/main/java/com/iformall/service/helper/WxRentContractHelper.java +++ b/mallinkService/src/main/java/com/iformall/service/helper/WxRentContractHelper.java @@ -412,7 +412,7 @@ public class WxRentContractHelper { //生成金额直接计算 if(!saveDb){ //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,part)).longValue(); - needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,part)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); + needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),part)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); return needpay; } @@ -431,7 +431,7 @@ public class WxRentContractHelper { needpay = new BigDecimal(months).multiply(priceD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); }else{ //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); - needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,false)) + needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false)) .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); } }else if(i == 0){//第一期 @@ -442,7 +442,7 @@ public class WxRentContractHelper { needpay = new BigDecimal(months).multiply(priceD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); }else{ //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); - needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,false)) + needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false)) .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); } }else{ @@ -454,7 +454,7 @@ public class WxRentContractHelper { needpay = new BigDecimal(months).multiply(priceD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); }else{ //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); - needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,false)) + needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false)) .setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); } } @@ -466,7 +466,7 @@ public class WxRentContractHelper { //如果当月费用需要按天计算 if (monthCalDay) { //needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue(); - needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,false)) + needpay = new BigDecimal(getMonthNeedPay(Constant.default_long_decimal_size,priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false)) .setScale(wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP).toPlainString(); }else { needpay = new BigDecimal(months).multiply(priceD).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_UP).toPlainString(); @@ -522,24 +522,25 @@ public class WxRentContractHelper { * @param end * @return */ - public static String getMonthNeedPay(Integer decimalSize,BigDecimal 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,Integer dayPriceCalcute,Integer monthAvageDays,boolean part){ SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); SimpleDateFormat sdD = new SimpleDateFormat("d"); BigDecimal total = new BigDecimal(0); int[] diff; - + //同一天 if(sd.format(start).equals(sd.format(end))){ - int dayCount = DateUtils.getMonthDayCount(start); + int dayCount = getRealDays(dayPriceCalcute, monthAvageDays, start); return price.divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP).toPlainString(); + } //同月 if(sdM.format(start).equals(sdM.format(end))){ diff = DateUtils.getDiff(start,end); - int dayCount = DateUtils.getMonthDayCount(start); + int dayCount = getRealDays(dayPriceCalcute, monthAvageDays, start); total = total.add(new BigDecimal((diff[1]+1)).multiply(price).divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP)); return total.toPlainString(); } @@ -557,7 +558,7 @@ public class WxRentContractHelper { instance.setTime(start); // instance.add(dayType, receivePeriod); // instance.add(Calendar.DATE, -1); - instance = EnumContractReceivePeriodUnit.getAfterCalendarDay(instance, receivePeriod, receivePeriod); + instance = EnumContractReceivePeriodUnit.getAfterCalendarDay(instance, receivePeriod, dayType); if(sd.format(instance.getTime()).equals(sd.format(end))){ isFullMonth = true; } @@ -571,7 +572,7 @@ public class WxRentContractHelper { //第一个月 Date lastMonthDay = DateUtils.getLastDayForMonth(start); diff = DateUtils.getDiff(start,lastMonthDay); - int dayCount = DateUtils.getMonthDayCount(start); + int dayCount = getRealDays(dayPriceCalcute, monthAvageDays, start); total = total.add(new BigDecimal((diff[1]+1)).multiply(price).divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP)); //中间月份 @@ -581,11 +582,26 @@ public class WxRentContractHelper { //最后一个月 diff = DateUtils.getDiff(DateUtils.getFirstDayForCurrMonth(end),end); - dayCount = DateUtils.getMonthDayCount(end); + dayCount = getRealDays(dayPriceCalcute, monthAvageDays, end); total = total.add(new BigDecimal((diff[1]+1)).multiply(price).divide(new BigDecimal(dayCount),decimalSize,BigDecimal.ROUND_HALF_UP)); return total.toPlainString(); } + private static int getRealDays(Integer dayPriceCalcute,Integer monthAvageDays,Date start) { + //是不是按实际天数来计算 + boolean isRealDays = true; + if (dayPriceCalcute.intValue() == EnumRentDayPriceCalcute.REAL_DAYS.getCode().intValue()) { + }else { + isRealDays = false; + } + if (isRealDays) { + return DateUtils.getMonthDayCount(start); + }else { + return monthAvageDays; + } + + } + public static int getMonths(String startStr,String endStr){ DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); DateTime start = formatter.parseDateTime(startStr); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java index a5d5ca806..f6f30024b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -923,7 +923,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService //生成金额直接计算 if(!saveDb){ - needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false); + needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false); return needpay; } @@ -938,7 +938,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService months++; needpay = new BigDecimal(months).multiply(priceD).toPlainString(); }else { - needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false); + needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false); } }else if(i == 0){//第一期 if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ @@ -947,7 +947,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService months++; needpay = new BigDecimal(months).multiply(priceD).toPlainString(); }else{ - needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false); + needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false); } }else{ if(isFirstDay(startDate)){ @@ -957,7 +957,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService } needpay = new BigDecimal(months).multiply(priceD).toPlainString(); }else{ - needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,false); + needpay = WxRentContractHelper.getMonthNeedPay(wxRentContract.getDecimalSize(),priceD, startDate, endDate,dayType,receivePeriod,wxRentContract.getDayPriceCalcute(),wxRentContract.getMonthAverageDays(),false); } } }else{//中间 diff --git a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml index 4227339e1..71fce6487 100644 --- a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml @@ -62,6 +62,8 @@ + + @@ -69,7 +71,7 @@ `sign_date`,`receive_period`,`tenant_id`,`parent_tenant_id`,`filepath`,`status`,`contract_number`,`price_detail`, `deposit`,`pay_date`,`is_del`,`merchant_name`,`brand`,`business_id`,`receive_period_unit`,`create_by`,`update_by`, `shop_type`,`updatetime`,`createtime`,`rent_area`,`rent_shop_type`,`fees_standards_info`, - `link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`, + `link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`,`day_price_calcute`,`month_average_days`, `start_date`,`end_date`,`apply_status`,`adjust_period`,`business_type`,adjust_ratio,`rent_info`,fixed_price, `file_names`,price_unit,rent_price,subject_name,rent_start_type,`operation_type`,late_pay_ratio,late_pay_day,end_contract_time,out_date_notify_days,out_date_notify_phone @@ -116,6 +118,8 @@ and `rent_shop_type` = #{rentShopType} and `operation_type` = #{operationType} and `create_type` = #{createType} + and `day_price_calcute` = #{dayPriceCalcute} + and `month_average_days` = #{monthAverageDays} and business_id in (${businessForRule}) diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index bf8cf1147..2b778ee86 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -128,6 +128,8 @@ + + @@ -135,8 +137,8 @@ `shop_type_sub`,`lease_purpose`,`contractual_rules`,`delivery_date`,`delivery_grace_period`,`opening_date`,`business_hours`,`scope_metre`, `decimal_size`,`price`,`rental_start_date`,`rental_end_date`,`sign_date`,`receive_period`,`receive_period_unit`, `tenant_id`,`parent_tenant_id`,`filepath`,`status`,`contract_number`,`price_detail`,`create_by`,`update_by`, - `first_party_bank_info`,`second_party_bank_info`,`second_party_tax_info`, - `property_name`,`property_fee`,`fee_cycle`,`water_fee`,`electricity_fees`, + `first_party_bank_info`,`second_party_bank_info`,`second_party_tax_info`,`day_price_calcute`, + `property_name`,`property_fee`,`fee_cycle`,`water_fee`,`electricity_fees`,`month_average_days`, `deposit`,cashtype_content_lsit,cashtype_lsit,`pay_date`,`is_del`,`merchant_name`, `brand`,`business_id`,`shop_type`,`shop_type_str`,`updatetime`,`createtime`,`link_person`,`link_phone`,`link_address`, `pay_account`,`filename`,`lease`,`type`,`revenue`,`revenue_ratio`,`revenue_year`,`revenue_ratio_way`,`revenue_ratio_set`,`adjust_ratio`,`adjust_period`,`pay_ratio`, @@ -191,6 +193,8 @@ and `rent_shop_type` = #{rentShopType} and `operation_type` = #{operationType} and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{queryShopId},'"')) + and `day_price_calcute` = #{dayPriceCalcute} + and `month_average_days` = #{monthAverageDays} and shop_name like concat('%',#{shopNumber},'%') @@ -372,6 +376,8 @@ + + @@ -379,8 +385,8 @@ select rc.id,rc.tenant_id,rc.parent_tenant_id,rc.id as rent_id, pc.id as property_id, rc.merchant_name,rc.rental_start_date,rc.rental_end_date,rc.`status`, rc.price as rent_price,rc.contract_number,rc.shop_name,rc.type,rc.apply_status,rc.price_detail, rc.rent_shop_type,rc.rent_info,pc.price as property_price,rc.merchant_id,pc.`status` as property_status, - rc.price_unit as rent_price_unit,pc.price_unit as property_price_unit, - rc.business_type businessType,rc.bus_discount_ratio,rc.bus_discount_time + rc.price_unit as rent_price_unit,pc.price_unit as property_price_unit,rc.day_price_calcute, + rc.business_type businessType,rc.bus_discount_ratio,rc.bus_discount_time,rc.month_average_days from wx_rent_contract rc left join wx_property_contract pc on rc.id=pc.rent_contract_id @@ -417,6 +423,8 @@ and rc.`apply_status` = #{applyStatus} and rc.`operation_type` = #{operationType} + and rc.`day_price_calcute` = #{dayPriceCalcute} + and rc.`month_average_days` = #{monthAverageDays} and rc.business_id in (${businessForRule})