记录退款金额到订单支付记录

This commit is contained in:
2024-01-17 16:35:03 +08:00
parent 5a35135500
commit 8f7e3eaa94
8 changed files with 61 additions and 42 deletions

View File

@@ -1299,11 +1299,10 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
// List<String> collect = list.stream().map(BalanceDeductionAmountVO::getPaymentId).collect(Collectors.toList());
List<OrderPayRecord> orderPayRecordList = orderPayRecordService.getOrderPayRecordList(orderBasicInfo.getOrderCode());
AbstractProgramLogic orderLogic = new DelayMerchantProgramLogic();
List<PaymentInfo> paymentInfos = Lists.newArrayList();
for (OrderPayRecord orderPayRecord : orderPayRecordList) {
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());

View File

@@ -1,6 +1,9 @@
package com.jsowell.pile.service.impl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.google.common.collect.Lists;
import com.jsowell.adapay.vo.PaymentInfo;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.ykc.ActionTypeEnum;
@@ -18,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -155,6 +159,44 @@ public class OrderPayRecordServiceImpl implements OrderPayRecordService {
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
public int insertSelective(OrderPayRecord record) {
return orderPayRecordMapper.insertSelective(record);