记录方法 新增收单机构字段

This commit is contained in:
2023-07-13 16:53:14 +08:00
parent f267ac9f34
commit 18f47009a5
7 changed files with 50 additions and 255 deletions

View File

@@ -24,6 +24,7 @@ import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
import com.jsowell.common.core.page.PageResponse;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.AcquirerEnum;
import com.jsowell.common.enums.InvoiceRecordEnum;
import com.jsowell.common.enums.MemberWalletEnum;
import com.jsowell.common.enums.adapay.AdapayEventEnum;
@@ -382,6 +383,7 @@ public class OrderService {
.orderCode(orderCode)
.payMode(OrderPayRecordEnum.PRINCIPAL_BALANCE_PAYMENT.getValue())
.payAmount(principalPay)
.acquirer(AcquirerEnum.LOCAL.getValue())
.createBy(dto.getMemberId())
.build());
}
@@ -390,6 +392,7 @@ public class OrderService {
.orderCode(orderCode)
.payMode(OrderPayRecordEnum.GIFT_BALANCE_PAYMENT.getValue())
.payAmount(giftPay)
.acquirer(AcquirerEnum.LOCAL.getValue())
.createBy(dto.getMemberId())
.build());
}
@@ -419,179 +422,6 @@ public class OrderService {
}
}
/**
* 订单支付成功 支付回调
* 支付成功后掉用这个方法
* 1. 修改订单支付状态
* 2. 发送启动充电指令
*/
/*public void payOrderSuccessCallback(PayOrderSuccessCallbackDTO dto) {
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
BigDecimal payAmount = dto.getPayAmount();
// 修改订单
orderInfo.setPayMode(dto.getPayMode());
orderInfo.setPayStatus(Constants.ONE);
orderInfo.setPayAmount(payAmount);
orderInfo.setPayTime(new Date());
orderBasicInfoService.updateOrderBasicInfo(orderInfo);
if (StringUtils.equals(orderInfo.getStartType(), StartTypeEnum.NOW.getValue())) { // 立即启动充电
String pileSn = orderInfo.getPileSn();
// 发送启动充电指令前,再次下发计费模板
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(pileSn);
if (billingTemplateVO != null) {
pileRemoteService.publishPileBillingTemplate(pileSn, billingTemplateVO);
}
// 发送启动指令
pileRemoteService.remoteStartCharging(pileSn, orderInfo.getConnectorCode(), orderInfo.getTransactionCode(), orderInfo.getPayAmount());
} else { // 预约充电
// 修改枪口状态为 占用预约
// 下发修改充电桩设置指令
}
}*/
/**
* 保存订单信息到数据库
*
* @param dto
* @return
*/
// private String saveOrder2Database(GenerateOrderDTO dto) throws ParseException {
// String orderCode = IdUtils.getOrderCode();
// 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()) : "";
//
// // 订单基本信息
// 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())
// .orderAmount(BigDecimal.ZERO)
// .virtualAmount(BigDecimal.ZERO)
// .settleAmount(BigDecimal.ZERO)
// .startType(dto.getStartType())
// .build();
// 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();
// log.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();
// pileTransactionService.doCreateOrder(createOrderTransactionDTO);
// return orderCode;
// }
/**
* 校验充电桩相关的信息
*
* @param dto
*/
// private void checkPileInfo(GenerateOrderDTO dto) {
// // 查询充电桩状态 是否空闲 枪口是否占用
// PileConnectorDetailVO pileConnector = pileService.queryPileConnectorDetail(dto.getPileSn() + dto.getConnectorCode());
// if (pileConnector == null) {
// log.error("checkPileInfo充电枪口为空 pileSn:{}, connectorCode:{}", dto.getPileSn(), dto.getConnectorCode());
// throw new BusinessException(ReturnCodeEnum.CODE_CONNECTOR_INFO_NULL_ERROR);
// }
//
// // 查询站点状态
// PileStationVO stationInfo = pileStationInfoService.getStationInfo(pileConnector.getStationId());
// if (stationInfo == null || StringUtils.equals(stationInfo.getOpenFlag(), Constants.ZERO)) {
// throw new BusinessException(ReturnCodeEnum.CODE_STATION_IS_NOT_OPEN);
// }
//
// // 判断枪口状态
// if (!(StringUtils.equals(pileConnector.getConnectorStatus(), PileConnectorDataBaseStatusEnum.FREE.getValue())
// || StringUtils.equals(pileConnector.getConnectorStatus(), PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue()))) {
// log.error("checkPileInfo充电枪口状态不正确当前状态为:{}", pileConnector.getConnectorStatus());
// throw new BusinessException(ReturnCodeEnum.CODE_PILE_CONNECTOR_STATUS_ERROR);
// }
// // 查询充电桩的计费模板
// BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateDetailByPileSn(dto.getPileSn());
// if (billingTemplateVO == null) {
// throw new BusinessException(ReturnCodeEnum.CODE_BILLING_TEMPLATE_NULL_ERROR);
// }
// dto.setPileConnector(pileConnector);
// dto.setBillingTemplate(billingTemplateVO);
// }
/**
* 处理前端传的参数
* pileConnectorCode = pileSn + connectorCode
*
* @param dto
*/
// public 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);
// }
// }
// }
/**
* 结算订单
* endCharging
@@ -733,6 +563,7 @@ public class OrderService {
.orderCode(orderCode)
.payMode(OrderPayRecordEnum.WECHATPAY_PAYMENT.getValue())
.payAmount(amount)
.acquirer(AcquirerEnum.WECHAT_PAY.getValue())
.createBy(null)
.build();
orderPayRecordService.batchInsert(Lists.newArrayList(orderPayRecord));
@@ -1342,6 +1173,11 @@ public class OrderService {
}
/**
* adapay支付成功回调
* @param data
* @throws JsonProcessingException
*/
private void paymentSucceeded(String data) throws JsonProcessingException {
//验签成功 保存到回调记录表中
JSONObject jsonObject = JSON.parseObject(data);
@@ -1378,6 +1214,7 @@ public class OrderService {
.orderCode(orderCode)
.payMode(OrderPayRecordEnum.WECHATPAY_PAYMENT.getValue())
.payAmount(amount)
.acquirer(AcquirerEnum.ADAPAY.getValue())
.createBy(null)
.build();
orderPayRecordService.batchInsert(Lists.newArrayList(orderPayRecord));