diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderBasicInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderBasicInfoService.java index eceea1990..642786870 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderBasicInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/OrderBasicInfoService.java @@ -77,7 +77,9 @@ public interface OrderBasicInfoService{ */ List selectChargingOrder(String pileSn); - public OrderBasicInfo saveOrder2Database(GenerateOrderDTO dto) throws ParseException; + void checkPileInfo(GenerateOrderDTO dto); + + OrderBasicInfo saveOrder2Database(GenerateOrderDTO dto) throws ParseException; /** * 修改订单 diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java index 315f5a72d..cf41ba1ef 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java @@ -3422,7 +3422,8 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { * * @param dto */ - private void checkPileInfo(GenerateOrderDTO dto) { + @Override + public void checkPileInfo(GenerateOrderDTO dto) { // 查询充电桩状态 是否空闲 枪口是否占用 PileConnectorDetailVO pileConnector = pileBasicInfoService.queryPileConnectorDetail(dto.getPileSn() + dto.getConnectorCode()); if (pileConnector == null) { @@ -3471,6 +3472,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { * @param dto * @return */ + @Override public OrderBasicInfo saveOrder2Database(GenerateOrderDTO dto) throws ParseException { String orderCode = generateNewOrderCode(); String transactionCode = IdUtils.generateTransactionCode(dto.getPileSn(), dto.getConnectorCode()); @@ -3497,7 +3499,7 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { .pileConnectorCode(dto.getPileSn() + dto.getConnectorCode()) .startMode(dto.getStartMode()) .payStatus(Constants.ZERO) - // .payAmount(dto.getChargeAmount()) // 支付完成后填入支付金额 + .payAmount(dto.getChargeAmount()) // 支付完成后填入支付金额 .payMode(dto.getPayMode()) .plateNumber(plateNumber) .orderAmount(BigDecimal.ZERO) 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 8899866fb..6252bba1f 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 @@ -19,10 +19,8 @@ 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.MemberVO; -import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO; import com.jsowell.pile.vo.web.*; import com.jsowell.wxpay.dto.WechatSendMsgDTO; import com.jsowell.wxpay.service.WxAppletRemoteService; @@ -297,30 +295,30 @@ public abstract class AbstractProgramLogic implements InitializingBean { * * @param dto */ - protected void analysisPileParameter(BasicPileDTO dto) { - if (StringUtils.isBlank(dto.getPileSn()) || StringUtils.isBlank(dto.getConnectorCode())) { - // 从pileConnectorCode解析 - String pileConnectorCode = dto.getPileConnectorCode(); - if (StringUtils.isNotEmpty(pileConnectorCode) && pileConnectorCode.length() == Constants.PILE_CONNECTOR_CODE_LENGTH) { - dto.setPileSn(StringUtils.substring(pileConnectorCode, 0, pileConnectorCode.length() - 2)); - dto.setConnectorCode(StringUtils.substring(pileConnectorCode, pileConnectorCode.length() - 2, pileConnectorCode.length())); - } else { - throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR); - } - } else { - // 说明pileSn 和 connectorCode前端传了,那就校验一下长度 - if (dto.getPileSn().length() != Constants.PILE_SN_LENGTH || dto.getConnectorCode().length() != Constants.CONNECTOR_CODE_LENGTH) { - throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR); - } - } - } + // protected void analysisPileParameter(BasicPileDTO dto) { + // if (StringUtils.isBlank(dto.getPileSn()) || StringUtils.isBlank(dto.getConnectorCode())) { + // // 从pileConnectorCode解析 + // String pileConnectorCode = dto.getPileConnectorCode(); + // if (StringUtils.isNotEmpty(pileConnectorCode) && pileConnectorCode.length() == Constants.PILE_CONNECTOR_CODE_LENGTH) { + // dto.setPileSn(StringUtils.substring(pileConnectorCode, 0, pileConnectorCode.length() - 2)); + // dto.setConnectorCode(StringUtils.substring(pileConnectorCode, pileConnectorCode.length() - 2, pileConnectorCode.length())); + // } else { + // throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR); + // } + // } else { + // // 说明pileSn 和 connectorCode前端传了,那就校验一下长度 + // if (dto.getPileSn().length() != Constants.PILE_SN_LENGTH || dto.getConnectorCode().length() != Constants.CONNECTOR_CODE_LENGTH) { + // throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR); + // } + // } + // } /** * 校验充电桩相关的信息 * * @param dto */ - protected void checkPileInfo(GenerateOrderDTO dto) { + /*protected void checkPileInfo(GenerateOrderDTO dto) { // 查询充电桩状态 是否空闲 枪口是否占用 PileConnectorDetailVO pileConnector = pileBasicInfoService.queryPileConnectorDetail(dto.getPileSn() + dto.getConnectorCode()); if (pileConnector == null) { @@ -358,7 +356,7 @@ public abstract class AbstractProgramLogic implements InitializingBean { } dto.setPileConnector(pileConnector); dto.setBillingTemplate(billingTemplateVO); - } + }*/ @@ -734,96 +732,96 @@ public abstract class AbstractProgramLogic implements InitializingBean { * @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; + // } /** * 计算订单折扣 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 3d910c00b..c9886a510 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 @@ -67,13 +67,13 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic { public OrderBasicInfo generateOrder(GenerateOrderDTO dto) throws ParseException { logger.info("【{}】-生成订单start, param:{}", this.getClass().getSimpleName(), JSONObject.toJSONString(dto)); // 处理前端传的参数 - analysisPileParameter(dto); + orderBasicInfoService.analysisPileParameter(dto); // 校验充电桩相关的信息 - checkPileInfo(dto); + orderBasicInfoService.checkPileInfo(dto); // 保存订单到数据库 saveOrder2Database - return saveOrder2Database(dto); + return orderBasicInfoService.saveOrder2Database(dto); } @Override 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 09da065de..4e7e8de29 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 @@ -69,13 +69,13 @@ public class NotDelayMerchantProgramLogic extends AbstractProgramLogic { public OrderBasicInfo generateOrder(GenerateOrderDTO dto) throws ParseException { logger.info("【{}】-生成订单start, param:{}", this.getClass().getSimpleName(), JSONObject.toJSONString(dto)); // 处理前端传的参数 - analysisPileParameter(dto); + orderBasicInfoService.analysisPileParameter(dto); // 校验充电桩相关的信息 - checkPileInfo(dto); + orderBasicInfoService.checkPileInfo(dto); // 保存订单到数据库 saveOrder2Database - return saveOrder2Database(dto); + return orderBasicInfoService.saveOrder2Database(dto); } /**