mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-25 01:29:47 +08:00
update 卡启动、vin启动逻辑修改
This commit is contained in:
@@ -19,9 +19,7 @@ import com.jsowell.common.core.domain.entity.SysDictData;
|
|||||||
import com.jsowell.common.core.domain.ykc.LoginRequestData;
|
import com.jsowell.common.core.domain.ykc.LoginRequestData;
|
||||||
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||||
import com.jsowell.common.core.redis.RedisCache;
|
import com.jsowell.common.core.redis.RedisCache;
|
||||||
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
import com.jsowell.common.enums.ykc.*;
|
||||||
import com.jsowell.common.enums.ykc.StartModeEnum;
|
|
||||||
import com.jsowell.common.enums.ykc.YKCChargingStopReasonEnum;
|
|
||||||
import com.jsowell.common.exception.BusinessException;
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.util.*;
|
import com.jsowell.common.util.*;
|
||||||
import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil;
|
import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil;
|
||||||
@@ -42,6 +40,7 @@ import com.jsowell.pile.mapper.MemberBasicInfoMapper;
|
|||||||
import com.jsowell.pile.mapper.PileBillingTemplateMapper;
|
import com.jsowell.pile.mapper.PileBillingTemplateMapper;
|
||||||
import com.jsowell.pile.service.*;
|
import com.jsowell.pile.service.*;
|
||||||
import com.jsowell.pile.vo.base.PileInfoVO;
|
import com.jsowell.pile.vo.base.PileInfoVO;
|
||||||
|
import com.jsowell.pile.vo.uniapp.MemberVO;
|
||||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||||
import com.jsowell.pile.vo.web.OrderListVO;
|
import com.jsowell.pile.vo.web.OrderListVO;
|
||||||
import com.jsowell.pile.vo.web.PileDetailVO;
|
import com.jsowell.pile.vo.web.PileDetailVO;
|
||||||
@@ -177,6 +176,48 @@ public class SpringBootTestController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TransactionRecordsRequestHandler transactionRecordsRequestHandler;
|
private TransactionRecordsRequestHandler transactionRecordsRequestHandler;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMemberBasicInfoService memberBasicInfoService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOrder() throws Exception {
|
||||||
|
// 通过vin码查询数据库绑定用户信息
|
||||||
|
MemberPlateNumberRelation plateInfo = memberPlateNumberRelationService.getMemberPlateInfoByVinCode("LNBSCC4H1LT107646");
|
||||||
|
GenerateOrderDTO dto = new GenerateOrderDTO();
|
||||||
|
dto.setMemberPlateNumberRelation(plateInfo);
|
||||||
|
dto.setPileSn("88000000000126");
|
||||||
|
dto.setConnectorCode("01");
|
||||||
|
dto.setStartMode(StartModeEnum.VIN_CODE.getValue());
|
||||||
|
dto.setMemberId(plateInfo.getMemberId());
|
||||||
|
// 通过memberId获取账户余额
|
||||||
|
MemberVO memberVO = memberBasicInfoService.queryMemberInfoByMemberId(dto.getMemberId());
|
||||||
|
if (memberVO == null) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_GET_MEMBER_ACCOUNT_AMOUNT_ERROR);
|
||||||
|
}
|
||||||
|
BigDecimal totalAccountAmount = memberVO.getTotalAccountAmount();
|
||||||
|
if (totalAccountAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_BALANCE_IS_INSUFFICIENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
dto.setChargeAmount(totalAccountAmount); // 充电金额
|
||||||
|
dto.setPayMode(OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue()); // 1-余额支付
|
||||||
|
|
||||||
|
OrderBasicInfo basicInfo = orderBasicInfoService.generateOrder(dto);
|
||||||
|
|
||||||
|
// 支付订单
|
||||||
|
PayOrderDTO payOrderDTO = new PayOrderDTO();
|
||||||
|
payOrderDTO.setOrderCode(basicInfo.getOrderCode());
|
||||||
|
payOrderDTO.setPayAmount(totalAccountAmount);
|
||||||
|
payOrderDTO.setPayMode(dto.getPayMode());
|
||||||
|
payOrderDTO.setMemberId(dto.getMemberId());
|
||||||
|
// payOrderDTO.setCode();
|
||||||
|
// payOrderDTO.setLockValue();
|
||||||
|
payOrderDTO.setOrderBasicInfo(basicInfo);
|
||||||
|
|
||||||
|
Map<String, Object> map = orderBasicInfoService.payOrder(payOrderDTO);
|
||||||
|
|
||||||
|
System.out.println(map);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransactionRecord() {
|
public void testTransactionRecord() {
|
||||||
@@ -423,7 +464,7 @@ public class SpringBootTestController {
|
|||||||
// redis锁
|
// redis锁
|
||||||
Boolean isLock = redisCache.lock(lockKey, uuid, 1500);
|
Boolean isLock = redisCache.lock(lockKey, uuid, 1500);
|
||||||
if (isLock) {
|
if (isLock) {
|
||||||
transactionRecordsRequestHandler.processOrder(data);
|
// transactionRecordsRequestHandler.processOrder(data);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("处理订单发生异常: " + e);
|
System.out.println("处理订单发生异常: " + e);
|
||||||
|
|||||||
@@ -1637,125 +1637,116 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
|||||||
|
|
||||||
wxAppletRemoteService.startChargingSendMsg(sendMsgDTO);
|
wxAppletRemoteService.startChargingSendMsg(sendMsgDTO);
|
||||||
|
|
||||||
// return map;
|
return map;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// String pileSn = dto.getPileSn();
|
||||||
|
// String connectorCode = dto.getConnectorCode();
|
||||||
|
// String startMode = dto.getStartMode();
|
||||||
|
// String logicCard = "";
|
||||||
|
// String memberId = "";
|
||||||
|
// String vinCode = "";
|
||||||
|
// PileAuthCard pileAuthCardInfo = new PileAuthCard();
|
||||||
|
// // CarVinInfoVO carVinInfoVO = new CarVinInfoVO();
|
||||||
|
// MemberPlateNumberRelation relation = new MemberPlateNumberRelation();
|
||||||
String pileSn = dto.getPileSn();
|
// if (StringUtils.equals(StartModeEnum.AUTH_CARD.getValue(), startMode)) {
|
||||||
String connectorCode = dto.getConnectorCode();
|
// // 刷卡启动充电
|
||||||
String startMode = dto.getStartMode();
|
// pileAuthCardInfo = dto.getPileAuthCardInfo();
|
||||||
String logicCard = "";
|
// memberId = pileAuthCardInfo.getMemberId();
|
||||||
String memberId = "";
|
// logicCard = pileAuthCardInfo.getLogicCard();
|
||||||
String vinCode = "";
|
// }else if (StringUtils.equals(StartModeEnum.VIN_CODE.getValue(), startMode)) {
|
||||||
PileAuthCard pileAuthCardInfo = new PileAuthCard();
|
// logger.info("车辆vin启动充电 params:{}", JSON.toJSONString(dto));
|
||||||
// CarVinInfoVO carVinInfoVO = new CarVinInfoVO();
|
// // vin启动充电
|
||||||
MemberPlateNumberRelation relation = new MemberPlateNumberRelation();
|
// relation = dto.getMemberPlateNumberRelation();
|
||||||
if (StringUtils.equals(StartModeEnum.AUTH_CARD.getValue(), startMode)) {
|
// memberId = relation.getMemberId();
|
||||||
// 刷卡启动充电
|
// vinCode = relation.getVinCode();
|
||||||
pileAuthCardInfo = dto.getPileAuthCardInfo();
|
|
||||||
memberId = pileAuthCardInfo.getMemberId();
|
|
||||||
logicCard = pileAuthCardInfo.getLogicCard();
|
|
||||||
}else if (StringUtils.equals(StartModeEnum.VIN_CODE.getValue(), startMode)) {
|
|
||||||
logger.info("车辆vin启动充电 params:{}", JSON.toJSONString(dto));
|
|
||||||
// vin启动充电
|
|
||||||
relation = dto.getMemberPlateNumberRelation();
|
|
||||||
memberId = relation.getMemberId();
|
|
||||||
vinCode = relation.getVinCode();
|
|
||||||
}
|
|
||||||
// 通过memberId获取账户余额
|
|
||||||
// MemberVO memberVO = memberBasicInfoService.queryMemberInfoByMemberId(memberId);
|
|
||||||
// if (memberVO == null) {
|
|
||||||
// throw new BusinessException(ReturnCodeEnum.CODE_GET_MEMBER_ACCOUNT_AMOUNT_ERROR);
|
|
||||||
// }
|
// }
|
||||||
// BigDecimal totalAccountAmount = memberVO.getTotalAccountAmount();
|
// // 通过memberId获取账户余额
|
||||||
// if (totalAccountAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
// // MemberVO memberVO = memberBasicInfoService.queryMemberInfoByMemberId(memberId);
|
||||||
// throw new BusinessException(ReturnCodeEnum.CODE_BALANCE_IS_INSUFFICIENT);
|
// // if (memberVO == null) {
|
||||||
|
// // throw new BusinessException(ReturnCodeEnum.CODE_GET_MEMBER_ACCOUNT_AMOUNT_ERROR);
|
||||||
|
// // }
|
||||||
|
// // BigDecimal totalAccountAmount = memberVO.getTotalAccountAmount();
|
||||||
|
// // if (totalAccountAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
// // throw new BusinessException(ReturnCodeEnum.CODE_BALANCE_IS_INSUFFICIENT);
|
||||||
|
// // }
|
||||||
|
//
|
||||||
|
// String transactionCode = IdUtils.generateTransactionCode(pileSn, connectorCode);
|
||||||
|
// // 通过桩号查询所属站点
|
||||||
|
// 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();
|
||||||
|
// // 订单基本信息
|
||||||
|
// OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
|
||||||
|
// .orderCode(orderCode)
|
||||||
|
// .transactionCode(transactionCode)
|
||||||
|
// .orderStatus(OrderStatusEnum.NOT_START.getValue())
|
||||||
|
// .memberId(memberVO.getMemberId())
|
||||||
|
// .stationId(String.valueOf(stationId))
|
||||||
|
// .merchantId(merchantId)
|
||||||
|
// .pileSn(pileSn)
|
||||||
|
// .connectorCode(connectorCode)
|
||||||
|
// .pileConnectorCode(pileSn + connectorCode)
|
||||||
|
// .logicCard(logicCard)
|
||||||
|
// .vinCode(vinCode)
|
||||||
|
// .startMode(startMode)
|
||||||
|
// .payStatus(Constants.ONE)
|
||||||
|
// .payAmount(totalAccountAmount)
|
||||||
|
// .payTime(new Date())
|
||||||
|
// .payMode(OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue())
|
||||||
|
// .orderAmount(BigDecimal.ZERO)
|
||||||
|
// .virtualAmount(BigDecimal.ZERO)
|
||||||
|
// .settleAmount(BigDecimal.ZERO)
|
||||||
|
// .build();
|
||||||
|
// // 根据桩编码查询当前计费模板
|
||||||
|
// BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
|
||||||
|
// // 订单详情
|
||||||
|
// OrderDetail orderDetail = OrderDetail.builder()
|
||||||
|
// .orderCode(orderCode)
|
||||||
|
// .sharpElectricityPrice(billingTemplateVO.getSharpElectricityPrice())
|
||||||
|
// .sharpServicePrice(billingTemplateVO.getSharpServicePrice())
|
||||||
|
// .peakElectricityPrice(billingTemplateVO.getPeakElectricityPrice())
|
||||||
|
// .peakServicePrice(billingTemplateVO.getPeakServicePrice())
|
||||||
|
// .flatElectricityPrice(billingTemplateVO.getFlatElectricityPrice())
|
||||||
|
// .flatServicePrice(billingTemplateVO.getFlatServicePrice())
|
||||||
|
// .valleyElectricityPrice(billingTemplateVO.getValleyElectricityPrice())
|
||||||
|
// .valleyServicePrice(billingTemplateVO.getValleyServicePrice())
|
||||||
|
// .build();
|
||||||
|
//
|
||||||
|
// OrderTransactionDTO createOrderTransactionDTO = OrderTransactionDTO.builder()
|
||||||
|
// .orderBasicInfo(orderBasicInfo)
|
||||||
|
// .orderDetail(orderDetail)
|
||||||
|
// .build();
|
||||||
|
// pileTransactionService.doCreateOrder(createOrderTransactionDTO);
|
||||||
|
//
|
||||||
|
// if (StringUtils.equals(StartModeEnum.AUTH_CARD.getValue(), startMode)) {
|
||||||
|
// // 将卡状态改为启动锁定
|
||||||
|
// PileAuthCard pileAuthCard = PileAuthCard.builder()
|
||||||
|
// .id(pileAuthCardInfo.getId())
|
||||||
|
// .logicCard(pileAuthCardInfo.getLogicCard())
|
||||||
|
// .status("2")
|
||||||
|
// .build();
|
||||||
|
// pileAuthCardService.updatePileAuthCard(pileAuthCard);
|
||||||
|
// } else if (StringUtils.equals(StartModeEnum.VIN_CODE.getValue(), startMode)) {
|
||||||
|
// // 将vin码改成启动锁定
|
||||||
|
// relation.setVinStatus("2");
|
||||||
|
// memberPlateNumberRelationService.updateMemberPlateNumberRelation(relation);
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
String transactionCode = IdUtils.generateTransactionCode(pileSn, connectorCode);
|
// // 组装结果集
|
||||||
// 通过桩号查询所属站点
|
// Map<String, Object> resultMap = Maps.newHashMap();
|
||||||
PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn);
|
// resultMap.put("orderCode", orderBasicInfo.getOrderCode());
|
||||||
Long stationId = pileBasicInfo.getStationId();
|
// resultMap.put("transactionCode", orderBasicInfo.getTransactionCode());
|
||||||
PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(stationId);
|
// resultMap.put("accountBalance", totalAccountAmount);
|
||||||
String merchantId = pileStationInfo != null ? String.valueOf(pileStationInfo.getMerchantId()) : "";
|
//
|
||||||
// 自动余额全部支付订单 个人桩站点不计费
|
// logger.info("生成订单 result:{}", JSON.toJSONString(resultMap));
|
||||||
|
// return resultMap;
|
||||||
// 将此订单信息存入订单表
|
|
||||||
String orderCode = IdUtils.getOrderCode();
|
|
||||||
// 订单基本信息
|
|
||||||
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
|
|
||||||
.orderCode(orderCode)
|
|
||||||
.transactionCode(transactionCode)
|
|
||||||
.orderStatus(OrderStatusEnum.NOT_START.getValue())
|
|
||||||
.memberId(memberVO.getMemberId())
|
|
||||||
.stationId(String.valueOf(stationId))
|
|
||||||
.merchantId(merchantId)
|
|
||||||
.pileSn(pileSn)
|
|
||||||
.connectorCode(connectorCode)
|
|
||||||
.pileConnectorCode(pileSn + connectorCode)
|
|
||||||
.logicCard(logicCard)
|
|
||||||
.vinCode(vinCode)
|
|
||||||
.startMode(startMode)
|
|
||||||
.payStatus(Constants.ONE)
|
|
||||||
.payAmount(totalAccountAmount)
|
|
||||||
.payTime(new Date())
|
|
||||||
.payMode(OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue())
|
|
||||||
.orderAmount(BigDecimal.ZERO)
|
|
||||||
.virtualAmount(BigDecimal.ZERO)
|
|
||||||
.settleAmount(BigDecimal.ZERO)
|
|
||||||
.build();
|
|
||||||
// 根据桩编码查询当前计费模板
|
|
||||||
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
|
|
||||||
// 订单详情
|
|
||||||
OrderDetail orderDetail = OrderDetail.builder()
|
|
||||||
.orderCode(orderCode)
|
|
||||||
.sharpElectricityPrice(billingTemplateVO.getSharpElectricityPrice())
|
|
||||||
.sharpServicePrice(billingTemplateVO.getSharpServicePrice())
|
|
||||||
.peakElectricityPrice(billingTemplateVO.getPeakElectricityPrice())
|
|
||||||
.peakServicePrice(billingTemplateVO.getPeakServicePrice())
|
|
||||||
.flatElectricityPrice(billingTemplateVO.getFlatElectricityPrice())
|
|
||||||
.flatServicePrice(billingTemplateVO.getFlatServicePrice())
|
|
||||||
.valleyElectricityPrice(billingTemplateVO.getValleyElectricityPrice())
|
|
||||||
.valleyServicePrice(billingTemplateVO.getValleyServicePrice())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
OrderTransactionDTO createOrderTransactionDTO = OrderTransactionDTO.builder()
|
|
||||||
.orderBasicInfo(orderBasicInfo)
|
|
||||||
.orderDetail(orderDetail)
|
|
||||||
.build();
|
|
||||||
pileTransactionService.doCreateOrder(createOrderTransactionDTO);
|
|
||||||
|
|
||||||
if (StringUtils.equals(StartModeEnum.AUTH_CARD.getValue(), startMode)) {
|
|
||||||
// 将卡状态改为启动锁定
|
|
||||||
PileAuthCard pileAuthCard = PileAuthCard.builder()
|
|
||||||
.id(pileAuthCardInfo.getId())
|
|
||||||
.logicCard(pileAuthCardInfo.getLogicCard())
|
|
||||||
.status("2")
|
|
||||||
.build();
|
|
||||||
pileAuthCardService.updatePileAuthCard(pileAuthCard);
|
|
||||||
} else if (StringUtils.equals(StartModeEnum.VIN_CODE.getValue(), startMode)) {
|
|
||||||
// 将vin码改成启动锁定
|
|
||||||
relation.setVinStatus("2");
|
|
||||||
memberPlateNumberRelationService.updateMemberPlateNumberRelation(relation);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 组装结果集
|
|
||||||
Map<String, Object> resultMap = Maps.newHashMap();
|
|
||||||
resultMap.put("orderCode", orderBasicInfo.getOrderCode());
|
|
||||||
resultMap.put("transactionCode", orderBasicInfo.getTransactionCode());
|
|
||||||
resultMap.put("accountBalance", totalAccountAmount);
|
|
||||||
|
|
||||||
logger.info("生成订单 result:{}", JSON.toJSONString(resultMap));
|
|
||||||
return resultMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user