zhibing.pu
2024-08-28 f021540afe09a1b9bfeb9cefeb030e6ccf09375d
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -16,6 +16,7 @@
import com.ruoyi.chargingPile.api.model.Site;
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.model.TChargingPile;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.BasePage;
import com.ruoyi.common.core.web.page.PageInfo;
@@ -27,6 +28,7 @@
import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.model.TChargingOrderAccountingStrategy;
import com.ruoyi.order.api.model.TChargingOrderRefund;
import com.ruoyi.order.api.query.ChargingOrderQuery;
import com.ruoyi.order.api.vo.ChargingOrderVO;
import com.ruoyi.order.api.vo.TCharingOrderVO;
@@ -524,7 +526,9 @@
       BigDecimal electronicMoney = new BigDecimal("0");
       BigDecimal serviceMoney = new BigDecimal("0");
      for (ChargingOrderVO chargingOrderVO : list) {
         total = total.add(chargingOrderVO.getChargingCapacity());
         if (chargingOrderVO.getChargingCapacity()!=null){
            total = total.add(chargingOrderVO.getChargingCapacity());
         }
         // 充电订单 明细记录
         List<TChargingOrderAccountingStrategy> chargingOrderId = chargingOrderAccountingStrategyService.list(new QueryWrapper<TChargingOrderAccountingStrategy>()
               .eq("charging_order_id", chargingOrderVO.getId()));
@@ -535,14 +539,18 @@
         LocalDateTime startTime = chargingOrderVO.getStartTime();
         LocalDateTime endTime = chargingOrderVO.getEndTime();
         // 计算时间差 秒 充电时长
         long between = ChronoUnit.SECONDS.between(startTime, endTime);
         chargingOrderVO.setChargingSecond(between);
         time += between;
         if (startTime!=null && endTime!=null){
            long between = ChronoUnit.SECONDS.between(startTime, endTime);
            chargingOrderVO.setChargingSecond(between);
            time += between;
         }
         // 总收入
         if (chargingOrderVO.getRefundStatus() == 2){
         if (chargingOrderVO.getRefundStatus() !=null && chargingOrderVO.getRefundStatus() == 2){
            income = income.add(chargingOrderVO.getPaymentAmount().subtract(chargingOrderVO.getRefundAmount()));
         }else{
            income = income.add(chargingOrderVO.getPaymentAmount());
            if (chargingOrderVO.getPaymentAmount()!=null){
               income = income.add(chargingOrderVO.getPaymentAmount());
            }
         }
         for (TChargingOrderAccountingStrategy tChargingOrderAccountingStrategy : chargingOrderId) {
            // 累计电费
@@ -564,11 +572,14 @@
            // 车牌号
            chargingOrderVO.setPhone(data.getPhone());
            List<Long> longs = new ArrayList<>();
            longs.add(chargingOrderVO.getAppUserCarId());
            List<TAppUserCar> data1 = appUserCarClient.getCarByIds(longs).getData();
            if (!data1.isEmpty()){
               chargingOrderVO.setLicensePlate(data1.get(0).getLicensePlate());
            if (chargingOrderVO.getAppUserCarId()!=null){
               longs.add(chargingOrderVO.getAppUserCarId());
               List<TAppUserCar> data1 = appUserCarClient.getCarByIds(longs).getData();
               if (!data1.isEmpty()){
                  chargingOrderVO.setLicensePlate(data1.get(0).getLicensePlate());
               }
            }
         }
      }
      tCharingOrderVO.setTotal(total);
@@ -580,4 +591,21 @@
      tCharingOrderVO.setList(pageInfo);
        return tCharingOrderVO;
    }
   @Override
   public R<PageInfo<PayOrderDto>> payOrderQuery(PayOrderQueryDto payOrderQueryDto) {
      PageInfo<PayOrderDto> pageInfo = new PageInfo<>(payOrderQueryDto.getPageCurr(),payOrderQueryDto.getPageSize());
      List<PayOrderDto> list = this.baseMapper.payOrderQuery(pageInfo,payOrderQueryDto);
      pageInfo.setRecords(list);
      return R.ok(pageInfo);
   }
   @Override
   public R<PageInfo<TChargingOrderRefund>> getRefundList(ChargingRefundDto chargingRefundDto) {
      PageInfo<TChargingOrderRefund> pageInfo = new PageInfo<>(chargingRefundDto.getPageCurr(),chargingRefundDto.getPageSize());
      List<TChargingOrderRefund> list = this.baseMapper.getRefundList(pageInfo,chargingRefundDto);
      pageInfo.setRecords(list);
      return R.ok(pageInfo);
   }
}