用户获取车辆信息
This commit is contained in:
parent
afdd119b3c
commit
7c6b109dab
@ -4,6 +4,7 @@ import com.cdzy.common.model.response.JsonResult;
|
|||||||
import com.ebike.feign.component.FeignTokenInterceptor;
|
import com.ebike.feign.component.FeignTokenInterceptor;
|
||||||
import com.ebike.feign.config.ExampleFeignConfiguration;
|
import com.ebike.feign.config.ExampleFeignConfiguration;
|
||||||
import com.ebike.feign.model.dto.FeignEbikeDto;
|
import com.ebike.feign.model.dto.FeignEbikeDto;
|
||||||
|
import com.ebike.feign.model.dto.FeignEbikeUserBikeInfo;
|
||||||
import com.ebike.feign.model.vo.FeignEbikeBikeRadiusVo;
|
import com.ebike.feign.model.vo.FeignEbikeBikeRadiusVo;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -36,4 +37,12 @@ public interface OperationsFeignClient {
|
|||||||
@PostMapping("/ebikeBikeInfo/api/openLock")
|
@PostMapping("/ebikeBikeInfo/api/openLock")
|
||||||
JsonResult<?> openLock(@RequestParam("bikeCode")String bikeCode);
|
JsonResult<?> openLock(@RequestParam("bikeCode")String bikeCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户获取车辆详情及其计费规则
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/ebikeBikeInfo/api/bikeInfo")
|
||||||
|
JsonResult<FeignEbikeUserBikeInfo> bikeInfo(@RequestParam("bikeCode")String bikeCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,98 @@
|
|||||||
|
package com.ebike.feign.model.dto;
|
||||||
|
|
||||||
|
import com.mybatisflex.annotation.Table;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实体类。
|
||||||
|
*
|
||||||
|
* @author attiya
|
||||||
|
* @since 2025-10-21
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table("ebike_bike_info")
|
||||||
|
public class FeignEbikeUserBikeInfo implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运营商ID
|
||||||
|
*/
|
||||||
|
private Long operatorId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运营区ID
|
||||||
|
*/
|
||||||
|
private Long regionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆编号(与车辆二维码编号相同
|
||||||
|
*/
|
||||||
|
private String bikeCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 免费时长(分钟):使用服务前的免费时间
|
||||||
|
*/
|
||||||
|
private Integer freeDurationMinutes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 起步时长(分钟
|
||||||
|
*/
|
||||||
|
private Integer baseDurationMinutes;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 起步费用(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal baseFee;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时长(分钟)
|
||||||
|
*/
|
||||||
|
private Integer chargeDurationMinutes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时长费用(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal durationFee;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运营区域外调度费(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal outOfServiceAreaFee;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停车区外调度费(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal outOfParkingAreaFee;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封顶金额(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal maxFeeAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁停区调度费(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal noParkingZoneFee;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 头盔管理费(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal helmetManagementFee;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
|
|||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实体类。
|
* 实体类。
|
||||||
@ -36,15 +37,67 @@ public class EbikeUserBikeInfo implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Long regionId;
|
private Long regionId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 运营区名称
|
|
||||||
*/
|
|
||||||
private String regionName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆编号(与车辆二维码编号相同
|
* 车辆编号(与车辆二维码编号相同
|
||||||
*/
|
*/
|
||||||
private String bikeCode;
|
private String bikeCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆电量
|
||||||
|
*/
|
||||||
|
private Float soc = 50F;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 免费时长(分钟):使用服务前的免费时间
|
||||||
|
*/
|
||||||
|
private Integer freeDurationMinutes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 起步时长(分钟
|
||||||
|
*/
|
||||||
|
private Integer baseDurationMinutes;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 起步费用(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal baseFee;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时长(分钟)
|
||||||
|
*/
|
||||||
|
private Integer chargeDurationMinutes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时长费用(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal durationFee;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运营区域外调度费(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal outOfServiceAreaFee;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停车区外调度费(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal outOfParkingAreaFee;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封顶金额(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal maxFeeAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁停区调度费(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal noParkingZoneFee;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 头盔管理费(元)
|
||||||
|
*/
|
||||||
|
private BigDecimal helmetManagementFee;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,9 @@ import org.postgresql.geometric.PGpolygon;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -31,8 +34,12 @@ import java.util.Objects;
|
|||||||
import static com.cdzy.operations.model.entity.table.EbikeBatteryInfoTableDef.EBIKE_BATTERY_INFO;
|
import static com.cdzy.operations.model.entity.table.EbikeBatteryInfoTableDef.EBIKE_BATTERY_INFO;
|
||||||
import static com.cdzy.operations.model.entity.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
|
import static com.cdzy.operations.model.entity.table.EbikeBikeInfoTableDef.EBIKE_BIKE_INFO;
|
||||||
import static com.cdzy.operations.model.entity.table.EbikeBikeQrTableDef.EBIKE_BIKE_QR;
|
import static com.cdzy.operations.model.entity.table.EbikeBikeQrTableDef.EBIKE_BIKE_QR;
|
||||||
|
import static com.cdzy.operations.model.entity.table.EbikeDefaultBillingConfigurationTableDef.EBIKE_DEFAULT_BILLING_CONFIGURATION;
|
||||||
import static com.cdzy.operations.model.entity.table.EbikeEcuInfoTableDef.EBIKE_ECU_INFO;
|
import static com.cdzy.operations.model.entity.table.EbikeEcuInfoTableDef.EBIKE_ECU_INFO;
|
||||||
import static com.cdzy.operations.model.entity.table.EbikeRegionTableDef.EBIKE_REGION;
|
import static com.cdzy.operations.model.entity.table.EbikeRegionTableDef.EBIKE_REGION;
|
||||||
|
import static com.cdzy.operations.model.entity.table.EbikeSpecialBillingConfigurationTableDef.EBIKE_SPECIAL_BILLING_CONFIGURATION;
|
||||||
|
import static com.cdzy.operations.model.entity.table.EbikeSpecialDayTableDef.EBIKE_SPECIAL_DAY;
|
||||||
|
import static com.cdzy.operations.model.entity.table.EbikeSpecialTimeTableDef.EBIKE_SPECIAL_TIME;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务层实现。
|
* 服务层实现。
|
||||||
@ -55,6 +62,18 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
|||||||
@Resource
|
@Resource
|
||||||
EbikeEcuInfoMapper ebikeEcuInfoMapper;
|
EbikeEcuInfoMapper ebikeEcuInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
EbikeDefaultBillingConfigurationMapper defaultBillingConfigurationMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
EbikeSpecialBillingConfigurationMapper specialBillingConfigurationMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
EbiekSpecialDayMapper specialDayMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
EbiekSpecialTimeMapper specialTimeMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
EbikeInventoryService inventoryService;
|
EbikeInventoryService inventoryService;
|
||||||
|
|
||||||
@ -290,7 +309,98 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EbikeUserBikeInfo bikeInfo(String bikeCode) {
|
public EbikeUserBikeInfo bikeInfo(String bikeCode) {
|
||||||
|
QueryWrapper query = QueryWrapper.create()
|
||||||
|
.where(EBIKE_BIKE_INFO.BIKE_CODE.eq(bikeCode));
|
||||||
|
EbikeBikeInfo info = this.mapper.selectOneByQuery(query);
|
||||||
|
|
||||||
|
query.clear();
|
||||||
|
query.where(EBIKE_DEFAULT_BILLING_CONFIGURATION.REGION_ID.eq(info.getRegionId()));
|
||||||
|
EbikeDefaultBillingConfiguration configurations = defaultBillingConfigurationMapper.selectOneByQuery(query);
|
||||||
|
|
||||||
|
|
||||||
|
query.clear();
|
||||||
|
query.where(EBIKE_SPECIAL_BILLING_CONFIGURATION.REGION_ID.eq(info.getRegionId()));
|
||||||
|
EbikeSpecialBillingConfiguration specialBillingConfiguration = specialBillingConfigurationMapper.selectOneByQuery(query);
|
||||||
|
|
||||||
|
if (specialBillingConfiguration == null || specialBillingConfiguration.getType() == SpecialBillingConfigurationType.CLOSED) {
|
||||||
|
return EbikeUserBikeInfo.builder()
|
||||||
|
.operatorId(info.getOperatorId())
|
||||||
|
.regionId(info.getRegionId())
|
||||||
|
.bikeCode(info.getBikeCode())
|
||||||
|
.freeDurationMinutes(configurations.getFreeDurationMinutes())
|
||||||
|
.baseDurationMinutes(configurations.getBaseDurationMinutes())
|
||||||
|
.baseFee(configurations.getBaseFee())
|
||||||
|
.chargeDurationMinutes(configurations.getChargeDurationMinutes())
|
||||||
|
.durationFee(configurations.getDurationFee())
|
||||||
|
.outOfServiceAreaFee(configurations.getOutOfServiceAreaFee())
|
||||||
|
.outOfParkingAreaFee(configurations.getOutOfParkingAreaFee())
|
||||||
|
.maxFeeAmount(configurations.getMaxFeeAmount())
|
||||||
|
.noParkingZoneFee(configurations.getNoParkingZoneFee())
|
||||||
|
.helmetManagementFee(configurations.getHelmetManagementFee())
|
||||||
|
.build();
|
||||||
|
} else {
|
||||||
|
EbikeUserBikeInfo userBikeInfo = EbikeUserBikeInfo.builder()
|
||||||
|
.operatorId(info.getOperatorId())
|
||||||
|
.regionId(info.getRegionId())
|
||||||
|
.bikeCode(info.getBikeCode())
|
||||||
|
.freeDurationMinutes(configurations.getFreeDurationMinutes())
|
||||||
|
.baseDurationMinutes(configurations.getBaseDurationMinutes())
|
||||||
|
.baseFee(configurations.getBaseFee())
|
||||||
|
.chargeDurationMinutes(configurations.getChargeDurationMinutes())
|
||||||
|
.durationFee(configurations.getDurationFee())
|
||||||
|
.outOfServiceAreaFee(configurations.getOutOfServiceAreaFee())
|
||||||
|
.outOfParkingAreaFee(configurations.getOutOfParkingAreaFee())
|
||||||
|
.maxFeeAmount(configurations.getMaxFeeAmount())
|
||||||
|
.noParkingZoneFee(configurations.getNoParkingZoneFee())
|
||||||
|
.helmetManagementFee(configurations.getHelmetManagementFee())
|
||||||
|
.build();
|
||||||
|
if (specialBillingConfiguration.getType() == SpecialBillingConfigurationType.DAY) {
|
||||||
|
query.clear();
|
||||||
|
query.where(EBIKE_SPECIAL_DAY.REGION_ID.eq(info.getRegionId()));
|
||||||
|
List<EbikeSpecialDay> ebikeSpecialDays = specialDayMapper.selectListByQuery(query);
|
||||||
|
EbikeSpecialDay ebikeSpecialDay = getEbikeSpecialDay(ebikeSpecialDays);
|
||||||
|
if (ebikeSpecialDay != null) {
|
||||||
|
userBikeInfo.setBaseFee(ebikeSpecialDay.getBaseFee());
|
||||||
|
userBikeInfo.setDurationFee(ebikeSpecialDay.getDurationFee());
|
||||||
|
userBikeInfo.setBaseDurationMinutes(ebikeSpecialDay.getBaseDurationMinutes());
|
||||||
|
userBikeInfo.setChargeDurationMinutes(ebikeSpecialDay.getChargeDurationMinutes());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (specialBillingConfiguration.getType() == SpecialBillingConfigurationType.TIME) {
|
||||||
|
query.clear();
|
||||||
|
query.where(EBIKE_SPECIAL_TIME.REGION_ID.eq(info.getRegionId()));
|
||||||
|
List<EbikeSpecialTime> ebikeSpecialTimes = specialTimeMapper.selectListByQuery(query);
|
||||||
|
EbikeSpecialTime ebikeSpecialTime = getEbikeSpecialTime(ebikeSpecialTimes);
|
||||||
|
if (ebikeSpecialTime != null) {
|
||||||
|
userBikeInfo.setBaseFee(ebikeSpecialTime.getBaseFee());
|
||||||
|
userBikeInfo.setDurationFee(ebikeSpecialTime.getDurationFee());
|
||||||
|
userBikeInfo.setBaseDurationMinutes(ebikeSpecialTime.getBaseDurationMinutes());
|
||||||
|
userBikeInfo.setChargeDurationMinutes(ebikeSpecialTime.getChargeDurationMinutes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return userBikeInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static EbikeSpecialDay getEbikeSpecialDay(List<EbikeSpecialDay> ebikeSpecialDays) {
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
DayOfWeek dayOfWeek = today.getDayOfWeek();
|
||||||
|
String value = String.valueOf(dayOfWeek.getValue());
|
||||||
|
for (EbikeSpecialDay ebikeSpecialDay : ebikeSpecialDays) {
|
||||||
|
if (ebikeSpecialDay.getSpecialDayNum().equals(value)) {
|
||||||
|
return ebikeSpecialDay;
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static EbikeSpecialTime getEbikeSpecialTime(List<EbikeSpecialTime> EbikeSpecialTimes) {
|
||||||
|
LocalTime time = LocalTime.now();
|
||||||
|
for (EbikeSpecialTime ebikeSpecialTime : EbikeSpecialTimes) {
|
||||||
|
if (time.isAfter(ebikeSpecialTime.getStartTime()) && time.isBefore(ebikeSpecialTime.getEndTime())) {
|
||||||
|
return ebikeSpecialTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user