mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
记录方法 新增收单机构字段
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.jsowell.common.enums;
|
||||
|
||||
/**
|
||||
* 收单机构enum
|
||||
*/
|
||||
public enum AcquirerEnum {
|
||||
LOCAL("0", "本账户余额"),
|
||||
WECHAT_PAY("1", "微信支付"),
|
||||
ADAPAY("2", "汇付支付"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
AcquirerEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
package com.jsowell.pile.service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.jsowell.pile.domain.AdapayCallbackRecord;
|
||||
|
||||
public interface AdapayCallbackRecordService {
|
||||
void saveAdapayCallbackRecord(AdapayCallbackRecord callbackRecord);
|
||||
|
||||
void saveAdapayCallbackRecord(String data) throws JsonProcessingException;
|
||||
|
||||
AdapayCallbackRecord selectByOrderCode(String orderCode);
|
||||
|
||||
AdapayCallbackRecord selectByPaymentId(String paymentId);
|
||||
|
||||
@@ -6,18 +6,8 @@ import java.util.List;
|
||||
|
||||
public interface IOrderPayRecordService {
|
||||
|
||||
// int deleteByPrimaryKey(Integer id);
|
||||
|
||||
// int insert(OrderPayRecord record);
|
||||
|
||||
// int insertSelective(OrderPayRecord record);
|
||||
|
||||
// OrderPayRecord selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(OrderPayRecord record);
|
||||
|
||||
// int updateByPrimaryKey(OrderPayRecord record);
|
||||
|
||||
/**
|
||||
* 批量保存订单支付记录
|
||||
* @param payRecordList
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package com.jsowell.pile.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
@@ -15,8 +10,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AdapayCallbackRecordServiceImpl implements AdapayCallbackRecordService {
|
||||
@@ -32,29 +25,7 @@ public class AdapayCallbackRecordServiceImpl implements AdapayCallbackRecordServ
|
||||
adapayCallbackRecordMapper.insert(callbackRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAdapayCallbackRecord(String data) throws JsonProcessingException {
|
||||
JSONObject jsonObject = JSON.parseObject(data);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
|
||||
AdapayCallbackRecord adapayCallbackRecord = mapper.readValue(jsonObject.toJSONString(), AdapayCallbackRecord.class);
|
||||
adapayCallbackRecord.setExpend(jsonObject.getString("expend"));
|
||||
adapayCallbackRecord.setPaymentId(jsonObject.getString("id"));
|
||||
|
||||
JSONObject descJson = JSON.parseObject(adapayCallbackRecord.getDescription());
|
||||
String type = descJson.getString("type");
|
||||
adapayCallbackRecord.setPayScenario(type);
|
||||
String memberId = descJson.getString("memberId");
|
||||
adapayCallbackRecord.setMemberId(memberId);
|
||||
String orderCode = descJson.getString("orderCode");
|
||||
adapayCallbackRecord.setOrderCode(orderCode);
|
||||
BigDecimal amount = adapayCallbackRecord.getPayAmt();
|
||||
|
||||
// 保存到数据库
|
||||
this.saveAdapayCallbackRecord(adapayCallbackRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 根据订单号查询支付回调信息
|
||||
* @param orderCode
|
||||
* @return
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.AcquirerEnum;
|
||||
import com.jsowell.common.enums.MemberWalletEnum;
|
||||
import com.jsowell.common.enums.ykc.*;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
@@ -2203,22 +2204,8 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
// 微信支付
|
||||
dto.setOrderBasicInfo(orderInfo);
|
||||
|
||||
// 2023-07-11 全部改为汇付支付
|
||||
Map<String, Object> weixinMap = adapayPayOrder(dto);
|
||||
// 从字典中获取使用汇付支付的站点
|
||||
// List<SysDictData> adapay_station = DictUtils.getDictCache("adapay_station");
|
||||
// List<String> stationIdList = Lists.newArrayList();
|
||||
// if (CollectionUtils.isNotEmpty(adapay_station)) {
|
||||
// for (SysDictData sysDictData : adapay_station) {
|
||||
// stationIdList.add(sysDictData.getDictValue());
|
||||
// }
|
||||
// }
|
||||
// if (stationIdList.contains(orderInfo.getStationId())) {
|
||||
// logger.info("该站点:{}在字典中配置了使用汇付支付", orderInfo.getStationId());
|
||||
// weixinMap = adapayPayOrder(dto);
|
||||
// } else {
|
||||
// logger.info("该站点:{}使用微信支付", orderInfo.getStationId());
|
||||
// weixinMap = wechatPayOrder(dto);
|
||||
// }
|
||||
|
||||
// 返回微信支付参数
|
||||
resultMap.put("weixinMap", weixinMap);
|
||||
@@ -2496,6 +2483,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
.orderCode(orderCode)
|
||||
.payMode(OrderPayRecordEnum.PRINCIPAL_BALANCE_PAYMENT.getValue())
|
||||
.payAmount(principalPay)
|
||||
.acquirer(AcquirerEnum.LOCAL.getValue())
|
||||
.createBy(dto.getMemberId())
|
||||
.build());
|
||||
}
|
||||
@@ -2504,6 +2492,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
.orderCode(orderCode)
|
||||
.payMode(OrderPayRecordEnum.GIFT_BALANCE_PAYMENT.getValue())
|
||||
.payAmount(giftPay)
|
||||
.acquirer(AcquirerEnum.LOCAL.getValue())
|
||||
.createBy(dto.getMemberId())
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -15,35 +15,11 @@ public class OrderPayRecordServiceImpl implements IOrderPayRecordService {
|
||||
private OrderPayRecordMapper orderPayRecordMapper;
|
||||
|
||||
|
||||
// @Override
|
||||
// public int deleteByPrimaryKey(Integer id) {
|
||||
// return orderPayRecordMapper.deleteByPrimaryKey(id);
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public int insert(OrderPayRecord record) {
|
||||
// return orderPayRecordMapper.insert(record);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int insertSelective(OrderPayRecord record) {
|
||||
// return orderPayRecordMapper.insertSelective(record);
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public OrderPayRecord selectByPrimaryKey(Integer id) {
|
||||
// return orderPayRecordMapper.selectByPrimaryKey(id);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int updateByPrimaryKeySelective(OrderPayRecord record) {
|
||||
return orderPayRecordMapper.updateByPrimaryKeySelective(record);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int updateByPrimaryKey(OrderPayRecord record) {
|
||||
// return orderPayRecordMapper.updateByPrimaryKey(record);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int batchInsert(List<OrderPayRecord> payRecordList) {
|
||||
|
||||
Reference in New Issue
Block a user