Parcourir la source

获取手机号

guoshuai il y a 1 mois
Parent
commit
c2d4598a18

+ 23 - 0
src/main/java/com/qmrb/system/service/impl/CarParkChargingRulesServiceImpl.java

@@ -1,10 +1,13 @@
 package com.qmrb.system.service.impl;
 
 import java.math.BigDecimal;
+import java.time.Instant;
 import java.time.LocalDateTime;
+import java.time.ZoneId;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import com.qmrb.system.pojo.entity.BarnRecord;
 import com.qmrb.system.pojo.entity.CarParkStoredCard;
 import com.qmrb.system.service.IBarnRecordService;
 import com.qmrb.system.service.ICarParkStoredCardService;
@@ -116,8 +119,28 @@ public class CarParkChargingRulesServiceImpl extends ServiceImpl<CarParkCharging
 	public BigDecimal calcuExpenses(Long recordId, Long userId) {
 		// 查询当前用户是否有月卡
 		List<CarParkStoredCard> list = parkStoredCardService.list(new LambdaQueryWrapper<CarParkStoredCard>().eq(CarParkStoredCard::getUserId, userId).ge(CarParkStoredCard::getEndTime, LocalDateTime.now()));
+		BarnRecord barnRecord = barnRecordService.getById(recordId);
+		Assert.isTrue(barnRecord != null, "计费时停车记录不存在,id为"+recordId);
 		if(CollectionUtil.isNotEmpty(list)){
+			CarParkStoredCard parkStoredCard = list.get(0);
+			// 将 Date 转换为 Instant
+			Instant instant = barnRecord.getInTime().toInstant();
+
+			// 将 Instant 转换为 LocalDateTime(假设使用系统默认时区)
+			LocalDateTime inDateTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
 			
+			if(parkStoredCard.getStartTime().isAfter(inDateTime) && parkStoredCard.getEndTime().isBefore(LocalDateTime.now())){
+				//入库时间在月卡开始日前,出库时间在结束日前
+			} else if(parkStoredCard.getStartTime().isAfter(inDateTime) && parkStoredCard.getEndTime().isAfter(LocalDateTime.now())){
+				//入库时间在月卡开始日前,出库时间在结束日内
+			} else if (parkStoredCard.getStartTime().isBefore(inDateTime) && parkStoredCard.getEndTime().isBefore(LocalDateTime.now())) {
+				//入库时间在月卡开始日后,出库时间在结束日前
+				return BigDecimal.ZERO;
+			} else if(parkStoredCard.getStartTime().isBefore(inDateTime) && parkStoredCard.getEndTime().isAfter(LocalDateTime.now())){
+				//入库时间在月卡开始日后,出库时间在结束日后
+			}
+		}else{
+			//直接计算费用
 		}
 		return null;
 	}

+ 1 - 0
src/main/java/com/qmrb/system/service/impl/SysUserServiceImpl.java

@@ -245,6 +245,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 .select(
                         SysUser::getId,
                         SysUser::getNickname,
+                        SysUser::getMobile,
                         SysUser::getAvatar
                 )
         );