| @@ -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); | |||
| } | |||
| @@ -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); | |||
| } | |||
| @@ -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 '每月平均天数'; | |||
| @@ -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; | |||
| @@ -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; | |||
| @@ -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; | |||
| } | |||
| } | |||
| @@ -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); | |||
| @@ -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{//中间 | |||
| @@ -62,6 +62,8 @@ | |||
| <result column="shop_numbers" jdbcType="VARCHAR" property="shopNumbers"/> | |||
| <result column="price_detail" jdbcType="VARCHAR" property="priceDetail"/> | |||
| <result column="fees_standards_info" jdbcType="VARCHAR" property="feesStandardsInfo"/> | |||
| <result column="day_price_calcute" jdbcType="INTEGER" property="dayPriceCalcute"/> | |||
| <result column="month_average_days" jdbcType="INTEGER" property="monthAverageDays"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| @@ -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 | |||
| </sql> | |||
| @@ -116,6 +118,8 @@ | |||
| <if test=" null != rentShopType">and `rent_shop_type` = #{rentShopType}</if> | |||
| <if test=" null != operationType ">and `operation_type` = #{operationType}</if> | |||
| <if test=" null != createType ">and `create_type` = #{createType}</if> | |||
| <if test=" null != dayPriceCalcute ">and `day_price_calcute` = #{dayPriceCalcute}</if> | |||
| <if test=" null != monthAverageDays ">and `month_average_days` = #{monthAverageDays}</if> | |||
| <if test=" null != businessForRule and '' != businessForRule "> | |||
| and business_id in (${businessForRule}) | |||
| </if> | |||
| @@ -128,6 +128,8 @@ | |||
| <result column="out_date_notify_phone" jdbcType="VARCHAR" property="outDateNotifyPhone"/> | |||
| <result column="design_file" jdbcType="VARCHAR" property="designFile"/> | |||
| <result column="price_detail" jdbcType="VARCHAR" property="priceDetail"/> | |||
| <result column="day_price_calcute" jdbcType="INTEGER" property="dayPriceCalcute"/> | |||
| <result column="month_average_days" jdbcType="INTEGER" property="monthAverageDays"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| @@ -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 @@ | |||
| <if test=" null != rentShopType and '' != rentShopType">and `rent_shop_type` = #{rentShopType}</if> | |||
| <if test=" null != operationType and '' != operationType">and `operation_type` = #{operationType}</if> | |||
| <if test=" null != queryShopId and '' != queryShopId">and json_contains(json_extract(rent_info,'$[*].id'),concat('"',#{queryShopId},'"'))</if> | |||
| <if test=" null != dayPriceCalcute ">and `day_price_calcute` = #{dayPriceCalcute}</if> | |||
| <if test=" null != monthAverageDays ">and `month_average_days` = #{monthAverageDays}</if> | |||
| <if test=" null != shopNumber and shopNumber!=''"> | |||
| and shop_name like concat('%',#{shopNumber},'%') | |||
| </if> | |||
| @@ -372,6 +376,8 @@ | |||
| <result column="property_price_unit" property="propertyPriceUnit"/> | |||
| <result column="bus_discount_time" property="busDiscountTime"/> | |||
| <result column="bus_discount_ratio" property="busDiscountRatio"/> | |||
| <result column="day_price_calcute" property="dayPriceCalcute"/> | |||
| <result column="month_average_days" property="monthAverageDays"/> | |||
| </resultMap> | |||
| @@ -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 | |||
| <where> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| @@ -417,6 +423,8 @@ | |||
| </if> | |||
| <if test=" null != applyStatus ">and rc.`apply_status` = #{applyStatus}</if> | |||
| <if test=" null != operationType ">and rc.`operation_type` = #{operationType}</if> | |||
| <if test=" null != dayPriceCalcute ">and rc.`day_price_calcute` = #{dayPriceCalcute}</if> | |||
| <if test=" null != monthAverageDays ">and rc.`month_average_days` = #{monthAverageDays}</if> | |||
| <if test=" null != businessForRule and '' != businessForRule "> | |||
| and rc.business_id in (${businessForRule}) | |||
| </if> | |||