|
|
|
@@ -33,6 +33,7 @@ import com.iformall.domain.vo.RentContractFreePeriodVo; |
|
|
|
import com.iformall.domain.vo.WxBillSum;
|
|
|
|
import com.iformall.domain.vo.WxRentContractRevenueSetSalesVo;
|
|
|
|
import com.iformall.domain.vo.WxRentContractYearsSumVo;
|
|
|
|
import com.iformall.domain.vo.WxRentContractYearsVo;
|
|
|
|
import com.iformall.enums.EnumBillAllType;
|
|
|
|
import com.iformall.enums.EnumBillExtraCreateFrom;
|
|
|
|
import com.iformall.enums.EnumBillStatus;
|
|
|
|
@@ -55,6 +56,7 @@ import com.iformall.enums.EnumRentContractStatus; |
|
|
|
import com.iformall.enums.EnumRentContractType;
|
|
|
|
import com.iformall.enums.EnumRentDayPriceCalcute;
|
|
|
|
import com.iformall.enums.EnumRentShopType;
|
|
|
|
import com.iformall.enums.EnumRentStartType;
|
|
|
|
import com.iformall.enums.EnumTradeDailyDateType;
|
|
|
|
import com.iformall.enums.EnumYesOrNo;
|
|
|
|
import com.iformall.exception.MallinkException;
|
|
|
|
@@ -2298,9 +2300,20 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
|
|
|
|
@Override
|
|
|
|
public void saveFreePeriods(WxRentContract wxRentContract) {
|
|
|
|
WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId());
|
|
|
|
List<WxRentContractYearsVo> yearsVo = getRentContractYears(rentContract);
|
|
|
|
if (null == yearsVo) {
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"无缴费年限");
|
|
|
|
}
|
|
|
|
Map<Integer,WxRentContractYearsVo> yearsMap = new HashMap<Integer,WxRentContractYearsVo>();
|
|
|
|
for (int i = 0 ; i < yearsVo.size() ; i++) {
|
|
|
|
WxRentContractYearsVo vo = yearsVo.get(i);
|
|
|
|
yearsMap.put(vo.getYearIndex(), vo);
|
|
|
|
}
|
|
|
|
|
|
|
|
WxRentContractFreePeriod del = new WxRentContractFreePeriod();
|
|
|
|
del.updateTenantInfo(wxRentContract);
|
|
|
|
del.setRentContractId(wxRentContract.getId());; |
|
|
|
del.setRentContractId(wxRentContract.getId()); |
|
|
|
wxRentContractFreePeriodMapper.deleteByContract(del);
|
|
|
|
List<RentContractFreePeriodVo> volist = wxRentContract.getFreePeriods();
|
|
|
|
if (null != volist && volist.size() > 0 ) {
|
|
|
|
@@ -2310,20 +2323,79 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
if (null != vo.getPeriods()) {
|
|
|
|
for (int j = 0 ; j < vo.getPeriods().size(); j++ ){
|
|
|
|
WxRentContractFreePeriod fp = vo.getPeriods().get(j);
|
|
|
|
final IdWorker idWorker = IdWorker.get();
|
|
|
|
fp.setId(idWorker.nextId());
|
|
|
|
fp.updateTenantInfo(wxRentContract);
|
|
|
|
fp.setYearIndex(vo.getYearIndex());
|
|
|
|
fp.setCreateTime(new Date());
|
|
|
|
fp.setUpdateTime(new Date());
|
|
|
|
fp.setRentContractId(wxRentContract.getId());
|
|
|
|
fpList.add(fp);
|
|
|
|
WxRentContractYearsVo yearVo = yearsMap.get(vo.getYearIndex());
|
|
|
|
if ((fp.getStartDate().after(yearVo.getStart()) || fp.getStartDate().equals(yearVo.getStart()) ) &&
|
|
|
|
(fp.getEndDate().before(yearVo.getEnd()) || fp.getEndDate().equals(yearVo.getEnd()))) {
|
|
|
|
final IdWorker idWorker = IdWorker.get();
|
|
|
|
fp.setId(idWorker.nextId());
|
|
|
|
fp.updateTenantInfo(wxRentContract);
|
|
|
|
fp.setYearIndex(vo.getYearIndex());
|
|
|
|
fp.setCreateTime(new Date());
|
|
|
|
fp.setUpdateTime(new Date());
|
|
|
|
fp.setRentContractId(rentContract.getId());
|
|
|
|
fpList.add(fp);
|
|
|
|
}else {
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"第"+vo.getYearIndex()+"年度有时间选择有误,不能超过该年度时间范围");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wxRentContractFreePeriodMapper.inertPeriods(wxRentContract.getTenantId(), fpList);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<WxRentContractYearsVo> getRentContractYears(WxRentContract rentContract) {
|
|
|
|
String adjustRatio = rentContract.getAdjustRatio();
|
|
|
|
List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class);
|
|
|
|
integers.add(0, 0);
|
|
|
|
int years = integers.size();
|
|
|
|
//合同以什么日期来计算开始计租日期
|
|
|
|
if(rentContract.getRentStartType()!=null &&rentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){
|
|
|
|
rentContract.setRentalStartDate(rentContract.getStartDate());
|
|
|
|
}
|
|
|
|
//如果有撤铺日
|
|
|
|
Date endcontract = rentContract.getEndContractTime();
|
|
|
|
if (null != endcontract) {
|
|
|
|
endcontract = DateUtils.getDayEnd(endcontract);
|
|
|
|
}
|
|
|
|
List<Date> yearList = this.getYearList(years, 12, rentContract.getRentalStartDate(),endcontract);
|
|
|
|
List<WxRentContractYearsVo> retList = new ArrayList<WxRentContractYearsVo>();
|
|
|
|
if (null != yearList && yearList.size() > 0) {
|
|
|
|
if (yearList.size() == 1) {
|
|
|
|
WxRentContractYearsVo vo = new WxRentContractYearsVo();
|
|
|
|
vo.setStart(yearList.get(0));
|
|
|
|
vo.setEnd(rentContract.getRentalEndDate());
|
|
|
|
vo.setRemark("第1年度");
|
|
|
|
vo.setYearIndex(1);
|
|
|
|
retList.add(vo);
|
|
|
|
}else {
|
|
|
|
Date begin = null;
|
|
|
|
for (int i = 0 ; i < yearList.size()-1 ; i ++) {
|
|
|
|
int yearindex = i+1;
|
|
|
|
begin = yearList.get(i);
|
|
|
|
Date end = yearList.get(i+1);
|
|
|
|
Date realEnd = DateUtils.getDaySet(end, Calendar.SECOND, -1);
|
|
|
|
WxRentContractYearsVo vo = new WxRentContractYearsVo();
|
|
|
|
vo.setStart(begin);
|
|
|
|
vo.setEnd(realEnd);
|
|
|
|
vo.setRemark("第"+yearindex+"年度");
|
|
|
|
vo.setYearIndex(yearindex);
|
|
|
|
retList.add(vo);
|
|
|
|
begin = end;
|
|
|
|
}
|
|
|
|
WxRentContractYearsVo vo = new WxRentContractYearsVo();
|
|
|
|
vo.setStart(yearList.get(yearList.size()-1));
|
|
|
|
vo.setEnd(rentContract.getRentalEndDate());
|
|
|
|
vo.setRemark("第"+yearList.size()+"年度");
|
|
|
|
vo.setYearIndex(yearList.size());
|
|
|
|
retList.add(vo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (retList.size() > 0 ) {
|
|
|
|
return retList;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|