| @@ -15,6 +15,8 @@ import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.enums.EnumBillAllType; | |||
| import com.iformall.enums.EnumEnergyMeterType; | |||
| import com.iformall.enums.EnumEnergyPublicCalcuteRule; | |||
| import com.iformall.enums.EnumFeesStandardsCalcuteUnit; | |||
| import com.iformall.enums.EnumFeesStandardsTimeUnit; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxEnergyService; | |||
| @@ -192,6 +194,9 @@ public class WxEnergyController extends BaseController { | |||
| if (null == record.getPublicCalcute()) { | |||
| return new ResultData(Result.ERROR,"请选择分摊计费规则"); | |||
| } | |||
| if (null == record.getFixedPrice()) { | |||
| return new ResultData(Result.ERROR,"请选择是否是一次性费用"); | |||
| } | |||
| if (StringUtils.isNotBlank(record.getPrice())) { | |||
| return new ResultData(Result.ERROR,"单价不能为空"); | |||
| } | |||
| @@ -206,6 +211,36 @@ public class WxEnergyController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("查询科目计量单位列表") | |||
| @GetMapping("feesCalcuteUnitList") | |||
| public ResultData typeCalcuteUnitList(Integer billType) { | |||
| List<EnumFeesStandardsCalcuteUnit> enumList = EnumBillAllType.getCalucuteUnites(billType); | |||
| if (null != enumList) { | |||
| Map<Integer,String> retMap = new HashMap<Integer,String>(); | |||
| for (int i = 0 ; i < enumList.size(); i++) { | |||
| EnumFeesStandardsCalcuteUnit cu = enumList.get(i); | |||
| retMap.put(cu.getCode(), cu.getMessage()); | |||
| } | |||
| return new ResultData(retMap); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("查询科目计算时间单位列表") | |||
| @GetMapping("feesTimeUnitList") | |||
| public ResultData typeTimeUnitList(Integer billType) { | |||
| List<EnumFeesStandardsTimeUnit> enumList = EnumBillAllType.getTimeUnites(billType); | |||
| if (null != enumList) { | |||
| Map<Integer,String> retMap = new HashMap<Integer,String>(); | |||
| for (int i = 0 ; i < enumList.size(); i++) { | |||
| EnumFeesStandardsTimeUnit cu = enumList.get(i); | |||
| retMap.put(cu.getCode(), cu.getMessage()); | |||
| } | |||
| return new ResultData(retMap); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("抄表数据分页列表接口") | |||
| @GetMapping("readingList") | |||
| @@ -1,20 +1,18 @@ | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxFeesStandards; | |||
| import com.iformall.domain.po.WxEnergyFees; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.enums.EnumBillAllType; | |||
| import com.iformall.enums.EnumFeesStandardsCalcuteUnit; | |||
| import com.iformall.enums.EnumFeesStandardsTimeUnit; | |||
| import com.iformall.enums.EnumFeesStandardsType; | |||
| import com.iformall.service.WxFeesStandardsService; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.WxEnergyService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -27,13 +25,18 @@ import org.springframework.web.bind.annotation.ModelAttribute; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| /** | |||
| * 物业合同的其他费用 | |||
| * @author Administrator | |||
| * | |||
| */ | |||
| @RestController | |||
| @RequestMapping("feesStandars") | |||
| public class WxFeesStandardsController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxFeesStandardsService wxFeesStandardsService; | |||
| private WxEnergyService wxEnergyService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @@ -41,45 +44,36 @@ public class WxFeesStandardsController extends BaseController { | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| }) | |||
| public ResultData list(@ModelAttribute WxFeesStandards record, Integer pageNum, Integer pageSize) { | |||
| public ResultData list(@ModelAttribute WxEnergyFees record, Integer pageNum, Integer pageSize) { | |||
| if (null == record) { | |||
| record = new WxFeesStandards(); | |||
| record = new WxEnergyFees(); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setBillType(EnumBillAllType.PROPERTY.getCode()); | |||
| record.setSortColumns(BaseEntity.SortField.CreateTime_DESC); | |||
| PageInfo<WxFeesStandards> page = wxFeesStandardsService.listAsPage(record, pageNum, pageSize); | |||
| PageInfo<WxEnergyFees> page = wxEnergyService.feesListAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("详情接口") | |||
| @GetMapping("detail") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| }) | |||
| public ResultData detail(Long id) { | |||
| WxFeesStandards record = wxFeesStandardsService.getById(id,getTenantInfo().getTenantId()); | |||
| return new ResultData(record); | |||
| } | |||
| @ApiOperation("查询某一个类型费用标砖列表") | |||
| @ApiOperation("查询物业合同费用标准列表") | |||
| @GetMapping("typeList") | |||
| public ResultData typeList(Integer type) { | |||
| if (null == type) { | |||
| return new ResultData(Result.ERROR,"参数错误"); | |||
| } | |||
| WxFeesStandards record = new WxFeesStandards(); | |||
| public ResultData typeList() { | |||
| WxEnergyFees record = new WxEnergyFees(); | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setType(type); | |||
| return new ResultData(wxFeesStandardsService.list(record)); | |||
| record.setBillType(EnumBillAllType.PROPERTY.getCode()); | |||
| record.setIsDel(EnumYesOrNo.NO.getCode()); | |||
| PageInfo<WxEnergyFees> page = wxEnergyService.feesListAsPage(record, 1, 100); | |||
| if (null != page) { | |||
| return new ResultData(page.getList()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("查询某一个类型计量单位列表") | |||
| @ApiOperation("查询物业合同计量单位列表") | |||
| @GetMapping("typeCalcuteUnitList") | |||
| public ResultData typeCalcuteUnitList(Integer type) { | |||
| if (null == type) { | |||
| return new ResultData(Result.ERROR,"参数错误"); | |||
| } | |||
| List<EnumFeesStandardsCalcuteUnit> enumList = EnumFeesStandardsType.getCalucuteUnites(type); | |||
| public ResultData typeCalcuteUnitList() { | |||
| List<EnumFeesStandardsCalcuteUnit> enumList = EnumBillAllType.getCalucuteUnites(EnumBillAllType.PROPERTY.getCode()); | |||
| if (null != enumList) { | |||
| Map<Integer,String> retMap = new HashMap<Integer,String>(); | |||
| for (int i = 0 ; i < enumList.size(); i++) { | |||
| @@ -91,13 +85,10 @@ public class WxFeesStandardsController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("查询某一个类型时间单位列表") | |||
| @ApiOperation("查询物业合同时间单位列表") | |||
| @GetMapping("typeTimeUnitList") | |||
| public ResultData typeTimeUnitList(Integer type) { | |||
| if (null == type) { | |||
| return new ResultData(Result.ERROR,"参数错误"); | |||
| } | |||
| List<EnumFeesStandardsTimeUnit> enumList = EnumFeesStandardsType.getTimeUnites(type); | |||
| public ResultData typeTimeUnitList() { | |||
| List<EnumFeesStandardsTimeUnit> enumList = EnumBillAllType.getTimeUnites(EnumBillAllType.PROPERTY.getCode()); | |||
| if (null != enumList) { | |||
| Map<Integer,String> retMap = new HashMap<Integer,String>(); | |||
| for (int i = 0 ; i < enumList.size(); i++) { | |||
| @@ -59,19 +59,15 @@ public class WxFinanceController extends BaseController { | |||
| @GetMapping("billTypes") | |||
| public ResultData billTypes() { | |||
| Map<Integer,String> tmap = new HashMap<Integer,String>(); | |||
| for (EnumBillAllType t : EnumBillAllType.getFinanceTypes()) { | |||
| for (EnumBillAllType t : EnumBillAllType.getOperateNotEnergyTypes()) { | |||
| tmap.put(t.getCode(), t.getMessage()); | |||
| } | |||
| return new ResultData(tmap); | |||
| } | |||
| //可以管理的类型 | |||
| @GetMapping("operateBillTypes") | |||
| public ResultData operateBillTypes() { | |||
| Map<Integer,String> tmap = new HashMap<Integer,String>(); | |||
| for (EnumBillAllType t : EnumBillAllType.getFinanceOperateTypes()) { | |||
| tmap.put(t.getCode(), t.getMessage()); | |||
| } | |||
| return new ResultData(tmap); | |||
| @GetMapping("billTypeIsFixedPrice") | |||
| public ResultData billTypeIsFixedPrice(Integer billType) { | |||
| return new ResultData(EnumBillAllType.getEnum(billType).isFixedPrice()); | |||
| } | |||
| @ApiOperation("费用科目列表") | |||
| @@ -1480,6 +1480,9 @@ CREATE TABLE `wx_energy_fees` ( | |||
| `type` int(1) DEFAULT NULL COMMENT '表类型', | |||
| `bill_type` int(11) NOT NULL COMMENT '所属账单类型', | |||
| `is_system` int(1) NOT NULL DEFAULT '0' COMMENT '是否系统内置', | |||
| `fixed_price` int(1) NOT NULL COMMENT '是否一次性费用', | |||
| `calcute_unit` int(1) COMMENT '计量单位', | |||
| `time_unit` int(1) COMMENT '时间单位', | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `id_UNIQUE` (`id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='能耗表'; | |||
| @@ -1,13 +1,25 @@ | |||
| package com.iformall.domain.po; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumBillAllType; | |||
| import com.iformall.enums.EnumEnergyPublicCalcuteRule; | |||
| import com.iformall.enums.EnumFeesStandardsCalcuteUnit; | |||
| import com.iformall.enums.EnumFeesStandardsTimeUnit; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.helper.WxRentContractHelper; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.DateUtils; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.math.BigDecimal; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Calendar; | |||
| import java.util.Date; | |||
| /** | |||
| @@ -40,6 +52,14 @@ public class WxEnergyFees extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "公摊计算规则EnumEnergyPublicCalcuteRule", name = "publicCalcute") | |||
| private Integer publicCalcute; | |||
| @TableField(exist = false) | |||
| private String publicCalcuteName; | |||
| public String getPublicCalcuteName() { | |||
| if (null != publicCalcute) { | |||
| return EnumEnergyPublicCalcuteRule.getEnum(publicCalcute).getMessage(); | |||
| } | |||
| return null; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value = "表类型EnumEnergyMeterType", name = "type") | |||
| private Integer type; | |||
| @@ -58,7 +78,107 @@ public class WxEnergyFees extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否系统内置", name = "isSystem") | |||
| private Integer isSystem; | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否一次性费用EnumYesOrNo", name = "fixedPrice") | |||
| private Integer fixedPrice; | |||
| @TableField(exist = false) | |||
| private String fixedPriceName; | |||
| public String getFixedPriceName() { | |||
| if (null != fixedPrice) { | |||
| if (fixedPrice.intValue() == EnumYesOrNo.YES.getCode().intValue()) { | |||
| return "一次性费用"; | |||
| }else { | |||
| return "非一次性费用"; | |||
| } | |||
| } | |||
| return ""; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value = "计量单位EnumFeesStandardsCalcuteUnit【非固定费用使用】", name = "calcuteUnit") | |||
| private Integer calcuteUnit; | |||
| @TableField(exist = false) | |||
| private String calcuteUnitName; | |||
| public String getCalcuteUnitName() { | |||
| if (null != calcuteUnit) { | |||
| return EnumFeesStandardsCalcuteUnit.getEnum(calcuteUnit).getMessage(); | |||
| } | |||
| return ""; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value = "时间单位EnumFeesStandardsTimeUnit【非固定费用使用】", name = "timeUnit") | |||
| private Integer timeUnit; | |||
| @TableField(exist = false) | |||
| private String timeUnitName; | |||
| public String getTimeUnitName() { | |||
| if (null != timeUnit) { | |||
| return EnumFeesStandardsTimeUnit.getEnum(timeUnit).getMessage(); | |||
| } | |||
| return ""; | |||
| } | |||
| public String calcuteTotalMoney(Integer decimalSize,Date start,Date end,String count,boolean isFixed) { | |||
| if (isFixed) { | |||
| return this.price; | |||
| } | |||
| if (StringUtils.isBlank(count)) { | |||
| count = "1"; | |||
| } | |||
| if (this.timeUnit.intValue() == EnumFeesStandardsTimeUnit.DAY.getCode().intValue()) { | |||
| BigDecimal priceD = new BigDecimal(this.price); | |||
| priceD = priceD.multiply(new BigDecimal(count)); | |||
| return WxRentContractHelper.getNeedPay(decimalSize,new BigDecimal(0),priceD,start,end); | |||
| }else { | |||
| //按月计算 | |||
| BigDecimal priceMonth = new BigDecimal(this.price); | |||
| if (this.timeUnit.intValue() == EnumFeesStandardsTimeUnit.YEAR.getCode().intValue()) { | |||
| priceMonth = new BigDecimal(price).divide(new BigDecimal(12),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); | |||
| } | |||
| priceMonth = priceMonth.multiply(new BigDecimal(count)); | |||
| //如果开始时间是1号,结束时间是当月最后一天,则是整月,*月数。 | |||
| //如果不是整月,跨月了的,则计算: 开始时间到当月底+ 中间整月 + 结束时间月1号到结束时间 | |||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |||
| Date startMonthFirstDay = DateUtils.getFirstDayForCurrMonth(start); | |||
| Date endMonthLastDay = DateUtils.getLastDayForMonth(end); | |||
| if(sd.format(start).equals(sd.format(startMonthFirstDay)) && sd.format(end).equals(sd.format(endMonthLastDay)) ){ | |||
| int months = WxRentContractHelper.getMonths(sd.format(start),sd.format(end)); | |||
| months++; | |||
| if (months > 0 ) { | |||
| return priceMonth.multiply(new BigDecimal(months)).toPlainString(); | |||
| }else { | |||
| return priceMonth.toPlainString(); | |||
| } | |||
| }else { | |||
| Date startMonthEndDay = DateUtils.getLastDayForMonth(start); | |||
| int startDays = DateUtils.daysBetween(start, startMonthEndDay); | |||
| int startMonthDays = DateUtils.daysBetween(startMonthFirstDay, startMonthEndDay); | |||
| Date endMontFirstDay = DateUtils.getFirstDayForCurrMonth(end); | |||
| int endDays = DateUtils.daysBetween(endMontFirstDay, end); | |||
| int endMonthDays = DateUtils.daysBetween(endMontFirstDay, endMonthLastDay); | |||
| int months = WxRentContractHelper.getMonths(sd.format(DateUtils.getDaySet(startMonthEndDay, Calendar.DATE, 1)),sd.format(DateUtils.getDaySet(endMontFirstDay, Calendar.DATE, -1))); | |||
| months++; | |||
| if (startDays > 0 ) { | |||
| priceMonth = priceMonth.multiply(new BigDecimal(startDays)).divide(new BigDecimal(startMonthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); | |||
| } | |||
| if (endDays > 0 ) { | |||
| priceMonth = priceMonth.multiply(new BigDecimal(endDays)).divide(new BigDecimal(endMonthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); | |||
| } | |||
| if (months > 0 ) { | |||
| priceMonth = priceMonth.multiply(new BigDecimal(months)); | |||
| } | |||
| return priceMonth.toPlainString(); | |||
| } | |||
| } | |||
| } | |||
| @TableField(exist = false) | |||
| private Integer notEnergy; | |||
| } | |||
| @@ -1,160 +0,0 @@ | |||
| package com.iformall.domain.po; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumContractReceivePeriodUnit; | |||
| import com.iformall.enums.EnumFeesStandardsCalcuteUnit; | |||
| import com.iformall.enums.EnumFeesStandardsTimeUnit; | |||
| import com.iformall.enums.EnumFeesStandardsType; | |||
| import com.iformall.enums.EnumRentContractAdjustPeriod; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.helper.WxRentContractHelper; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.DateUtils; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.math.BigDecimal; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Calendar; | |||
| import java.util.Date; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @TableName(value = "wx_fees_standards") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxFeesStandards extends TenantEntity { | |||
| private static final long serialVersionUID = -2034956838395479510L; | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否删除1是0否", name = "isDel") | |||
| private Integer isDel; | |||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updatetime") | |||
| private Date updateTime; | |||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createtime") | |||
| private Date createTime; | |||
| @io.swagger.annotations.ApiModelProperty(value = "名称", name = "createtime") | |||
| private String name; | |||
| @io.swagger.annotations.ApiModelProperty(value = "单价", name = "price") | |||
| private String price; | |||
| @io.swagger.annotations.ApiModelProperty(value = "类型EnumFeesStandardsType", name = "type") | |||
| private Integer type; | |||
| @TableField(exist = false) | |||
| private String typeName; | |||
| public String getTypeName() { | |||
| if (null != type) { | |||
| return EnumFeesStandardsType.getEnum(type).getMessage(); | |||
| } | |||
| return ""; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否一次性费用EnumYesOrNo", name = "fixedPrice") | |||
| private Integer fixedPrice; | |||
| @TableField(exist = false) | |||
| private String fixedPriceName; | |||
| public String getFixedPriceName() { | |||
| if (null != fixedPrice) { | |||
| if (fixedPrice.intValue() == EnumYesOrNo.YES.getCode().intValue()) { | |||
| return "一次性费用"; | |||
| }else { | |||
| return "非一次性费用"; | |||
| } | |||
| } | |||
| return ""; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value = "计量单位EnumFeesStandardsCalcuteUnit【非固定费用使用】", name = "calcuteUnit") | |||
| private Integer calcuteUnit; | |||
| @TableField(exist = false) | |||
| private String calcuteUnitName; | |||
| public String getCalcuteUnitName() { | |||
| if (null != calcuteUnit) { | |||
| return EnumFeesStandardsCalcuteUnit.getEnum(calcuteUnit).getMessage(); | |||
| } | |||
| return ""; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value = "时间单位EnumFeesStandardsTimeUnit【非固定费用使用】", name = "timeUnit") | |||
| private Integer timeUnit; | |||
| @TableField(exist = false) | |||
| private String timeUnitName; | |||
| public String getTimeUnitName() { | |||
| if (null != timeUnit) { | |||
| return EnumFeesStandardsTimeUnit.getEnum(timeUnit).getMessage(); | |||
| } | |||
| return ""; | |||
| } | |||
| public String calcuteTotalMoney(Integer decimalSize,Date start,Date end,String count,boolean isFixed) { | |||
| if (isFixed) { | |||
| return this.price; | |||
| } | |||
| if (StringUtils.isBlank(count)) { | |||
| count = "1"; | |||
| } | |||
| if (this.timeUnit.intValue() == EnumFeesStandardsTimeUnit.DAY.getCode().intValue()) { | |||
| BigDecimal priceD = new BigDecimal(this.price); | |||
| priceD = priceD.multiply(new BigDecimal(count)); | |||
| return WxRentContractHelper.getNeedPay(decimalSize,new BigDecimal(0),priceD,start,end); | |||
| }else { | |||
| //按月计算 | |||
| BigDecimal priceMonth = new BigDecimal(this.price); | |||
| if (this.timeUnit.intValue() == EnumFeesStandardsTimeUnit.YEAR.getCode().intValue()) { | |||
| priceMonth = new BigDecimal(price).divide(new BigDecimal(12),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); | |||
| } | |||
| priceMonth = priceMonth.multiply(new BigDecimal(count)); | |||
| //如果开始时间是1号,结束时间是当月最后一天,则是整月,*月数。 | |||
| //如果不是整月,跨月了的,则计算: 开始时间到当月底+ 中间整月 + 结束时间月1号到结束时间 | |||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |||
| Date startMonthFirstDay = DateUtils.getFirstDayForCurrMonth(start); | |||
| Date endMonthLastDay = DateUtils.getLastDayForMonth(end); | |||
| if(sd.format(start).equals(sd.format(startMonthFirstDay)) && sd.format(end).equals(sd.format(endMonthLastDay)) ){ | |||
| int months = WxRentContractHelper.getMonths(sd.format(start),sd.format(end)); | |||
| months++; | |||
| if (months > 0 ) { | |||
| return priceMonth.multiply(new BigDecimal(months)).toPlainString(); | |||
| }else { | |||
| return priceMonth.toPlainString(); | |||
| } | |||
| }else { | |||
| Date startMonthEndDay = DateUtils.getLastDayForMonth(start); | |||
| int startDays = DateUtils.daysBetween(start, startMonthEndDay); | |||
| int startMonthDays = DateUtils.daysBetween(startMonthFirstDay, startMonthEndDay); | |||
| Date endMontFirstDay = DateUtils.getFirstDayForCurrMonth(end); | |||
| int endDays = DateUtils.daysBetween(endMontFirstDay, end); | |||
| int endMonthDays = DateUtils.daysBetween(endMontFirstDay, endMonthLastDay); | |||
| int months = WxRentContractHelper.getMonths(sd.format(DateUtils.getDaySet(startMonthEndDay, Calendar.DATE, 1)),sd.format(DateUtils.getDaySet(endMontFirstDay, Calendar.DATE, -1))); | |||
| months++; | |||
| if (startDays > 0 ) { | |||
| priceMonth = priceMonth.multiply(new BigDecimal(startDays)).divide(new BigDecimal(startMonthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); | |||
| } | |||
| if (endDays > 0 ) { | |||
| priceMonth = priceMonth.multiply(new BigDecimal(endDays)).divide(new BigDecimal(endMonthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP); | |||
| } | |||
| if (months > 0 ) { | |||
| priceMonth = priceMonth.multiply(new BigDecimal(months)); | |||
| } | |||
| return priceMonth.toPlainString(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -307,21 +307,21 @@ public class WxPropertyContract extends TenantEntity { | |||
| return shopList; | |||
| } | |||
| public List<WxFeesStandards> getFeesStardarsList() { | |||
| public List<WxEnergyFees> getFeesStardarsList() { | |||
| if (StringUtils.isNotBlank(feesStandardsInfo)) { | |||
| return JSON.parseArray(feesStandardsInfo, WxFeesStandards.class); | |||
| return JSON.parseArray(feesStandardsInfo, WxEnergyFees.class); | |||
| } | |||
| return null; | |||
| } | |||
| @TableField(exist = false) | |||
| List<WxFeesStandards> unFixedfeeStandards; | |||
| public List<WxFeesStandards> getUnFixedfeeStandards() { | |||
| List<WxFeesStandards> fees = this.getFeesStardarsList(); | |||
| List<WxEnergyFees> unFixedfeeStandards; | |||
| public List<WxEnergyFees> getUnFixedfeeStandards() { | |||
| List<WxEnergyFees> fees = this.getFeesStardarsList(); | |||
| if (null != fees && fees.size() > 0 ) { | |||
| List<WxFeesStandards> unfixed = new ArrayList<WxFeesStandards>(); | |||
| List<WxEnergyFees> unfixed = new ArrayList<WxEnergyFees>(); | |||
| for (int i = 0 ; i < fees.size() ; i++ ) { | |||
| WxFeesStandards fs = fees.get(i); | |||
| WxEnergyFees fs = fees.get(i); | |||
| if (fs.getFixedPrice().intValue() == EnumYesOrNo.NO.getCode().intValue()) { | |||
| unfixed.add(fs); | |||
| } | |||
| @@ -342,7 +342,7 @@ public class WxPropertyContract extends TenantEntity { | |||
| private List<Long> merchantIds; | |||
| @TableField(exist = false) | |||
| List<WxFeesStandards> feeStandards; | |||
| List<WxEnergyFees> feeStandards; | |||
| @@ -4,7 +4,7 @@ import lombok.Data; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| import com.iformall.domain.po.WxFeesStandards; | |||
| import com.iformall.domain.po.WxEnergyFees; | |||
| @Data | |||
| public class WxBillFeesStandardsListVo implements Serializable { | |||
| @@ -14,7 +14,7 @@ public class WxBillFeesStandardsListVo implements Serializable { | |||
| private Date start; | |||
| private Date end; | |||
| private Date receiveDate; | |||
| private WxFeesStandards feeStandards; | |||
| private WxEnergyFees feeStandards; | |||
| private Long parentBillId; | |||
| } | |||
| @@ -1,16 +1,19 @@ | |||
| package com.iformall.enums; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| public enum EnumBillAllType { | |||
| RENT(1,"租金",1L), | |||
| RENT_BUSSINESS_MANAGE(11,"商业管理费",2L), | |||
| RENT_OPERATION_MANAGE(12,"运营管理费",3L), | |||
| RENT_DEPOSIT(13,"租赁押金",4L), | |||
| PROPERTY(2,"物业费",5L), | |||
| PROPERTY_DEPOSIT(21,"物业押金",6L), | |||
| DAILY(3, "日常(水电空调)费",null), | |||
| OTHER(4, "其他费用",null), | |||
| OTHER_DEPOSIT(5, "其他押金",null) | |||
| RENT(1,"租金",1L,false), | |||
| RENT_BUSSINESS_MANAGE(11,"商业管理费",2L,false), | |||
| RENT_OPERATION_MANAGE(12,"运营管理费",3L,false), | |||
| RENT_DEPOSIT(13,"租赁押金",4L,true), | |||
| PROPERTY(2,"物业费",5L,false), | |||
| PROPERTY_DEPOSIT(21,"物业押金",6L,true), | |||
| DAILY(3, "日常(水电空调)费",null,false), | |||
| OTHER(4, "其他费用",null,false), | |||
| OTHER_DEPOSIT(5, "其他押金",null,true) | |||
| ; | |||
| public static EnumBillAllType getEnum(Integer code) { | |||
| @@ -24,12 +27,14 @@ public enum EnumBillAllType { | |||
| private Integer code; | |||
| private String message; | |||
| private Long energyFeesId;//wx_energy_fees里的id,系统内置的有这个 | |||
| private Long energyFeesId;//wx_energy_fees(费用科目)里的id,系统内置的有这个 | |||
| private boolean isFixedPrice;//是否强制为一次性费用 | |||
| EnumBillAllType(Integer code, String message,Long energyFeesId) { | |||
| EnumBillAllType(Integer code, String message,Long energyFeesId,boolean isFixedPrice) { | |||
| this.code = code; | |||
| this.message = message; | |||
| this.energyFeesId = energyFeesId; | |||
| this.isFixedPrice = isFixedPrice; | |||
| } | |||
| public Integer getCode() { | |||
| @@ -43,21 +48,45 @@ public enum EnumBillAllType { | |||
| public Long getEnergyFeesId() { | |||
| return energyFeesId; | |||
| } | |||
| public boolean isFixedPrice() { | |||
| return isFixedPrice; | |||
| } | |||
| public static EnumBillAllType[] getSystemTypes() { | |||
| EnumBillAllType[] ret = new EnumBillAllType[] {RENT,RENT_BUSSINESS_MANAGE,RENT_OPERATION_MANAGE,RENT_DEPOSIT, | |||
| PROPERTY,PROPERTY_DEPOSIT}; | |||
| return ret; | |||
| } | |||
| public static EnumBillAllType[] getFinanceTypes() { | |||
| EnumBillAllType[] ret = new EnumBillAllType[] {RENT,RENT_BUSSINESS_MANAGE,RENT_OPERATION_MANAGE,RENT_DEPOSIT, | |||
| PROPERTY,PROPERTY_DEPOSIT,OTHER,OTHER_DEPOSIT}; | |||
| //可以自定义科目的非能源类型 | |||
| public static EnumBillAllType[] getOperateNotEnergyTypes() { | |||
| EnumBillAllType[] ret = new EnumBillAllType[] {RENT_DEPOSIT,PROPERTY,OTHER,OTHER_DEPOSIT}; | |||
| return ret; | |||
| } | |||
| public static EnumBillAllType[] getFinanceOperateTypes() { | |||
| EnumBillAllType[] ret = new EnumBillAllType[] {OTHER,OTHER_DEPOSIT}; | |||
| return ret; | |||
| public static List<EnumFeesStandardsCalcuteUnit> getCalucuteUnites(Integer type) { | |||
| //需要计算的费用,非一次性费用 | |||
| List<EnumFeesStandardsCalcuteUnit> retList = new ArrayList<EnumFeesStandardsCalcuteUnit>(); | |||
| if (type.intValue() == RENT.getCode().intValue() || type.intValue() == RENT_BUSSINESS_MANAGE.getCode().intValue() | |||
| || type.intValue() == RENT_OPERATION_MANAGE.getCode().intValue() || type.intValue() == PROPERTY.getCode().intValue()) { | |||
| retList.add(EnumFeesStandardsCalcuteUnit.MM); | |||
| retList.add(EnumFeesStandardsCalcuteUnit.HU); | |||
| }else if (type.intValue() == DAILY.getCode().intValue()) { | |||
| retList.add(EnumFeesStandardsCalcuteUnit.DIAN_DU); | |||
| retList.add(EnumFeesStandardsCalcuteUnit.SHUI_DUN); | |||
| } | |||
| if (retList.size() > 0 ) { | |||
| return retList; | |||
| } | |||
| return null; | |||
| } | |||
| public static List<EnumFeesStandardsTimeUnit> getTimeUnites(Integer type) { | |||
| List<EnumFeesStandardsTimeUnit> retList = new ArrayList<EnumFeesStandardsTimeUnit>(); | |||
| retList.add(EnumFeesStandardsTimeUnit.DAY); | |||
| retList.add(EnumFeesStandardsTimeUnit.MONTH); | |||
| retList.add(EnumFeesStandardsTimeUnit.YEAR); | |||
| return retList; | |||
| } | |||
| } | |||
| @@ -1,61 +0,0 @@ | |||
| package com.iformall.enums; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public enum EnumFeesStandardsType { | |||
| PROPERTY_CONTRACT(1, "物业合同费用标准"), | |||
| DAILY_BILL(2, "日常费用标准"); | |||
| public static EnumFeesStandardsType getEnum(Integer code) { | |||
| for (EnumFeesStandardsType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumFeesStandardsType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| public static List<EnumFeesStandardsCalcuteUnit> getCalucuteUnites(Integer type) { | |||
| List<EnumFeesStandardsCalcuteUnit> retList = new ArrayList<EnumFeesStandardsCalcuteUnit>(); | |||
| if (type.intValue() == PROPERTY_CONTRACT.getCode().intValue()) { | |||
| retList.add(EnumFeesStandardsCalcuteUnit.MM); | |||
| retList.add(EnumFeesStandardsCalcuteUnit.HU); | |||
| return retList; | |||
| }else if (type.intValue() == DAILY_BILL.getCode().intValue()) { | |||
| retList.add(EnumFeesStandardsCalcuteUnit.DIAN_DU); | |||
| retList.add(EnumFeesStandardsCalcuteUnit.SHUI_DUN); | |||
| return retList; | |||
| } | |||
| return null; | |||
| } | |||
| public static List<EnumFeesStandardsTimeUnit> getTimeUnites(Integer type) { | |||
| List<EnumFeesStandardsTimeUnit> retList = new ArrayList<EnumFeesStandardsTimeUnit>(); | |||
| retList.add(EnumFeesStandardsTimeUnit.DAY); | |||
| retList.add(EnumFeesStandardsTimeUnit.MONTH); | |||
| retList.add(EnumFeesStandardsTimeUnit.YEAR); | |||
| return retList; | |||
| } | |||
| } | |||
| @@ -1,16 +0,0 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxFeesStandards; | |||
| import java.util.List; | |||
| /** | |||
| */ | |||
| public interface WxFeesStandardsMapper extends CommonMapper<WxFeesStandards, Long> { | |||
| List<WxFeesStandards> findList(WxFeesStandards record); | |||
| WxFeesStandards getById(WxFeesStandards recordQ); | |||
| } | |||
| @@ -1,31 +0,0 @@ | |||
| package com.iformall.service; | |||
| import java.util.List; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxFeesStandards; | |||
| public interface WxFeesStandardsService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<WxFeesStandards> listAsPage(WxFeesStandards record, Integer pageIndex, Integer pageSize); | |||
| List<WxFeesStandards> list(WxFeesStandards record); | |||
| /** | |||
| * id+tenantId | |||
| * @param | |||
| * @return | |||
| */ | |||
| WxFeesStandards getById(Long id, String tenantId); | |||
| } | |||
| @@ -2,7 +2,7 @@ package com.iformall.service.helper; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.domain.po.WxFeesStandards; | |||
| import com.iformall.domain.po.WxEnergyFees; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.domain.vo.WxBillFeesStandardsListVo; | |||
| import com.iformall.enums.*; | |||
| @@ -477,14 +477,14 @@ public class WxRentContractHelper { | |||
| } | |||
| //其他标准计费项 | |||
| public static List<WxBillFeesStandardsListVo> getStandardsBillList(Integer decimalSize,List<WxFeesStandards> feesStandarsList,Date billStartDate,Date billEndDate,boolean isFixed) { | |||
| public static List<WxBillFeesStandardsListVo> getStandardsBillList(Integer decimalSize,List<WxEnergyFees> feesStandarsList,Date billStartDate,Date billEndDate,boolean isFixed) { | |||
| if (null == feesStandarsList || feesStandarsList.size() <= 0 ) { | |||
| return null; | |||
| } | |||
| List<WxBillFeesStandardsListVo> retList = new ArrayList<WxBillFeesStandardsListVo>(); | |||
| for (int i = 0 ; i < feesStandarsList.size() ; i ++) { | |||
| WxBillFeesStandardsListVo vo = new WxBillFeesStandardsListVo(); | |||
| WxFeesStandards fees = feesStandarsList.get(i); | |||
| WxEnergyFees fees = feesStandarsList.get(i); | |||
| vo.setBillName(fees.getName()); | |||
| //如果是一次性的,账单只有一个 | |||
| if (isFixed) { | |||
| @@ -1,42 +0,0 @@ | |||
| package com.iformall.service.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.mapper.WxFeesStandardsMapper; | |||
| import com.iformall.service.*; | |||
| import java.util.List; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @Service | |||
| public class WxFeesStandardsServiceImpl implements WxFeesStandardsService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxFeesStandardsMapper wxFeesStandardsMapper; | |||
| @Override | |||
| public PageInfo<WxFeesStandards> listAsPage(WxFeesStandards record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxFeesStandardsMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxFeesStandards getById(Long id, String tenantId) { | |||
| WxFeesStandards recordQ = new WxFeesStandards(); | |||
| recordQ.setId(id); | |||
| recordQ.setTenantId(tenantId); | |||
| return wxFeesStandardsMapper.getById(recordQ); | |||
| } | |||
| @Override | |||
| public List<WxFeesStandards> list(WxFeesStandards record) { | |||
| return wxFeesStandardsMapper.findList(record); | |||
| } | |||
| } | |||
| @@ -880,7 +880,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| BigDecimal total = new BigDecimal(0); | |||
| for (int j = 0 ; j < unFixedList.size(); j ++) { | |||
| WxBillFeesStandardsListVo bfsvo = unFixedList.get(j); | |||
| WxFeesStandards feeStandars = bfsvo.getFeeStandards(); | |||
| WxEnergyFees feeStandars = bfsvo.getFeeStandards(); | |||
| if(EnumFeesStandardsCalcuteUnit.MM.getCode().intValue() == feeStandars.getCalcuteUnit().intValue()) { | |||
| bfsvo.setTotal(feeStandars.calcuteTotalMoney(wxPropertyContract.getDecimalSize(), start, end,wxPropertyContract.getRentArea(),false)); | |||
| }else if (EnumFeesStandardsCalcuteUnit.HU.getCode().intValue() == feeStandars.getCalcuteUnit().intValue()) { | |||
| @@ -14,10 +14,13 @@ | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="bill_type" jdbcType="INTEGER" property="billType"/> | |||
| <result column="is_system" jdbcType="INTEGER" property="isSystem"/> | |||
| <result column="fixed_price" jdbcType="INTEGER" property="fixedPrice"/> | |||
| <result column="calcute_unit" jdbcType="INTEGER" property="calcuteUnit"/> | |||
| <result column="time_unit" jdbcType="INTEGER" property="timeUnit"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`is_del`,`name`,`price`,`public_calcute`,`type`,`bill_type`,`is_system` | |||
| `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`is_del`,`name`,`price`,`public_calcute`,`type`,`bill_type`,`is_system`,`fixed_price`,`calcute_unit`,`time_unit` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -35,6 +38,9 @@ | |||
| <if test=" null != billType ">and `bill_type` = #{billType}</if> | |||
| <if test=" null != notEnergy ">and `bill_type` != 3</if> | |||
| <if test=" null != isSystem ">and `is_system` = #{isSystem}</if> | |||
| <if test=" null != fixedPrice ">and `fixed_price` = #{fixedPrice}</if> | |||
| <if test=" null != calcuteUnit ">and `calcute_unit` = #{calcuteUnit}</if> | |||
| <if test=" null != timeUnit ">and `time_unit` = #{timeUnit}</if> | |||
| <if test=" null != name and '' != name ">and name like concat('%', #{name},'%')</if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| @@ -1,58 +0,0 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.WxFeesStandardsMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxFeesStandards"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <result column="is_del" jdbcType="INTEGER" property="isDel"/> | |||
| <result column="name" jdbcType="VARCHAR" property="name"/> | |||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||
| <result column="price" jdbcType="VARCHAR" property="price"/> | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="fixed_price" jdbcType="INTEGER" property="fixedPrice"/> | |||
| <result column="calcute_unit" jdbcType="INTEGER" property="calcuteUnit"/> | |||
| <result column="time_unit" jdbcType="INTEGER" property="timeUnit"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`is_del`,`name`,`update_time`,`create_time`,`price`,`type`,`fixed_price`,`calcute_unit`,`time_unit` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id ">and `id` = #{id}</if> | |||
| <if test=" null != tenantId and '' != tenantId"> and `tenant_id` = #{tenantId} </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> and `parent_tenant_id` = #{parentTenantId} </if> | |||
| <if test=" null != isDel">and `is_del` = #{isDel}</if> | |||
| <if test=" null != name and '' != name">and `name` like concat('%', #{name},'%') </if> | |||
| <if test=" null != type">and `type` = #{type}</if> | |||
| <if test=" null != fixedPrice">and `fixed_price` = #{fixedPrice}</if> | |||
| <if test=" null != calcuteUnit">and `calcute_unit` = #{calcuteUnit}</if> | |||
| <if test=" null != timeUnit">and `time_unit` = #{timeUnit}</if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxFeesStandards" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_fees_standards | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="getById" parameterType="com.iformall.domain.po.WxFeesStandards" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_fees_standards | |||
| where `id` = #{id} and `tenant_id` = #{tenantId} | |||
| </select> | |||
| </mapper> | |||