| | |
| | | } |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = Double.valueOf(Math.random() * 1000).intValue() + sdf.format(new Date()); |
| | | //获取开票类型 |
| | | TInvoiceType invoiceType = invoiceTypeClient.getInvoiceType(addOrderInvoice.getInvoiceTypeId()).getData(); |
| | | addOrderInvoice.setInvoicingCompany(invoiceType.getInvoicingCompany()); |
| | | addOrderInvoice.setInvoiceType(invoiceType.getName()); |
| | | addOrderInvoice.setInvoiceMaterial(2); |
| | | addOrderInvoice.setInvoicingMethod(invoiceType.getInvoicingMethod()); |
| | | addOrderInvoice.setAppUserId(userId); |
| | | addOrderInvoice.setCode(code); |
| | | addOrderInvoice.setStatus(1); |
| | | addOrderInvoice.setCreateTime(LocalDateTime.now()); |
| | | this.save(addOrderInvoice); |
| | | //获取开票类型 |
| | | TInvoiceType invoiceType = invoiceTypeClient.getInvoiceType(addOrderInvoice.getInvoiceTypeId()).getData(); |
| | | for (Long orderId : orderIds) { |
| | | List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.list(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>() |
| | | .eq(TChargingOrderAccountingStrategy::getChargingOrderId, orderId)); |
| | |
| | | List<TOrderInvoiceVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | for (TOrderInvoiceVO tOrderInvoiceVO : list) { |
| | | tOrderInvoiceVO.setUid(tOrderInvoiceVO.getId().toString()); |
| | | List<Long> collect = orderInvoiceDetailService.lambdaQuery().eq(TOrderInvoiceDetail::getOrderInvoiceId, tOrderInvoiceVO.getId()) |
| | | .eq(TOrderInvoiceDetail::getOrderType, 1).list().stream() |
| | | List<Long> collect = orderInvoiceDetailService.lambdaQuery().eq(TOrderInvoiceDetail::getOrderInvoiceId, tOrderInvoiceVO.getId()).list().stream() |
| | | .map(TOrderInvoiceDetail::getOrderId).collect(Collectors.toList()); |
| | | // 将其全部转化为String |
| | | tOrderInvoiceVO.setIds(collect.stream().map(String::valueOf).collect(Collectors.toList())); |
| | | } |
| | | // 查询这个开票的订单ids |
| | | |
| | | List<Long> ids = list.stream().map(TOrderInvoiceVO::getId).collect(Collectors.toList()); |
| | | if (!list.isEmpty()){ |
| | | List<Long> ids = list.stream().map(TOrderInvoiceVO::getId).collect(Collectors.toList()); |
| | | |
| | | List<TOrderInvoiceDetail> orderInvoiceDetailList = orderInvoiceDetailService.list(new LambdaQueryWrapper<TOrderInvoiceDetail>() |
| | | .in(TOrderInvoiceDetail::getOrderInvoiceId, ids)); |
| | | List<TOrderInvoiceDetail> orderInvoiceDetailList = orderInvoiceDetailService.list(new LambdaQueryWrapper<TOrderInvoiceDetail>() |
| | | .in(TOrderInvoiceDetail::getOrderInvoiceId, ids)); |
| | | |
| | | List<TAppUser> finalTAppUsers = tAppUsers; |
| | | list.forEach(e->{ |
| | | e.setServiceTariff(orderInvoiceDetailList.get(0).getServiceTariff()); |
| | | e.setElectricityTariff(orderInvoiceDetailList.get(0).getElectricityTariff()); |
| | | e.setAddedServiceTariff(orderInvoiceDetailList.get(0).getAddedServiceTariff()); |
| | | e.setAddedService(orderInvoiceDetailList.stream().filter(t->t.getAddedService()!=null).map(TOrderInvoiceDetail::getAddedService).reduce(BigDecimal::add).get()); |
| | | e.setElectrovalence(orderInvoiceDetailList.stream().filter(t->t.getElectrovalence()!=null).map(TOrderInvoiceDetail::getElectrovalence).reduce(BigDecimal::add).get()); |
| | | e.setServiceCharge(orderInvoiceDetailList.stream().filter(t->t.getServiceCharge()!=null).map(TOrderInvoiceDetail::getServiceCharge).reduce(BigDecimal::add).get()); |
| | | if (e.getBillingUserId()!=null){ |
| | | e.setUserPhone(finalTAppUsers.stream().filter(t->t.getId()!=null).filter(m->m.getId().equals(Long.parseLong(e.getBillingUserId().toString()))).findFirst().get().getPhone()); |
| | | } |
| | | }); |
| | | List<TAppUser> finalTAppUsers = tAppUsers; |
| | | list.forEach(e->{ |
| | | if (e.getOrderType()!=null&&e.getOrderType()==1){ |
| | | e.setServiceTariff(orderInvoiceDetailList.get(0).getServiceTariff()); |
| | | }else{ |
| | | e.setServiceTariff(new BigDecimal("0")); |
| | | } |
| | | e.setElectricityTariff(orderInvoiceDetailList.get(0).getElectricityTariff()); |
| | | e.setAddedServiceTariff(orderInvoiceDetailList.get(0).getAddedServiceTariff()); |
| | | e.setAddedService(orderInvoiceDetailList.stream().filter(t->t.getAddedService()!=null).map(TOrderInvoiceDetail::getAddedService).reduce(BigDecimal::add).get()); |
| | | e.setElectrovalence(orderInvoiceDetailList.stream().filter(t->t.getElectrovalence()!=null).map(TOrderInvoiceDetail::getElectrovalence).reduce(BigDecimal::add).get()); |
| | | e.setServiceCharge(orderInvoiceDetailList.stream().filter(t->t.getServiceCharge()!=null).map(TOrderInvoiceDetail::getServiceCharge).reduce(BigDecimal::add).get()); |
| | | if (e.getBillingUserId()!=null){ |
| | | e.setUserPhone(finalTAppUsers.stream().filter(t->t.getId()!=null).filter(m->m.getId().equals(Long.parseLong(e.getBillingUserId().toString()))).findFirst().get().getPhone()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |