| @@ -4,9 +4,8 @@ import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.WxBillProperty; | |||||
| import com.iformall.domain.po.WxPropertyContract; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.EnumIsPreview; | |||||
| import com.iformall.enums.EnumRentStartType; | import com.iformall.enums.EnumRentStartType; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxPropertyContractMapper; | import com.iformall.mapper.WxPropertyContractMapper; | ||||
| @@ -21,6 +20,7 @@ import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.List; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| /** | /** | ||||
| @@ -180,4 +180,18 @@ public class WxPropertyContractController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| /** | |||||
| * 预览账单展示,编辑账期,后端生成账单金额 | |||||
| * @param wxPropertyContract | |||||
| * @return | |||||
| */ | |||||
| @PostMapping("buildBillPriceList") | |||||
| @SystemControllerLog(description = "物业合同-生成账单列表金额") | |||||
| public ResultData buildBillPriceList(@RequestBody WxPropertyContract wxPropertyContract) throws Exception{ | |||||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::buildBillPriceList"); | |||||
| WxPropertyContract dbRent = wxPropertyContractMapper.selectByPrimaryKey(wxPropertyContract.getId()); | |||||
| dbRent.setPreviewBillRentList(wxPropertyContract.getPreviewBillRentList()); | |||||
| List<WxBillProperty> result = wxPropertyContractService.buildProperty(new WxMerchant(),getUserId(),dbRent, EnumIsPreview.YES.getCode(), false); | |||||
| return new ResultData(result); | |||||
| } | |||||
| } | } | ||||
| @@ -84,23 +84,8 @@ public class WxRentContractController extends BaseController { | |||||
| */ | */ | ||||
| @PostMapping("buildBillPriceList") | @PostMapping("buildBillPriceList") | ||||
| @SystemControllerLog(description = "租赁合同-生成账单列表金额") | @SystemControllerLog(description = "租赁合同-生成账单列表金额") | ||||
| public ResultData buildBillPriceList(@ModelAttribute WxRentContract wxRentContract) throws Exception{ | |||||
| public ResultData buildBillPriceList(@RequestBody WxRentContract wxRentContract) throws Exception{ | |||||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::buildBillPriceList"); | logger.debug("[" + getIpAddr() + "] WxRentContractController::buildBillPriceList"); | ||||
| //todo:test | |||||
| // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |||||
| // wxRentContract.setId(312447858201595904l); | |||||
| // List<WxBillRent> previewBillRentList = new ArrayList<>(); | |||||
| // WxBillRent b = new WxBillRent(); | |||||
| // b.setStarttime(sdf.parse("2019-07-10")); | |||||
| // b.setEndtime(sdf.parse("2020-08-10")); | |||||
| // previewBillRentList.add(b); | |||||
| // b = new WxBillRent(); | |||||
| // b.setStarttime(sdf.parse("2020-08-11")); | |||||
| // b.setEndtime(sdf.parse("2021-07-30")); | |||||
| // previewBillRentList.add(b); | |||||
| // wxRentContract.setPreviewBillRentList(previewBillRentList); | |||||
| WxRentContract dbRent = wxRentContractMapper.selectByPrimaryKey(wxRentContract.getId()); | WxRentContract dbRent = wxRentContractMapper.selectByPrimaryKey(wxRentContract.getId()); | ||||
| dbRent.setPreviewBillRentList(wxRentContract.getPreviewBillRentList()); | dbRent.setPreviewBillRentList(wxRentContract.getPreviewBillRentList()); | ||||
| List<WxBillRent> result = wxRentContractService.buildRent(new WxMerchant(),getUserId(),dbRent, EnumIsPreview.YES.getCode(), false); | List<WxBillRent> result = wxRentContractService.buildRent(new WxMerchant(),getUserId(),dbRent, EnumIsPreview.YES.getCode(), false); | ||||
| @@ -0,0 +1,11 @@ | |||||
| ALTER TABLE `wx_rent_contract` | |||||
| ADD COLUMN `late_pay_ratio` INT(10) NULL DEFAULT 0 COMMENT '滞纳金费率'; | |||||
| ALTER TABLE `wx_rent_contract` | |||||
| ADD COLUMN `late_pay_day` INT(10) NULL DEFAULT NULL COMMENT 'n天后开始计算滞纳金'; | |||||
| ALTER TABLE `wx_property_contract` | |||||
| ADD COLUMN `late_pay_ratio` INT(10) NULL DEFAULT 0 COMMENT '滞纳金费率'; | |||||
| ALTER TABLE `wx_property_contract` | |||||
| ADD COLUMN `late_pay_day` INT(10) NULL DEFAULT NULL COMMENT 'n天后开始计算滞纳金'; | |||||
| @@ -6,11 +6,9 @@ import com.iformall.enums.EnumRentContractAdjustPeriod; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| import javax.persistence.Id; | import javax.persistence.Id; | ||||
| import javax.persistence.Table; | import javax.persistence.Table; | ||||
| import javax.persistence.Transient; | import javax.persistence.Transient; | ||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -143,6 +141,11 @@ public class WxPropertyContract extends BaseEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "调整比例", name = "adjustRatio") | @io.swagger.annotations.ApiModelProperty(value = "调整比例", name = "adjustRatio") | ||||
| private String adjustRatio; | private String adjustRatio; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "滞纳金费率", name = "latePayRatio") | |||||
| private Integer latePayRatio; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "n日后开始计算滞纳金", name = "latePayRatio") | |||||
| private Integer daylatePay; | |||||
| @Transient | @Transient | ||||
| @io.swagger.annotations.ApiModelProperty(value = "物业预账单列表", name = "previewBillRentList") | @io.swagger.annotations.ApiModelProperty(value = "物业预账单列表", name = "previewBillRentList") | ||||
| @@ -226,6 +226,11 @@ public class WxRentContract extends BaseEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "操作类型1区分租赁物业2合并租赁物业", name = "operationType") | @io.swagger.annotations.ApiModelProperty(value = "操作类型1区分租赁物业2合并租赁物业", name = "operationType") | ||||
| private Integer operationType; | private Integer operationType; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "滞纳金费率", name = "latePayRatio") | |||||
| private Integer latePayRatio; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "n日后开始计算滞纳金", name = "latePayRatio") | |||||
| private Integer latePayDay; | |||||
| public void setAdjustPeriodHandle() { | public void setAdjustPeriodHandle() { | ||||
| if(EnumPriceUnit.D.getCode().equals(this.getPriceUnit()) && EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode().equals(adjustPeriod)){ | if(EnumPriceUnit.D.getCode().equals(this.getPriceUnit()) && EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode().equals(adjustPeriod)){ | ||||
| @@ -2,11 +2,10 @@ package com.iformall.service; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxBillProperty; | import com.iformall.domain.po.WxBillProperty; | ||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxPropertyContract; | import com.iformall.domain.po.WxPropertyContract; | ||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -72,4 +71,6 @@ public interface WxPropertyContractService { | |||||
| List<WxBillProperty> getWxBillPropertyPreview(Long id); | List<WxBillProperty> getWxBillPropertyPreview(Long id); | ||||
| Map<String, Object> updateStatus(WxPropertyContract record); | Map<String, Object> updateStatus(WxPropertyContract record); | ||||
| List<WxBillProperty> buildProperty(WxMerchant wxMerchant, Long userId, WxPropertyContract propertyContract, Integer isPreview,boolean saveDb); | |||||
| } | } | ||||
| @@ -344,7 +344,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| //生成预览账单 | //生成预览账单 | ||||
| wxBillPropertyMapper.deletePreviewBill(record); | wxBillPropertyMapper.deletePreviewBill(record); | ||||
| //重新生成 | //重新生成 | ||||
| List<WxBillProperty> billList = buildProperty(new WxMerchant(),userId,record,EnumIsPreview.YES.getCode()); | |||||
| List<WxBillProperty> billList = buildProperty(new WxMerchant(),userId,record,EnumIsPreview.YES.getCode(),true); | |||||
| record.setPreviewBillRentList(billList); | record.setPreviewBillRentList(billList); | ||||
| message = "保存物业合同信息成功"; | message = "保存物业合同信息成功"; | ||||
| @@ -363,7 +363,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| //删除预账单,重新生成 | //删除预账单,重新生成 | ||||
| wxBillPropertyMapper.deletePreviewBill(record); | wxBillPropertyMapper.deletePreviewBill(record); | ||||
| //重新生成 | //重新生成 | ||||
| billList = buildProperty(new WxMerchant(),userId,record,EnumIsPreview.YES.getCode()); | |||||
| billList = buildProperty(new WxMerchant(),userId,record,EnumIsPreview.YES.getCode(),true); | |||||
| record.setPreviewBillRentList(billList); | record.setPreviewBillRentList(billList); | ||||
| } | } | ||||
| } | } | ||||
| @@ -532,7 +532,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| return JSONObject.toJSONString(shopInfo); | return JSONObject.toJSONString(shopInfo); | ||||
| } | } | ||||
| public List<WxBillProperty> buildRentMonth(WxMerchant wxMerchant, Long userId, WxPropertyContract wxPropertyContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview) { | |||||
| public List<WxBillProperty> buildRentMonth(WxMerchant wxMerchant, Long userId, WxPropertyContract wxPropertyContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview,boolean saveDb) { | |||||
| String adjustRatio = wxPropertyContract.getAdjustRatio(); | String adjustRatio = wxPropertyContract.getAdjustRatio(); | ||||
| String rentInfo = wxPropertyContract.getRentInfo(); | String rentInfo = wxPropertyContract.getRentInfo(); | ||||
| Map<String, Object> shopInfo = new HashMap<>(); | Map<String, Object> shopInfo = new HashMap<>(); | ||||
| @@ -598,13 +598,13 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| } | } | ||||
| yearList.add(startDate); | yearList.add(startDate); | ||||
| } | } | ||||
| Map<String, Object> resultMap = buildRent(receivePeriod, priceArr, yearList, Calendar.MONTH, wxPropertyContract, userId, wxMerchant, billcount, isPreview, shopInfo); | |||||
| Map<String, Object> resultMap = buildRent(receivePeriod, priceArr, yearList, Calendar.MONTH, wxPropertyContract, userId, wxMerchant, billcount, isPreview, shopInfo,saveDb); | |||||
| List<WxBillProperty> billRentList = (List<WxBillProperty>)resultMap.get("billList"); | List<WxBillProperty> billRentList = (List<WxBillProperty>)resultMap.get("billList"); | ||||
| resultList.addAll(billRentList); | resultList.addAll(billRentList); | ||||
| return resultList; | return resultList; | ||||
| } | } | ||||
| public Map<String, Object> buildRent(int receivePeriod,long[] priceArrs, List<Date> yearList,int dayType, WxPropertyContract wxPropertyContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview,Map<String, Object> shopInfo) { | |||||
| public Map<String, Object> buildRent(int receivePeriod,long[] priceArrs, List<Date> yearList,int dayType, WxPropertyContract wxPropertyContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview,Map<String, Object> shopInfo,boolean saveDb) { | |||||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | ||||
| Map<String,Object> resultMap = new HashedMap(); | Map<String,Object> resultMap = new HashedMap(); | ||||
| List<WxBillProperty> resultList = new ArrayList<>(); | List<WxBillProperty> resultList = new ArrayList<>(); | ||||
| @@ -615,28 +615,58 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| endDate = yearList.get(1); | endDate = yearList.get(1); | ||||
| } | } | ||||
| List<BillTimeVo> billTimeVoList = WxRentContractServiceImpl.initBillTimeList(wxPropertyContract.getRentalStartDate(),wxPropertyContract.getRentalEndDate(),wxPropertyContract.getAdjustPeriod(),dayType,receivePeriod); | |||||
| List<BillTimeVo> billTimeVoList = new ArrayList<>(); | |||||
| if(saveDb){ | |||||
| billTimeVoList = WxRentContractServiceImpl.initBillTimeList(wxPropertyContract.getRentalStartDate(),wxPropertyContract.getRentalEndDate(),wxPropertyContract.getAdjustPeriod(),dayType,receivePeriod); | |||||
| }else{ | |||||
| //预账单编辑账期,生成金额 | |||||
| for (WxBillProperty rent:wxPropertyContract.getPreviewBillRentList()) { | |||||
| BillTimeVo billTimeVo = new BillTimeVo(); | |||||
| billTimeVo.setStartDate(rent.getStarttime()); | |||||
| billTimeVo.setEndDate(rent.getEndtime()); | |||||
| billTimeVo.setReceiveDate(DateUtils.getDaySet(rent.getStarttime(),Calendar.DATE,-1)); | |||||
| billTimeVoList.add(billTimeVo); | |||||
| } | |||||
| } | |||||
| int index = 0; | int index = 0; | ||||
| 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); | ||||
| //计算金额 | |||||
| long needpay = 0; | |||||
| boolean flag = false; | |||||
| if(yearList.size() > 1) { | if(yearList.size() > 1) { | ||||
| if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { | if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { | ||||
| logger.info("=====billTimeVo.getStartDate():"+sd.format(billTimeVo.getStartDate())+" endDate:"+sd.format(endDate)); | |||||
| index++; | |||||
| if(index >= yearList.size()-1){ | |||||
| endDate = null; | |||||
| }else{ | |||||
| endDate = yearList.get(index+1);//price index 0开始,year.end 从第二年开始 | |||||
| logger.info("==========cross:"+sd.format(endDate)); | |||||
| if(yearList.size() > 1) { | |||||
| if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { | |||||
| //logger.info("=====billTimeVo.getStartDate():"+sd.format(billTimeVo.getStartDate())+" endDate:"+sd.format(endDate)); | |||||
| index++; | |||||
| if(index >= yearList.size()-1){ | |||||
| endDate = null; | |||||
| }else{ | |||||
| //如果是计算账单金额&cross 拆分日期进行计算 | |||||
| if(!saveDb && billTimeVo.getEndDate().after(endDate)) { | |||||
| long needpayFront = getNeedPayMoney(wxPropertyContract,priceArrs[index-1],billTimeVo.getStartDate(),DateUtils.getDaySet(endDate,Calendar.DATE,-1),i,billTimeVoList.size()); | |||||
| long needpayAfter = getNeedPayMoney(wxPropertyContract,priceArrs[index],endDate,billTimeVo.getEndDate(),i,billTimeVoList.size()); | |||||
| System.out.println(); | |||||
| needpay = needpayFront+needpayAfter; | |||||
| flag = true; | |||||
| } | |||||
| endDate = yearList.get(index+1);//price index 0开始,year.end 从第二年开始 | |||||
| //logger.info("==========cross:"+sd.format(endDate)); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| //获取price 、shopInfo | |||||
| long price = priceArrs[index]; | |||||
| //计算金额 | |||||
| if(!flag){ | |||||
| needpay = getNeedPayMoney(wxPropertyContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size()); | |||||
| } | |||||
| WxBillProperty wxBillProperty = new WxBillProperty(); | WxBillProperty wxBillProperty = new WxBillProperty(); | ||||
| wxBillProperty.setIsPreview(isPreview); | wxBillProperty.setIsPreview(isPreview); | ||||
| @@ -647,53 +677,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| wxBillProperty.setEndtime(billTimeVo.getEndDate()); | wxBillProperty.setEndtime(billTimeVo.getEndDate()); | ||||
| wxBillProperty.setReceiveDate(billTimeVo.getReceiveDate()); | wxBillProperty.setReceiveDate(billTimeVo.getReceiveDate()); | ||||
| long needpay; | |||||
| //按日 | |||||
| if (wxPropertyContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ | |||||
| Double priceD = new Double(price); | |||||
| double needpayD = WxRentContractServiceImpl.getNeedPay(0,priceD,wxBillProperty.getStarttime(),wxBillProperty.getEndtime()); | |||||
| needpay = new Double(needpayD).longValue(); | |||||
| }else{ | |||||
| //年 需要除12 | |||||
| Double priceD = new Double(price); | |||||
| if(EnumPriceUnit.Y.getCode().equals(wxPropertyContract.getPriceUnit())){ | |||||
| priceD = new Double(price)/12; | |||||
| } | |||||
| SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); | |||||
| if(i == billTimeVoList.size()-1){//最后 | |||||
| if(isFirstDay(billTimeVo.getStartDate())){ | |||||
| int months = WxRentContractServiceImpl.getMonths(sdM.format(billTimeVo.getStartDate())+"-01",sdM.format(billTimeVo.getEndDate())+"-01"); | |||||
| months++; | |||||
| needpay = new Double(months * priceD).longValue(); | |||||
| }else { | |||||
| needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD,billTimeVo.getStartDate(),billTimeVo.getEndDate())).longValue(); | |||||
| } | |||||
| }else if(i == 0){//第一期 | |||||
| if(wxPropertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ | |||||
| if(isFirstDay(billTimeVo.getStartDate())){ | |||||
| int months = WxRentContractServiceImpl.getMonths(sdM.format(billTimeVo.getStartDate())+"-01",sdM.format(billTimeVo.getEndDate())+"-01"); | |||||
| months++; | |||||
| needpay = new Double(months * priceD).longValue(); | |||||
| }else{ | |||||
| needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, billTimeVo.getStartDate(), billTimeVo.getEndDate())).longValue(); | |||||
| } | |||||
| }else{ | |||||
| int months = WxRentContractServiceImpl.getMonths(sdM.format(billTimeVo.getStartDate())+"-01",sdM.format(billTimeVo.getEndDate())+"-01"); | |||||
| if(isFirstDay(billTimeVo.getStartDate())){ | |||||
| months++; | |||||
| } | |||||
| needpay = new Double(months * priceD).longValue(); | |||||
| } | |||||
| }else{//中间 | |||||
| int months = WxRentContractServiceImpl.getMonths(sdM.format(billTimeVo.getStartDate())+"-01",sdM.format(billTimeVo.getEndDate())+"-01"); | |||||
| if(isFirstDay(billTimeVo.getStartDate())){ | |||||
| months++; | |||||
| } | |||||
| needpay = new Double(months * priceD).longValue(); | |||||
| } | |||||
| } | |||||
| wxBillProperty.setNeedPay(needpay); | wxBillProperty.setNeedPay(needpay); | ||||
| wxBillProperty.setOwe(needpay); | wxBillProperty.setOwe(needpay); | ||||
| wxBillProperty.setReceivePay(needpay); | wxBillProperty.setReceivePay(needpay); | ||||
| @@ -715,16 +698,71 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| wxBillProperty.setShopInfo(JSONObject.toJSONString(shopInfo)); | wxBillProperty.setShopInfo(JSONObject.toJSONString(shopInfo)); | ||||
| } | } | ||||
| wxBillProperty.setLatePayRatio(0); | wxBillProperty.setLatePayRatio(0); | ||||
| //wxBillPropertyMapper.insertSelective(wxBillProperty); | |||||
| resultList.add(wxBillProperty); | resultList.add(wxBillProperty); | ||||
| } | } | ||||
| //批量生成预账单 | //批量生成预账单 | ||||
| wxBillPropertyMapper.insertBills(resultList); | |||||
| if(saveDb) { | |||||
| wxBillPropertyMapper.insertBills(resultList); | |||||
| } | |||||
| resultMap.put("billcount",billcount); | resultMap.put("billcount",billcount); | ||||
| resultMap.put("billList",resultList); | resultMap.put("billList",resultList); | ||||
| return resultMap; | return resultMap; | ||||
| } | } | ||||
| public long getNeedPayMoney(WxPropertyContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize){ | |||||
| long needpay; | |||||
| //按日 | |||||
| if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ | |||||
| Double priceD = new Double(price); | |||||
| double needpayD = WxRentContractServiceImpl.getNeedPay(0,priceD,startDate,endDate); | |||||
| needpay = new Double(needpayD).longValue(); | |||||
| }else{ | |||||
| //年 需要除12 | |||||
| Double priceD = new Double(price); | |||||
| if(EnumPriceUnit.Y.getCode().equals(wxRentContract.getPriceUnit())){ | |||||
| priceD = new Double(price)/12; | |||||
| } | |||||
| SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); | |||||
| if(i == billTimeVoListSize - 1){//最后 | |||||
| if(isFirstDay(startDate)){ | |||||
| int months = WxRentContractServiceImpl.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); | |||||
| months++; | |||||
| needpay = new Double(months * priceD).longValue(); | |||||
| }else { | |||||
| needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue(); | |||||
| } | |||||
| }else if(i == 0){//第一期 | |||||
| if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ | |||||
| if(isFirstDay(startDate)){ | |||||
| int months = WxRentContractServiceImpl.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); | |||||
| months++; | |||||
| needpay = new Double(months * priceD).longValue(); | |||||
| }else{ | |||||
| needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue(); | |||||
| } | |||||
| }else{ | |||||
| if(isFirstDay(startDate)){ | |||||
| int months = WxRentContractServiceImpl.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); | |||||
| if(isFirstDay(startDate)){ | |||||
| months++; | |||||
| } | |||||
| needpay = new Double(months * priceD).longValue(); | |||||
| }else{ | |||||
| needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue(); | |||||
| } | |||||
| } | |||||
| }else{//中间 | |||||
| int months = WxRentContractServiceImpl.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01"); | |||||
| if(isFirstDay(startDate)){ | |||||
| months++; | |||||
| } | |||||
| needpay = new Double(months * priceD).longValue(); | |||||
| } | |||||
| } | |||||
| return needpay; | |||||
| } | |||||
| public void setExpiredDay(WxBillProperty wxBillProperty,int dayType, int receivePeriod){ | public void setExpiredDay(WxBillProperty wxBillProperty,int dayType, int receivePeriod){ | ||||
| Date date = new Date(); | Date date = new Date(); | ||||
| if (wxBillProperty.getReceiveDate().before(date)) { | if (wxBillProperty.getReceiveDate().before(date)) { | ||||
| @@ -760,8 +798,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| * @param propertyContract | * @param propertyContract | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| @Override | |||||
| @Transactional(rollbackFor = {Exception.class}) | @Transactional(rollbackFor = {Exception.class}) | ||||
| public List<WxBillProperty> buildProperty(WxMerchant wxMerchant,Long userId,WxPropertyContract propertyContract,Integer isPreview) { | |||||
| public List<WxBillProperty> buildProperty(WxMerchant wxMerchant,Long userId,WxPropertyContract propertyContract,Integer isPreview,boolean saveDb) { | |||||
| List<WxBillProperty> result = new ArrayList<>(); | List<WxBillProperty> result = new ArrayList<>(); | ||||
| WxPropertyContract wxPropertyContract; | WxPropertyContract wxPropertyContract; | ||||
| @@ -788,7 +827,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| Long price = propertyContract.getPrice(); | Long price = propertyContract.getPrice(); | ||||
| //按月计租 | //按月计租 | ||||
| result = buildRentMonth(wxMerchant, userId, propertyContract, receivePeriod, lease, rentalStartDate, price,isPreview); | |||||
| result = buildRentMonth(wxMerchant, userId, propertyContract, receivePeriod, lease, rentalStartDate, price,isPreview,saveDb); | |||||
| } | } | ||||
| for (int i = 0; i < result.size(); i++) { | for (int i = 0; i < result.size(); i++) { | ||||
| result.get(i).setPeriod(i+1); | result.get(i).setPeriod(i+1); | ||||
| @@ -796,7 +835,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| return result; | return result; | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| wxPropertyContractMapper.deleteByPrimaryKey(id); | wxPropertyContractMapper.deleteByPrimaryKey(id); | ||||
| @@ -1034,8 +1034,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| boolean flag = false; | boolean flag = false; | ||||
| if(yearList.size() > 1) { | if(yearList.size() > 1) { | ||||
| if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { | if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { | ||||
| logger.info("=====billTimeVo.getStartDate():"+sd.format(billTimeVo.getStartDate())+" endDate:"+sd.format(endDate)); | |||||
| if(yearList.size() > 1) { | if(yearList.size() > 1) { | ||||
| if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { | if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { | ||||
| //logger.info("=====billTimeVo.getStartDate():"+sd.format(billTimeVo.getStartDate())+" endDate:"+sd.format(endDate)); | //logger.info("=====billTimeVo.getStartDate():"+sd.format(billTimeVo.getStartDate())+" endDate:"+sd.format(endDate)); | ||||
| @@ -1046,14 +1044,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| }else{ | }else{ | ||||
| //如果是计算账单金额&cross 拆分日期进行计算 | //如果是计算账单金额&cross 拆分日期进行计算 | ||||
| if(!saveDb && billTimeVo.getEndDate().after(endDate)) { | if(!saveDb && billTimeVo.getEndDate().after(endDate)) { | ||||
| logger.info("==========s:"+sd.format(billTimeVo.getStartDate())); | |||||
| logger.info("==========e:"+sd.format(billTimeVo.getEndDate())); | |||||
| logger.info("==========endDate:"+sd.format(endDate)); | |||||
| long needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),DateUtils.getDaySet(endDate,Calendar.DATE,-1),i,billTimeVoList.size()); | long needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),DateUtils.getDaySet(endDate,Calendar.DATE,-1),i,billTimeVoList.size()); | ||||
| long needpayAfter = getNeedPayMoney(wxRentContract,priceArrs[index],endDate,billTimeVo.getEndDate(),i,billTimeVoList.size()); | long needpayAfter = getNeedPayMoney(wxRentContract,priceArrs[index],endDate,billTimeVo.getEndDate(),i,billTimeVoList.size()); | ||||
| logger.info("==========needpayFront:"+needpayFront); | |||||
| logger.info("==========needpayAfter:"+needpayAfter); | |||||
| System.out.println(); | System.out.println(); | ||||
| needpay = needpayFront+needpayAfter; | needpay = needpayFront+needpayAfter; | ||||
| flag = true; | flag = true; | ||||
| @@ -92,12 +92,13 @@ | |||||
| merchant_name,s.shop_number,br.`updatetime`,br.`merchant_id`,br.`rent_shop_type`,br.`period`, | merchant_name,s.shop_number,br.`updatetime`,br.`merchant_id`,br.`rent_shop_type`,br.`period`, | ||||
| br.`revenue`,br.`late_pay_ratio`,br.`late_pay_time`,br.`property_contract_id`,d.receive_pay deposit, | br.`revenue`,br.`late_pay_ratio`,br.`late_pay_time`,br.`property_contract_id`,d.receive_pay deposit, | ||||
| case when br.late_pay_status=2 then (case when br.late_pay_time is null then 0 | case when br.late_pay_status=2 then (case when br.late_pay_time is null then 0 | ||||
| else FLOOR(DATEDIFF(now(),br.late_pay_time)*br.late_pay_ratio/10000*br.owe)end) | |||||
| else FLOOR(DATEDIFF(now(),date_add(br.receive_date,interval r.late_pay_day day))*r.late_pay_ratio/10000*br.owe)end) | |||||
| else br.late_pay_price end late_pay_price,d.`status` | else br.late_pay_price end late_pay_price,d.`status` | ||||
| deposit_status,br.`shop_info`,br.pay_way,br.late_pay_status, | deposit_status,br.`shop_info`,br.pay_way,br.late_pay_status, | ||||
| br.`comments`,br.starttime,br.endtime | br.`comments`,br.starttime,br.endtime | ||||
| from wx_bill_property br left join wx_merchant m on br.merchant_id=m.id | from wx_bill_property br left join wx_merchant m on br.merchant_id=m.id | ||||
| left join wx_shop s on br.shop_id=s.id | left join wx_shop s on br.shop_id=s.id | ||||
| left join wx_property_contract r on br.property_contract_id=r.id | |||||
| left join wx_bill_property_deposit d on br.property_contract_id=d.property_contract_id | left join wx_bill_property_deposit d on br.property_contract_id=d.property_contract_id | ||||
| <where> | <where> | ||||
| br.is_preview = 0 | br.is_preview = 0 | ||||
| @@ -98,8 +98,10 @@ | |||||
| case when br.status=1 then br.owe else 0 end owe,br.`status`,br.`need_pay`,r.merchant_name, | case when br.status=1 then br.owe else 0 end owe,br.`status`,br.`need_pay`,r.merchant_name, | ||||
| s.shop_number,br.`updatetime`,br.`merchant_id`,br.`rent_shop_type`,r.type as rent_type, | s.shop_number,br.`updatetime`,br.`merchant_id`,br.`rent_shop_type`,r.type as rent_type, | ||||
| r.pay_ratio,br.`revenue`,br.`late_pay_ratio`,br.`late_pay_time`,br.`period`,br.`rent_contract_id`, | r.pay_ratio,br.`revenue`,br.`late_pay_ratio`,br.`late_pay_time`,br.`period`,br.`rent_contract_id`, | ||||
| d.receive_pay deposit,case when br.late_pay_status=2 then (case when br.late_pay_time is null then 0 | |||||
| else FLOOR(DATEDIFF(now(),br.late_pay_time)*br.late_pay_ratio/10000*br.owe)end) else br.late_pay_price end | |||||
| d.receive_pay deposit, | |||||
| case when br.late_pay_status=2 then (case when br.late_pay_time is null then 0 | |||||
| else FLOOR(DATEDIFF(now(),date_add(br.receive_date,interval r.late_pay_day day))*r.late_pay_ratio/10000*br.owe)end) | |||||
| else br.late_pay_price end | |||||
| late_pay_price,d.`status` | late_pay_price,d.`status` | ||||
| deposit_status,br.shop_info,br.pay_way,br.late_pay_status,br.`comments`,br.starttime,br.endtime | deposit_status,br.shop_info,br.pay_way,br.late_pay_status,br.`comments`,br.starttime,br.endtime | ||||
| from wx_bill_rent br | from wx_bill_rent br | ||||
| @@ -44,7 +44,8 @@ | |||||
| <result column="rent_start_type" property="rentStartType"/> | <result column="rent_start_type" property="rentStartType"/> | ||||
| <result column="operation_type" property="operationType"/> | <result column="operation_type" property="operationType"/> | ||||
| <result column="late_pay_ratio" property="latePayRatio"/> | |||||
| <result column="late_pay_day" property="latePayDay"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| @@ -54,7 +55,7 @@ | |||||
| `shop_type`,`shop_id`,`updatetime`,`createtime`,`rent_area`, | `shop_type`,`shop_id`,`updatetime`,`createtime`,`rent_area`, | ||||
| `link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`, | `link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`, | ||||
| `start_date`,`end_date`,`apply_status`,`adjust_period`,`business_type`,adjust_ratio,`rent_info`, | `start_date`,`end_date`,`apply_status`,`adjust_period`,`business_type`,adjust_ratio,`rent_info`, | ||||
| `file_names`,price_unit,rent_price,subject_name,rent_start_type,`operation_type` | |||||
| `file_names`,price_unit,rent_price,subject_name,rent_start_type,`operation_type`,late_pay_ratio,late_pay_day | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -51,10 +51,10 @@ | |||||
| <result column="rent_input_way" property="rentInputWay"/> | <result column="rent_input_way" property="rentInputWay"/> | ||||
| <result column="adjust_ratio_way" property="adjustRatioWay"/> | <result column="adjust_ratio_way" property="adjustRatioWay"/> | ||||
| <result column="operation_type" property="operationType"/> | <result column="operation_type" property="operationType"/> | ||||
| <result column="late_pay_ratio" property="latePayRatio"/> | |||||
| <result column="late_pay_day" property="latePayDay"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| @@ -65,7 +65,7 @@ | |||||
| `start_date`,`end_date`, | `start_date`,`end_date`, | ||||
| `apply_status`,`bank_name`,`rent_shop_type`,`fix_start_date`,`fix_end_date`, | `apply_status`,`bank_name`,`rent_shop_type`,`fix_start_date`,`fix_end_date`, | ||||
| `business_type`,`rent_info`, `file_names`,price_unit,rent_price,`subject_name`,rent_start_type, | `business_type`,`rent_info`, `file_names`,price_unit,rent_price,`subject_name`,rent_start_type, | ||||
| `rent_input_way`,`adjust_ratio_way`,`operation_type` | |||||
| `rent_input_way`,`adjust_ratio_way`,`operation_type`,late_pay_ratio,late_pay_day | |||||
| </sql> | </sql> | ||||