diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/AbstractProgramLogic.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/AbstractProgramLogic.java index 1ab64ddbb..2e7b4525a 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/AbstractProgramLogic.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/AbstractProgramLogic.java @@ -16,9 +16,11 @@ import com.jsowell.common.enums.ykc.*; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.StringUtils; +import com.jsowell.common.util.id.IdUtils; import com.jsowell.pile.domain.*; import com.jsowell.pile.dto.*; import com.jsowell.pile.service.*; +import com.jsowell.pile.transaction.dto.OrderTransactionDTO; import com.jsowell.pile.transaction.service.TransactionService; import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO; import com.jsowell.pile.vo.web.BalanceDeductionAmountVO; @@ -105,6 +107,22 @@ public abstract class AbstractProgramLogic implements InitializingBean { @Autowired 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); } } + + /** + * 保存订单信息到数据库 + * + * @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; + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/DelayMerchantProgramLogic.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/DelayMerchantProgramLogic.java index 044bd2a57..973b7a3a3 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/DelayMerchantProgramLogic.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/DelayMerchantProgramLogic.java @@ -25,14 +25,12 @@ import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.AdapayUtil; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.StringUtils; -import com.jsowell.common.util.id.IdUtils; import com.jsowell.common.util.id.SnowflakeIdWorker; import com.jsowell.pile.domain.*; import com.jsowell.pile.dto.*; import com.jsowell.pile.transaction.dto.OrderTransactionDTO; import com.jsowell.pile.vo.uniapp.MemberVO; import com.jsowell.pile.vo.web.BalanceDeductionAmountVO; -import com.jsowell.pile.vo.web.BillingTemplateVO; import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO; import com.jsowell.wxpay.dto.WechatSendMsgDTO; import org.springframework.cglib.beans.BeanMap; @@ -81,16 +79,16 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic { * * @return */ - private String generateNewOrderCode() { - while (true) { - String orderCode = "C" + IdUtils.getOrderCode(); - // 通过orderCode查询是否已经存在 - OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); - if (orderBasicInfo == null) { - return orderCode; - } - } - } + // private String generateNewOrderCode() { + // while (true) { + // String orderCode = "C" + IdUtils.getOrderCode(); + // // 通过orderCode查询是否已经存在 + // OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + // if (orderBasicInfo == null) { + // return orderCode; + // } + // } + // } /** * 保存订单信息到数据库 @@ -98,96 +96,96 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic { * @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; - } + // 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; + // } @Override public Map payOrder(PayOrderDTO dto) { diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/NotDelayMerchantProgramLogic.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/NotDelayMerchantProgramLogic.java index 01f094102..77d7b3484 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/NotDelayMerchantProgramLogic.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/NotDelayMerchantProgramLogic.java @@ -23,16 +23,13 @@ import com.jsowell.common.enums.adapay.MerchantDelayModeEnum; import com.jsowell.common.enums.ykc.*; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.AdapayUtil; -import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.StringUtils; -import com.jsowell.common.util.id.IdUtils; import com.jsowell.common.util.id.SnowflakeIdWorker; import com.jsowell.pile.domain.*; import com.jsowell.pile.dto.*; import com.jsowell.pile.transaction.dto.OrderTransactionDTO; import com.jsowell.pile.vo.uniapp.MemberVO; import com.jsowell.pile.vo.web.BalanceDeductionAmountVO; -import com.jsowell.pile.vo.web.BillingTemplateVO; import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO; import com.jsowell.wxpay.dto.WechatSendMsgDTO; import org.springframework.cglib.beans.BeanMap; @@ -82,16 +79,16 @@ public class NotDelayMerchantProgramLogic extends AbstractProgramLogic { * * @return */ - private String generateNewOrderCode() { - while (true) { - String orderCode = "C" + IdUtils.getOrderCode(); - // 通过orderCode查询是否已经存在 - OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); - if (orderBasicInfo == null) { - return orderCode; - } - } - } + // private String generateNewOrderCode() { + // while (true) { + // String orderCode = "C" + IdUtils.getOrderCode(); + // // 通过orderCode查询是否已经存在 + // OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + // if (orderBasicInfo == null) { + // return orderCode; + // } + // } + // } /** * 保存订单信息到数据库 @@ -99,96 +96,96 @@ public class NotDelayMerchantProgramLogic extends AbstractProgramLogic { * @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; - } + // 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; + // } @Override public Map payOrder(PayOrderDTO dto) {