add 新增小程序首页查询站点列表接口

This commit is contained in:
Lemon
2025-03-25 10:40:13 +08:00
parent 9007b1db52
commit 6888c93d85
5 changed files with 105 additions and 4 deletions

View File

@@ -127,6 +127,12 @@ public class QueryStationDTO extends BaseEntity {
private String memberId;
private String canopyFlag;
private String barrierFlag;
private String parkingLockFlag;
@Data
public static class OtherOptions {
/**

View File

@@ -75,4 +75,6 @@ public interface MemberStationRelationService {
* @return
*/
int updateCollectedStation(CollectedStationDTO dto);
List<String> getStationIdListByMemberId(String memberId);
}

View File

@@ -124,6 +124,20 @@ public class MemberStationRelationServiceImpl implements MemberStationRelationSe
return memberStationRelationMapper.deleteMemberStationRelation(memberStationRelation);
}
/**
* 通过memberId查询列表
* @param memberId
* @return
*/
public List<String> getStationIdListByMemberId(String memberId) {
return memberStationRelationMapper.getStationIdListByMemberId(memberId);
}
/**
* 修改收藏的站点(添加/删除)
* @param dto
* @return
*/
@Override
public int updateCollectedStation(CollectedStationDTO dto) {
int result = 0;

View File

@@ -96,6 +96,9 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
@Autowired
private OrderBasicInfoService orderBasicInfoService;
@Autowired
private MemberStationRelationService memberStationRelationService;
@Autowired
private SettleOrderReportService settleOrderReportService;
@@ -624,14 +627,90 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
// 先判断是否选择我的收藏中的站点
if (StringUtils.isNotBlank(myCollectionFlag)) {
// 不为空先将要查询的站点idList添加进参数
// TODO 查询我的收藏下的站点id
// dto.setStationIds();
// 查询我的收藏下的站点id
List<String> stationIds = memberStationRelationService.getStationIdListByMemberId(dto.getMemberId());
dto.setStationIds(stationIds);
}
// 分页
PageHelper.startPage(pageNum, pageSize);
// 根据前端传的参数进行筛选查询(默认根据距离排序)
List<PileStationVO> list = pileStationInfoMapper.queryStationInfos(dto);
PageInfo<PileStationVO> pageInfo = new PageInfo<>(list);
List<StationInfoVO> stationVOList = Lists.newArrayList();
StationInfoVO stationVO;
String stationLng = dto.getStationLng();
String stationLat = dto.getStationLat();
double distance = 0d;
for (PileStationVO pileStationVO : pageInfo.getList()) {
stationVO = new StationInfoVO();
if (StringUtils.isNotEmpty(stationLng) && StringUtils.isNotEmpty(stationLat)) {
try {
// 计算当前经纬度和站点之间的距离
distance = DistanceUtils.getDistance(Double.parseDouble(stationLng), Double.parseDouble(stationLat),
Double.parseDouble(pileStationVO.getStationLng()), Double.parseDouble(pileStationVO.getStationLat()));
// 保留两位小数
stationVO.setDistance(String.format("%.2f", distance));
} catch (Exception e) {
stationVO.setDistance("0.00");
}
}
stationVO.setStationId(pileStationVO.getId());
stationVO.setStationName(pileStationVO.getStationName());
stationVO.setStationAddress(pileStationVO.getAddress());
stationVO.setStationLat(pileStationVO.getStationLat());
stationVO.setStationLng(pileStationVO.getStationLng());
if (StringUtils.isNotBlank(pileStationVO.getParkFeeDescribe())) {
stationVO.setParkFeeDescribe(pileStationVO.getParkFeeDescribe());
}
// 站点联系电话
if (StringUtils.isNotBlank(pileStationVO.getStationTel())) {
stationVO.setStationTel(pileStationVO.getStationTel());
}
// 站点图片
if (StringUtils.isNotBlank(pileStationVO.getPictures())) {
stationVO.setStationImgList(Lists.newArrayList(pileStationVO.getPictures().split(",")));
}
// 查询快慢充数量
Map<String, Integer> map = pileConnectorInfoService.getPileTypeNum(Long.parseLong(pileStationVO.getId()));
// Integer fastFree = map.get("fastFree");
// Integer slowFree = map.get("slowFree");
stationVO.setFastTotal(map.get("fastTotal"));
stationVO.setFastFree(map.get("fastFree"));
stationVO.setSlowTotal(map.get("slowTotal"));
stationVO.setSlowFree(map.get("slowFree"));
stationVO.setTotalFree(stationVO.getFastFree() + stationVO.getSlowFree());
// 查询当前时段电费
CurrentTimePriceDetails currentTimePriceDetails = pileBillingTemplateService.getCurrentTimePriceDetails(stationVO.getStationId());
if (currentTimePriceDetails != null) {
stationVO.setElectricityPrice(currentTimePriceDetails.getElectricityPrice());
stationVO.setServicePrice(currentTimePriceDetails.getServicePrice());
stationVO.setTotalPrice(currentTimePriceDetails.getTotalPrice());
stationVO.setFreeTime(currentTimePriceDetails.getFreeTime());
stationVO.setOccupyFee(currentTimePriceDetails.getOccupyFee());
// vip价
stationVO.setVipElectricityPrice(currentTimePriceDetails.getVipElectricityPrice());
stationVO.setVipServicePrice(currentTimePriceDetails.getVipServicePrice());
stationVO.setVipTotalPrice(currentTimePriceDetails.getVipTotalPrice());
}
stationVOList.add(stationVO);
}
if (distance != 0.00) {
// 对集合按照距离排序,距离小的在前
stationVOList.sort((o1, o2) -> {
Double a = Double.valueOf(o1.getDistance());
Double b = Double.valueOf(o2.getDistance());
return a.compareTo(b);
});
}
// if () {
//
// }
return null;