This commit is contained in:
Lemon
2023-07-04 16:38:52 +08:00
3 changed files with 28 additions and 14 deletions

View File

@@ -57,6 +57,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@@ -1059,7 +1060,12 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
// 交易流水号
orderBasicInfo.setTransactionCode(data.getTransactionCode());
// 站点id
orderBasicInfo.setStationId(pileInfoVO.getStationId());
String stationId = pileInfoVO.getStationId();
orderBasicInfo.setStationId(stationId);
// 运营商id
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.valueOf(stationId));
String merchantId = pileStationInfo != null ? String.valueOf(pileStationInfo.getMerchantId()) : "";
orderBasicInfo.setMerchantId(merchantId);
// 充电桩编号
orderBasicInfo.setPileSn(data.getPileSn());
// 枪口号
@@ -1603,9 +1609,10 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
// 通过桩号查询所属站点
PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn);
Long stationId = pileBasicInfo.getStationId();
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(stationId);
String merchantId = pileStationInfo != null ? String.valueOf(pileStationInfo.getMerchantId()) : "";
// 自动余额全部支付订单 个人桩站点不计费
// 将此订单信息存入订单表
String orderCode = IdUtils.getOrderCode();
// 订单基本信息
@@ -1615,6 +1622,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
.orderStatus(OrderStatusEnum.NOT_START.getValue())
.memberId(memberVO.getMemberId())
.stationId(String.valueOf(stationId))
.merchantId(merchantId)
.pileSn(pileSn)
.connectorCode(connectorCode)
.pileConnectorCode(pileSn + connectorCode)
@@ -1704,7 +1712,8 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
// 通过桩号查询所属站点
PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn);
Long stationId = pileBasicInfo.getStationId();
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(stationId);
String merchantId = pileStationInfo != null ? String.valueOf(pileStationInfo.getMerchantId()) : "";
// 将此订单信息存入订单表
// 订单基本信息
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
@@ -1713,6 +1722,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
.orderStatus(OrderStatusEnum.NOT_START.getValue())
// .memberId(memberVO.getMemberId()) // 会员memberId
.stationId(String.valueOf(stationId))
.merchantId(merchantId)
.pileSn(pileSn)
.connectorCode(connectorCode)
.pileConnectorCode(pileConnectorCode)
@@ -1784,8 +1794,8 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
sharp.setServicePrice(orderDetail.getSharpServicePrice());
BigDecimal sharpUsedElectricity = orderDetail.getSharpUsedElectricity() == null ? BigDecimal.ZERO : orderDetail.getSharpUsedElectricity();
sharp.setUsedElectricity(sharpUsedElectricity);
sharp.setElectricityAmount(sharp.getElectricityPrice().multiply(sharp.getUsedElectricity()).setScale(2, BigDecimal.ROUND_DOWN));
sharp.setServiceAmount(sharp.getServicePrice().multiply(sharp.getUsedElectricity()).setScale(2, BigDecimal.ROUND_DOWN));
sharp.setElectricityAmount(sharp.getElectricityPrice().multiply(sharp.getUsedElectricity()).setScale(2, RoundingMode.DOWN));
sharp.setServiceAmount(sharp.getServicePrice().multiply(sharp.getUsedElectricity()).setScale(2, RoundingMode.DOWN));
// 峰时段
OrderPeriodAmountVO peak = new OrderPeriodAmountVO();
@@ -1794,8 +1804,8 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
peak.setServicePrice(orderDetail.getPeakServicePrice());
BigDecimal peakUsedElectricity = orderDetail.getPeakUsedElectricity() == null ? BigDecimal.ZERO : orderDetail.getPeakUsedElectricity();
peak.setUsedElectricity(peakUsedElectricity);
peak.setElectricityAmount(peak.getElectricityPrice().multiply(peak.getUsedElectricity()).setScale(2, BigDecimal.ROUND_DOWN));
peak.setServiceAmount(peak.getServicePrice().multiply(peak.getUsedElectricity()).setScale(2, BigDecimal.ROUND_DOWN));
peak.setElectricityAmount(peak.getElectricityPrice().multiply(peak.getUsedElectricity()).setScale(2, RoundingMode.DOWN));
peak.setServiceAmount(peak.getServicePrice().multiply(peak.getUsedElectricity()).setScale(2, RoundingMode.DOWN));
// 平时段
OrderPeriodAmountVO flat = new OrderPeriodAmountVO();
@@ -1804,8 +1814,8 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
flat.setServicePrice(orderDetail.getFlatServicePrice());
BigDecimal flatUsedElectricity = orderDetail.getFlatUsedElectricity() == null ? BigDecimal.ZERO : orderDetail.getFlatUsedElectricity();
flat.setUsedElectricity(flatUsedElectricity);
flat.setElectricityAmount(flat.getElectricityPrice().multiply(flat.getUsedElectricity()).setScale(2, BigDecimal.ROUND_DOWN));
flat.setServiceAmount(flat.getServicePrice().multiply(flat.getUsedElectricity()).setScale(2, BigDecimal.ROUND_DOWN));
flat.setElectricityAmount(flat.getElectricityPrice().multiply(flat.getUsedElectricity()).setScale(2, RoundingMode.DOWN));
flat.setServiceAmount(flat.getServicePrice().multiply(flat.getUsedElectricity()).setScale(2, RoundingMode.DOWN));
// 谷时段
OrderPeriodAmountVO valley = new OrderPeriodAmountVO();
@@ -1814,8 +1824,8 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
valley.setServicePrice(orderDetail.getValleyServicePrice());
BigDecimal valleyUsedElectricity = orderDetail.getValleyUsedElectricity() == null ? BigDecimal.ZERO : orderDetail.getValleyUsedElectricity();
valley.setUsedElectricity(valleyUsedElectricity);
valley.setElectricityAmount(valley.getElectricityPrice().multiply(valley.getUsedElectricity()).setScale(2, BigDecimal.ROUND_DOWN));
valley.setServiceAmount(valley.getServicePrice().multiply(valley.getUsedElectricity()).setScale(2, BigDecimal.ROUND_DOWN));
valley.setElectricityAmount(valley.getElectricityPrice().multiply(valley.getUsedElectricity()).setScale(2, RoundingMode.DOWN));
valley.setServiceAmount(valley.getServicePrice().multiply(valley.getUsedElectricity()).setScale(2, RoundingMode.DOWN));
return Lists.newArrayList(sharp, peak, flat, valley);
}

View File

@@ -116,8 +116,6 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
if (StringUtils.isNotBlank(pileStationInfo.getQrcodePrefix())) {
vo.setQrcodePrefix(pileStationInfo.getQrcodePrefix());
}
// vo.setMerchantId(pileStationInfo.getMerchantId().toString());
// vo.setMerchantName(pileStationInfo.getmer());
vo.setMerchantAdminName(pileStationInfo.getStationAdminName());
vo.setStationStatus(Integer.parseInt(pileStationInfo.getStationStatus()));
vo.setStationType(pileStationInfo.getStationType());