| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public Integer create(YwContract model) { |
| | | isParamValidCreated(model); |
| | | |
| | | |
| | | model.setCreator(model.getLoginUserInfo().getId()); |
| | | model.setIsdeleted(Constants.ZERO); |
| | | model.setCreateDate(new Date()); |
| | | model.setStatus(Constants.ZERO); |
| | | model.setEditDate(model.getCreateDate()); |
| | | model.setEditor(model.getCreator()); |
| | | if(model.getStartDate().getTime() > System.currentTimeMillis()){ |
| | | model.setStatus(Constants.ZERO); |
| | | }else if(model.getStartDate().getTime() <= System.currentTimeMillis() && model.getEndDate().getTime() > System.currentTimeMillis()){ |
| | | model.setStatus(Constants.ONE); |
| | | }else{ |
| | | model.setStatus(Constants.TWO); |
| | | } |
| | | model.setStatus(Constants.ZERO);//待执行 |
| | | model.setRemark(getRemarlByParam(model)); |
| | | ywContractMapper.insert(model); |
| | |
| | | } |
| | | model.setTotalArea(new BigDecimal(0)); |
| | | for(YwRoom r : rooms){ |
| | | model.setTotalArea(model.getTotalArea().add(Constants.formatBigdecimal(r.getArea()))); |
| | | model.setTotalArea(model.getTotalArea().add(Constants.formatBigdecimal(r.getRentArea()))); |
| | | } |
| | | model.setRoomList(rooms); |
| | | } |
| | |
| | | update.setBtFee(param.getBtFee()); |
| | | update.setBtRemark(getbackRentRemarkByParam(param)); |
| | | ywContractMapper.updateById(update); |
| | | // if(1==1){ |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED); |
| | | // } |
| | | dealLogBiz(param,Constants.YwLogType.CONTRACT_BACK, param.getLoginUserInfo().getRealname(),getbackRentLogByParam(param)); |
| | | return param.getId(); |
| | | } |
| | |
| | | closeBills.add(bill); |
| | | noBills.add(bill); |
| | | } |
| | | // if(bill.getStartDate().getTime()>param.getEditDate().getTime()){ |
| | | // //如果还没开始,账单直接关闭 |
| | | // closeBills.add(bill); |
| | | // noBills.add(bill); |
| | | // }else{ |
| | | // canBills.add(bill); |
| | | // } |
| | | }else if(Constants.equalsInteger(bill.getPayStatus(),Constants.ONE) ){ |
| | | if(bill.getStartDate().getTime()>param.getBtDate().getTime()){ |
| | | // if(bill.getEndDate().getTime()<param.getEditDate().getTime()){ |
| | | //如果已结清,账单直接关闭 |
| | | noBills.add(bill); |
| | | }else{ |
| | |
| | | addBill.setContractId(param.getId()); |
| | | addBill.setType(Constants.ONE); |
| | | addBill.setStatus(Constants.ZERO); |
| | | addBill.setTotleFee(addBill.getReceivableFee()); |
| | | if(Constants.equalsInteger(addBill.getFeeType(),Constants.ONE)){ |
| | | addBill.setStartDate(addBill.getPlanPayDate()); |
| | | addBill.setEndDate(addBill.getPlanPayDate()); |
| | |
| | | } |
| | | int num =1; |
| | | for(int i=0;i<billList1.size();i++){ |
| | | if(Constants.equalsInteger(billList1.get(i).getCostType(),Constants.ZERO)){ |
| | | billList1.get(i).setSortnum(num); |
| | | num++; |
| | | } |
| | | } |
| | | for(int i=0;i<billList2.size();i++){ |
| | | if(Constants.equalsInteger(billList1.get(i).getCostType(),Constants.ONE)) { |
| | | billList2.get(i).setSortnum(num); |
| | | num++; |
| | | } |
| | | } |
| | | if(model.getId()!=null){ |
| | | ywContractBillMapper.insert(billList1); |
| | |
| | | BigDecimal totalFee = new BigDecimal(0); |
| | | DateCompare dateCompare = DateCompare.dayCompare(bill.getStartDate(),bill.getEndDate(),freeStart, freeEnd); |
| | | if(Constants.equalsInteger(d.getCircleType(),Constants.ZERO)){ |
| | | //0=元每平米天 |
| | | //0=元每平米天 账单金额=账单周期的天数*租赁面积*单价; |
| | | int days = dateCompare.getDay() ; |
| | | BigDecimal areas = getAreasNumBYRooms(model.getRoomList()); |
| | | totalFee = new BigDecimal(days).multiply(areas).multiply(Constants.formatBigdecimal(d.getPrice()));//总价格 |
| | | }else if(Constants.equalsInteger(d.getCircleType(),Constants.ONE)){ |
| | | //1=元每平米月 |
| | | //1=元每平米月 账单金额=账单周期的月数(开始日期计算自然月)*租赁面积*单价+不满一个月的天数*租赁面积*单价*12/365; |
| | | BigDecimal areas = getAreasNumBYRooms(model.getRoomList()); |
| | | BigDecimal month =dateCompare.getMonthFloat(); |
| | | totalFee = month.multiply(areas).multiply(Constants.formatBigdecimal(d.getPrice()));//总价格 |
| | | }else if(Constants.equalsInteger(d.getCircleType(),Constants.TWO)){ |
| | | //2=元每平米年 |
| | | //2=元每平米年 账单金额=账单周期的月数(开始日期计算自然月)*单价*面积/12+不满一个月的天数*租赁面积*单价/365; |
| | | BigDecimal areas = getAreasNumBYRooms(model.getRoomList()); |
| | | BigDecimal year = dateCompare.getYearFloat(); |
| | | totalFee = year.multiply(areas).multiply(Constants.formatBigdecimal(d.getPrice()));//总价格 |
| | | BigDecimal month = new BigDecimal(dateCompare.getMonth()); |
| | | totalFee = ((month.multiply(Constants.formatBigdecimal(d.getPrice())).divide(new BigDecimal(12),2, RoundingMode.HALF_UP)) |
| | | .add(new BigDecimal(dateCompare.getMonthDays()).multiply(Constants.formatBigdecimal(d.getPrice())).divide(new BigDecimal(365),2, RoundingMode.HALF_UP))) |
| | | .multiply(areas);//总价格 |
| | | }else if(Constants.equalsInteger(d.getCircleType(),Constants.THREE)){ |
| | | //3=元每天 |
| | | //3=元每天 账单金额=账单周期的天数*单价; |
| | | int days = dateCompare.getDay() ; |
| | | totalFee = new BigDecimal(days).multiply(Constants.formatBigdecimal(d.getPrice()));//总价格 |
| | | }else if(Constants.equalsInteger(d.getCircleType(),Constants.FOUR)){ |
| | | //4=元每月 |
| | | //4=元每月 账单金额=账单周期的月数(开始日期计算自然月)*单价+不满一个月的天数*单价*12/365 |
| | | BigDecimal month = dateCompare.getMonthFloat(); |
| | | totalFee = month.multiply(Constants.formatBigdecimal(d.getPrice()));//总价格 |
| | | }else if(Constants.equalsInteger(d.getCircleType(),Constants.FIVE)){ |
| | | //5=元每年 |
| | | BigDecimal year = dateCompare.getYearFloat(); |
| | | totalFee = year.multiply(Constants.formatBigdecimal(d.getPrice()));//总价格 |
| | | //5=元每年 账单金额=账单周期的月数(开始日期计算自然月)*单价*面积/12+不满一个月的天数*租赁面积*单价/365; |
| | | BigDecimal month = new BigDecimal(dateCompare.getMonth()); |
| | | totalFee =( month.multiply(Constants.formatBigdecimal(d.getPrice())).divide(new BigDecimal(12),2, RoundingMode.HALF_UP)) |
| | | .add(new BigDecimal(dateCompare.getMonthDays()).multiply(Constants.formatBigdecimal(d.getPrice())).divide(new BigDecimal(365),2, RoundingMode.HALF_UP));//总价格 |
| | | }else if(Constants.equalsInteger(d.getCircleType(),Constants.SIX)){ |
| | | //6=元每场 |
| | | //6=元每场 账单金额=单价;只有选择一次性付款时,才能选择该单价维度; |
| | | totalFee =Constants.formatBigdecimal(d.getPrice()); |
| | | } |
| | | if(Constants.equalsInteger(model.getRoundedUp(),Constants.ONE)){ |
| | |
| | | BigDecimal data= new BigDecimal(0); |
| | | if(roomList!=null){ |
| | | for(YwRoom r :roomList){ |
| | | data = data.add(Constants.formatBigdecimal(r.getArea())); |
| | | data = data.add(Constants.formatBigdecimal(r.getRentArea())); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | model.setTotalArea(new BigDecimal(0)); |
| | | for(YwRoom r : rooms){ |
| | | model.setTotalArea(model.getTotalArea().add(Constants.formatBigdecimal(r.getArea()))); |
| | | model.setTotalArea(model.getTotalArea().add(Constants.formatBigdecimal(r.getRentArea()))); |
| | | } |
| | | model.setRoomList(rooms); |
| | | YwCustomer customer = customerMapper.selectById(model.getRenterId()); |