无关风月
2024-10-21 87713346e00fdded8dff48c4a79180a9ada84504
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -1283,7 +1283,7 @@
         BigDecimal serviceMoney1 = new BigDecimal("0");
         UploadRealTimeMonitoringData data5 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrderVO.getCode()).getData();
         if (data5!=null){
            chargingOrderVO.setChargingSecond(data5.getTime_remaining()*60L);
            chargingOrderVO.setChargingSecond(data5.getCumulative_charging_time()*60L);
         }
         // 总收入
         if (chargingOrderVO.getRefundStatus() !=null && chargingOrderVO.getRefundStatus() == 2){
@@ -1410,7 +1410,36 @@
         startTime2 = split[1];
      }
      ChargingOrderTimeVO chargingOrderTimeVO = new ChargingOrderTimeVO();
      if (StringUtils.hasLength(dto.getPhone())){
         List<Long> data = appUserClient.getUserIdsByPhone(dto.getPhone()).getData();
         if(data!=null){
            if (!data.isEmpty()){
               dto.setUserIds(data);
            }
         }else{
            dto.setUserIds(new ArrayList<Long>());
         }
         if (dto.getUserIds().isEmpty()){
            List<Long> carIds = dto.getUserIds();
            carIds.add(-1L);
            dto.setUserIds(carIds);
         }
      }
      if (StringUtils.hasLength(dto.getPhone())){
         List<Long> data = appUserCarClient.getAppUserCarByLicensePlates(dto.getLicensePlate()).getData();
         if(data!=null){
            if (!data.isEmpty()){
               dto.setCarIds(data);
            }
         }else{
            dto.setCarIds(new ArrayList<Long>());
         }
         if (dto.getCarIds().isEmpty()){
            List<Long> carIds = dto.getCarIds();
            carIds.add(-1L);
            dto.setCarIds(carIds);
         }
      }
      PageInfo<ChargingOrderListVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize());
      List<ChargingOrderListVO> list = this.baseMapper.chargingList(pageInfo,dto,startTime1,startTime2,endTime1,endTime2);
      for (ChargingOrderListVO chargingOrderListVO : list) {
@@ -1802,13 +1831,13 @@
                  break;
               case 4:
                  //充电度数
                  invoke = clazz.getMethod("getValley_amount" + (i + 1)).invoke(vo);
                  invoke = clazz.getMethod("getValley_charge" + (i + 1)).invoke(vo);
                  break;
            }
            if(null == invoke || invoke.toString().equals("0")){
            if(null == invoke || Integer.valueOf(invoke.toString()) == 0){
               continue;
            }
            BigDecimal Sharp_peak_charge = new BigDecimal(invoke.toString());
            BigDecimal sharp_peak_charge = new BigDecimal(invoke.toString());
            TChargingOrderAccountingStrategy chargingOrderAccountingStrategy = new TChargingOrderAccountingStrategy();
            chargingOrderAccountingStrategy.setChargingOrderId(chargingOrder.getId());
            chargingOrderAccountingStrategy.setAccountingStrategyDetailId(strategyDetail.getId());
@@ -1819,14 +1848,14 @@
            chargingOrderAccountingStrategy.setServiceCharge(strategyDetail.getServiceCharge());
            chargingOrderAccountingStrategy.setCostServiceCharge(strategyDetail.getCostServiceCharge());
            //已充电总度数
            BigDecimal electrovalenc = strategyDetail.getElectrovalence().multiply(Sharp_peak_charge);
            BigDecimal originalServicePrice = strategyDetail.getServiceCharge().multiply(Sharp_peak_charge);
            BigDecimal electrovalenc = strategyDetail.getElectrovalence().multiply(sharp_peak_charge).setScale(2, RoundingMode.DOWN);
            BigDecimal originalServicePrice = strategyDetail.getServiceCharge().multiply(sharp_peak_charge).setScale(2, RoundingMode.DOWN);
            BigDecimal serviceCharge = originalServicePrice;
            //计算优惠金额
            if(null != chargingOrder.getVipDiscount()){
               serviceCharge = serviceCharge.multiply(chargingOrder.getVipDiscount().divide(new BigDecimal(10)));
               serviceCharge = serviceCharge.multiply(chargingOrder.getVipDiscount().divide(new BigDecimal(10))).setScale(2, RoundingMode.DOWN);
            }
            chargingOrderAccountingStrategy.setChargingCapacity(Sharp_peak_charge);
            chargingOrderAccountingStrategy.setChargingCapacity(sharp_peak_charge);
            chargingOrderAccountingStrategy.setPeriodElectricPrice(electrovalenc);
            chargingOrderAccountingStrategy.setPeriodServicePrice(serviceCharge);
            chargingOrderAccountingStrategy.setPeriodOriginalServicePrice(originalServicePrice);
@@ -1837,7 +1866,7 @@
            BigDecimal periodServicePrice = chargingOrderAccountingStrategy.getPeriodOriginalServicePrice();
            periodElectricPrice_total = periodElectricPrice_total.add(periodElectricPrice);
            periodServicePrice_total = periodServicePrice_total.add(periodServicePrice);
            total = total.add(periodElectricPrice).add(periodServicePrice);
            total = total.add(periodElectricPrice.add(periodServicePrice));
         } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
         } catch (InvocationTargetException e) {
@@ -1898,11 +1927,12 @@
      order.setStartTime(LocalDateTime.parse(vo.getStart_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SS")));
      order.setEndTime(LocalDateTime.parse(vo.getEnd_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SS")));
      order.setStatus(5);
      order.setOrderAmount(orderAmount.setScale(2, RoundingMode.DOWN));
      order.setVipDiscountAmount(discountAmount.setScale(2, RoundingMode.DOWN));
      order.setServiceCharge(periodServicePrice_total.setScale(2, RoundingMode.DOWN));
      order.setElectrovalence(periodElectricPrice_total.setScale(2, RoundingMode.DOWN));
      order.setOrderAmount(orderAmount);
      order.setVipDiscountAmount(discountAmount);
      order.setServiceCharge(periodServicePrice_total);
      order.setElectrovalence(periodElectricPrice_total);
      order.setChargingCapacity(vo.getTotal_electricity());
      order.setElectricity(vo.getTotal_electricity());
      
      //计算优惠券
      if(null != chargingOrder.getAppCouponId()){
@@ -1939,8 +1969,8 @@
            }
         }
      }
      order.setPaymentAmount(payAmount.setScale(2, RoundingMode.DOWN));
      order.setRefundAmount(refundAmount.setScale(2, RoundingMode.DOWN));
      order.setPaymentAmount(payAmount);
      order.setRefundAmount(refundAmount);
      order.setRefundStatus(1);
      this.updateById(order);
      chargingOrder = this.getById(order.getId());