无关风月
2024-09-11 879b0872824fccbf0db86941c43059d1bcf2fed2
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -1804,8 +1804,15 @@
      String startTime = dto.getStartTime();
      String endTime = dto.getEndTime();
      // 将这两个时间转化为localDateTime
      tSettlementConfirm.setStartTime(LocalDateTime.parse(startTime));
      tSettlementConfirm.setEndTime(LocalDateTime.parse(endTime));
      // 创建 DateTimeFormatter 对象,指定格式
      DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
      // 将字符串解析为 LocalDateTime 对象
      LocalDateTime localDateTime = LocalDateTime.parse(startTime, formatter);
      LocalDateTime localDateTime1 = LocalDateTime.parse(endTime, formatter);
      tSettlementConfirm.setEndTime(localDateTime1);
      tSettlementConfirm.setStartTime(localDateTime);
      // 根据站点id和开始时间和结束时间和归属日期 查询充电订单列表
      QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>()
            .eq("site_id", dto.getSiteId())
@@ -1839,13 +1846,23 @@
      BigDecimal paymentAmount = new BigDecimal("0");
      for (TChargingOrder tChargingOrder : tChargingOrders) {
         // 累加充电总度数
         chargingElectronic = chargingElectronic.add(tChargingOrder.getChargingCapacity());
         if (tChargingOrder.getChargingCapacity()!=null){
            chargingElectronic = chargingElectronic.add(tChargingOrder.getChargingCapacity());
         }
         // 累加分佣
         sharingAmount = sharingAmount.add(tChargingOrder.getSharingAmount());
         if (tChargingOrder.getSharingAmount()!=null) {
            sharingAmount = sharingAmount.add(tChargingOrder.getSharingAmount());
         }
         // 累加电费
         if (tChargingOrder.getElectrovalence()!=null) {
         electrovalence = electrovalence.add(tChargingOrder.getElectrovalence());
         }
         // 累加服务费
         serviceCharge = serviceCharge.add(tChargingOrder.getServiceCharge());
         if (tChargingOrder.getServiceCharge()!=null){
            serviceCharge = serviceCharge.add(tChargingOrder.getServiceCharge());
         }
         // 累加会员折扣
         if (tChargingOrder.getVipDiscountAmount()!=null){
            vipDiscount = vipDiscount.add(tChargingOrder.getVipDiscountAmount());
@@ -1854,11 +1871,13 @@
         if (tChargingOrder.getCouponDiscountAmount()!=null){
            couponDiscount = couponDiscount.add(tChargingOrder.getCouponDiscountAmount());
         }
         if (tChargingOrder.getRefundStatus() == 2){
         if (tChargingOrder.getRefundStatus()!=null &&tChargingOrder.getRefundStatus() == 2){
            // 如果成功退款 那么减去退款金额
            paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount().subtract(tChargingOrder.getRefundAmount()));
         }else{
            paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount());
            if (tChargingOrder.getPaymentAmount()!=null){
               paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount());
            }
         }
      }
      // 三方交易手续费 三方收费*0.6%
@@ -1874,34 +1893,36 @@
      tSettlementConfirm.setVipDiscount(vipDiscount);
      tSettlementConfirm.setCouponDiscount(couponDiscount);
      tSettlementConfirm.setSiteId(dto.getSiteId());
      tSettlementConfirm.setMeteringElectronic(dto.getData().getMeteringElectronic());
      tSettlementConfirm.setChargingElectronic(chargingElectronic);
      tSettlementConfirm.setLossElectronic(dto.getData().getLossElectronic());
      tSettlementConfirm.setIncome(chargingElectronic.add(serviceCharge));
      tSettlementConfirm.setVenue(dto.getData().getVenue());
      tSettlementConfirm.setMetering(dto.getData().getMetering());
      tSettlementConfirm.setClean(dto.getData().getClean());
      tSettlementConfirm.setMaintain(dto.getData().getMaintain());
      tSettlementConfirm.setCost(dto.getData().getVenue().add(dto.getData().getClean()).add(dto.getData().getMaintain()));
      tSettlementConfirm.setProfitMoney(new BigDecimal("0"));
      tSettlementConfirm.setNewMoney(new BigDecimal("0"));
      tSettlementConfirm.setNewSettlement(new BigDecimal("0"));
      tSettlementConfirm.setVipDiscount(vipDiscount);
      tSettlementConfirm.setCouponDiscount(couponDiscount);
      tSettlementConfirm.setSupplyElectronic(dto.getData().getSupplyElectronic());
      tSettlementConfirm.setType(dto.getType());
      tSettlementConfirm.setProportionPartner(dto.getData().getProportionPartner());
      tSettlementConfirm.setProportionMoney(dto.getData().getProportionMoney());
      tSettlementConfirm.setTotalElectronic(dto.getData().getTotalElectronic());
      tSettlementConfirm.setTotalService(dto.getData().getTotalService());
      tSettlementConfirm.setRemark(dto.getData().getRemark());
      tSettlementConfirm.setServicePartner(dto.getData().getServicePartner());
      tSettlementConfirm.setServiceMoney(dto.getData().getServiceMoney());
      tSettlementConfirm.setTotalService(dto.getData().getTotalService());
      tSettlementConfirm.setServiceRemark(dto.getData().getServiceRemark());
      tSettlementConfirm.setDistribution(dto.getData().getDistribution());
      tSettlementConfirm.setIncome(dto.getData().getElectrovalence().add(dto.getData().getServiceCharge()));
      if (dto.getState() == 2){
         tSettlementConfirm.setSupplyElectronic(dto.getData().getSupplyElectronic());
         tSettlementConfirm.setVenue(dto.getData().getVenue());
         tSettlementConfirm.setMetering(dto.getData().getMetering());
         tSettlementConfirm.setClean(dto.getData().getClean());
         tSettlementConfirm.setLossElectronic(dto.getData().getLossElectronic());
         tSettlementConfirm.setMaintain(dto.getData().getMaintain());
         tSettlementConfirm.setMeteringElectronic(dto.getData().getMeteringElectronic());
         tSettlementConfirm.setProportionPartner(dto.getData().getProportionPartner());
         tSettlementConfirm.setProportionMoney(dto.getData().getProportionMoney());
         tSettlementConfirm.setTotalElectronic(dto.getData().getTotalElectronic());
         tSettlementConfirm.setTotalService(dto.getData().getTotalService());
         tSettlementConfirm.setRemark(dto.getData().getRemark());
         tSettlementConfirm.setServicePartner(dto.getData().getServicePartner());
         tSettlementConfirm.setServiceMoney(dto.getData().getServiceMoney());
         tSettlementConfirm.setTotalService(dto.getData().getTotalService());
         tSettlementConfirm.setServiceRemark(dto.getData().getServiceRemark());
         tSettlementConfirm.setDistribution(dto.getData().getDistribution());
         tSettlementConfirm.setIncome(dto.getData().getElectrovalence().add(dto.getData().getServiceCharge()));
         tSettlementConfirm.setCost(dto.getData().getVenue().add(dto.getData().getClean()).add(dto.getData().getMaintain()));
         tSettlementConfirmMapper.insert(tSettlementConfirm);
      }
      return tSettlementConfirm;
@@ -2088,13 +2109,23 @@
      tSettlementConfirm.setVipDiscount(vipDiscount);
      tSettlementConfirm.setCouponDiscount(couponDiscount);
      // 本月
      BigDecimal subtract = income.subtract(beforeIncome).divide(beforeIncome).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100"));
      tSettlementConfirm.setIncomePercentage(subtract+"%");
      if (beforeIncome.compareTo(new BigDecimal("0")) == 0){
         tSettlementConfirm.setIncomePercentage(0+"%");
         tSettlementConfirm.setIncomePercentage(0+"%");
      }else{
         BigDecimal subtract = income.subtract(beforeIncome).divide(beforeIncome).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100"));
         tSettlementConfirm.setIncomePercentage(subtract+"%");
         tSettlementConfirm.setIncomePercentage(subtract+"%");
      }
      // 比较总利润 收入合计-成本合计
      BigDecimal subtract1 = income.subtract(cost);
      BigDecimal subtract2 = beforeIncome.subtract(beforeCost);
      tSettlementConfirm.setTotalPercentage(subtract1.subtract(subtract2).divide(subtract2).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100"))+"%");
      tSettlementConfirm.setIncomePercentage(subtract+"%");
      if (subtract2.compareTo(new BigDecimal("0")) == 0){
         tSettlementConfirm.setTotalPercentage(0+"%");
      }else{
         tSettlementConfirm.setTotalPercentage(subtract1.subtract(subtract2).divide(subtract2).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100"))+"%");
      }
      tSettlementConfirm.setElectronicRefund(0);
      // 查询上次汇报数据 进行比对涨幅跌幅
      total.add(tSettlementConfirm);