mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-20 23:29:48 +08:00
记录退款金额到订单支付记录
This commit is contained in:
@@ -23,8 +23,6 @@ import com.jsowell.pile.dto.QueryOrderDTO;
|
|||||||
import com.jsowell.pile.dto.SettleOrderReportDTO;
|
import com.jsowell.pile.dto.SettleOrderReportDTO;
|
||||||
import com.jsowell.pile.mapper.OrderBasicInfoMapper;
|
import com.jsowell.pile.mapper.OrderBasicInfoMapper;
|
||||||
import com.jsowell.pile.service.*;
|
import com.jsowell.pile.service.*;
|
||||||
import com.jsowell.pile.service.programlogic.AbstractProgramLogic;
|
|
||||||
import com.jsowell.pile.service.programlogic.DelayMerchantProgramLogic;
|
|
||||||
import com.jsowell.pile.vo.web.ClearingBillVO;
|
import com.jsowell.pile.vo.web.ClearingBillVO;
|
||||||
import com.jsowell.pile.vo.web.OrderListVO;
|
import com.jsowell.pile.vo.web.OrderListVO;
|
||||||
import com.jsowell.pile.vo.web.OrderPayDetailVO;
|
import com.jsowell.pile.vo.web.OrderPayDetailVO;
|
||||||
@@ -428,8 +426,7 @@ public class TempService {
|
|||||||
BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
|
BigDecimal settleAmount = orderBasicInfo.getSettleAmount();
|
||||||
OrderPayRecord record = orderPayRecordList.get(0);
|
OrderPayRecord record = orderPayRecordList.get(0);
|
||||||
String deductionRecord = record.getDeductionRecord();
|
String deductionRecord = record.getDeductionRecord();
|
||||||
AbstractProgramLogic orderLogic = new DelayMerchantProgramLogic();
|
List<PaymentInfo> paymentInfos = orderPayRecordService.parseDeductionRecord(deductionRecord);
|
||||||
List<PaymentInfo> paymentInfos = orderLogic.parseDeductionRecord(deductionRecord);
|
|
||||||
|
|
||||||
// 通过paymentId查询 分账记录
|
// 通过paymentId查询 分账记录
|
||||||
for (PaymentInfo paymentInfo : paymentInfos) {
|
for (PaymentInfo paymentInfo : paymentInfos) {
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.jsowell.pile.service;
|
package com.jsowell.pile.service;
|
||||||
|
|
||||||
|
import com.jsowell.adapay.vo.PaymentInfo;
|
||||||
import com.jsowell.pile.domain.OrderPayRecord;
|
import com.jsowell.pile.domain.OrderPayRecord;
|
||||||
import com.jsowell.pile.vo.web.OrderDetailInfoVO;
|
import com.jsowell.pile.vo.web.OrderDetailInfoVO;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface OrderPayRecordService{
|
public interface OrderPayRecordService{
|
||||||
@@ -31,4 +33,8 @@ public interface OrderPayRecordService{
|
|||||||
|
|
||||||
List<OrderDetailInfoVO.PayRecord> selectOrderPayInfoList(String orderCode);
|
List<OrderDetailInfoVO.PayRecord> selectOrderPayInfoList(String orderCode);
|
||||||
|
|
||||||
|
List<PaymentInfo> parseDeductionRecord(String deductionRecord);
|
||||||
|
|
||||||
|
// 更新订单退款金额
|
||||||
|
void updateRefundAmount(String orderCode, String paymentId, BigDecimal refundAmt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1299,11 +1299,10 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
|||||||
// List<String> collect = list.stream().map(BalanceDeductionAmountVO::getPaymentId).collect(Collectors.toList());
|
// List<String> collect = list.stream().map(BalanceDeductionAmountVO::getPaymentId).collect(Collectors.toList());
|
||||||
|
|
||||||
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderBasicInfo.getOrderCode());
|
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderBasicInfo.getOrderCode());
|
||||||
AbstractProgramLogic orderLogic = new DelayMerchantProgramLogic();
|
|
||||||
List<PaymentInfo> paymentInfos = Lists.newArrayList();
|
List<PaymentInfo> paymentInfos = Lists.newArrayList();
|
||||||
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
||||||
String deductionRecord = orderPayRecord.getDeductionRecord();
|
String deductionRecord = orderPayRecord.getDeductionRecord();
|
||||||
paymentInfos.addAll(orderLogic.parseDeductionRecord(deductionRecord));
|
paymentInfos.addAll(orderPayRecordService.parseDeductionRecord(deductionRecord));
|
||||||
}
|
}
|
||||||
List<String> collect = paymentInfos.stream().map(PaymentInfo::getPaymentId).collect(Collectors.toList());
|
List<String> collect = paymentInfos.stream().map(PaymentInfo::getPaymentId).collect(Collectors.toList());
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.jsowell.pile.service.impl;
|
package com.jsowell.pile.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.jsowell.adapay.vo.PaymentInfo;
|
||||||
import com.jsowell.common.constant.CacheConstants;
|
import com.jsowell.common.constant.CacheConstants;
|
||||||
import com.jsowell.common.core.redis.RedisCache;
|
import com.jsowell.common.core.redis.RedisCache;
|
||||||
import com.jsowell.common.enums.ykc.ActionTypeEnum;
|
import com.jsowell.common.enums.ykc.ActionTypeEnum;
|
||||||
@@ -18,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -155,6 +159,44 @@ public class OrderPayRecordServiceImpl implements OrderPayRecordService {
|
|||||||
return payRecordList;
|
return payRecordList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析deductionRecord
|
||||||
|
* 【公共方法】
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<PaymentInfo> parseDeductionRecord(String deductionRecord) {
|
||||||
|
List<PaymentInfo> resultList = Lists.newArrayList();
|
||||||
|
if (StringUtils.isBlank(deductionRecord)) {
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
Object object = JSON.parse(deductionRecord);
|
||||||
|
|
||||||
|
// 都放入list里
|
||||||
|
String s = JSON.toJSONString(object);
|
||||||
|
if (object instanceof JSONArray) {
|
||||||
|
List<PaymentInfo> paymentInfos = JSON.parseArray(s, PaymentInfo.class);
|
||||||
|
resultList.addAll(paymentInfos);
|
||||||
|
} else {
|
||||||
|
PaymentInfo paymentInfo = JSON.parseObject(s, PaymentInfo.class);
|
||||||
|
resultList.add(paymentInfo);
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateRefundAmount(String orderCode, String paymentId, BigDecimal refundAmt) {
|
||||||
|
List<OrderPayRecord> orderPayRecordList = getOrderPayRecordList(orderCode);
|
||||||
|
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
|
||||||
|
List<PaymentInfo> paymentInfos = parseDeductionRecord(orderPayRecord.getDeductionRecord());
|
||||||
|
for (PaymentInfo paymentInfo : paymentInfos) {
|
||||||
|
if (StringUtils.equals(paymentId, paymentInfo.getPaymentId())) {
|
||||||
|
orderPayRecord.setRefundAmount(refundAmt);
|
||||||
|
updateByPrimaryKeySelective(orderPayRecord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertSelective(OrderPayRecord record) {
|
public int insertSelective(OrderPayRecord record) {
|
||||||
return orderPayRecordMapper.insertSelective(record);
|
return orderPayRecordMapper.insertSelective(record);
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.jsowell.pile.service.programlogic;
|
package com.jsowell.pile.service.programlogic;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
|
||||||
import com.alibaba.fastjson2.JSONArray;
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
@@ -489,7 +487,7 @@ public abstract class AbstractProgramLogic implements InitializingBean {
|
|||||||
|
|
||||||
BigDecimal tempAmount = new BigDecimal(orderAmount.toString()); // 临时金额
|
BigDecimal tempAmount = new BigDecimal(orderAmount.toString()); // 临时金额
|
||||||
for (OrderPayRecord record : payRecordList) {
|
for (OrderPayRecord record : payRecordList) {
|
||||||
List<PaymentInfo> paymentInfos = parseDeductionRecord(record.getDeductionRecord());
|
List<PaymentInfo> paymentInfos = orderPayRecordService.parseDeductionRecord(record.getDeductionRecord());
|
||||||
for (PaymentInfo object : paymentInfos) {
|
for (PaymentInfo object : paymentInfos) {
|
||||||
String paymentId = object.getPaymentId();
|
String paymentId = object.getPaymentId();
|
||||||
BigDecimal payAmount = new BigDecimal(object.getAmount()); // 此交易单支付的金额
|
BigDecimal payAmount = new BigDecimal(object.getAmount()); // 此交易单支付的金额
|
||||||
@@ -517,29 +515,6 @@ public abstract class AbstractProgramLogic implements InitializingBean {
|
|||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析deductionRecord
|
|
||||||
* 【公共方法】
|
|
||||||
*/
|
|
||||||
public List<PaymentInfo> parseDeductionRecord(String deductionRecord) {
|
|
||||||
List<PaymentInfo> resultList = Lists.newArrayList();
|
|
||||||
if (StringUtils.isBlank(deductionRecord)) {
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
Object object = JSON.parse(deductionRecord);
|
|
||||||
|
|
||||||
// 都放入list里
|
|
||||||
String s = JSON.toJSONString(object);
|
|
||||||
if (object instanceof JSONArray) {
|
|
||||||
List<PaymentInfo> paymentInfos = JSON.parseArray(s, PaymentInfo.class);
|
|
||||||
resultList.addAll(paymentInfos);
|
|
||||||
} else {
|
|
||||||
PaymentInfo paymentInfo = JSON.parseObject(s, PaymentInfo.class);
|
|
||||||
resultList.add(paymentInfo);
|
|
||||||
}
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从redis中取出实时记录保存到表中j
|
* 从redis中取出实时记录保存到表中j
|
||||||
* 当订单完成的时候调用
|
* 当订单完成的时候调用
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
|
|||||||
|
|
||||||
// 把消费金额冻结
|
// 把消费金额冻结
|
||||||
for (OrderPayRecord record : payRecordList) {
|
for (OrderPayRecord record : payRecordList) {
|
||||||
List<PaymentInfo> paymentInfoList = parseDeductionRecord(record.getDeductionRecord());
|
List<PaymentInfo> paymentInfoList = orderPayRecordService.parseDeductionRecord(record.getDeductionRecord());
|
||||||
// 循环冻结金额
|
// 循环冻结金额
|
||||||
for (PaymentInfo paymentInfo : paymentInfoList) {
|
for (PaymentInfo paymentInfo : paymentInfoList) {
|
||||||
String paymentId = paymentInfo.getPaymentId();
|
String paymentId = paymentInfo.getPaymentId();
|
||||||
@@ -677,20 +677,15 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
|
|||||||
|
|
||||||
// BigDecimal refundAmt = null; // 交易退款金额
|
// BigDecimal refundAmt = null; // 交易退款金额
|
||||||
// 延迟分账未确认调撤销调撤销接口退款
|
// 延迟分账未确认调撤销调撤销接口退款
|
||||||
// PaymentReverseOperation operation = new PaymentReverseOperation();
|
|
||||||
// operation.setPaymentId(paymentId);
|
|
||||||
// operation.setReverseAmt(refundAmount);
|
|
||||||
// operation.setMerchantKey(dto.getWechatAppId());
|
|
||||||
// operation.setMemberId(dto.getMemberId());
|
|
||||||
// operation.setScenarioType(ScenarioEnum.ORDER.getValue());
|
|
||||||
// operation.setOrderCode(dto.getOrderCode());
|
|
||||||
// PaymentReverseResponse response = adapayService.createPaymentReverseRequest(operation);
|
|
||||||
PaymentReverseResponse response = adapayService.createPaymentReverseRequest(paymentId, refundAmount,
|
PaymentReverseResponse response = adapayService.createPaymentReverseRequest(paymentId, refundAmount,
|
||||||
dto.getWechatAppId(), dto.getMemberId(), ScenarioEnum.ORDER.getValue(), dto.getOrderCode());
|
dto.getWechatAppId(), dto.getMemberId(), ScenarioEnum.ORDER.getValue(), dto.getOrderCode());
|
||||||
if (response != null && response.isNotFailed()) {
|
if (response != null && response.isNotFailed()) {
|
||||||
// 交易退款金额
|
// 交易退款金额
|
||||||
BigDecimal refundAmt = new BigDecimal(response.getReverse_amt());
|
BigDecimal refundAmt = new BigDecimal(response.getReverse_amt());
|
||||||
memberAdapayRecordService.updateRefundAmountFromFreezeAmount(paymentId, refundAmt);
|
memberAdapayRecordService.updateRefundAmountFromFreezeAmount(paymentId, refundAmt);
|
||||||
|
|
||||||
|
// 更新订单支付记录的退款金额
|
||||||
|
orderPayRecordService.updateRefundAmount(dto.getOrderCode(), paymentId, refundAmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ public class NotDelayMerchantProgramLogic extends AbstractProgramLogic {
|
|||||||
|
|
||||||
// 把消费金额冻结
|
// 把消费金额冻结
|
||||||
for (OrderPayRecord record : payRecordList) {
|
for (OrderPayRecord record : payRecordList) {
|
||||||
List<PaymentInfo> paymentInfoList = parseDeductionRecord(record.getDeductionRecord());
|
List<PaymentInfo> paymentInfoList = orderPayRecordService.parseDeductionRecord(record.getDeductionRecord());
|
||||||
// 循环冻结金额
|
// 循环冻结金额
|
||||||
for (PaymentInfo paymentInfo : paymentInfoList) {
|
for (PaymentInfo paymentInfo : paymentInfoList) {
|
||||||
String paymentId = paymentInfo.getPaymentId();
|
String paymentId = paymentInfo.getPaymentId();
|
||||||
|
|||||||
@@ -84,6 +84,11 @@ public class UniAppOrderVO {
|
|||||||
*/
|
*/
|
||||||
private String chargingAmount;
|
private String chargingAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应补缴金额
|
||||||
|
*/
|
||||||
|
private String remedialAmount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充电电量
|
* 充电电量
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user