优化订单支付
This commit is contained in:
@@ -3,6 +3,7 @@ package dispute
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
@@ -268,6 +269,16 @@ func (r *Repository) Arbitrate(adminID uint64, id uint64, req ArbitrateRequest,
|
||||
if err := tx.Save(&account).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
handoffRecord := model.HandoffRecord{
|
||||
OrderID: order.ID,
|
||||
FromUserID: adminID,
|
||||
ToUserID: order.RenterID,
|
||||
Type: "admin_arbitration",
|
||||
Content: buildArbitrationHandoffContent(req, settlement),
|
||||
}
|
||||
if err := tx.Create(&handoffRecord).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
disputeID := row.ID
|
||||
if err := appendAuditLog(tx, adminID, "dispute.arbitrate", "dispute", row.ID, meta, map[string]any{
|
||||
"dispute_id": row.ID,
|
||||
@@ -525,6 +536,44 @@ func arbitrateOrderStatus(result string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func buildArbitrationHandoffContent(req ArbitrateRequest, settlement arbitrationSettlement) string {
|
||||
content := fmt.Sprintf("客服仲裁结果:%s", arbitrationResultLabel(req.Result))
|
||||
if req.Remark != "" {
|
||||
content += "\n处理说明:" + req.Remark
|
||||
}
|
||||
if settlement.RenterRefundAmount > 0 {
|
||||
content += fmt.Sprintf("\n退款给租客:¥%.2f", settlement.RenterRefundAmount)
|
||||
}
|
||||
if settlement.OwnerIncomeAmount > 0 {
|
||||
content += fmt.Sprintf("\n结算给号主:¥%.2f", settlement.OwnerIncomeAmount)
|
||||
}
|
||||
if settlement.DepositDeductAmount > 0 {
|
||||
content += fmt.Sprintf("\n押金扣除:¥%.2f", settlement.DepositDeductAmount)
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
func arbitrationResultLabel(result string) string {
|
||||
switch result {
|
||||
case "full_refund":
|
||||
return "全额退款"
|
||||
case "partial_refund":
|
||||
return "部分退款"
|
||||
case "deduct_deposit":
|
||||
return "扣押金"
|
||||
case "release_deposit":
|
||||
return "释放押金"
|
||||
case "compensate_owner":
|
||||
return "赔付号主"
|
||||
case "order_close":
|
||||
return "关闭订单"
|
||||
case "mark_abnormal":
|
||||
return "标记异常"
|
||||
default:
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
func disputeType(input string, isCheckoutDispute bool) string {
|
||||
if isCheckoutDispute {
|
||||
return "checkout_dispute"
|
||||
|
||||
Reference in New Issue
Block a user