From ae84ae528290f44c66ef14c92f4a68bd3c1ce617 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期一, 11 十一月 2024 08:50:50 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TParkingRecordServiceImpl.java |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TParkingRecordServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TParkingRecordServiceImpl.java
index 119f6ac..35ede90 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TParkingRecordServiceImpl.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TParkingRecordServiceImpl.java
@@ -18,6 +18,7 @@
 import com.ruoyi.common.core.web.page.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.time.LocalDate;
@@ -49,6 +50,7 @@
 
     @Override
     public TParkingRecordPageInfoVO pageList(ParkingRecordQuery query) {
+        PageInfo<TParkingRecordVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize());
         // 查询站点的停车场id
         if(Objects.nonNull(query.getSiteId())){
             Site site = siteMapper.selectById(query.getSiteId());
@@ -56,12 +58,28 @@
                 List<TParkingLot> tParkingLots = parkingLotMapper.selectList(Wrappers.lambdaQuery(TParkingLot.class)
                         .eq(TParkingLot::getSiteId, site.getId()));
                 List<Integer> lotIds = tParkingLots.stream().map(TParkingLot::getId).collect(Collectors.toList());
+                if(CollectionUtils.isEmpty(lotIds)){
+                    TParkingRecordPageInfoVO tParkingRecordPageInfoVO = new TParkingRecordPageInfoVO();
+                    tParkingRecordPageInfoVO.setParkingRecordVOS(new PageInfo<TParkingRecordVO>());
+                    return tParkingRecordPageInfoVO;
+                }
                 query.setLotIds(lotIds);
             }
 
         }
-        PageInfo<TParkingRecordVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize());
         List<TParkingRecordVO> list = this.baseMapper.pageList(query,pageInfo);
+        for (TParkingRecordVO tParkingRecordVO : list) {
+            if (tParkingRecordVO.getParkingDuration()==null){
+                tParkingRecordVO.setFeeDuration(0);
+            }else if(tParkingRecordVO.getFreeDuration()==null){
+                tParkingRecordVO.setFeeDuration(tParkingRecordVO.getParkingDuration());
+            }else{
+                tParkingRecordVO.setFeeDuration(tParkingRecordVO.getParkingDuration()-tParkingRecordVO.getFreeDuration());
+            }
+            tParkingRecordVO.setOrderAmount(tParkingRecordVO.getOrderAmount()!=null?tParkingRecordVO.getOrderAmount():new BigDecimal("0")
+                    .add(tParkingRecordVO.getTimeoutAmount()!=null?tParkingRecordVO.getTimeoutAmount():new BigDecimal("0")));
+            tParkingRecordVO.setParkingFee(tParkingRecordVO.getOrderAmount());
+        }
         pageInfo.setRecords(list);
         // 查询总数
         TParkingRecordPageInfoVO infoVO = this.baseMapper.getParkingRecordCount(query);

--
Gitblit v1.7.1