This commit is contained in:
2023-12-27 14:37:46 +08:00
parent 527e604be9
commit 26be291014
3 changed files with 315 additions and 205 deletions

View File

@@ -16,9 +16,11 @@ import com.jsowell.common.enums.ykc.*;
import com.jsowell.common.exception.BusinessException; import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.id.IdUtils;
import com.jsowell.pile.domain.*; import com.jsowell.pile.domain.*;
import com.jsowell.pile.dto.*; import com.jsowell.pile.dto.*;
import com.jsowell.pile.service.*; import com.jsowell.pile.service.*;
import com.jsowell.pile.transaction.dto.OrderTransactionDTO;
import com.jsowell.pile.transaction.service.TransactionService; import com.jsowell.pile.transaction.service.TransactionService;
import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO; import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO;
import com.jsowell.pile.vo.web.BalanceDeductionAmountVO; import com.jsowell.pile.vo.web.BalanceDeductionAmountVO;
@@ -105,6 +107,22 @@ public abstract class AbstractProgramLogic implements InitializingBean {
@Autowired @Autowired
protected RedisCache redisCache; protected RedisCache redisCache;
/**
* 生成订单编号
*
* @return
*/
protected String generateNewOrderCode() {
while (true) {
String orderCode = "C" + IdUtils.getOrderCode();
// 通过orderCode查询是否已经存在
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
if (orderBasicInfo == null) {
return orderCode;
}
}
}
/** /**
* 生成订单 * 生成订单
*/ */
@@ -579,4 +597,101 @@ public abstract class AbstractProgramLogic implements InitializingBean {
logger.error("解锁vin状态 error,", e); logger.error("解锁vin状态 error,", e);
} }
} }
/**
* 保存订单信息到数据库
*
* @param dto
* @return
*/
protected OrderBasicInfo saveOrder2Database(GenerateOrderDTO dto) throws ParseException {
String orderCode = generateNewOrderCode();
String transactionCode = IdUtils.generateTransactionCode(dto.getPileSn(), dto.getConnectorCode());
if (StringUtils.isBlank(dto.getStartType())) {
dto.setStartType(StartTypeEnum.NOW.getValue());
}
String stationId = dto.getPileConnector().getStationId();
// 查询站点信息
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.valueOf(stationId));
String merchantId = pileStationInfo != null ? String.valueOf(pileStationInfo.getMerchantId()) : "";
String plateNumber = dto.getPlateNumber() != null ? dto.getPlateNumber() : "";
// 订单基本信息
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
.orderCode(orderCode)
.transactionCode(transactionCode)
.orderStatus(OrderStatusEnum.NOT_START.getValue())
.memberId(dto.getMemberId())
.stationId(stationId)
.merchantId(merchantId)
.pileSn(dto.getPileSn())
.connectorCode(dto.getConnectorCode())
.pileConnectorCode(dto.getPileSn() + dto.getConnectorCode())
.startMode(dto.getStartMode())
.payStatus(Constants.ZERO)
.payAmount(dto.getChargeAmount())
.payMode(dto.getPayMode())
.plateNumber(plateNumber)
.orderAmount(BigDecimal.ZERO)
.virtualAmount(BigDecimal.ZERO)
.settleAmount(BigDecimal.ZERO)
.startType(dto.getStartType())
.build();
if (StringUtils.equals(dto.getStartMode(), StartModeEnum.AUTH_CARD.getValue())) {
// 鉴权卡启动
orderBasicInfo.setLogicCard(dto.getPileAuthCardInfo().getLogicCard());
}
if (StringUtils.equals(dto.getStartMode(), StartModeEnum.VIN_CODE.getValue())) {
// vin启动
MemberPlateNumberRelation memberPlateNumberRelation = dto.getMemberPlateNumberRelation();
if (memberPlateNumberRelation != null) {
if (StringUtils.isNotBlank(memberPlateNumberRelation.getVinCode())) {
orderBasicInfo.setVinCode(memberPlateNumberRelation.getVinCode());
}
if (StringUtils.isNotBlank(memberPlateNumberRelation.getLicensePlateNumber())) {
orderBasicInfo.setPlateNumber(memberPlateNumberRelation.getLicensePlateNumber());
}
}
}
if (StringUtils.equals(dto.getStartType(), StartTypeEnum.APPOINTMENT.getValue())) {
orderBasicInfo.setAppointmentTime(DateUtils.parseDate(dto.getAppointmentTime(), DateUtils.YYYY_MM_DD_HH_MM_SS));
}
// 订单详情
BillingTemplateVO billingTemplate = dto.getBillingTemplate();
logger.info("订单使用的计费模板-orderCode:{}, billingTemplate:{}", orderCode, JSONObject.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 = 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)
.build();
transactionService.doCreateOrder(createOrderTransactionDTO);
return orderBasicInfo;
}
} }

View File

@@ -25,14 +25,12 @@ import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.AdapayUtil; import com.jsowell.common.util.AdapayUtil;
import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.id.IdUtils;
import com.jsowell.common.util.id.SnowflakeIdWorker; import com.jsowell.common.util.id.SnowflakeIdWorker;
import com.jsowell.pile.domain.*; import com.jsowell.pile.domain.*;
import com.jsowell.pile.dto.*; import com.jsowell.pile.dto.*;
import com.jsowell.pile.transaction.dto.OrderTransactionDTO; import com.jsowell.pile.transaction.dto.OrderTransactionDTO;
import com.jsowell.pile.vo.uniapp.MemberVO; import com.jsowell.pile.vo.uniapp.MemberVO;
import com.jsowell.pile.vo.web.BalanceDeductionAmountVO; import com.jsowell.pile.vo.web.BalanceDeductionAmountVO;
import com.jsowell.pile.vo.web.BillingTemplateVO;
import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO; import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO;
import com.jsowell.wxpay.dto.WechatSendMsgDTO; import com.jsowell.wxpay.dto.WechatSendMsgDTO;
import org.springframework.cglib.beans.BeanMap; import org.springframework.cglib.beans.BeanMap;
@@ -81,16 +79,16 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
* *
* @return * @return
*/ */
private String generateNewOrderCode() { // private String generateNewOrderCode() {
while (true) { // while (true) {
String orderCode = "C" + IdUtils.getOrderCode(); // String orderCode = "C" + IdUtils.getOrderCode();
// 通过orderCode查询是否已经存在 // // 通过orderCode查询是否已经存在
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); // OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
if (orderBasicInfo == null) { // if (orderBasicInfo == null) {
return orderCode; // return orderCode;
} // }
} // }
} // }
/** /**
* 保存订单信息到数据库 * 保存订单信息到数据库
@@ -98,96 +96,96 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
* @param dto * @param dto
* @return * @return
*/ */
protected OrderBasicInfo saveOrder2Database(GenerateOrderDTO dto) throws ParseException { // protected OrderBasicInfo saveOrder2Database(GenerateOrderDTO dto) throws ParseException {
String orderCode = generateNewOrderCode(); // String orderCode = generateNewOrderCode();
String transactionCode = IdUtils.generateTransactionCode(dto.getPileSn(), dto.getConnectorCode()); // String transactionCode = IdUtils.generateTransactionCode(dto.getPileSn(), dto.getConnectorCode());
//
if (StringUtils.isBlank(dto.getStartType())) { // if (StringUtils.isBlank(dto.getStartType())) {
dto.setStartType(StartTypeEnum.NOW.getValue()); // dto.setStartType(StartTypeEnum.NOW.getValue());
} // }
//
String stationId = dto.getPileConnector().getStationId(); // String stationId = dto.getPileConnector().getStationId();
// 查询站点信息 // // 查询站点信息
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.valueOf(stationId)); // PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.valueOf(stationId));
String merchantId = pileStationInfo != null ? String.valueOf(pileStationInfo.getMerchantId()) : ""; // String merchantId = pileStationInfo != null ? String.valueOf(pileStationInfo.getMerchantId()) : "";
String plateNumber = dto.getPlateNumber() != null ? dto.getPlateNumber() : ""; // String plateNumber = dto.getPlateNumber() != null ? dto.getPlateNumber() : "";
// 订单基本信息 // // 订单基本信息
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder() // OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
.orderCode(orderCode) // .orderCode(orderCode)
.transactionCode(transactionCode) // .transactionCode(transactionCode)
.orderStatus(OrderStatusEnum.NOT_START.getValue()) // .orderStatus(OrderStatusEnum.NOT_START.getValue())
.memberId(dto.getMemberId()) // .memberId(dto.getMemberId())
.stationId(stationId) // .stationId(stationId)
.merchantId(merchantId) // .merchantId(merchantId)
.pileSn(dto.getPileSn()) // .pileSn(dto.getPileSn())
.connectorCode(dto.getConnectorCode()) // .connectorCode(dto.getConnectorCode())
.pileConnectorCode(dto.getPileSn() + dto.getConnectorCode()) // .pileConnectorCode(dto.getPileSn() + dto.getConnectorCode())
.startMode(dto.getStartMode()) // .startMode(dto.getStartMode())
.payStatus(Constants.ZERO) // .payStatus(Constants.ZERO)
.payAmount(dto.getChargeAmount()) // .payAmount(dto.getChargeAmount())
.payMode(dto.getPayMode()) // .payMode(dto.getPayMode())
.plateNumber(plateNumber) // .plateNumber(plateNumber)
.orderAmount(BigDecimal.ZERO) // .orderAmount(BigDecimal.ZERO)
.virtualAmount(BigDecimal.ZERO) // .virtualAmount(BigDecimal.ZERO)
.settleAmount(BigDecimal.ZERO) // .settleAmount(BigDecimal.ZERO)
.startType(dto.getStartType()) // .startType(dto.getStartType())
.build(); // .build();
if (StringUtils.equals(dto.getStartMode(), StartModeEnum.AUTH_CARD.getValue())) { // if (StringUtils.equals(dto.getStartMode(), StartModeEnum.AUTH_CARD.getValue())) {
// 鉴权卡启动 // // 鉴权卡启动
orderBasicInfo.setLogicCard(dto.getPileAuthCardInfo().getLogicCard()); // orderBasicInfo.setLogicCard(dto.getPileAuthCardInfo().getLogicCard());
} // }
if (StringUtils.equals(dto.getStartMode(), StartModeEnum.VIN_CODE.getValue())) { // if (StringUtils.equals(dto.getStartMode(), StartModeEnum.VIN_CODE.getValue())) {
// vin启动 // // vin启动
MemberPlateNumberRelation memberPlateNumberRelation = dto.getMemberPlateNumberRelation(); // MemberPlateNumberRelation memberPlateNumberRelation = dto.getMemberPlateNumberRelation();
if (memberPlateNumberRelation != null) { // if (memberPlateNumberRelation != null) {
if (StringUtils.isNotBlank(memberPlateNumberRelation.getVinCode())) { // if (StringUtils.isNotBlank(memberPlateNumberRelation.getVinCode())) {
orderBasicInfo.setVinCode(memberPlateNumberRelation.getVinCode()); // orderBasicInfo.setVinCode(memberPlateNumberRelation.getVinCode());
} // }
if (StringUtils.isNotBlank(memberPlateNumberRelation.getLicensePlateNumber())) { // if (StringUtils.isNotBlank(memberPlateNumberRelation.getLicensePlateNumber())) {
orderBasicInfo.setPlateNumber(memberPlateNumberRelation.getLicensePlateNumber()); // orderBasicInfo.setPlateNumber(memberPlateNumberRelation.getLicensePlateNumber());
} // }
} // }
} // }
//
if (StringUtils.equals(dto.getStartType(), StartTypeEnum.APPOINTMENT.getValue())) { // if (StringUtils.equals(dto.getStartType(), StartTypeEnum.APPOINTMENT.getValue())) {
orderBasicInfo.setAppointmentTime(DateUtils.parseDate(dto.getAppointmentTime(), DateUtils.YYYY_MM_DD_HH_MM_SS)); // orderBasicInfo.setAppointmentTime(DateUtils.parseDate(dto.getAppointmentTime(), DateUtils.YYYY_MM_DD_HH_MM_SS));
} // }
//
// 订单详情 // // 订单详情
BillingTemplateVO billingTemplate = dto.getBillingTemplate(); // BillingTemplateVO billingTemplate = dto.getBillingTemplate();
logger.info("订单使用的计费模板-orderCode:{}, billingTemplate:{}", orderCode, JSONObject.toJSONString(billingTemplate)); // logger.info("订单使用的计费模板-orderCode:{}, billingTemplate:{}", orderCode, JSONObject.toJSONString(billingTemplate));
BigDecimal sharpElectricityPrice = billingTemplate.getSharpElectricityPrice() != null ? billingTemplate.getSharpElectricityPrice() : BigDecimal.ZERO; // BigDecimal sharpElectricityPrice = billingTemplate.getSharpElectricityPrice() != null ? billingTemplate.getSharpElectricityPrice() : BigDecimal.ZERO;
BigDecimal sharpServicePrice = billingTemplate.getSharpServicePrice() != null ? billingTemplate.getSharpServicePrice() : BigDecimal.ZERO; // BigDecimal sharpServicePrice = billingTemplate.getSharpServicePrice() != null ? billingTemplate.getSharpServicePrice() : BigDecimal.ZERO;
BigDecimal peakElectricityPrice = billingTemplate.getPeakElectricityPrice() != null ? billingTemplate.getPeakElectricityPrice() : BigDecimal.ZERO; // BigDecimal peakElectricityPrice = billingTemplate.getPeakElectricityPrice() != null ? billingTemplate.getPeakElectricityPrice() : BigDecimal.ZERO;
BigDecimal peakServicePrice = billingTemplate.getPeakServicePrice() != null ? billingTemplate.getPeakServicePrice() : BigDecimal.ZERO; // BigDecimal peakServicePrice = billingTemplate.getPeakServicePrice() != null ? billingTemplate.getPeakServicePrice() : BigDecimal.ZERO;
BigDecimal flatElectricityPrice = billingTemplate.getFlatElectricityPrice() != null ? billingTemplate.getFlatElectricityPrice() : BigDecimal.ZERO; // BigDecimal flatElectricityPrice = billingTemplate.getFlatElectricityPrice() != null ? billingTemplate.getFlatElectricityPrice() : BigDecimal.ZERO;
BigDecimal flatServicePrice = billingTemplate.getFlatServicePrice() != null ? billingTemplate.getFlatServicePrice() : BigDecimal.ZERO; // BigDecimal flatServicePrice = billingTemplate.getFlatServicePrice() != null ? billingTemplate.getFlatServicePrice() : BigDecimal.ZERO;
BigDecimal valleyElectricityPrice = billingTemplate.getValleyElectricityPrice() != null ? billingTemplate.getValleyElectricityPrice() : BigDecimal.ZERO; // BigDecimal valleyElectricityPrice = billingTemplate.getValleyElectricityPrice() != null ? billingTemplate.getValleyElectricityPrice() : BigDecimal.ZERO;
BigDecimal valleyServicePrice = billingTemplate.getValleyServicePrice() != null ? billingTemplate.getValleyServicePrice() : BigDecimal.ZERO; // BigDecimal valleyServicePrice = billingTemplate.getValleyServicePrice() != null ? billingTemplate.getValleyServicePrice() : BigDecimal.ZERO;
//
OrderDetail orderDetail = OrderDetail.builder() // OrderDetail orderDetail = OrderDetail.builder()
.orderCode(orderCode) // .orderCode(orderCode)
.sharpPrice(sharpElectricityPrice.add(sharpServicePrice)) // .sharpPrice(sharpElectricityPrice.add(sharpServicePrice))
.sharpElectricityPrice(sharpElectricityPrice) // .sharpElectricityPrice(sharpElectricityPrice)
.sharpServicePrice(sharpServicePrice) // .sharpServicePrice(sharpServicePrice)
.peakPrice(peakElectricityPrice.add(peakServicePrice)) // .peakPrice(peakElectricityPrice.add(peakServicePrice))
.peakElectricityPrice(peakElectricityPrice) // .peakElectricityPrice(peakElectricityPrice)
.peakServicePrice(peakServicePrice) // .peakServicePrice(peakServicePrice)
.flatPrice(flatElectricityPrice.add(flatServicePrice)) // .flatPrice(flatElectricityPrice.add(flatServicePrice))
.flatElectricityPrice(flatElectricityPrice) // .flatElectricityPrice(flatElectricityPrice)
.flatServicePrice(flatServicePrice) // .flatServicePrice(flatServicePrice)
.valleyPrice(valleyElectricityPrice.add(valleyServicePrice)) // .valleyPrice(valleyElectricityPrice.add(valleyServicePrice))
.valleyElectricityPrice(valleyElectricityPrice) // .valleyElectricityPrice(valleyElectricityPrice)
.valleyServicePrice(valleyServicePrice) // .valleyServicePrice(valleyServicePrice)
.build(); // .build();
//
OrderTransactionDTO createOrderTransactionDTO = OrderTransactionDTO.builder() // OrderTransactionDTO createOrderTransactionDTO = OrderTransactionDTO.builder()
.orderBasicInfo(orderBasicInfo) // .orderBasicInfo(orderBasicInfo)
.orderDetail(orderDetail) // .orderDetail(orderDetail)
.build(); // .build();
transactionService.doCreateOrder(createOrderTransactionDTO); // transactionService.doCreateOrder(createOrderTransactionDTO);
return orderBasicInfo; // return orderBasicInfo;
} // }
@Override @Override
public Map<String, Object> payOrder(PayOrderDTO dto) { public Map<String, Object> payOrder(PayOrderDTO dto) {

View File

@@ -23,16 +23,13 @@ import com.jsowell.common.enums.adapay.MerchantDelayModeEnum;
import com.jsowell.common.enums.ykc.*; import com.jsowell.common.enums.ykc.*;
import com.jsowell.common.exception.BusinessException; import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.AdapayUtil; import com.jsowell.common.util.AdapayUtil;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.StringUtils; import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.id.IdUtils;
import com.jsowell.common.util.id.SnowflakeIdWorker; import com.jsowell.common.util.id.SnowflakeIdWorker;
import com.jsowell.pile.domain.*; import com.jsowell.pile.domain.*;
import com.jsowell.pile.dto.*; import com.jsowell.pile.dto.*;
import com.jsowell.pile.transaction.dto.OrderTransactionDTO; import com.jsowell.pile.transaction.dto.OrderTransactionDTO;
import com.jsowell.pile.vo.uniapp.MemberVO; import com.jsowell.pile.vo.uniapp.MemberVO;
import com.jsowell.pile.vo.web.BalanceDeductionAmountVO; import com.jsowell.pile.vo.web.BalanceDeductionAmountVO;
import com.jsowell.pile.vo.web.BillingTemplateVO;
import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO; import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO;
import com.jsowell.wxpay.dto.WechatSendMsgDTO; import com.jsowell.wxpay.dto.WechatSendMsgDTO;
import org.springframework.cglib.beans.BeanMap; import org.springframework.cglib.beans.BeanMap;
@@ -82,16 +79,16 @@ public class NotDelayMerchantProgramLogic extends AbstractProgramLogic {
* *
* @return * @return
*/ */
private String generateNewOrderCode() { // private String generateNewOrderCode() {
while (true) { // while (true) {
String orderCode = "C" + IdUtils.getOrderCode(); // String orderCode = "C" + IdUtils.getOrderCode();
// 通过orderCode查询是否已经存在 // // 通过orderCode查询是否已经存在
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); // OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
if (orderBasicInfo == null) { // if (orderBasicInfo == null) {
return orderCode; // return orderCode;
} // }
} // }
} // }
/** /**
* 保存订单信息到数据库 * 保存订单信息到数据库
@@ -99,96 +96,96 @@ public class NotDelayMerchantProgramLogic extends AbstractProgramLogic {
* @param dto * @param dto
* @return * @return
*/ */
protected OrderBasicInfo saveOrder2Database(GenerateOrderDTO dto) throws ParseException { // protected OrderBasicInfo saveOrder2Database(GenerateOrderDTO dto) throws ParseException {
String orderCode = generateNewOrderCode(); // String orderCode = generateNewOrderCode();
String transactionCode = IdUtils.generateTransactionCode(dto.getPileSn(), dto.getConnectorCode()); // String transactionCode = IdUtils.generateTransactionCode(dto.getPileSn(), dto.getConnectorCode());
//
if (StringUtils.isBlank(dto.getStartType())) { // if (StringUtils.isBlank(dto.getStartType())) {
dto.setStartType(StartTypeEnum.NOW.getValue()); // dto.setStartType(StartTypeEnum.NOW.getValue());
} // }
//
String stationId = dto.getPileConnector().getStationId(); // String stationId = dto.getPileConnector().getStationId();
// 查询站点信息 // // 查询站点信息
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.valueOf(stationId)); // PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.valueOf(stationId));
String merchantId = pileStationInfo != null ? String.valueOf(pileStationInfo.getMerchantId()) : ""; // String merchantId = pileStationInfo != null ? String.valueOf(pileStationInfo.getMerchantId()) : "";
String plateNumber = dto.getPlateNumber() != null ? dto.getPlateNumber() : ""; // String plateNumber = dto.getPlateNumber() != null ? dto.getPlateNumber() : "";
// 订单基本信息 // // 订单基本信息
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder() // OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
.orderCode(orderCode) // .orderCode(orderCode)
.transactionCode(transactionCode) // .transactionCode(transactionCode)
.orderStatus(OrderStatusEnum.NOT_START.getValue()) // .orderStatus(OrderStatusEnum.NOT_START.getValue())
.memberId(dto.getMemberId()) // .memberId(dto.getMemberId())
.stationId(stationId) // .stationId(stationId)
.merchantId(merchantId) // .merchantId(merchantId)
.pileSn(dto.getPileSn()) // .pileSn(dto.getPileSn())
.connectorCode(dto.getConnectorCode()) // .connectorCode(dto.getConnectorCode())
.pileConnectorCode(dto.getPileSn() + dto.getConnectorCode()) // .pileConnectorCode(dto.getPileSn() + dto.getConnectorCode())
.startMode(dto.getStartMode()) // .startMode(dto.getStartMode())
.payStatus(Constants.ZERO) // .payStatus(Constants.ZERO)
.payAmount(dto.getChargeAmount()) // .payAmount(dto.getChargeAmount())
.payMode(dto.getPayMode()) // .payMode(dto.getPayMode())
.plateNumber(plateNumber) // .plateNumber(plateNumber)
.orderAmount(BigDecimal.ZERO) // .orderAmount(BigDecimal.ZERO)
.virtualAmount(BigDecimal.ZERO) // .virtualAmount(BigDecimal.ZERO)
.settleAmount(BigDecimal.ZERO) // .settleAmount(BigDecimal.ZERO)
.startType(dto.getStartType()) // .startType(dto.getStartType())
.build(); // .build();
if (StringUtils.equals(dto.getStartMode(), StartModeEnum.AUTH_CARD.getValue())) { // if (StringUtils.equals(dto.getStartMode(), StartModeEnum.AUTH_CARD.getValue())) {
// 鉴权卡启动 // // 鉴权卡启动
orderBasicInfo.setLogicCard(dto.getPileAuthCardInfo().getLogicCard()); // orderBasicInfo.setLogicCard(dto.getPileAuthCardInfo().getLogicCard());
} // }
if (StringUtils.equals(dto.getStartMode(), StartModeEnum.VIN_CODE.getValue())) { // if (StringUtils.equals(dto.getStartMode(), StartModeEnum.VIN_CODE.getValue())) {
// vin启动 // // vin启动
MemberPlateNumberRelation memberPlateNumberRelation = dto.getMemberPlateNumberRelation(); // MemberPlateNumberRelation memberPlateNumberRelation = dto.getMemberPlateNumberRelation();
if (memberPlateNumberRelation != null) { // if (memberPlateNumberRelation != null) {
if (StringUtils.isNotBlank(memberPlateNumberRelation.getVinCode())) { // if (StringUtils.isNotBlank(memberPlateNumberRelation.getVinCode())) {
orderBasicInfo.setVinCode(memberPlateNumberRelation.getVinCode()); // orderBasicInfo.setVinCode(memberPlateNumberRelation.getVinCode());
} // }
if (StringUtils.isNotBlank(memberPlateNumberRelation.getLicensePlateNumber())) { // if (StringUtils.isNotBlank(memberPlateNumberRelation.getLicensePlateNumber())) {
orderBasicInfo.setPlateNumber(memberPlateNumberRelation.getLicensePlateNumber()); // orderBasicInfo.setPlateNumber(memberPlateNumberRelation.getLicensePlateNumber());
} // }
} // }
} // }
//
if (StringUtils.equals(dto.getStartType(), StartTypeEnum.APPOINTMENT.getValue())) { // if (StringUtils.equals(dto.getStartType(), StartTypeEnum.APPOINTMENT.getValue())) {
orderBasicInfo.setAppointmentTime(DateUtils.parseDate(dto.getAppointmentTime(), DateUtils.YYYY_MM_DD_HH_MM_SS)); // orderBasicInfo.setAppointmentTime(DateUtils.parseDate(dto.getAppointmentTime(), DateUtils.YYYY_MM_DD_HH_MM_SS));
} // }
//
// 订单详情 // // 订单详情
BillingTemplateVO billingTemplate = dto.getBillingTemplate(); // BillingTemplateVO billingTemplate = dto.getBillingTemplate();
logger.info("订单使用的计费模板-orderCode:{}, billingTemplate:{}", orderCode, JSONObject.toJSONString(billingTemplate)); // logger.info("订单使用的计费模板-orderCode:{}, billingTemplate:{}", orderCode, JSONObject.toJSONString(billingTemplate));
BigDecimal sharpElectricityPrice = billingTemplate.getSharpElectricityPrice() != null ? billingTemplate.getSharpElectricityPrice() : BigDecimal.ZERO; // BigDecimal sharpElectricityPrice = billingTemplate.getSharpElectricityPrice() != null ? billingTemplate.getSharpElectricityPrice() : BigDecimal.ZERO;
BigDecimal sharpServicePrice = billingTemplate.getSharpServicePrice() != null ? billingTemplate.getSharpServicePrice() : BigDecimal.ZERO; // BigDecimal sharpServicePrice = billingTemplate.getSharpServicePrice() != null ? billingTemplate.getSharpServicePrice() : BigDecimal.ZERO;
BigDecimal peakElectricityPrice = billingTemplate.getPeakElectricityPrice() != null ? billingTemplate.getPeakElectricityPrice() : BigDecimal.ZERO; // BigDecimal peakElectricityPrice = billingTemplate.getPeakElectricityPrice() != null ? billingTemplate.getPeakElectricityPrice() : BigDecimal.ZERO;
BigDecimal peakServicePrice = billingTemplate.getPeakServicePrice() != null ? billingTemplate.getPeakServicePrice() : BigDecimal.ZERO; // BigDecimal peakServicePrice = billingTemplate.getPeakServicePrice() != null ? billingTemplate.getPeakServicePrice() : BigDecimal.ZERO;
BigDecimal flatElectricityPrice = billingTemplate.getFlatElectricityPrice() != null ? billingTemplate.getFlatElectricityPrice() : BigDecimal.ZERO; // BigDecimal flatElectricityPrice = billingTemplate.getFlatElectricityPrice() != null ? billingTemplate.getFlatElectricityPrice() : BigDecimal.ZERO;
BigDecimal flatServicePrice = billingTemplate.getFlatServicePrice() != null ? billingTemplate.getFlatServicePrice() : BigDecimal.ZERO; // BigDecimal flatServicePrice = billingTemplate.getFlatServicePrice() != null ? billingTemplate.getFlatServicePrice() : BigDecimal.ZERO;
BigDecimal valleyElectricityPrice = billingTemplate.getValleyElectricityPrice() != null ? billingTemplate.getValleyElectricityPrice() : BigDecimal.ZERO; // BigDecimal valleyElectricityPrice = billingTemplate.getValleyElectricityPrice() != null ? billingTemplate.getValleyElectricityPrice() : BigDecimal.ZERO;
BigDecimal valleyServicePrice = billingTemplate.getValleyServicePrice() != null ? billingTemplate.getValleyServicePrice() : BigDecimal.ZERO; // BigDecimal valleyServicePrice = billingTemplate.getValleyServicePrice() != null ? billingTemplate.getValleyServicePrice() : BigDecimal.ZERO;
//
OrderDetail orderDetail = OrderDetail.builder() // OrderDetail orderDetail = OrderDetail.builder()
.orderCode(orderCode) // .orderCode(orderCode)
.sharpPrice(sharpElectricityPrice.add(sharpServicePrice)) // .sharpPrice(sharpElectricityPrice.add(sharpServicePrice))
.sharpElectricityPrice(sharpElectricityPrice) // .sharpElectricityPrice(sharpElectricityPrice)
.sharpServicePrice(sharpServicePrice) // .sharpServicePrice(sharpServicePrice)
.peakPrice(peakElectricityPrice.add(peakServicePrice)) // .peakPrice(peakElectricityPrice.add(peakServicePrice))
.peakElectricityPrice(peakElectricityPrice) // .peakElectricityPrice(peakElectricityPrice)
.peakServicePrice(peakServicePrice) // .peakServicePrice(peakServicePrice)
.flatPrice(flatElectricityPrice.add(flatServicePrice)) // .flatPrice(flatElectricityPrice.add(flatServicePrice))
.flatElectricityPrice(flatElectricityPrice) // .flatElectricityPrice(flatElectricityPrice)
.flatServicePrice(flatServicePrice) // .flatServicePrice(flatServicePrice)
.valleyPrice(valleyElectricityPrice.add(valleyServicePrice)) // .valleyPrice(valleyElectricityPrice.add(valleyServicePrice))
.valleyElectricityPrice(valleyElectricityPrice) // .valleyElectricityPrice(valleyElectricityPrice)
.valleyServicePrice(valleyServicePrice) // .valleyServicePrice(valleyServicePrice)
.build(); // .build();
//
OrderTransactionDTO createOrderTransactionDTO = OrderTransactionDTO.builder() // OrderTransactionDTO createOrderTransactionDTO = OrderTransactionDTO.builder()
.orderBasicInfo(orderBasicInfo) // .orderBasicInfo(orderBasicInfo)
.orderDetail(orderDetail) // .orderDetail(orderDetail)
.build(); // .build();
transactionService.doCreateOrder(createOrderTransactionDTO); // transactionService.doCreateOrder(createOrderTransactionDTO);
return orderBasicInfo; // return orderBasicInfo;
} // }
@Override @Override
public Map<String, Object> payOrder(PayOrderDTO dto) { public Map<String, Object> payOrder(PayOrderDTO dto) {