| | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.dto.PropertyWhiteListFlowDto; |
| | | import com.java110.dto.fee.ComputeDiscountDto; |
| | | import com.java110.dto.fee.FeeAttrDto; |
| | | import com.java110.dto.fee.FeeConfigDto; |
| | | import com.java110.dto.fee.FeeDto; |
| | | import com.java110.dto.fee.*; |
| | | import com.java110.dto.importData.ImportRoomFee; |
| | | import com.java110.dto.log.AssetImportLogDetailDto; |
| | | import com.java110.dto.owner.OwnerRoomRelDto; |
| | | import com.java110.dto.payFee.PayFeeDetailDiscountDto; |
| | | import com.java110.dto.room.RoomDto; |
| | | import com.java110.dto.system.ComponentValidateResult; |
| | | import com.java110.fee.api.FeeDiscountApi; |
| | |
| | | import com.java110.po.fee.FeeAttrPo; |
| | | import com.java110.po.fee.PayFeeDetailPo; |
| | | import com.java110.po.fee.PayFeePo; |
| | | import com.java110.po.payFee.PayFeeDetailDiscountPo; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.exception.DAOException; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | |
| | | @Autowired |
| | | private ImportCarHistoryFeeDetailQueueDataAdapt importCarHistoryFeeDetailQueueDataAdapt; |
| | | |
| | | @Autowired |
| | | private IPayFeeDetailDiscountNewV1InnerServiceSMO payFeeDetailDiscountNewV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ImportRoomFeeQueueDataAdapt importRoomFeeQueueDataAdapt; |
| | | |
| | | @Override |
| | | public void importData(List<AssetImportLogDetailDto> assetImportLogDetailDtos) { |
| | | importDatas(assetImportLogDetailDtos); |
| | | |
| | | for (AssetImportLogDetailDto assetImportLogDetailDto : assetImportLogDetailDtos) { |
| | | try { |
| | | importDatas(assetImportLogDetailDto); |
| | | updateImportLogDetailState(assetImportLogDetailDto.getDetailId()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | updateImportLogDetailState(assetImportLogDetailDto.getDetailId(), e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void importDatas(List<AssetImportLogDetailDto> infos) { |
| | | private void importDatas(AssetImportLogDetailDto assetImportLogDetailDto) { |
| | | |
| | | List<ImportRoomFee> importRoomFees = new ArrayList<>(); |
| | | List<ImportRoomFee> importCarFees = new ArrayList<>(); |
| | | for (AssetImportLogDetailDto assetImportLogDetailDto : infos) { |
| | | List<ImportRoomFee> importContractFees = new ArrayList<>(); |
| | | List<CarInoutPo> carInoutPos = new ArrayList<>(); |
| | | String communityId = assetImportLogDetailDto.getCommunityId(); |
| | | JSONObject data = JSONObject.parseObject(assetImportLogDetailDto.getContent()); |
| | | ImportRoomFee importRoomFee = BeanConvertUtil.covertBean(data, ImportRoomFee.class); |
| | | RoomDto roomDto = new RoomDto(); |
| | | roomDto.setDoorRoomNum(importRoomFee.getDoorRoomNum()); |
| | | roomDto.setCommunityId(communityId); |
| | | // List<String> roomTypes = Arrays.asList("住宅物业费","商铺物业费","维修收入","维修基金收入","电费及管理费","代收水费","各类押金","租金收入"); |
| | | List<String> carTypes = Arrays.asList("临时停车费", "业主产权过道停车费", "小业主产权车辆管理费","地下停车费","地面停车费"); |
| | | List<String> contractTypes = Arrays.asList("垃圾清运费","其他收入","补贴费用","场地使用费","电梯广告(业委会)","快递柜","电梯广告(联讯)","房产中介","非机动车管理费","其他广告"); |
| | |
| | | carInout.setCreateTime(JSONObject.parseObject(assetImportLogDetailDto.getContent().toString()).getString("inputTime")); |
| | | carInout.setbId(JSONObject.parseObject(assetImportLogDetailDto.getContent().toString()).getString("batchId")); |
| | | |
| | | List<CarInoutPo> carInoutPos = new ArrayList<>(); |
| | | carInout.setInoutId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_inoutId)); |
| | | carInout.setDetailId(assetImportLogDetailDto.getDetailId()); |
| | | carInoutPos.add(carInout); |
| | | |
| | | // 如果有结束时间,创建新的对象作为出口记录 |
| | |
| | | exitCarInout.setState("100400"); |
| | | exitCarInout.setInoutId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_inoutId)); |
| | | exitCarInout.setPaymentAmount(JSONObject.parseObject(assetImportLogDetailDto.getContent().toString()).getString("chargeAmount")); |
| | | |
| | | exitCarInout.setDetailId(assetImportLogDetailDto.getDetailId()); |
| | | carInoutPos.add(exitCarInout); |
| | | } |
| | | |
| | | try { |
| | | carInoutInnerServiceSMOImpl.batchSaveCarInout2(carInoutPos); |
| | | }catch (Exception e){ |
| | | |
| | | updateImportLogDetailState(importRoomFee.getDetailId(),e); |
| | | throw new IllegalArgumentException(e.getMessage()); |
| | | } |
| | | updateImportLogDetailState(importRoomFee.getDetailId()); |
| | | } |
| | | else if(contractTypes.contains(importRoomFee.getSecondaryFeeTypeCd())){ |
| | | List<RoomDto> roomDtos = iRoomInnerServiceSMOImpl.queryRooms(roomDto); |
| | | try { |
| | | importRoomFee.setRoomId(roomDtos.get(0).getRoomId()); |
| | | }catch (Exception e){ |
| | | throw new IllegalArgumentException("门室号"+importRoomFee.getDoorRoomNum()+"未查询到房屋"); |
| | | } |
| | | importRoomFee.setFeeName(data.getString("secondaryFeeTypeCd")); |
| | | FeeDto feeDto = new FeeDto(); |
| | | feeDto.setFeeName(importRoomFee.getFeeName()); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | if(feeDtos.size() == 0){ |
| | | updateImportLogDetailState(importRoomFee.getDetailId(),new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在")); |
| | | |
| | | throw new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在"); |
| | | } |
| | | |
| | | importRoomFee.setCommunityId(communityId); |
| | | importRoomFee.setDetailId(assetImportLogDetailDto.getDetailId()); |
| | | importRoomFee.setStartTime(data.getString("chargeStart")); |
| | | importRoomFee.setEndTime(data.getString("chargeEnd").split(" ")[0]+" 23:59:59"); |
| | |
| | | // if(importRoomFee.getPayerObjName()) |
| | | importCarFees.add(importRoomFee); |
| | | } |
| | | else if(carTypes.contains(JSONObject.parseObject(infos.get(0).getContent()).get("category22"))){ |
| | | List<RoomDto> roomDtos = iRoomInnerServiceSMOImpl.queryRooms(roomDto); |
| | | try { |
| | | importRoomFee.setRoomId(roomDtos.get(0).getRoomId()); |
| | | }catch (Exception e){ |
| | | updateImportLogDetailState(importRoomFee.getDetailId(),new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在")); |
| | | throw new IllegalArgumentException("门室号"+importRoomFee.getDoorRoomNum()+"未查询到房屋"); |
| | | } |
| | | else if(carTypes.contains(JSONObject.parseObject(assetImportLogDetailDto.getContent()).get("category22"))){ |
| | | importRoomFee.setCommunityId(communityId); |
| | | importRoomFee.setFeeName(data.getString("secondaryFeeTypeCd")); |
| | | importRoomFee.setDetailId(assetImportLogDetailDto.getDetailId()); |
| | | importRoomFee.setStartTime(data.getString("chargeStart")); |
| | |
| | | importCarFees.add(importRoomFee); |
| | | } |
| | | else{ |
| | | List<RoomDto> roomDtos = iRoomInnerServiceSMOImpl.queryRooms(roomDto); |
| | | try { |
| | | importRoomFee.setRoomId(roomDtos.get(0).getRoomId()); |
| | | }catch (Exception e){ |
| | | updateImportLogDetailState(importRoomFee.getDetailId(),new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在")); |
| | | throw new IllegalArgumentException("门室号"+importRoomFee.getDoorRoomNum()+"未查询到房屋"); |
| | | } |
| | | importRoomFee.setCommunityId(communityId); |
| | | importRoomFee.setFeeName(data.getString("secondaryFeeTypeCd")); |
| | | importRoomFee.setDetailId(assetImportLogDetailDto.getDetailId()); |
| | | importRoomFee.setStartTime(data.getString("chargeStart")); |
| | |
| | | // if(importRoomFee.getPayerObjName()) |
| | | importRoomFees.add(importRoomFee); |
| | | } |
| | | } |
| | | importFeeDetailsByCarInout(carInoutPos); |
| | | |
| | | if (ListUtil.isNull(importRoomFees) && ListUtil.isNull(importCarFees)) { |
| | | return; |
| | |
| | | if(!(ListUtil.isNull(importCarFees))){ |
| | | importCarHistoryFeeDetailQueueDataAdapt.importCarFeeDetails(importCarFees.get(0).getStoreId(), importCarFees.get(0).getUserId(), importCarFees, importCarFees.get(0).getBatchId()); |
| | | } |
| | | // |
| | | // |
| | | |
| | | } |
| | | |
| | | private void importFeeDetailsByCarInout(List<CarInoutPo> carInoutPos) { |
| | | |
| | | for (CarInoutPo carInoutPo : carInoutPos) { |
| | | try { |
| | | ArrayList<CarInoutPo> carInoutPos1 = new ArrayList<>(); |
| | | carInoutPos1.add(carInoutPo); |
| | | carInoutInnerServiceSMOImpl.batchSaveCarInout2(carInoutPos1); |
| | | updateImportLogDetailState(carInoutPo.getDetailId()); |
| | | }catch (Exception e){ |
| | | updateImportLogDetailState(carInoutPo.getDetailId(),e); |
| | | throw new IllegalArgumentException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | updateImportLogDetailState(importRoomFee.getDetailId(), e); |
| | | throw new IllegalArgumentException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | private void importFeeDetail(ImportRoomFee importRoomFee, String storeId, String userId, String batchId) { |
| | | |
| | | FeeConfigDto feeConfigDto = new FeeConfigDto(); |
| | | feeConfigDto.setFeeNameEq(importRoomFee.getFeeName().trim()); |
| | | feeConfigDto.setCommunityId(importRoomFee.getCommunityId()); |
| | | List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto); |
| | | |
| | | if (ListUtil.isNull(feeConfigDtos)) { |
| | | throw new IllegalArgumentException("收费项不存在"); |
| | | RoomDto roomDto = new RoomDto(); |
| | | // roomDto.setDoorRoomNum(importRoomFee.getDoorRoomNum()); |
| | | roomDto.setCommunityId(importRoomFee.getCommunityId()); |
| | | if(importRoomFee.getDoorRoomNum()!=null){ |
| | | String[] split = importRoomFee.getDoorRoomNum().split("-"); |
| | | if(split.length==2){ |
| | | roomDto.setDoorRoomNum(importRoomFee.getDoorRoomNum()); |
| | | }else if(split.length > 2){ |
| | | roomDto.setFloorNum(split[0]); |
| | | roomDto.setUnitNum(split[1]); |
| | | roomDto.setRoomNum(split[2]); |
| | | } |
| | | } |
| | | List<RoomDto> roomDtos = iRoomInnerServiceSMOImpl.queryRooms(roomDto); |
| | | try { |
| | | importRoomFee.setRoomId(roomDtos.get(0).getRoomId()); |
| | | }catch (Exception e){ |
| | | throw new IllegalArgumentException("门室号"+importRoomFee.getDoorRoomNum()+"未查询到房屋"); |
| | | } |
| | | FeeDto feeDto2 = new FeeDto(); |
| | | feeDto2.setFeeName(importRoomFee.getFeeName()); |
| | | feeDto2.setPayerObjId(importRoomFee.getRoomId()); |
| | | feeDto2.setCommunityId(importRoomFee.getCommunityId()); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto2); |
| | | if(feeDtos.size() == 0){ |
| | | updateImportLogDetailState(importRoomFee.getDetailId(),new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在")); |
| | | |
| | | FeeConfigDto tmpFeeConfigDto = feeConfigDtos.get(0); |
| | | |
| | | FeeDto feeDto = new FeeDto(); |
| | | feeDto.setConfigId(tmpFeeConfigDto.getConfigId()); |
| | | feeDto.setCommunityId(importRoomFee.getCommunityId()); |
| | | feeDto.setPayerObjId(importRoomFee.getRoomId()); |
| | | feeDto.setPayerObjType(importRoomFee.getObjType() ==null?FeeDto.PAYER_OBJ_TYPE_ROOM:importRoomFee.getObjType()); |
| | | feeDto.setFeeTypeCd(feeConfigDtos.get(0).getFeeTypeCd()); |
| | | feeDto.setConfigId(tmpFeeConfigDto.getConfigId()); |
| | | // 解析日期字符串 |
| | | LocalDateTime startDate = LocalDateTime.parse(importRoomFee.getStartTime(), formatter); |
| | | LocalDateTime endDate = LocalDateTime.parse(importRoomFee.getEndTime(), formatter); |
| | | importRoomFee.setCycle(String.valueOf(ChronoUnit.MONTHS.between(startDate, endDate))); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | throw new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在"); |
| | | } |
| | | importRoomFee.setPayObjId(importRoomFee.getRoomId()); |
| | | if (ListUtil.isNull(feeDtos)) { |
| | | throw new IllegalArgumentException("查询不到该记录的费用项:"+importRoomFee.getFeeName()+startDate+endDate); |
| | | throw new IllegalArgumentException("查询不到该记录的费用项:"+importRoomFee.getFeeName()); |
| | | // List<FeeAttrPo> feeAttrsPos = new ArrayList<>(); |
| | | // PayFeePo payFeePo = new PayFeePo(); |
| | | // payFeePo.setCommunityId(importRoomFee.getCommunityId()); |
| | |
| | | // feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | } |
| | | if(feeDtos.size()>1){ |
| | | throw new IllegalArgumentException("该初始化缴费记录信息中包含多个费用记录"+importRoomFee.getFeeName()+startDate+endDate); |
| | | throw new IllegalArgumentException("该初始化缴费记录信息中包含多个费用记录"+importRoomFee.getFeeName()); |
| | | } |
| | | for (FeeDto tmpFeeDto : feeDtos) { |
| | | if(DateUtil.getDateFromStringB(importRoomFee.getEndTime()).getTime() > tmpFeeDto.getMaxEndTime().getTime()){ |
| | | throw new IllegalArgumentException("该费用记录结束时间大于费用记录最大缴费时间"); |
| | | } |
| | | doImportFeeDetail(tmpFeeDto, importRoomFee); |
| | | } |
| | | |
| | |
| | | PayFeeDetailPo payFeeDetailPo = new PayFeeDetailPo(); |
| | | payFeeDetailPo.setCommunityId(importRoomFee.getCommunityId()); |
| | | payFeeDetailPo.setReceivedAmount(importRoomFee.getAmount()); |
| | | payFeeDetailPo.setReceivableAmount(importRoomFee.getAmount()); |
| | | payFeeDetailPo.setCycles(importRoomFee.getCycle()); |
| | | payFeeDetailPo.setPrimeRate("1.0"); |
| | | payFeeDetailPo.setFeeId(tmpFeeDto.getFeeId()); |
| | | payFeeDetailPo.setStartTime(importRoomFee.getStartTime()); |
| | | payFeeDetailPo.setEndTime(importRoomFee.getEndTime()); |
| | | payFeeDetailPo.setRemark(importRoomFee.getRemark()); |
| | | payFeeDetailPo.setCreateTime(importRoomFee.getCreateTime()); |
| | | payFeeDetailPo.setState("1400"); |
| | | payFeeDetailPo.setCashierName(importRoomFee.getStaffName()); |
| | | payFeeDetailPo.setPayableAmount(importRoomFee.getAmount()); |
| | | payFeeDetailPo.setPayOrderId(importRoomFee.getPayObjId()); |
| | | payFeeDetailPo.setB("T"); |
| | | double cycle = (DateUtil.dayCompare( |
| | | DateUtil.getDateFromStringA(payFeeDetailPo.getStartTime()), |
| | | DateUtil.getDateFromStringA(importRoomFee.getEndTime()) |
| | | )); |
| | | int count = feeDetailInnerServiceSMOImpl.queryFeeDetailsCountByVo(payFeeDetailPo); |
| | | |
| | | payFeeDetailPo.setPayableAmount(importRoomFee.getAmount()); |
| | | |
| | | |
| | | payFeeDetailPo.setCycles(importRoomFee.getCycle()); |
| | | payFeeDetailPo.setCycles(cycle+""); |
| | | payFeeDetailPo.setEndTime(importRoomFee.getEndTime()); |
| | | if (count > 0) { |
| | | throw new IllegalStateException("重复的缴费记录"); |
| | | } |
| | | |
| | | PayFeeDetailDiscountPo payFeeDetailDiscount = new PayFeeDetailDiscountPo(); |
| | | try { |
| | | ResponseEntity<String> resultVo = feeDiscountApi.computeFeeDiscount(tmpFeeDto.getFeeId(), tmpFeeDto.getCommunityId(), Double.parseDouble(importRoomFee.getCycle()), importRoomFee.getPayObjId(), |
| | | ResponseEntity<String> resultVo = feeDiscountApi.computeFeeDiscount(tmpFeeDto.getFeeId(), tmpFeeDto.getCommunityId(), 105, importRoomFee.getPayObjId(), |
| | | tmpFeeDto.getPayerObjType(), importRoomFee.getEndTime(), importRoomFee.getEndTime(), importRoomFee.getStartTime(), 1, 20); |
| | | |
| | | // 2. 从 ResultVo 中获取 data 并强转为目标类型 |
| | | if (resultVo != null) { |
| | | // 假设 data 字段存储的是 List<ComputeDiscountDto> |
| | | JSONArray data = (JSONArray) JSONObject.parseObject(resultVo.getBody()).get("data"); |
| | | JSONObject o = (JSONObject) data.get(0); |
| | | String discountPrice = o.get("discountPrice").toString(); |
| | | String discountId = o.get("discountId").toString(); |
| | | |
| | | if(data.size() > 0) { |
| | | JSONObject o = (JSONObject) data.get(0); |
| | | String discountPrice = o.get("discountPrice").toString(); |
| | | String discountId = o.get("discountId").toString(); |
| | | payFeeDetailPo.setDiscountAmount(discountPrice); |
| | | payFeeDetailPo.setReceivableAmount((Double.parseDouble(payFeeDetailPo.getReceivedAmount()) + Double.parseDouble(payFeeDetailPo.getDiscountAmount()))+""); |
| | | payFeeDetailDiscount.setDiscountId(discountId); |
| | | payFeeDetailDiscount.setDiscountPrice(discountPrice); |
| | | }else{ |
| | | payFeeDetailPo.setReceivableAmount(payFeeDetailPo.getReceivedAmount()+""); |
| | | } |
| | | } |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | |
| | | |
| | |
| | | payFeeDetailPo.setOpenInvoice(importRoomFee.getOpenInv()); |
| | | } |
| | | int saved = feeDetailInnerServiceSMOImpl.saveFeeDetail(payFeeDetailPo); |
| | | |
| | | FeeDetailDto feeDetailDto = new FeeDetailDto(); |
| | | feeDetailDto.setDetailId(payFeeDetailPo.getDetailId()); |
| | | |
| | | List<FeeDetailDto> feeDtos = feeDetailInnerServiceSMOImpl.queryFeeDetails(feeDetailDto); |
| | | |
| | | if (payFeeDetailDiscount.getDiscountId() != null) { |
| | | payFeeDetailDiscount.setDetailId(payFeeDetailPo.getDetailId()); |
| | | payFeeDetailDiscount.setStatusCd("0"); |
| | | payFeeDetailDiscount.setCommunityId(feeDtos.get(0).getCommunityId()); |
| | | payFeeDetailDiscount.setFeeId(feeDtos.get(0).getFeeId()); |
| | | payFeeDetailDiscount.setDetailDiscountId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_discountId)); |
| | | |
| | | payFeeDetailDiscountNewV1InnerServiceSMOImpl.savePayFeeDetailDiscountNew(payFeeDetailDiscount); |
| | | } |
| | | |
| | | if (saved < 1) { |
| | | return; |
| | |
| | | payFeePo.setFeeId(tmpFeeDto.getFeeId()); |
| | | String[] arr = importRoomFee.getEndTime().split(" "); |
| | | if (arr.length >= 2 &&arr[1].equals("23:59:59")){ |
| | | importRoomFee.setEndTime(arr[0] + " 00:00:00"); |
| | | payFeePo.setEndTime(DateUtil.getNextSecTime(importRoomFee.getEndTime())); |
| | | } |
| | | payFeePo.setEndTime(DateUtil.getNextSecTime(importRoomFee.getEndTime())); |
| | | if (FeeDto.FEE_FLAG_ONCE.equals(tmpFeeDto.getFeeFlag())) { |
| | | payFeePo.setState(FeeDto.STATE_FINISH); |
| | | } |