diff --git a/package2/shop/orderDetail.vue b/package2/shop/orderDetail.vue index c4b14e1..0ab1efa 100644 --- a/package2/shop/orderDetail.vue +++ b/package2/shop/orderDetail.vue @@ -525,6 +525,18 @@ settlement }; }, + getMerchantDeliveryResponsibilityAmount(record, order) { + if (!record || !this.isMerchantDeliveryOrder(order)) return 0; + let responsibilityAmount = this.toAmount(this.getMerchantRefundDisplayAmount(record)); + let goodsPackageAmount = this.roundAmount(this.toAmount(order.goodsAmount) + this.toAmount(order.packageFee)); + let deliveryFee = this.toAmount(order.deliveryFee); + let deliveryResponsibilityAmount = this.roundAmount(responsibilityAmount - goodsPackageAmount); + if (deliveryResponsibilityAmount <= 0) return 0; + if (deliveryFee > 0 && deliveryResponsibilityAmount > deliveryFee) { + return this.roundAmount(deliveryFee); + } + return deliveryResponsibilityAmount; + }, buildMerchantIncomeSummary(order) { if (!order || this.isRunnerOrder(order)) { return { @@ -533,12 +545,12 @@ }; } let baseAmount = this.roundAmount(this.toAmount(order.goodsAmount) + this.toAmount(order.packageFee)); - let deliveryFee = this.toAmount(order.deliveryFee); let commissionRate = this.getCommissionRate(order); let refundRecords = Array.isArray(order.mallRefundRecord) ? order.mallRefundRecord : []; let approvedRefundRecords = refundRecords.filter(item => this.isApprovedRefundRecord(item)); let hasWorkerReasonRefund = approvedRefundRecords.some(item => item.status == 1 && item.refundTypeStatus == 2 && this.isWorkerRefundRecord(item)); - let hasMerchantReasonRefund = approvedRefundRecords.some(item => item.status == 1 && item.refundTypeStatus == 1 && this.isMerchantResponsibilityRecord(item)); + let merchantReasonRefundRecord = approvedRefundRecords.find(item => item.status == 1 && item.refundTypeStatus == 1 && this.isMerchantResponsibilityRecord(item)); + let hasMerchantReasonRefund = !!merchantReasonRefundRecord; let hasBothReasonRefund = approvedRefundRecords.some(item => item.status == 1 && item.refundTypeStatus == 3); let normalBaseAmount = (order.status == 6 || order.status == 8) ? 0 : baseAmount; if (order.status == 8 && hasWorkerReasonRefund) { @@ -558,9 +570,10 @@ amount: normalNet.settlement }); } - if (order.status == 8 && hasMerchantReasonRefund && this.isMerchantDeliveryOrder(order)) { - let deliveryDeduction = this.roundAmount(deliveryFee); - deductionBaseAmount = this.roundAmount(deductionBaseAmount + deliveryFee); + let refundDeliveryResponsibilityAmount = this.getMerchantDeliveryResponsibilityAmount(merchantReasonRefundRecord, order); + if (order.status == 8 && hasMerchantReasonRefund && refundDeliveryResponsibilityAmount > 0) { + let deliveryDeduction = this.roundAmount(refundDeliveryResponsibilityAmount); + deductionBaseAmount = this.roundAmount(deductionBaseAmount + refundDeliveryResponsibilityAmount); deductionSettlementAmount = this.roundAmount(deductionSettlementAmount + deliveryDeduction); lines.push({ name: '商家原因退款承担配送费', @@ -571,8 +584,8 @@ if (!this.isMerchantAfterSaleDeductionRecord(item)) return; let responsibilityAmount = this.toAmount(this.getMerchantRefundDisplayAmount(item)); if (responsibilityAmount <= 0) return; - let includesDeliveryFee = item.refundType == 3 && item.refundTypeStatus == 1 && this.isMerchantDeliveryOrder(order); - let commissionBase = includesDeliveryFee ? Math.max(0, responsibilityAmount - deliveryFee) : responsibilityAmount; + let deliveryResponsibilityAmount = this.getMerchantDeliveryResponsibilityAmount(item, order); + let commissionBase = deliveryResponsibilityAmount > 0 ? Math.max(0, responsibilityAmount - deliveryResponsibilityAmount) : responsibilityAmount; let deductionNet = this.getSettlementNet(responsibilityAmount, commissionBase, commissionRate); deductionBaseAmount = this.roundAmount(deductionBaseAmount + responsibilityAmount); deductionCommissionAmount = this.roundAmount(deductionCommissionAmount + deductionNet.commission); @@ -587,7 +600,7 @@ if (order.status == 8 && hasWorkerReasonRefund) { remark = '配送员原因全额退款,商家餐费仍按正常订单结算'; } else if (order.status == 8 && hasMerchantReasonRefund) { - remark = this.isMerchantDeliveryOrder(order) ? '商家原因全额退款,商家不结餐费并承担配送费' : '商家原因全额退款,商家不产生收入'; + remark = refundDeliveryResponsibilityAmount > 0 ? '商家原因全额退款,商家不结餐费并承担配送费' : '商家原因全额退款,商家不产生收入'; } else if (order.status == 8 && hasBothReasonRefund) { remark = '商家/配送员都有原因全额退款,商家不产生收入'; }