优化申诉仲裁流程和证据展示

This commit is contained in:
yml2213
2026-06-13 21:26:38 +08:00
parent 529ad1e433
commit 3ef7705776
22 changed files with 1455 additions and 138 deletions
+38 -8
View File
@@ -44,13 +44,27 @@ func (r *Repository) Create(ctx context.Context, userID uint64, orderID uint64,
return err
}
row := model.Dispute{
OrderID: order.ID,
InitiatorID: userID,
TargetUserID: targetID,
Type: disputeType(req.Type, isCheckoutDispute),
Status: "open",
Description: req.Description,
EvidenceURLS: evidence,
OrderID: order.ID,
InitiatorID: userID,
TargetUserID: targetID,
Type: disputeType(req.Type, isCheckoutDispute),
Status: "open",
Description: req.Description,
EvidenceURLS: evidence,
PreviousOrderStatus: order.Status,
PreviousHandoffStatus: order.HandoffStatus,
PreviousSettlementStatus: order.SettlementStatus,
}
var checkout model.OrderCheckout
if isCheckoutDispute {
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).
Where("order_id = ? AND status IN ?", order.ID, []string{"submitted", "countered"}).
Order("id DESC").
First(&checkout).Error; err != nil {
return err
}
row.CheckoutID = &checkout.ID
row.PreviousCheckoutStatus = checkout.Status
}
if err := tx.Create(&row).Error; err != nil {
return err
@@ -68,13 +82,29 @@ func (r *Repository) Create(ctx context.Context, userID uint64, orderID uint64,
updates["renter_rejected_at"] = now
}
if err := tx.Model(&model.OrderCheckout{}).
Where("order_id = ? AND status IN ?", order.ID, []string{"submitted", "countered"}).
Where("id = ?", checkout.ID).
Updates(updates).Error; err != nil {
return err
}
} else {
order.Status = "disputing"
}
recordType := "dispute_opened"
recordContent := "用户发起订单申诉:" + req.Description
if isCheckoutDispute {
recordType = "checkout_dispute_opened"
recordContent = "用户发起结账争议:" + req.Description
}
record := model.HandoffRecord{
OrderID: order.ID,
FromUserID: userID,
ToUserID: targetID,
Type: recordType,
Content: recordContent,
}
if err := tx.Create(&record).Error; err != nil {
return err
}
if err := tx.Save(&order).Error; err != nil {
return err
}