| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import com.iformall.common.SortColumn; | import com.iformall.common.SortColumn; | ||||
| import com.iformall.enums.EnumPriceUnit; | |||||
| import com.iformall.enums.EnumRentContractAdjustPeriod; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| @@ -252,4 +254,16 @@ public class WxPropertyContract extends BaseEntity { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | this.setSortColumns(Field.valueOf(sortColumns)); | ||||
| } | } | ||||
| } | } | ||||
| public Integer getAdjustPeriod() { | |||||
| if(EnumPriceUnit.D.getCode().equals(this.getPriceUnit()) && EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode().equals(adjustPeriod)){ | |||||
| return EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode(); | |||||
| } | |||||
| return adjustPeriod; | |||||
| } | |||||
| public void setAdjustPeriod(Integer adjustPeriod) { | |||||
| this.adjustPeriod = adjustPeriod; | |||||
| } | |||||
| } | } | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import com.iformall.common.SortColumn; | import com.iformall.common.SortColumn; | ||||
| import com.iformall.enums.EnumPriceUnit; | |||||
| import com.iformall.enums.EnumRentContractAdjustPeriod; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| @@ -290,4 +292,16 @@ public class WxRentContract extends BaseEntity { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | this.setSortColumns(Field.valueOf(sortColumns)); | ||||
| } | } | ||||
| } | } | ||||
| public Integer getAdjustPeriod() { | |||||
| if(EnumPriceUnit.D.getCode().equals(this.getPriceUnit()) && EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode().equals(adjustPeriod)){ | |||||
| return EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode(); | |||||
| } | |||||
| return adjustPeriod; | |||||
| } | |||||
| public void setAdjustPeriod(Integer adjustPeriod) { | |||||
| this.adjustPeriod = adjustPeriod; | |||||
| } | |||||
| } | } | ||||
| @@ -92,7 +92,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); | return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); | ||||
| } | } | ||||
| //m:init dateDiff | |||||
| //init dateDiff | |||||
| if(wxPropertyContract.getRentalStartDate() != null && wxPropertyContract.getRentalEndDate() != null){ | if(wxPropertyContract.getRentalStartDate() != null && wxPropertyContract.getRentalEndDate() != null){ | ||||
| Calendar instance = Calendar.getInstance(); | Calendar instance = Calendar.getInstance(); | ||||
| instance.setTime(wxPropertyContract.getRentalEndDate()); | instance.setTime(wxPropertyContract.getRentalEndDate()); | ||||
| @@ -102,7 +102,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| result.put("totalPeriodDay",array[1]); | result.put("totalPeriodDay",array[1]); | ||||
| } | } | ||||
| //m:init 租赁单价 | |||||
| //init 租赁单价 | |||||
| String rentInfo = wxPropertyContract.getRentInfo(); | String rentInfo = wxPropertyContract.getRentInfo(); | ||||
| if(StringUtils.isNotBlank(rentInfo)){ | if(StringUtils.isNotBlank(rentInfo)){ | ||||
| JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | ||||
| @@ -134,6 +134,10 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| if(wxPropertyContract.getPriceUnit() == null){ | if(wxPropertyContract.getPriceUnit() == null){ | ||||
| wxPropertyContract.setPriceUnit(EnumPriceUnit.M.getCode()); | wxPropertyContract.setPriceUnit(EnumPriceUnit.M.getCode()); | ||||
| } | } | ||||
| if(wxPropertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode())){ | |||||
| wxPropertyContract.setAdjustPeriod(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode()); | |||||
| wxPropertyContract.setPriceUnit(EnumPriceUnit.D.getCode()); | |||||
| } | |||||
| wxPropertyContract.setPrice(wxPropertyContract.getPrice() != null ? wxPropertyContract.getPrice() : 0); | wxPropertyContract.setPrice(wxPropertyContract.getPrice() != null ? wxPropertyContract.getPrice() : 0); | ||||
| wxPropertyContract.setDeposit(wxPropertyContract.getDeposit() != null ? wxPropertyContract.getDeposit() : 0); | wxPropertyContract.setDeposit(wxPropertyContract.getDeposit() != null ? wxPropertyContract.getDeposit() : 0); | ||||
| @@ -182,13 +186,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| result.put("remark",flowRecordList.get(0).getRemark()); | result.put("remark",flowRecordList.get(0).getRemark()); | ||||
| } | } | ||||
| // //生成预览账单 | |||||
| // if(wxPropertyContract.getReceivePeriod() != null && wxPropertyContract.getLease()!=null) { | |||||
| // wxBillPropertyMapper.deletePreviewBill(wxPropertyContract); | |||||
| // //重新生成 | |||||
| // List<WxBillProperty> billList = buildProperty(new WxMerchant(),wxPropertyContract,EnumIsPreview.YES.getCode()); | |||||
| // wxPropertyContract.setPreviewBillRentList(billList); | |||||
| // } | |||||
| //查询预账单用于展示 | //查询预账单用于展示 | ||||
| WxBillProperty wxBillRent = new WxBillProperty(); | WxBillProperty wxBillRent = new WxBillProperty(); | ||||
| wxBillRent.setPropertyContractId(id); | wxBillRent.setPropertyContractId(id); | ||||
| @@ -548,6 +545,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| && !isFirstDay(wxPropertyContract.getRentalStartDate()) | && !isFirstDay(wxPropertyContract.getRentalStartDate()) | ||||
| && (wxPropertyContract.getLease() % wxPropertyContract.getReceivePeriod() == 0) | && (wxPropertyContract.getLease() % wxPropertyContract.getReceivePeriod() == 0) | ||||
| && isLastYesr | && isLastYesr | ||||
| && wxPropertyContract.getReceivePeriod() != 1 | |||||
| ){ | ){ | ||||
| paycount ++; | paycount ++; | ||||
| } | } | ||||
| @@ -717,6 +715,19 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| } | } | ||||
| } | } | ||||
| //最后一期截止到结束日期 | |||||
| if(i == paycount - 1){ | |||||
| wxBillProperty.setEndtime(wxPropertyContract.getRentalEndDate()); | |||||
| //当天也算,加1天 | |||||
| Date newEndDate = DateUtils.getDaySet(wxBillProperty.getEndtime(),Calendar.DATE,1); | |||||
| int[] diff = DateUtils.getDiff(wxBillProperty.getStarttime(),newEndDate); | |||||
| needpay = diff[0]*price; | |||||
| double oneDayProce = (double) price/DateUtils.getMonthDayCount(wxPropertyContract.getRentalEndDate()); | |||||
| needpay += diff[1] * oneDayProce; | |||||
| } | |||||
| wxBillProperty.setNeedPay(needpay); | wxBillProperty.setNeedPay(needpay); | ||||
| wxBillProperty.setOwe(needpay); | wxBillProperty.setOwe(needpay); | ||||
| wxBillProperty.setReceivePay(needpay); | wxBillProperty.setReceivePay(needpay); | ||||
| @@ -800,7 +811,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| ||propertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { | ||propertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { | ||||
| result = buildRentMonth(wxMerchant, userId, propertyContract, receivePeriod, lease, rentalStartDate, price,isPreview); | result = buildRentMonth(wxMerchant, userId, propertyContract, receivePeriod, lease, rentalStartDate, price,isPreview); | ||||
| } else { | } else { | ||||
| //按日计租 | |||||
| //如果按日 | |||||
| //处理lease | |||||
| lease = DateUtils.daysBetween(propertyContract.getRentalStartDate(),propertyContract.getRentalEndDate()); | |||||
| Map<String, Object> resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, propertyContract, userId, wxMerchant, 0, isPreview, null,false); | Map<String, Object> resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, propertyContract, userId, wxMerchant, 0, isPreview, null,false); | ||||
| result = (List<WxBillProperty>)resultMap.get("billList"); | result = (List<WxBillProperty>)resultMap.get("billList"); | ||||
| } | } | ||||
| @@ -115,7 +115,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); | return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); | ||||
| } | } | ||||
| //m: init dateDiff | |||||
| //init dateDiff | |||||
| if(wxRentContract.getRentalStartDate() != null && wxRentContract.getRentalEndDate() != null){ | if(wxRentContract.getRentalStartDate() != null && wxRentContract.getRentalEndDate() != null){ | ||||
| Calendar instance = Calendar.getInstance(); | Calendar instance = Calendar.getInstance(); | ||||
| instance.setTime(wxRentContract.getRentalEndDate()); | instance.setTime(wxRentContract.getRentalEndDate()); | ||||
| @@ -125,7 +125,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| result.put("totalPeriodDay",array[1]); | result.put("totalPeriodDay",array[1]); | ||||
| } | } | ||||
| //m: init 租赁单价 | |||||
| //init 租赁单价 | |||||
| String rentInfo = wxRentContract.getRentInfo(); | String rentInfo = wxRentContract.getRentInfo(); | ||||
| if(StringUtils.isNotBlank(rentInfo)){ | if(StringUtils.isNotBlank(rentInfo)){ | ||||
| JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); | ||||
| @@ -157,6 +157,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| if(wxRentContract.getPriceUnit() == null){ | if(wxRentContract.getPriceUnit() == null){ | ||||
| wxRentContract.setPriceUnit(EnumPriceUnit.M.getCode()); | wxRentContract.setPriceUnit(EnumPriceUnit.M.getCode()); | ||||
| } | } | ||||
| if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode())){ | |||||
| wxRentContract.setAdjustPeriod(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode()); | |||||
| wxRentContract.setPriceUnit(EnumPriceUnit.D.getCode()); | |||||
| } | |||||
| //商场信息 | //商场信息 | ||||
| WxMall wxMall = new WxMall(); | WxMall wxMall = new WxMall(); | ||||
| @@ -703,12 +707,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| Date rentalStartDate = wxRentContract.getRentalStartDate(); | Date rentalStartDate = wxRentContract.getRentalStartDate(); | ||||
| Long price = wxRentContract.getPrice(); | Long price = wxRentContract.getPrice(); | ||||
| //按月计租 | //按月计租 | ||||
| if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode()) | if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode()) | ||||
| ||wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { | ||wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { | ||||
| rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview); | rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview); | ||||
| } else { | } else { | ||||
| //按日计租 | |||||
| //如果按日 | |||||
| //处理lease | |||||
| lease = DateUtils.daysBetween(wxRentContract.getRentalStartDate(),wxRentContract.getRentalEndDate()); | |||||
| Map<String, Object> resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0, isPreview, null,false); | Map<String, Object> resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0, isPreview, null,false); | ||||
| rentList = ( List<WxBillRent>)resultMap.get("billList"); | rentList = ( List<WxBillRent>)resultMap.get("billList"); | ||||
| } | } | ||||
| @@ -888,9 +896,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| wxBillRent.setId(idWorker.nextId()); | wxBillRent.setId(idWorker.nextId()); | ||||
| wxBillRent.setRentContractId(wxRentContract.getId()); | wxBillRent.setRentContractId(wxRentContract.getId()); | ||||
| wxBillRent.setPay(0L); | wxBillRent.setPay(0L); | ||||
| //System.out.println("-----------price:"+price+",receivePeriod:"+receivePeriod); | |||||
| long needpay = new BigDecimal(price).multiply(new BigDecimal(receivePeriod)).longValue(); | long needpay = new BigDecimal(price).multiply(new BigDecimal(receivePeriod)).longValue(); | ||||
| //System.out.println("--------needpay:"+needpay); | |||||
| Calendar instance = Calendar.getInstance(); | Calendar instance = Calendar.getInstance(); | ||||
| Date date = new Date(); | Date date = new Date(); | ||||