显示vip价格

This commit is contained in:
2024-02-22 14:46:54 +08:00
parent 2dcc224d99
commit 6d8be9c640
7 changed files with 171 additions and 5 deletions

View File

@@ -64,6 +64,7 @@ import com.jsowell.pile.transaction.service.TransactionService;
import com.jsowell.pile.util.SnUtils; import com.jsowell.pile.util.SnUtils;
import com.jsowell.pile.vo.base.MemberWalletVO; import com.jsowell.pile.vo.base.MemberWalletVO;
import com.jsowell.pile.vo.base.PileInfoVO; import com.jsowell.pile.vo.base.PileInfoVO;
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
import com.jsowell.pile.vo.uniapp.MemberVO; import com.jsowell.pile.vo.uniapp.MemberVO;
import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO; import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO;
import com.jsowell.pile.vo.web.*; import com.jsowell.pile.vo.web.*;
@@ -249,6 +250,16 @@ public class SpringBootTestController {
@Autowired @Autowired
private HuaWeiService huaWeiService; private HuaWeiService huaWeiService;
@Test
public void queryBillingPriceTest() {
String stationId = "19";
List<BillingPriceVO> billingPriceVOS = pileBillingTemplateService.queryBillingPriceOld(stationId);
System.out.println("老版:" + JSON.toJSONString(billingPriceVOS));
List<BillingPriceVO> billingPriceVOS1 = pileBillingTemplateService.queryBillingPrice(stationId);
System.out.println("新版:" + JSON.toJSONString(billingPriceVOS1));
}
@Test @Test
public void queryPaymentRefundTest() { public void queryPaymentRefundTest() {
String paymentId = "002212023122615542010585629628950949888"; String paymentId = "002212023122615542010585629628950949888";

View File

@@ -115,6 +115,9 @@ public interface PileBillingTemplateService {
*/ */
List<BillingPriceVO> queryBillingPrice(String stationId); List<BillingPriceVO> queryBillingPrice(String stationId);
List<BillingPriceVO> queryBillingPriceOld(String stationId);
/** /**
* 通过桩sn号查询计费模板信息 * 通过桩sn号查询计费模板信息
* *

View File

@@ -42,6 +42,7 @@ import java.math.BigDecimal;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -371,7 +372,6 @@ public class PileBillingTemplateServiceImpl implements PileBillingTemplateServic
LocalTime localTime = LocalTime.now(); LocalTime localTime = LocalTime.now();
String now = LocalTime.of(localTime.getHour(), localTime.getMinute(), localTime.getSecond()).toString(); String now = LocalTime.of(localTime.getHour(), localTime.getMinute(), localTime.getSecond()).toString();
// 通过站点id查询计费模板 // 通过站点id查询计费模板
// BillingTemplateVO billingTemplateVO = pileBillingTemplateMapper.selectBillingTemplateByStationId(stationId);
BillingTemplateVO billingTemplateVO = queryUsedBillingTemplate(stationId); BillingTemplateVO billingTemplateVO = queryUsedBillingTemplate(stationId);
if (Objects.nonNull(billingTemplateVO)) { if (Objects.nonNull(billingTemplateVO)) {
result = new CurrentTimePriceDetails(); result = new CurrentTimePriceDetails();
@@ -380,7 +380,6 @@ public class PileBillingTemplateServiceImpl implements PileBillingTemplateServic
result.setDateTime(localTime.toString()); result.setDateTime(localTime.toString());
result.setFreeTime(billingTemplateVO.getFreeTime()); result.setFreeTime(billingTemplateVO.getFreeTime());
result.setOccupyFee(billingTemplateVO.getOccupyFee()); result.setOccupyFee(billingTemplateVO.getOccupyFee());
List<BillingDetailVO> billingDetailList = billingTemplateVO.getBillingDetailList(); List<BillingDetailVO> billingDetailList = billingTemplateVO.getBillingDetailList();
for (BillingDetailVO detailVO : billingDetailList) { for (BillingDetailVO detailVO : billingDetailList) {
List<String> applyTimeList = detailVO.getApplyTime(); List<String> applyTimeList = detailVO.getApplyTime();
@@ -390,7 +389,6 @@ public class PileBillingTemplateServiceImpl implements PileBillingTemplateServic
// 将桩的费率存入stationVO // 将桩的费率存入stationVO
BigDecimal electricityPrice = detailVO.getElectricityPrice(); BigDecimal electricityPrice = detailVO.getElectricityPrice();
BigDecimal servicePrice = detailVO.getServicePrice(); BigDecimal servicePrice = detailVO.getServicePrice();
result.setElectricityPrice(electricityPrice.toString()); result.setElectricityPrice(electricityPrice.toString());
result.setServicePrice(servicePrice.toString()); result.setServicePrice(servicePrice.toString());
result.setTotalPrice(electricityPrice.add(servicePrice).toString()); result.setTotalPrice(electricityPrice.add(servicePrice).toString());
@@ -398,6 +396,27 @@ public class PileBillingTemplateServiceImpl implements PileBillingTemplateServic
} }
} }
} }
// 查询站点的集团会员计费模板
BillingTemplateVO preferentialBillingTemplate = this.queryPreferentialBillingTemplate(stationId);
if (Objects.nonNull(preferentialBillingTemplate) && Objects.nonNull(result) ) {
List<BillingDetailVO> billingDetailList = billingTemplateVO.getBillingDetailList();
for (BillingDetailVO detailVO : billingDetailList) {
List<String> applyTimeList = detailVO.getApplyTime();
for (String applyTime : applyTimeList) {
boolean b = DateUtils.checkTime(now + "-" + now, applyTime);
if (b) {
// 将桩的费率存入stationVO
BigDecimal electricityPrice = detailVO.getElectricityPrice();
BigDecimal servicePrice = detailVO.getServicePrice();
result.setVipElectricityPrice(electricityPrice.toString());
result.setVipServicePrice(servicePrice.toString());
result.setVipTotalPrice(electricityPrice.add(servicePrice).toString());
}
}
}
}
// log.info("通过站点id查询当前时间的收费详情 stationId:{}, result:{}", stationId, JSON.toJSONString(result)); // log.info("通过站点id查询当前时间的收费详情 stationId:{}, result:{}", stationId, JSON.toJSONString(result));
return result; return result;
} }
@@ -477,6 +496,11 @@ public class PileBillingTemplateServiceImpl implements PileBillingTemplateServic
return 1; return 1;
} }
/**
* 根据站点id查询优惠计费模板
* @param stationId
* @return
*/
@Override @Override
public BillingTemplateVO queryPreferentialBillingTemplate(String stationId) { public BillingTemplateVO queryPreferentialBillingTemplate(String stationId) {
return pileBillingTemplateMapper.queryPreferentialBillingTemplate(stationId); return pileBillingTemplateMapper.queryPreferentialBillingTemplate(stationId);
@@ -611,7 +635,7 @@ public class PileBillingTemplateServiceImpl implements PileBillingTemplateServic
* @return * @return
*/ */
@Override @Override
public List<BillingPriceVO> queryBillingPrice(String stationId) { public List<BillingPriceVO> queryBillingPriceOld(String stationId) {
// 查询站点当前计费模板 有缓存 // 查询站点当前计费模板 有缓存
BillingTemplateVO billingTemplateVO = queryUsedBillingTemplate(stationId); BillingTemplateVO billingTemplateVO = queryUsedBillingTemplate(stationId);
if (billingTemplateVO == null) { if (billingTemplateVO == null) {
@@ -663,6 +687,85 @@ public class PileBillingTemplateServiceImpl implements PileBillingTemplateServic
return resultList; return resultList;
} }
@Override
public List<BillingPriceVO> queryBillingPrice(String stationId) {
// 查询站点当前计费模板 有缓存
BillingTemplateVO billingTemplateVO = queryUsedBillingTemplate(stationId);
if (billingTemplateVO == null) {
return Lists.newArrayList();
}
Map<String, BillingDetailVO> billingDetailVOMap = Maps.newHashMap();
Map<String, BillingDetailVO> preferentialBillingDetailVOMap = Maps.newHashMap();
List<BillingDetailVO> billingDetailList = billingTemplateVO.getBillingDetailList();
if (CollectionUtils.isNotEmpty(billingDetailList)) {
billingDetailVOMap = billingDetailList.stream().collect(Collectors.toMap(BillingDetailVO::getTimeType, Function.identity(), (k1, k2) -> k1));
}
// 查询站点的集团会员计费模板
BillingTemplateVO preferentialBillingTemplate = queryPreferentialBillingTemplate(stationId);
if (preferentialBillingTemplate != null) {
List<BillingDetailVO> preferentialBillingDetailList = preferentialBillingTemplate.getBillingDetailList();
if (CollectionUtils.isNotEmpty(preferentialBillingDetailList)) {
preferentialBillingDetailVOMap = preferentialBillingDetailList.stream().collect(Collectors.toMap(BillingDetailVO::getTimeType, Function.identity(), (k1, k2) -> k1));
}
}
//
EchoBillingTemplateVO echoBillingTemplateVO = queryPileBillingTemplateById(Long.parseLong(billingTemplateVO.getTemplateId()));
// 时段清单
List<BillingTimeDTO> timeArray = echoBillingTemplateVO.getTimeArray();
log.info("计费模板时段:{}", JSONObject.toJSONString(timeArray));
List<BillingPriceVO> resultList = Lists.newArrayList();
for (BillingTimeDTO billingTimeDTO : timeArray) {
BillingPriceVO vo = new BillingPriceVO();
String type = billingTimeDTO.getType();
// 普通计费模板价格
BillingDetailVO billingDetailVO = billingDetailVOMap.get(type);
if (Objects.nonNull(billingDetailVO)) {
// 电费
vo.setElectricityPrice(billingDetailVO.getElectricityPrice().toString());
// 服务费
vo.setServicePrice(billingDetailVO.getServicePrice().toString());
// 总费用
vo.setTotalPrice(billingDetailVO.getElectricityPrice().add(billingDetailVO.getServicePrice()).toString());
}
// 优惠计费模板价格
BillingDetailVO preferentialBillingDetailVO = preferentialBillingDetailVOMap.get(type);
if (Objects.nonNull(preferentialBillingDetailVO)) {
// vip电费
vo.setVipElectricityPrice(preferentialBillingDetailVO.getElectricityPrice().toString());
// vip服务费
vo.setVipServicePrice(preferentialBillingDetailVO.getServicePrice().toString());
// vip总费用
vo.setVipTotalPrice(preferentialBillingDetailVO.getElectricityPrice().add(preferentialBillingDetailVO.getServicePrice()).toString());
}
// 计费模板id
vo.setTemplateId(billingTemplateVO.getTemplateId());
// 计费模板编号
vo.setTemplateCode(billingTemplateVO.getTemplateCode());
// 发布时间
vo.setPublishTime(billingTemplateVO.getPublishTime());
// 开始时间
vo.setStartTime(billingTimeDTO.getStartTime());
// 结束时间
String endTime = StringUtils.equals("24:00", billingTimeDTO.getEndTime()) ? "23:59" : billingTimeDTO.getEndTime();
vo.setEndTime(endTime);
// 时段类型
vo.setTimeType(type);
// 是否当前时间
boolean in = DateUtils.isIn(LocalTime.now(), LocalTime.parse(vo.getStartTime()), LocalTime.parse(vo.getEndTime()));
vo.setIsCurrentTime(in ? Constants.ONE : Constants.ZERO);
resultList.add(vo);
}
return resultList;
}
public static void main(String[] args) { public static void main(String[] args) {
// 21:30-23:00 // 21:30-23:00
String startTime = "01:30"; String startTime = "01:30";

View File

@@ -510,6 +510,10 @@ public class PileStationInfoServiceImpl implements PileStationInfoService {
stationVO.setTotalPrice(currentTimePriceDetails.getTotalPrice()); stationVO.setTotalPrice(currentTimePriceDetails.getTotalPrice());
stationVO.setFreeTime(currentTimePriceDetails.getFreeTime()); stationVO.setFreeTime(currentTimePriceDetails.getFreeTime());
stationVO.setOccupyFee(currentTimePriceDetails.getOccupyFee()); stationVO.setOccupyFee(currentTimePriceDetails.getOccupyFee());
// vip价
stationVO.setVipElectricityPrice(currentTimePriceDetails.getVipElectricityPrice());
stationVO.setVipServicePrice(currentTimePriceDetails.getVipServicePrice());
stationVO.setVipTotalPrice(currentTimePriceDetails.getVipTotalPrice());
} }
stationVOList.add(stationVO); stationVOList.add(stationVO);
} }

View File

@@ -58,6 +58,21 @@ public class StationInfoVO {
*/ */
private String totalPrice; private String totalPrice;
/**
* vip电费
*/
private String vipElectricityPrice;
/**
* 服务费 每度单价
*/
private String vipServicePrice;
/**
* 电费 + 服务费 每度单价
*/
private String vipTotalPrice;
/** /**
* 停车费率描述 * 停车费率描述
*/ */

View File

@@ -42,6 +42,21 @@ public class BillingPriceVO {
*/ */
private String totalPrice; private String totalPrice;
/**
* vip电费
*/
private String vipElectricityPrice;
/**
* 服务费 每度单价
*/
private String vipServicePrice;
/**
* 电费 + 服务费 每度单价
*/
private String vipTotalPrice;
/** /**
* 时段类型1-尖时2-峰时3-平时4-谷时) * 时段类型1-尖时2-峰时3-平时4-谷时)
* @see BillingTimeTypeEnum * @see BillingTimeTypeEnum

View File

@@ -42,6 +42,21 @@ public class CurrentTimePriceDetails {
*/ */
private String totalPrice; private String totalPrice;
/**
* vip电费
*/
private String vipElectricityPrice;
/**
* 服务费 每度单价
*/
private String vipServicePrice;
/**
* 电费 + 服务费 每度单价
*/
private String vipTotalPrice;
/** /**
* 占桩免费时长 * 占桩免费时长
*/ */