update 预约充电

This commit is contained in:
Guoqs
2024-07-30 15:26:11 +08:00
parent 8d3fbda9a2
commit b58c272121
11 changed files with 110 additions and 32 deletions

View File

@@ -3530,7 +3530,10 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
@Override
public OrderBasicInfo saveOrder2Database(GenerateOrderDTO dto) throws ParseException {
String orderCode = generateNewOrderCode();
String transactionCode = IdUtils.generateTransactionCode(dto.getPileSn(), dto.getConnectorCode());
String transactionCode = dto.getTransactionCode();
if (StringUtils.isBlank(transactionCode)) {
transactionCode = IdUtils.generateTransactionCode(dto.getPileSn(), dto.getConnectorCode());
}
if (StringUtils.isBlank(dto.getStartType())) {
dto.setStartType(StartTypeEnum.NOW.getValue());
@@ -3593,31 +3596,35 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
// 订单详情
BillingTemplateVO billingTemplate = dto.getBillingTemplate();
logger.info("订单使用的计费模板-orderCode:{}, billingTemplate:{}", orderCode, JSON.toJSONString(billingTemplate));
BigDecimal sharpElectricityPrice = billingTemplate.getSharpElectricityPrice() != null ? billingTemplate.getSharpElectricityPrice() : BigDecimal.ZERO;
BigDecimal sharpServicePrice = billingTemplate.getSharpServicePrice() != null ? billingTemplate.getSharpServicePrice() : BigDecimal.ZERO;
BigDecimal peakElectricityPrice = billingTemplate.getPeakElectricityPrice() != null ? billingTemplate.getPeakElectricityPrice() : BigDecimal.ZERO;
BigDecimal peakServicePrice = billingTemplate.getPeakServicePrice() != null ? billingTemplate.getPeakServicePrice() : BigDecimal.ZERO;
BigDecimal flatElectricityPrice = billingTemplate.getFlatElectricityPrice() != null ? billingTemplate.getFlatElectricityPrice() : BigDecimal.ZERO;
BigDecimal flatServicePrice = billingTemplate.getFlatServicePrice() != null ? billingTemplate.getFlatServicePrice() : BigDecimal.ZERO;
BigDecimal valleyElectricityPrice = billingTemplate.getValleyElectricityPrice() != null ? billingTemplate.getValleyElectricityPrice() : BigDecimal.ZERO;
BigDecimal valleyServicePrice = billingTemplate.getValleyServicePrice() != null ? billingTemplate.getValleyServicePrice() : BigDecimal.ZERO;
OrderDetail orderDetail = null;
if (billingTemplate != null) {
BigDecimal sharpElectricityPrice = billingTemplate.getSharpElectricityPrice() != null ? billingTemplate.getSharpElectricityPrice() : BigDecimal.ZERO;
BigDecimal sharpServicePrice = billingTemplate.getSharpServicePrice() != null ? billingTemplate.getSharpServicePrice() : BigDecimal.ZERO;
BigDecimal peakElectricityPrice = billingTemplate.getPeakElectricityPrice() != null ? billingTemplate.getPeakElectricityPrice() : BigDecimal.ZERO;
BigDecimal peakServicePrice = billingTemplate.getPeakServicePrice() != null ? billingTemplate.getPeakServicePrice() : BigDecimal.ZERO;
BigDecimal flatElectricityPrice = billingTemplate.getFlatElectricityPrice() != null ? billingTemplate.getFlatElectricityPrice() : BigDecimal.ZERO;
BigDecimal flatServicePrice = billingTemplate.getFlatServicePrice() != null ? billingTemplate.getFlatServicePrice() : BigDecimal.ZERO;
BigDecimal valleyElectricityPrice = billingTemplate.getValleyElectricityPrice() != null ? billingTemplate.getValleyElectricityPrice() : BigDecimal.ZERO;
BigDecimal valleyServicePrice = billingTemplate.getValleyServicePrice() != null ? billingTemplate.getValleyServicePrice() : BigDecimal.ZERO;
OrderDetail orderDetail = OrderDetail.builder()
.orderCode(orderCode)
.sharpPrice(sharpElectricityPrice.add(sharpServicePrice))
.sharpElectricityPrice(sharpElectricityPrice)
.sharpServicePrice(sharpServicePrice)
.peakPrice(peakElectricityPrice.add(peakServicePrice))
.peakElectricityPrice(peakElectricityPrice)
.peakServicePrice(peakServicePrice)
.flatPrice(flatElectricityPrice.add(flatServicePrice))
.flatElectricityPrice(flatElectricityPrice)
.flatServicePrice(flatServicePrice)
.valleyPrice(valleyElectricityPrice.add(valleyServicePrice))
.valleyElectricityPrice(valleyElectricityPrice)
.valleyServicePrice(valleyServicePrice)
.build();
orderDetail = OrderDetail.builder()
.orderCode(orderCode)
.sharpPrice(sharpElectricityPrice.add(sharpServicePrice))
.sharpElectricityPrice(sharpElectricityPrice)
.sharpServicePrice(sharpServicePrice)
.peakPrice(peakElectricityPrice.add(peakServicePrice))
.peakElectricityPrice(peakElectricityPrice)
.peakServicePrice(peakServicePrice)
.flatPrice(flatElectricityPrice.add(flatServicePrice))
.flatElectricityPrice(flatElectricityPrice)
.flatServicePrice(flatServicePrice)
.valleyPrice(valleyElectricityPrice.add(valleyServicePrice))
.valleyElectricityPrice(valleyElectricityPrice)
.valleyServicePrice(valleyServicePrice)
.build();
}
// 保存到数据库
OrderTransactionDTO createOrderTransactionDTO = OrderTransactionDTO.builder()
.orderBasicInfo(orderBasicInfo)
.orderDetail(orderDetail)
@@ -3745,5 +3752,40 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
return orderBasicInfoMapper.getOrderDetailByStationIds(stationIds, startTime, endTime);
}
@Override
public void createReservationOrder(ReservationChargingStartupResult chargingStartupResult) {
String orderCode = generateNewOrderCode();
String transactionCode = chargingStartupResult.getTransactionCode();
String status = StringUtils.equals(chargingStartupResult.getStartupResult(), "00")
? OrderStatusEnum.IN_THE_CHARGING.getValue()
: OrderStatusEnum.ABNORMAL.getValue();
// 订单基本信息
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
.orderCode(orderCode)
.transactionCode(transactionCode)
.orderStatus(status)
.pileSn(chargingStartupResult.getPileSn())
.connectorCode(chargingStartupResult.getConnectorCode())
.pileConnectorCode(chargingStartupResult.getPileSn() + chargingStartupResult.getConnectorCode())
.startMode("6")
.payStatus(Constants.TWO)
.payMode(Constants.THREE)
.orderAmount(BigDecimal.ZERO)
.virtualAmount(BigDecimal.ZERO)
.settleAmount(BigDecimal.ZERO)
.startType(StartTypeEnum.RESERVED.getValue())
.reason(chargingStartupResult.getFailReason())
.build();
// 保存到数据库
OrderTransactionDTO createOrderTransactionDTO = OrderTransactionDTO.builder()
.orderBasicInfo(orderBasicInfo)
.orderDetail(null)
.build();
pileTransactionService.doCreateOrder(createOrderTransactionDTO);
}
}

View File

@@ -90,6 +90,9 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
@Autowired
private WxAppletRemoteService wxAppletRemoteService;
@Autowired
private OrderBasicInfoService orderBasicInfoService;
/**
* 查询设备管理
*
@@ -1218,7 +1221,10 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
*/
@Override
public void startupResult(ReservationChargingStartupResult chargingStartupResult) {
// 创建订单
orderBasicInfoService.createReservationOrder(chargingStartupResult);
// 小程序通知
wxAppletRemoteService.reservationStartupResultSendMsg();
wxAppletRemoteService.reservationStartupResultSendMsg(chargingStartupResult);
}
}