| | |
| | | import com.java110.core.factory.CommunitySettingFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.core.smo.IComputeFeeSMO; |
| | | import com.java110.dto.fee.FeeAttrDto; |
| | | import com.java110.dto.fee.FeeConfigDto; |
| | | import com.java110.dto.FloorDto; |
| | | import com.java110.dto.RoomDto; |
| | | import com.java110.dto.UnitDto; |
| | | import com.java110.dto.fee.FeeDto; |
| | | import com.java110.dto.owner.OwnerCarDto; |
| | | import com.java110.dto.owner.OwnerRoomRelDto; |
| | | import com.java110.dto.parking.ParkingSpaceDto; |
| | | import com.java110.intf.community.IFloorInnerServiceSMO; |
| | | import com.java110.intf.community.IParkingSpaceInnerServiceSMO; |
| | | import com.java110.intf.community.IRoomInnerServiceSMO; |
| | | import com.java110.intf.community.IUnitInnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeAttrInnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeConfigInnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeInnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerCarInnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerRoomRelV1InnerServiceSMO; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.util.Assert; |
| | |
| | | |
| | | @Java110Cmd(serviceCode = "fee.listFee") |
| | | public class ListFeeCmd extends Cmd { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(ListFeeCmd.class); |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private IComputeFeeSMO computeFeeSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFloorInnerServiceSMO floorInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IUnitInnerServiceSMO unitInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IRoomInnerServiceSMO roomInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOwnerRoomRelV1InnerServiceSMO ownerRoomRelV1InnerServiceSMOImpl; |
| | | |
| | | //域 |
| | | public static final String DOMAIN_COMMON = "DOMAIN.COMMON"; |
| | |
| | | |
| | | @Override |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | if (reqJson.containsKey("roomNum") && !StringUtil.isEmpty(reqJson.getString("roomNum"))) { |
| | | String[] roomNums = reqJson.getString("roomNum").split("-", 3); |
| | | if (roomNums == null || roomNums.length != 3) { |
| | | throw new IllegalArgumentException("房屋编号格式错误!"); |
| | | } |
| | | String floorNum = roomNums[0]; |
| | | String unitNum = roomNums[1]; |
| | | String roomNum = roomNums[2]; |
| | | FloorDto floorDto = new FloorDto(); |
| | | floorDto.setFloorNum(floorNum); |
| | | floorDto.setCommunityId(reqJson.getString("communityId")); |
| | | List<FloorDto> floorDtos = floorInnerServiceSMOImpl.queryFloors(floorDto); |
| | | if (floorDtos != null && floorDtos.size() > 0) { |
| | | for (FloorDto floor : floorDtos) { |
| | | UnitDto unitDto = new UnitDto(); |
| | | unitDto.setFloorId(floor.getFloorId()); |
| | | unitDto.setUnitNum(unitNum); |
| | | List<UnitDto> unitDtos = unitInnerServiceSMOImpl.queryUnits(unitDto); |
| | | if (unitDtos != null && unitDtos.size() > 0) { |
| | | for (UnitDto unit : unitDtos) { |
| | | RoomDto roomDto = new RoomDto(); |
| | | roomDto.setUnitId(unit.getUnitId()); |
| | | roomDto.setRoomNum(roomNum); |
| | | roomDto.setCommunityId(reqJson.getString("communityId")); |
| | | List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto); |
| | | Assert.listOnlyOne(roomDtos, "查询房屋错误!"); |
| | | reqJson.put("payerObjId", roomDtos.get(0).getRoomId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | FeeDto feeDto = BeanConvertUtil.covertBean(reqJson, FeeDto.class); |
| | | |
| | | int count = feeInnerServiceSMOImpl.queryFeesCount(feeDto); |
| | | |
| | | List<ApiFeeDataVo> fees = new ArrayList<>(); |
| | | |
| | | if (reqJson.containsKey("ownerId") && !StringUtil.isEmpty(reqJson.getString("ownerId"))) { |
| | | OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto(); |
| | | ownerRoomRelDto.setRoomId(reqJson.getString("payerObjId")); |
| | | ownerRoomRelDto.setOwnerId(reqJson.getString("ownerId")); |
| | | List<OwnerRoomRelDto> ownerRoomRelDtos = ownerRoomRelV1InnerServiceSMOImpl.queryOwnerRoomRels(ownerRoomRelDto); |
| | | if (ownerRoomRelDtos == null || ownerRoomRelDtos.size() < 1) { |
| | | ApiFeeVo apiFeeVo = new ApiFeeVo(); |
| | | apiFeeVo.setTotal(0); |
| | | apiFeeVo.setRecords((int) Math.ceil((double) 0 / (double) reqJson.getInteger("row"))); |
| | | apiFeeVo.setFees(fees); |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiFeeVo), HttpStatus.OK); |
| | | cmdDataFlowContext.setResponseEntity(responseEntity); |
| | | } |
| | | } |
| | | int count = feeInnerServiceSMOImpl.queryFeesCount(feeDto); |
| | | if (count > 0) { |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);//查询费用项目 |
| | | computeFeePrice(feeDtos);//计算费用 |
| | |
| | | feeDto.setAmountOwed(df.format(curFeePrice)); |
| | | feeDto.setDeadlineTime(DateUtil.getCurrentDate()); |
| | | } |
| | | |
| | | //考虑租金递增 |
| | | computeFeeSMOImpl.dealRentRate(feeDto); |
| | | } |
| | | |
| | | /** |
| | |
| | | //动态费用 |
| | | if ("4004".equals(computingFormula) |
| | | && FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag()) |
| | | && !FeeDto.STATE_FINISH.equals(feeDto.getState())) { |
| | | feeDto.setAmountOwed(df.format(curFeePrice) + ""); |
| | | && !FeeDto.STATE_FINISH.equals(feeDto.getState()) |
| | | && feeDto.getDeadlineTime() == null) { |
| | | feeDto.setDeadlineTime(DateUtil.getCurrentDate()); |
| | | } |
| | | |
| | | //考虑租金递增 |
| | | dealRentRate(feeDto, oweMonth); |
| | | computeFeeSMOImpl.dealRentRate(feeDto); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 租金处理 |
| | | * |
| | | * @param feeDto |
| | | * @param oweMonth |
| | | */ |
| | | private void dealRentRate(FeeDto feeDto, double oweMonth) { |
| | | if (!FeeConfigDto.COMPUTING_FORMULA_RANT_RATE.equals(feeDto.getComputingFormula())) { |
| | | return; |
| | | } |
| | | |
| | | if (!FeeDto.STATE_DOING.equals(feeDto.getState())) { |
| | | return; |
| | | } |
| | | |
| | | //查询递增信息 |
| | | FeeAttrDto feeAttrDto = new FeeAttrDto(); |
| | | feeAttrDto.setFeeId(feeDto.getFeeId()); |
| | | feeAttrDto.setCommunityId(feeDto.getCommunityId()); |
| | | List<FeeAttrDto> feeAttrDtos = feeAttrInnerServiceSMOImpl.queryFeeAttrs(feeAttrDto); |
| | | |
| | | if (feeAttrDtos == null || feeAttrDtos.size() < 1) { |
| | | return; |
| | | } |
| | | int rateCycle = 0; |
| | | double rate = 0.0; |
| | | Date rateStartTime = null; |
| | | try { |
| | | for (FeeAttrDto tmpFeeAttrDto : feeAttrDtos) { |
| | | if (FeeAttrDto.SPEC_CD_RATE.equals(tmpFeeAttrDto.getSpecCd())) { |
| | | feeDto.setRate(tmpFeeAttrDto.getValue()); |
| | | rate = Double.parseDouble(tmpFeeAttrDto.getValue()); |
| | | } |
| | | if (FeeAttrDto.SPEC_CD_RATE_CYCLE.equals(tmpFeeAttrDto.getSpecCd())) { |
| | | feeDto.setRateCycle(tmpFeeAttrDto.getValue()); |
| | | rateCycle = Integer.parseInt(tmpFeeAttrDto.getValue()); |
| | | } |
| | | if (FeeAttrDto.SPEC_CD_RATE_START_TIME.equals(tmpFeeAttrDto.getSpecCd())) { |
| | | rateStartTime = DateUtil.getDateFromString(tmpFeeAttrDto.getValue(), DateUtil.DATE_FORMATE_STRING_B); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error("租金递增异常", e); |
| | | return; |
| | | } |
| | | |
| | | if (rateCycle == 0 || rate == 0) { |
| | | return; |
| | | } |
| | | |
| | | if (feeDto.getDeadlineTime().getTime() <= rateStartTime.getTime()) { |
| | | return; |
| | | } |
| | | |
| | | BigDecimal oweAmountDec = new BigDecimal(0); |
| | | //计算 计费起始时间 到 rateStartTime 时的费用 |
| | | double curOweMonth = 0; |
| | | BigDecimal curFeePrice = new BigDecimal(feeDto.getFeePrice()); |
| | | if(feeDto.getEndTime().getTime() < rateStartTime.getTime()){ |
| | | curOweMonth = computeFeeSMOImpl.dayCompare(feeDto.getEndTime(),rateStartTime); |
| | | oweAmountDec = curFeePrice.multiply(new BigDecimal(curOweMonth)); |
| | | } |
| | | |
| | | curOweMonth = computeFeeSMOImpl.dayCompare(rateStartTime,feeDto.getDeadlineTime()); |
| | | |
| | | double maxCycle = Math.floor(curOweMonth/rateCycle); |
| | | |
| | | //基准 |
| | | BigDecimal firstAmount = curFeePrice.multiply(new BigDecimal(rateCycle)); |
| | | BigDecimal preCycleAmount = firstAmount; |
| | | BigDecimal rateDec = null; |
| | | BigDecimal lastRateAmountDec = null; |
| | | double curCycle = 0; |
| | | for(int cycleIndex = 0; cycleIndex < maxCycle; maxCycle ++){ |
| | | rateDec = preCycleAmount.multiply(new BigDecimal(rate)); |
| | | //增长周期的倍数 |
| | | curCycle = (cycleIndex +1) * rateCycle; |
| | | if(curCycle > curOweMonth){ |
| | | rateDec = new BigDecimal(curOweMonth/rateCycle -Math.ceil(curOweMonth/rateCycle)).multiply(rateDec); |
| | | lastRateAmountDec = new BigDecimal(curOweMonth/rateCycle -Math.ceil(curOweMonth/rateCycle)).multiply(rateDec); |
| | | firstAmount = firstAmount.add(rateDec).add(preCycleAmount); |
| | | continue; |
| | | } |
| | | firstAmount = firstAmount.add(rateDec).add(preCycleAmount); |
| | | preCycleAmount = preCycleAmount.add(rateDec); |
| | | } |
| | | // 1.0 还没有到 递增开始时间 |
| | | //2.0 5.3 个月 24个月 一个递增周期 |
| | | // 200 * 5.3 + 0.03 * (24 * 200) * (5.3/24) |
| | | |
| | | // 200* 24 |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 根据合同来算单价 |
| | |
| | | feeDto.setAmountOwed(df.format(curFeePrice) + ""); |
| | | feeDto.setDeadlineTime(DateUtil.getCurrentDate()); |
| | | } |
| | | //考虑租金递增 |
| | | computeFeeSMOImpl.dealRentRate(feeDto); |
| | | } |
| | | } |