202507251746

This commit is contained in:
张潘 2025-08-13 22:45:57 +08:00
parent 90268bd97b
commit 64d1cd8fad
3 changed files with 312 additions and 123 deletions

View File

@ -54,6 +54,38 @@ public class UsersPayBeforController extends BaseController
@Autowired
private RefundUtil refundUtil;
/**
* 安全地解析BigDecimal参数
*/
private BigDecimal parseBigDecimalSafely(Object obj) {
if (obj == null) {
return BigDecimal.ZERO;
}
try {
if (obj instanceof BigDecimal) {
return (BigDecimal) obj;
} else if (obj instanceof Number) {
return new BigDecimal(obj.toString());
} else if (obj instanceof String) {
String str = ((String) obj).trim();
if (str.isEmpty() || "0".equals(str) || "0.00".equals(str)) {
return BigDecimal.ZERO;
}
return new BigDecimal(str);
} else {
String str = obj.toString().trim();
if (str.isEmpty() || "0".equals(str) || "0.00".equals(str)) {
return BigDecimal.ZERO;
}
return new BigDecimal(str);
}
} catch (NumberFormatException e) {
System.err.println("无法解析BigDecimal: " + obj + ", 错误: " + e.getMessage());
return BigDecimal.ZERO;
}
}
/**
* 查询预支付列表
*/
@ -238,25 +270,58 @@ public class UsersPayBeforController extends BaseController
// 添加调试日志
System.out.println("=== 统一退款接口开始 ===");
System.out.println("接收到的参数: " + params);
String orderId = params.get("orderId") == null ? null : params.get("orderId").toString();
BigDecimal wechatRefund = params.get("wechatRefund") == null ? BigDecimal.ZERO : new BigDecimal(params.get("wechatRefund").toString());
BigDecimal balanceRefund = params.get("balanceRefund") == null ? BigDecimal.ZERO : new BigDecimal(params.get("balanceRefund").toString());
BigDecimal shoppingGoldRefund = params.get("shoppingGoldRefund") == null ? BigDecimal.ZERO : new BigDecimal(params.get("shoppingGoldRefund").toString());
BigDecimal serviceGoldRefund = params.get("serviceGoldRefund") == null ? BigDecimal.ZERO : new BigDecimal(params.get("serviceGoldRefund").toString());
BigDecimal memberDiscountRefund = params.get("memberDiscountRefund") == null ? BigDecimal.ZERO : new BigDecimal(params.get("memberDiscountRefund").toString());
BigDecimal couponRefund = params.get("couponRefund") == null ? BigDecimal.ZERO : new BigDecimal(params.get("couponRefund").toString());
// 修复确保BigDecimal转换正确处理可能的null值和类型问题
BigDecimal wechatRefund = BigDecimal.ZERO;
BigDecimal balanceRefund = BigDecimal.ZERO;
BigDecimal shoppingGoldRefund = BigDecimal.ZERO;
BigDecimal serviceGoldRefund = BigDecimal.ZERO;
BigDecimal memberDiscountRefund = BigDecimal.ZERO;
BigDecimal couponRefund = BigDecimal.ZERO;
try {
Object wxObj = params.get("wechatRefund");
Object balanceObj = params.get("balanceRefund");
Object shopObj = params.get("shoppingGoldRefund");
Object serviceObj = params.get("serviceGoldRefund");
Object memberObj = params.get("memberDiscountRefund");
Object couponObj = params.get("couponRefund");
System.out.println("=== 参数对象类型检查 ===");
System.out.println("wechatRefund对象: " + wxObj + " (类型: " + (wxObj != null ? wxObj.getClass().getName() : "null") + ")");
System.out.println("balanceRefund对象: " + balanceObj + " (类型: " + (balanceObj != null ? balanceObj.getClass().getName() : "null") + ")");
System.out.println("shoppingGoldRefund对象: " + shopObj + " (类型: " + (shopObj != null ? shopObj.getClass().getName() : "null") + ")");
System.out.println("serviceGoldRefund对象: " + serviceObj + " (类型: " + (serviceObj != null ? serviceObj.getClass().getName() : "null") + ")");
System.out.println("memberDiscountRefund对象: " + memberObj + " (类型: " + (memberObj != null ? memberObj.getClass().getName() : "null") + ")");
System.out.println("couponRefund对象: " + couponObj + " (类型: " + (couponObj != null ? couponObj.getClass().getName() : "null") + ")");
// 安全的BigDecimal转换
wechatRefund = parseBigDecimalSafely(wxObj);
balanceRefund = parseBigDecimalSafely(balanceObj);
shoppingGoldRefund = parseBigDecimalSafely(shopObj);
serviceGoldRefund = parseBigDecimalSafely(serviceObj);
memberDiscountRefund = parseBigDecimalSafely(memberObj);
couponRefund = parseBigDecimalSafely(couponObj);
} catch (Exception e) {
System.err.println("参数转换异常: " + e.getMessage());
e.printStackTrace();
return error("参数转换失败:" + e.getMessage());
}
String refundRemark = params.get("refundRemark") == null ? "" : params.get("refundRemark").toString();
// 添加参数解析后的调试日志
System.out.println("解析后的参数:");
System.out.println("=== 解析后的参数 ===");
System.out.println(" orderId: " + orderId);
System.out.println(" wechatRefund: " + wechatRefund);
System.out.println(" balanceRefund: " + balanceRefund);
System.out.println(" shoppingGoldRefund: " + shoppingGoldRefund);
System.out.println(" serviceGoldRefund: " + serviceGoldRefund);
System.out.println(" memberDiscountRefund: " + memberDiscountRefund);
System.out.println(" couponRefund: " + couponRefund);
System.out.println(" wechatRefund: " + wechatRefund + " (类型: " + wechatRefund.getClass().getName() + ")");
System.out.println(" balanceRefund: " + balanceRefund + " (类型: " + balanceRefund.getClass().getName() + ")");
System.out.println(" shoppingGoldRefund: " + shoppingGoldRefund + " (类型: " + shoppingGoldRefund.getClass().getName() + ")");
System.out.println(" serviceGoldRefund: " + serviceGoldRefund + " (类型: " + serviceGoldRefund.getClass().getName() + ")");
System.out.println(" memberDiscountRefund: " + memberDiscountRefund + " (类型: " + memberDiscountRefund.getClass().getName() + ")");
System.out.println(" couponRefund: " + couponRefund + " (类型: " + couponRefund.getClass().getName() + ")");
System.out.println(" refundRemark: " + refundRemark);
if (orderId == null || orderId.trim().isEmpty()) {
@ -301,6 +366,7 @@ public class UsersPayBeforController extends BaseController
// }
List<UsersPayBefor> payRecords = usersPayBeforService.selectPayDetailsByOrderId(orderId);
System.out.println("000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"+payRecords.size());
if (payRecords == null || payRecords.isEmpty()) {
return error("未找到支付记录");
}
@ -308,11 +374,12 @@ public class UsersPayBeforController extends BaseController
// 计算已退款金额
BigDecimal totalRefunded = BigDecimal.ZERO;
for (UsersPayBefor record : payRecords) {
System.out.println("111%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"+record.getReturnmoney());
if (record.getReturnmoney() != null) {
totalRefunded = totalRefunded.add(record.getReturnmoney());
}
}
System.out.println("222%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"+totalRefunded);
// 计算总支付金额减去会员优惠因为会员优惠不参与退款
BigDecimal totalPaid = BigDecimal.ZERO;
BigDecimal totalMemberDiscount = BigDecimal.ZERO;
@ -325,17 +392,56 @@ public class UsersPayBeforController extends BaseController
totalMemberDiscount = totalMemberDiscount.add(record.getMembermoney());
}
}
// 实际可退款金额 = 总支付金额 - 会员优惠金额
BigDecimal actualRefundableAmount = totalPaid.subtract(totalMemberDiscount);
//退款金额不能超过剩余可退款金额剩余可退款10.90总支付199.00会员优惠9.90已退款178.20
// 验证退款金额不能超过剩余可退款金额基于实际可退金额
BigDecimal remainingRefundable = actualRefundableAmount.subtract(totalRefunded);
if (totalRefund.compareTo(remainingRefundable) > 0) {
return error("退款金额不能超过剩余可退款金额,剩余可退款:¥" + remainingRefundable +
return error("退款金额不能超过剩余可退款金额,剩余可退款:¥" + remainingRefundable +
"(总支付:¥" + totalPaid + ",会员优惠:¥" + totalMemberDiscount + ",已退款:¥" + totalRefunded + "");
}
// 添加关键验证确保各项退款金额不超过对应的支付金额
System.out.println("=== 退款金额验证 ===");
System.out.println("微信退款: " + wechatRefund + " vs 微信支付: " + paymentInfo.getWxmoney());
System.out.println("余额退款: " + balanceRefund + " vs 余额支付: " + paymentInfo.getYemoney());
System.out.println("购物金退款: " + shoppingGoldRefund + " vs 购物金: " + paymentInfo.getShopmoney());
System.out.println("服务金退款: " + serviceGoldRefund + " vs 服务金: " + paymentInfo.getServicemoney());
System.out.println("优惠券退款: " + couponRefund + " vs 优惠券: " + paymentInfo.getCouponmoney());
// 验证各项退款金额不超过对应的支付金额
if (wechatRefund.compareTo(BigDecimal.ZERO) > 0 &&
paymentInfo.getWxmoney() != null &&
wechatRefund.compareTo(paymentInfo.getWxmoney()) > 0) {
return error("微信退款金额不能超过微信支付金额");
}
if (balanceRefund.compareTo(BigDecimal.ZERO) > 0 &&
paymentInfo.getYemoney() != null &&
balanceRefund.compareTo(paymentInfo.getYemoney()) > 0) {
return error("余额退款金额不能超过余额支付金额");
}
if (shoppingGoldRefund.compareTo(BigDecimal.ZERO) > 0 &&
paymentInfo.getShopmoney() != null &&
shoppingGoldRefund.compareTo(paymentInfo.getShopmoney()) > 0) {
return error("购物金退款金额不能超过购物金金额");
}
if (serviceGoldRefund.compareTo(BigDecimal.ZERO) > 0 &&
paymentInfo.getServicemoney() != null &&
serviceGoldRefund.compareTo(paymentInfo.getServicemoney()) > 0) {
return error("服务金退款金额不能超过服务金金额");
}
if (couponRefund.compareTo(BigDecimal.ZERO) > 0 &&
paymentInfo.getCouponmoney() != null &&
couponRefund.compareTo(paymentInfo.getCouponmoney()) > 0) {
return error("优惠券退款金额不能超过优惠券金额");
}
// 记录退款日志
OrderLog orderLog = new OrderLog();
orderLog.setOrderId(orderId);
@ -401,77 +507,111 @@ public class UsersPayBeforController extends BaseController
BigDecimal remainingShoppingGoldRefund = shoppingGoldRefund;
BigDecimal remainingServiceGoldRefund = serviceGoldRefund;
BigDecimal remainingCouponRefund = couponRefund;
// 修复正确计算各项支付方式的退款金额
for (UsersPayBefor record : payRecords) {
BigDecimal currentRefunded = record.getReturnmoney() != null ? record.getReturnmoney() : BigDecimal.ZERO;
// 计算本次退款中该记录应承担的退款金额
BigDecimal recordRefundAmount = BigDecimal.ZERO;
// 根据该记录的支付方式分配退款金额
if (record.getWxmoney() != null && record.getWxmoney().compareTo(BigDecimal.ZERO) > 0) {
BigDecimal wxRefund = remainingWechatRefund.min(record.getWxmoney().subtract(currentRefunded));
if (wxRefund.compareTo(BigDecimal.ZERO) > 0) {
// 修复计算该记录微信支付的剩余可退款金额
BigDecimal wxRemaining = record.getWxmoney().subtract(currentRefunded);
if (wxRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingWechatRefund.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal wxRefund = remainingWechatRefund.min(wxRemaining);
recordRefundAmount = recordRefundAmount.add(wxRefund);
remainingWechatRefund = remainingWechatRefund.subtract(wxRefund);
}
}
if (record.getYemoney() != null && record.getYemoney().compareTo(BigDecimal.ZERO) > 0) {
BigDecimal yeRefund = remainingBalanceRefund.min(record.getYemoney().subtract(currentRefunded));
if (yeRefund.compareTo(BigDecimal.ZERO) > 0) {
// 修复计算该记录余额支付的剩余可退款金额
BigDecimal yeRemaining = record.getYemoney().subtract(currentRefunded);
if (yeRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingBalanceRefund.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal yeRefund = remainingBalanceRefund.min(yeRemaining);
recordRefundAmount = recordRefundAmount.add(yeRefund);
remainingBalanceRefund = remainingBalanceRefund.subtract(yeRefund);
}
}
if (record.getShopmoney() != null && record.getShopmoney().compareTo(BigDecimal.ZERO) > 0) {
BigDecimal shopRefund = remainingShoppingGoldRefund.min(record.getShopmoney().subtract(currentRefunded));
if (shopRefund.compareTo(BigDecimal.ZERO) > 0) {
// 修复计算该记录购物金的剩余可退款金额
BigDecimal shopRemaining = record.getShopmoney().subtract(currentRefunded);
if (shopRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingShoppingGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal shopRefund = remainingShoppingGoldRefund.min(shopRemaining);
recordRefundAmount = recordRefundAmount.add(shopRefund);
remainingShoppingGoldRefund = remainingShoppingGoldRefund.subtract(shopRefund);
}
}
if (record.getServicemoney() != null && record.getServicemoney().compareTo(BigDecimal.ZERO) > 0) {
BigDecimal serviceRefund = remainingServiceGoldRefund.min(record.getServicemoney().subtract(currentRefunded));
if (serviceRefund.compareTo(BigDecimal.ZERO) > 0) {
// 修复计算该记录服务金的剩余可退款金额
BigDecimal serviceRemaining = record.getServicemoney().subtract(currentRefunded);
if (serviceRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingServiceGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal serviceRefund = remainingServiceGoldRefund.min(serviceRemaining);
recordRefundAmount = recordRefundAmount.add(serviceRefund);
remainingServiceGoldRefund = remainingServiceGoldRefund.subtract(serviceRefund);
}
}
if (record.getCouponmoney() != null && record.getCouponmoney().compareTo(BigDecimal.ZERO) > 0) {
BigDecimal couponRefundAmount = remainingCouponRefund.min(record.getCouponmoney().subtract(currentRefunded));
if (couponRefundAmount.compareTo(BigDecimal.ZERO) > 0) {
// 修复计算该记录优惠券的剩余可退款金额
BigDecimal couponRemaining = record.getCouponmoney().subtract(currentRefunded);
if (couponRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingCouponRefund.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal couponRefundAmount = remainingCouponRefund.min(couponRemaining);
recordRefundAmount = recordRefundAmount.add(couponRefundAmount);
remainingCouponRefund = remainingCouponRefund.subtract(couponRefundAmount);
}
}
// 如果该记录有退款金额则更新
if (recordRefundAmount.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal newTotalRefunded = currentRefunded.add(recordRefundAmount);
// 如果累计退款金额等于或超过支付金额设置为已退款状态
if (newTotalRefunded.compareTo(record.getAllmoney()) >= 0) {
record.setStatus(3L); // 完全退款
} else {
record.setStatus(2L); // 部分退款
}
record.setReturnmoney(newTotalRefunded);
usersPayBeforService.updateUsersPayBefor(record);
System.out.println("更新支付记录: ID=" + record.getId() +
", 原退款金额=" + currentRefunded +
", 本次退款=" + recordRefundAmount +
", 新总退款=" + newTotalRefunded +
", 状态=" + record.getStatus());
}
}
// 调用退款工具方法实现真实的业务退款与金额变动
// 使用原始参数而不是被修改的副本
System.out.println("=== 调用退款工具方法前的参数验证 ===");
System.out.println("原始退款参数:");
System.out.println(" orderId: " + orderId);
System.out.println(" wechatRefund: " + wechatRefund);
System.out.println(" balanceRefund: " + balanceRefund);
System.out.println(" shoppingGoldRefund: " + shoppingGoldRefund);
System.out.println(" serviceGoldRefund: " + serviceGoldRefund);
System.out.println(" memberDiscountRefund: " + memberDiscountRefund);
System.out.println(" couponRefund: " + couponRefund);
System.out.println(" refundRemark: " + refundRemark);
// 验证参数类型和值
System.out.println("参数类型检查:");
System.out.println(" balanceRefund类型: " + balanceRefund.getClass().getName());
System.out.println(" balanceRefund值: " + balanceRefund);
System.out.println(" balanceRefund比较0: " + balanceRefund.compareTo(BigDecimal.ZERO));
Map<String, Object> refundResult = refundUtil.processUnifiedRefund(
orderId, wechatRefund, balanceRefund, shoppingGoldRefund,
serviceGoldRefund, memberDiscountRefund, couponRefund, refundRemark
);
if (refundResult != null && (Boolean) refundResult.get("success")) {
return success("退款成功");
} else {

View File

@ -9,8 +9,17 @@
<div class="payment-info" v-if="actualPaymentData">
<h4>支付信息</h4>
<!-- 调试信息 -->
<!-- &lt;!&ndash; 调试信息 &ndash;&gt;-->
<!-- <div class="debug-info" style="background: #f0f9ff; padding: 10px; margin-bottom: 15px; border-radius: 4px; font-size: 12px;">-->
<!-- <div>调试信息</div>-->
<!-- <div>allmoney: {{ actualPaymentData.allmoney }}</div>-->
<!-- <div>wxmoney: {{ actualPaymentData.wxmoney }}</div>-->
<!-- <div>yemoney: {{ actualPaymentData.yemoney }}</div>-->
<!-- <div>shopmoney: {{ actualPaymentData.shopmoney }}</div>-->
<!-- <div>servicemoney: {{ actualPaymentData.servicemoney }}</div>-->
<!-- <div>couponmoney: {{ actualPaymentData.couponmoney }}</div>-->
<!-- <div>membermoney: {{ actualPaymentData.membermoney }}</div>-->
<!-- </div>-->
<el-row :gutter="20">
<el-col :span="8">
@ -46,7 +55,7 @@
</div>
</el-col>
</el-row>
<!-- 会员优惠单独显示仅当不为0时 -->
<div v-if="actualPaymentData.membermoney && parseFloat(actualPaymentData.membermoney) > 0" class="member-discount-row">
<div class="member-discount-item">
@ -56,7 +65,7 @@
</div>
<div class="total-amount">
<label>总支付金额</label>
<span class="amount total">{{ formatAmount(totalPaymentAmount) }}</span>
<span class="amount total">{{ formatAmount(actualPaymentData.allmoney) }}</span>
</div>
<!-- 退款统计信息 -->
@ -76,7 +85,7 @@
</el-col>
</el-row>
<div class="summary-note">
<span class="note-text">💡 实际可退款金额{{ formatAmount(actualRefundableAmount) }}总支付{{ formatAmount(totalPaymentAmount) }} - 会员优惠{{ formatAmount(actualPaymentData.membermoney || 0) }}</span>
<span class="note-text">💡 实际可退款金额{{ formatAmount(actualRefundableAmount) }}总支付{{ formatAmount(actualPaymentData.allmoney) }} - 会员优惠{{ formatAmount(actualPaymentData.membermoney || 0) }}</span>
</div>
<!-- <div class="summary-extra">-->
<!-- <span class="refund-count">退款次数{{ refundHistory.length }}</span>-->
@ -274,7 +283,7 @@
<div class="timeline-header">
<div class="header-title">
<span class="title-text">退款记录 #{{ index + 1 }}</span>
<span class="title-time">&nbsp;&nbsp;&nbsp;{{ formatTime(item.createdAt) }}</span>
<span class="title-time">&nbsp;&nbsp;&nbsp;{{ formatTime(item.createTime) }}</span>
</div>
<!-- <div class="header-actions">-->
<!-- <el-button-->
@ -395,18 +404,17 @@ export default {
computed: {
totalPaymentAmount() {
if (!this.actualPaymentData) return "0.00";
const total = (this.actualPaymentData.wxmoney || 0) + (this.actualPaymentData.yemoney || 0) +
(this.actualPaymentData.shopmoney || 0) + (this.actualPaymentData.servicemoney || 0) +
(this.actualPaymentData.membermoney || 0) + (this.actualPaymentData.couponmoney || 0);
return total.toFixed(2);
// allmoney
return this.formatAmount(this.actualPaymentData.allmoney);
},
// 退
actualRefundableAmount() {
if (!this.actualPaymentData) return "0.00";
const allMoney = parseFloat(this.actualPaymentData.allmoney || 0);
const memberDiscount = parseFloat(this.actualPaymentData.membermoney || 0);
const total = parseFloat(this.totalPaymentAmount);
return (total - memberDiscount).toFixed(2);
// 退 = allmoney -
return (allMoney - memberDiscount).toFixed(2);
},
canRefund() {
@ -625,10 +633,24 @@ export default {
this.actualPaymentData = response.data;
console.log('支付数据加载成功:', this.actualPaymentData);
//
if (!this.actualPaymentData.allmoney) {
console.warn('警告支付数据缺少allmoney字段');
this.$message.warning("支付数据不完整,请检查数据源");
}
// 退
this.refundHistory = [];
this.totalRefundedAmount = "0.00";
this.remainingRefundableAmount = this.actualRefundableAmount;
// 退 = allmoney - 退
const allMoney = parseFloat(this.actualPaymentData.allmoney || 0);
const memberDiscount = parseFloat(this.actualPaymentData.membermoney || 0);
this.remainingRefundableAmount = (allMoney - memberDiscount).toFixed(2);
console.log('初始计算:');
console.log(' allmoney:', allMoney);
console.log(' 会员优惠:', memberDiscount);
console.log(' 初始剩余可退款:', this.remainingRefundableAmount);
// 退
await this.loadRefundHistory();
@ -710,9 +732,12 @@ export default {
console.warn('响应码:', response.code, '响应消息:', response.msg);
if (attempt === maxRetries) { //
this.refundHistory = [];
this.totalRefundedAmount = "0.00";
this.remainingRefundableAmount = this.totalPaymentAmount;
this.refundHistory = [];
this.totalRefundedAmount = "0.00";
// 使
const allMoney = parseFloat(this.actualPaymentData.allmoney || 0);
const memberDiscount = parseFloat(this.actualPaymentData.membermoney || 0);
this.remainingRefundableAmount = (allMoney - memberDiscount).toFixed(2);
this.refundHistoryError = response.msg || "加载退款历史失败";
this.errorDetails = {
code: response.code,
@ -726,13 +751,16 @@ export default {
await new Promise(resolve => setTimeout(resolve, delay));
}
}
} catch (error) {
} catch (error) {
console.error(`加载退款历史失败,第${attempt}次尝试:`, error);
if (attempt === maxRetries) { //
this.refundHistory = [];
this.totalRefundedAmount = "0.00";
this.remainingRefundableAmount = this.totalPaymentAmount;
// 使
const allMoney = parseFloat(this.actualPaymentData.allmoney || 0);
const memberDiscount = parseFloat(this.actualPaymentData.membermoney || 0);
this.remainingRefundableAmount = (allMoney - memberDiscount).toFixed(2);
this.refundHistoryError = "加载退款历史失败,请稍后再试";
this.errorDetails = {
code: 'N/A',
@ -798,14 +826,22 @@ export default {
});
this.totalRefundedAmount = total.toFixed(2);
// 退退 - 退
const actualRefundable = parseFloat(this.actualRefundableAmount);
// 退 = allmoney - - returnmoney
const allMoney = parseFloat(this.actualPaymentData.allmoney || 0);
const memberDiscount = parseFloat(this.actualPaymentData.membermoney || 0);
const totalRefunded = parseFloat(this.totalRefundedAmount);
const remaining = Math.max(0, actualRefundable - totalRefunded);
// allmoney - - returnmoney
const remaining = Math.max(0, allMoney - memberDiscount - totalRefunded);
this.remainingRefundableAmount = remaining.toFixed(2);
console.log('累计退款金额:', this.totalRefundedAmount, '实际可退款金额:', this.actualRefundableAmount, '剩余可退款:', this.remainingRefundableAmount);
console.log('计算详情:');
console.log(' allmoney:', allMoney);
console.log(' 会员优惠:', memberDiscount);
console.log(' 累计已退款:', totalRefunded);
console.log(' 剩余可退款:', this.remainingRefundableAmount);
console.log(' 计算公式: allmoney - 优惠金额 - returnmoney =', allMoney, '-', memberDiscount, '-', totalRefunded, '=', remaining);
},
initForm() {
@ -821,38 +857,40 @@ export default {
this.refundForm.serviceGoldRefund = "";
this.refundForm.couponRefund = "0"; // 退
this.refundForm.refundRemark = "";
// 退退
if (this.refundHistory.length > 0) {
this.calculateTotalRefunded();
} else {
// 退
this.remainingRefundableAmount = this.actualRefundableAmount;
// 退allmoney -
const allMoney = parseFloat(this.actualPaymentData.allmoney || 0);
const memberDiscount = parseFloat(this.actualPaymentData.membermoney || 0);
this.remainingRefundableAmount = (allMoney - memberDiscount).toFixed(2);
}
this.calculateTotalRefund();
},
calculateTotalRefund() {
console.log('=== 开始计算总退款金额 ===');
console.log('refundForm:', this.refundForm);
const wechatAmount = parseFloat(this.refundForm.wechatRefund) || 0;
const balanceAmount = parseFloat(this.refundForm.balanceRefund) || 0;
const shoppingAmount = parseFloat(this.refundForm.shoppingGoldRefund) || 0;
const serviceAmount = parseFloat(this.refundForm.serviceGoldRefund) || 0;
const couponAmount = parseFloat(this.refundForm.couponRefund === '1' ? this.actualPaymentData.couponmoney : 0) || 0;
console.log('各项金额:');
console.log(' 微信退款:', wechatAmount);
console.log(' 余额退款:', balanceAmount);
console.log(' 购物金退款:', shoppingAmount);
console.log(' 服务金退款:', serviceAmount);
console.log(' 优惠券退款:', couponAmount);
const total = wechatAmount + balanceAmount + shoppingAmount + serviceAmount + couponAmount;
this.totalRefundAmount = total.toFixed(2);
console.log('总退款金额:', this.totalRefundAmount);
},
@ -883,7 +921,7 @@ export default {
console.log('=== 开始确认退款 ===');
console.log('refundForm:', this.refundForm);
console.log('actualPaymentData:', this.actualPaymentData);
const params = {
orderId: this.orderId,
wechatRefund: this.refundForm.wechatRefund || "0",
@ -894,17 +932,28 @@ export default {
refundRemark: this.refundForm.refundRemark
};
console.log('构建的参数:', params);
console.log('参数类型检查:');
console.log(' orderId:', typeof params.orderId, params.orderId);
console.log(' wechatRefund:', typeof params.wechatRefund, params.wechatRefund);
console.log(' balanceRefund:', typeof params.balanceRefund, params.balanceRefund);
console.log(' shoppingGoldRefund:', typeof params.shoppingGoldRefund, params.shoppingGoldRefund);
console.log(' serviceGoldRefund:', typeof params.serviceGoldRefund, params.serviceGoldRefund);
console.log(' couponRefund:', typeof params.couponRefund, params.couponRefund);
console.log(' refundRemark:', typeof params.refundRemark, params.refundRemark);
//
console.log('=== 参数验证和转换 ===');
console.log('原始表单数据:', this.refundForm);
const response = await unifiedRefund(params);
//
const validatedParams = {
orderId: this.orderId,
wechatRefund: parseFloat(this.refundForm.wechatRefund || "0").toFixed(2),
balanceRefund: parseFloat(this.refundForm.balanceRefund || "0").toFixed(2),
shoppingGoldRefund: parseFloat(this.refundForm.shoppingGoldRefund || "0").toFixed(2),
serviceGoldRefund: parseFloat(this.refundForm.serviceGoldRefund || "0").toFixed(2),
couponRefund: this.refundForm.couponRefund === '1' ? parseFloat(this.actualPaymentData.couponmoney || "0").toFixed(2) : "0.00",
refundRemark: this.refundForm.refundRemark
};
console.log('验证后的参数:', validatedParams);
console.log('参数类型检查:');
console.log(' balanceRefund:', typeof validatedParams.balanceRefund, validatedParams.balanceRefund);
console.log(' balanceRefund数值:', parseFloat(validatedParams.balanceRefund));
// 使
const response = await unifiedRefund(validatedParams);
console.log('退款接口响应:', response);
@ -912,8 +961,8 @@ export default {
this.$message.success("退款成功");
this.$emit("success", response.data);
// 退
await this.loadRefundHistory();
// 退
await this.loadPaymentData();
this.handleClose();
} else {
@ -1191,11 +1240,11 @@ export default {
.payment-info h4 { margin: 0 0 15px 0; color: #303133; font-size: 16px; font-weight: 600; }
.info-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding: 8px 0; }
.info-item label { font-weight: 500; color: #606266; min-width: 80px; }
.info-item .member-discount-note {
font-size: 12px;
color: #909399;
margin-top: 5px;
font-style: italic;
.info-item .member-discount-note {
font-size: 12px;
color: #909399;
margin-top: 5px;
font-style: italic;
text-align: center;
width: 100%;
}

View File

@ -10,7 +10,7 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="支付单号" prop="transactionId">
<el-input
v-model="queryParams.transactionId"
@ -152,7 +152,7 @@
<!-- 操作按钮 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="warning"
@ -163,7 +163,7 @@
v-hasPermi="['system:GoodsOrder:edit']"
>Excel批量发货</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
@ -186,16 +186,16 @@
>
<el-table-column type="selection" width="55" align="center" />
<!-- 订单基本信息 -->
<el-table-column label="主订单号" align="center" prop="mainOrderId" class-name="order-column" />
<el-table-column label="订单状态" align="center" prop="status" class-name="order-column">
<template slot-scope="scope">
<dict-tag :options="dict.type.goods_order_status" :value="scope.row.status"/>
</template>
</el-table-column>
<!-- 商品信息 -->
<el-table-column label="商品" align="center" prop="productName" class-name="product-column">
<template slot-scope="scope">
@ -213,7 +213,7 @@
</template>
</el-table-column>
<el-table-column label="数量" align="center" width="65" prop="num" class-name="product-column" />
<!-- 金额信息 -->
<el-table-column label="总价" width="100px" align="center" prop="totalPrice" class-name="amount-column">
<template slot-scope="scope">
@ -234,11 +234,11 @@
<span class="amount-deduction">{{scope.row.deduction ? scope.row.deduction.toFixed(2) : '0.00'}}</span>
</template>
</el-table-column>
<!-- 用户信息 -->
<el-table-column label="姓名" align="center" width="75" prop="name" class-name="user-column" />
<el-table-column label="电话" align="center" width="125" prop="phone" class-name="user-column" />
<!-- 时间信息 -->
<el-table-column label="支付时间" align="center" prop="payTime" width="120" class-name="time-column">
<template slot-scope="scope">
@ -257,7 +257,7 @@
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
<template slot-scope="scope">
<!-- 发货按钮 - 只有已支付待发货状态的订单才显示 -->
<el-button
v-if="scope.row.status === 2"
@ -276,10 +276,10 @@
@click="handleAfterSale(scope.row)"
style="color: #E6A23C;"
>售后</el-button>
<!-- v-if="scope.row.status >= 15"-->
<!-- 统一退款按钮 -->
<el-button
v-if="scope.row.status >= 15"
size="mini"
type="text"
icon="el-icon-money"
@ -289,7 +289,7 @@
<!-- 如果是主行显示查看详情按钮 -->
<el-button
size="mini"
type="text"
icon="el-icon-view"
@ -386,14 +386,14 @@
/>
<!-- Excel导入结果对话框 -->
<ImportResultDialog
<ImportResultDialog
:visible.sync="importResultVisible"
:importResult="importResult"
@close="importResultVisible = false"
@refresh="refreshOrderList"
/>
<!-- 订单详情组件 -->
<GoodsOrderDetails
@ -416,9 +416,9 @@
:paymentData="currentRefundPaymentData"
@success="handleRefundSuccess"
/>
</div>
@ -676,7 +676,7 @@ export default {
if (!this.GoodsOrderList || this.GoodsOrderList.length === 0) {
return;
}
this.GoodsOrderList.forEach((item, index) => {
if (item.mainOrderId) {
getGoodsOrderByMainOrderId(item.mainOrderId).then(response => {
@ -699,7 +699,7 @@ export default {
this.loading = false
this.groupedGoodsOrderList()
this.total = response.total
})
},
@ -795,7 +795,7 @@ export default {
this.unifiedRefundDialogVisible = false;
this.currentRefundOrder = null;
this.currentRefundPaymentData = null;
// 使nextTick
this.$nextTick(() => {
//
@ -803,10 +803,10 @@ export default {
this.currentDetailOrder = null;
this.currentDetailOrderId = null;
this.currentShipOrder = null;
//
this.prePaymentData = null;
//
this.shipmentOrders = [];
this.shipForm = {
@ -833,7 +833,7 @@ export default {
//
this.currentAfterSaleOrder = null;
this.afterSaleDialogVisible = false;
// 使nextTickDOM
this.$nextTick(() => {
this.currentAfterSaleOrder = row;
@ -863,10 +863,10 @@ export default {
if (response.code === 200) {
this.$modal.msgSuccess('操作成功');
this.closeAllDialogs();
//
this.currentAfterSaleOrder = null;
//
this.getList();
} else {
@ -987,7 +987,7 @@ export default {
this.currentShipOrder = null;
this.shipmentOrders = [];
this.shipDialogVisible = false;
// 使nextTickDOM
this.$nextTick(() => {
this.currentShipOrder = row;
@ -1039,7 +1039,7 @@ export default {
this.$modal.msgSuccess('发货成功')
this.shipDialogVisible = false
this.shipLoading = false;
//
this.currentShipOrder = null;
this.shipmentOrders = [];
@ -1055,7 +1055,7 @@ export default {
sendTime: '',
mark: ''
};
this.getList() //
}).catch(error => {
this.$modal.msgError('发货失败:' + (error.message || '未知错误'))
@ -1070,7 +1070,7 @@ export default {
//
this.prePaymentData = null;
this.prePaymentDialogVisible = false;
if (!row.orderId) {
this.$modal.msgWarning('该订单没有订单号');
return;
@ -1098,7 +1098,7 @@ export default {
//
this.excelImportDialogVisible = false;
this.excelImportForm.file = null;
// 使nextTickDOM
this.$nextTick(() => {
this.excelImportDialogVisible = true;
@ -1196,7 +1196,7 @@ export default {
/** 查看订单详情 */
async handleViewDetails(row) {
this.currentDetailOrder = row;
this.currentDetailOrderId = row.id; // ID
this.detailDialogVisible = true;
@ -1635,7 +1635,7 @@ export default {
.el-table .el-table__cell {
padding: 8px 4px;
}
.el-table th {
padding: 10px 4px;
}
@ -1645,11 +1645,11 @@ export default {
.el-table {
font-size: 12px;
}
.el-table .el-table__cell {
padding: 6px 2px;
}
.el-table th {
padding: 8px 2px;
}