@@ -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;
// }
/**
* 计算订单折扣