|
|
|
@@ -32,6 +32,7 @@ import com.iformall.domain.vo.WxBillSum; |
|
|
|
import com.iformall.domain.vo.WxRentContractRevenueSetSalesVo;
|
|
|
|
import com.iformall.domain.vo.WxRentContractYearsSumVo;
|
|
|
|
import com.iformall.enums.EnumBillAllType;
|
|
|
|
import com.iformall.enums.EnumBillExtraCreateFrom;
|
|
|
|
import com.iformall.enums.EnumBillStatus;
|
|
|
|
import com.iformall.enums.EnumContractOperationType;
|
|
|
|
import com.iformall.enums.EnumContractReceivePeriodUnit;
|
|
|
|
@@ -1023,26 +1024,18 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<Date> getYearList(int years,int month,Date rentalStartDate ) {
|
|
|
|
public List<Date> getYearList(int years,int month,Date rentalStartDate,Date endContractTime ) {
|
|
|
|
List<Date> yearList = new ArrayList<>();
|
|
|
|
for (int i = 0; i < years; i++) {
|
|
|
|
Calendar instance = Calendar.getInstance();
|
|
|
|
Date startDate;
|
|
|
|
// //自然月
|
|
|
|
// if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){
|
|
|
|
// if(i == 0){ //第一期
|
|
|
|
// startDate = rentalStartDate;
|
|
|
|
// }else{
|
|
|
|
// instance.setTime(rentalStartDate);
|
|
|
|
// instance.add(Calendar.MONTH, month * i);
|
|
|
|
// startDate = DateUtils.getFirstDayForCurrMonth(instance.getTime());
|
|
|
|
// }
|
|
|
|
// }else{
|
|
|
|
instance.setTime(rentalStartDate);
|
|
|
|
instance.add(Calendar.MONTH, month * i);
|
|
|
|
startDate = instance.getTime();
|
|
|
|
// }
|
|
|
|
yearList.add(startDate);
|
|
|
|
instance.setTime(rentalStartDate);
|
|
|
|
instance.add(Calendar.MONTH, month * i);
|
|
|
|
Date startDate = instance.getTime();
|
|
|
|
if (null != endContractTime && endContractTime.before(startDate)) {
|
|
|
|
yearList.add(endContractTime);
|
|
|
|
}else {
|
|
|
|
yearList.add(startDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return yearList;
|
|
|
|
}
|
|
|
|
@@ -1059,7 +1052,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
int billcount = 0;
|
|
|
|
List<WxAllBill> resultList = new ArrayList<WxAllBill>();
|
|
|
|
years = priceArrs.length;
|
|
|
|
List<Date> yearList = getYearList(years,month,rentalStartDate);
|
|
|
|
List<Date> yearList = getYearList(years,month,rentalStartDate,null);
|
|
|
|
|
|
|
|
String shopInfoStr = getShopInfoStr(wxRentContract);
|
|
|
|
Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs,bussinessManagerPriceArrs,operationManagerPriceArrs, yearList, wxRentContract.getReceivePeriodUnit(), wxRentContract, user, billcount, isPreview, shopInfoStr,saveDb);
|
|
|
|
@@ -2529,7 +2522,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
}
|
|
|
|
//计算每一年的基数
|
|
|
|
String[] priceArrs = WxRentContractHelper.calcuteRentPrice(rentcontract);
|
|
|
|
List<Date> yearList = this.getYearList(priceArrs.length, 12, rentcontract.getRentalStartDate());
|
|
|
|
List<Date> yearList = this.getYearList(priceArrs.length, 12, rentcontract.getRentalStartDate(),null);
|
|
|
|
int yearIndex = 0;
|
|
|
|
for( int i = 0 ; i < yearList.size() ; i ++) {
|
|
|
|
Date yearEndDate = yearList.get(i);
|
|
|
|
@@ -2635,25 +2628,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
WxRentContractRevenueSales rsq = new WxRentContractRevenueSales();
|
|
|
|
rsq.updateTenantInfo(rentcontract);
|
|
|
|
rsq.setRentContractId(rentcontract.getId());
|
|
|
|
//BigDecimal sum = wxRentContractRevenueSalesMapper.findSumSalesMoney(rsq);
|
|
|
|
List<Long> billIdList = wxRentContractRevenueSalesMapper.findBillId(rsq);
|
|
|
|
Date realStartTime = null;
|
|
|
|
Date realEndTime = null;
|
|
|
|
|
|
|
|
if (null != billIdList && billIdList.size() > 0 ) {
|
|
|
|
WxAllBill abq = new WxAllBill();
|
|
|
|
abq.updateTenantInfo(rentcontract);
|
|
|
|
abq.setIds(billIdList);
|
|
|
|
abq.setStarttime(rentcontract.getYearsBegin());
|
|
|
|
abq.setEndtime(rentcontract.getYearsEnd());
|
|
|
|
abq.setSortColumn(" starttime asc");
|
|
|
|
List<WxAllBill> billList = wxAllBillMapper.findList(abq);
|
|
|
|
if (null == billList || billList.size() <= 0 ){
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
realStartTime = billList.get(0).getStarttime();
|
|
|
|
realEndTime = billList.get(billList.size()-1).getEndtime();
|
|
|
|
}
|
|
|
|
BigDecimal sum = wxRentContractRevenueSalesMapper.findSumSalesMoney(rsq);
|
|
|
|
if (null == sum || sum.compareTo(new BigDecimal(0)) <= 0 ) {
|
|
|
|
WxRentContractYearsSumVo vo = new WxRentContractYearsSumVo();
|
|
|
|
@@ -2662,20 +2636,29 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
vo.setBillReceivePay("0");
|
|
|
|
return vo;
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除未支付,未冲抵,未退款的之前的账单
|
|
|
|
WxAllBill billd = new WxAllBill();
|
|
|
|
billd.updateTenantInfo(rentcontract);
|
|
|
|
billd.setRentContractId(rentcontract.getId());
|
|
|
|
//删除这个时间的,因为可能之前有了账单。,然后撤铺,结束时间虽然不一样,开始时间是一致的。
|
|
|
|
billd.setStarttimeEqual(rentcontract.getYearsBegin());
|
|
|
|
billd.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_TIAODIAN_HUISUAN.getCode());
|
|
|
|
wxAllBillMapper.deleteByRentHuiSuan(billd);
|
|
|
|
|
|
|
|
//计算跳点。
|
|
|
|
BigDecimal[] jumppays = calcuteReveneuJump(sum, rentcontract,rentcontract.getYearsBegin(), rentcontract.getYearsEnd(),null);
|
|
|
|
BigDecimal jumpRevenuePay = jumppays[0];
|
|
|
|
//BigDecimal jumpRentPay = jumppays[1];
|
|
|
|
|
|
|
|
//销售收入不满足一年怎么算。
|
|
|
|
if (realStartTime.equals(rentcontract.getYearsBegin()) && realEndTime.equals(rentcontract.getYearsEnd())) {
|
|
|
|
int yearDays = DateUtils.daysBetween(rentcontract.getYearsBegin(), rentcontract.getYearsEnd())+1;
|
|
|
|
if (yearDays == 365) {
|
|
|
|
}else {
|
|
|
|
int days = DateUtils.daysBetween(realStartTime, realEndTime)+1;
|
|
|
|
if (rentcontract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) {
|
|
|
|
jumpRevenuePay = jumpRevenuePay.multiply(new BigDecimal(days)).divide(new BigDecimal(12*rentcontract.getMonthAverageDays()),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
|
|
|
|
jumpRevenuePay = jumpRevenuePay.multiply(new BigDecimal(yearDays)).divide(new BigDecimal(12*rentcontract.getMonthAverageDays()),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
|
|
|
|
}else {
|
|
|
|
|
|
|
|
jumpRevenuePay = jumpRevenuePay.multiply(new BigDecimal(days)).divide(new BigDecimal(365),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
|
|
|
|
jumpRevenuePay = jumpRevenuePay.multiply(new BigDecimal(yearDays)).divide(new BigDecimal(365),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2687,8 +2670,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
rentBillq.setBillType(EnumBillAllType.RENT.getCode());
|
|
|
|
rentBillq.setEnergyFeesId(EnumBillAllType.RENT.getEnergyFeesId());
|
|
|
|
rentBillq.setIsPreview(EnumYesOrNo.NO.getCode());
|
|
|
|
rentBillq.setStarttimeEqual(rentcontract.getYearsBegin());
|
|
|
|
rentBillq.setEndtimeEqual(rentcontract.getYearsEnd());
|
|
|
|
rentBillq.setStarttime(rentcontract.getYearsBegin());
|
|
|
|
rentBillq.setEndtime(rentcontract.getYearsEnd());
|
|
|
|
List<Integer> status = new ArrayList<Integer>();
|
|
|
|
status.add(EnumBillStatus.WAIT_PAY.getCode());
|
|
|
|
status.add(EnumBillStatus.PAID.getCode());
|
|
|
|
status.add(EnumBillStatus.BAD.getCode());
|
|
|
|
status.add(EnumBillStatus.STOP_TO_SETTLE.getCode());
|
|
|
|
rentBillq.setStatusList(status);
|
|
|
|
WxBillSum rentBillSum = wxAllBillMapper.getBillMonthSum(rentBillq);
|
|
|
|
if (null != rentBillSum) {
|
|
|
|
receivepay = receivepay.add(rentBillSum.getNeedPayNumber());
|
|
|
|
@@ -2738,12 +2727,13 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
createBillq.setPay("0");
|
|
|
|
createBillq.setBillType(EnumBillAllType.RENT.getCode());
|
|
|
|
createBillq.setStarttime(rentcontract.getYearsBegin());
|
|
|
|
createBillq.setEndtime(rentcontract.getYearsEnd());
|
|
|
|
createBillq.setEndtime(DateUtils.getDayEnd(rentcontract.getYearsBegin()));
|
|
|
|
createBillq.setStatus(EnumBillStatus.WAIT_PAY.getCode());
|
|
|
|
createBillq.setEnergyFeesId(EnumBillAllType.RENT.getEnergyFeesId());
|
|
|
|
createBillq.setBillRemark("扣点年度汇算自动生成");
|
|
|
|
createBillq.setIsPreview(EnumYesOrNo.NO.getCode());
|
|
|
|
createBillq.setRentContractId(rentcontract.getId());
|
|
|
|
createBillq.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_TIAODIAN_HUISUAN.getCode());
|
|
|
|
wxAllBillMapper.insert(createBillq);
|
|
|
|
}
|
|
|
|
|
|
|
|
|