chore(init): 初始化解忧商行项目并完成 Phase 0 基座
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package dispute
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
|
||||
type disputeRow struct {
|
||||
model.Dispute
|
||||
OrderNo string
|
||||
OrderStatus string
|
||||
HandoffStatus string
|
||||
SettlementStatus string
|
||||
ExtraItemOriginalAmountCent int64
|
||||
ListingNo string
|
||||
Title string
|
||||
OwnerID uint64
|
||||
RenterID uint64
|
||||
OwnerPhone string
|
||||
RenterPhone string
|
||||
CheckoutCoinConsumedM *float64
|
||||
CheckoutConsumableAmountCent *int64
|
||||
CheckoutDepositDeductAmountCent *int64
|
||||
}
|
||||
|
||||
func (row disputeRow) toDTO() DisputeDTO {
|
||||
return DisputeDTO{
|
||||
ID: row.ID,
|
||||
OrderID: row.OrderID,
|
||||
OrderNo: row.OrderNo,
|
||||
OrderStatus: row.OrderStatus,
|
||||
HandoffStatus: row.HandoffStatus,
|
||||
SettlementStatus: row.SettlementStatus,
|
||||
ExtraItemOriginalAmountCent: row.ExtraItemOriginalAmountCent,
|
||||
ListingNo: row.ListingNo,
|
||||
Title: row.Title,
|
||||
OwnerID: row.OwnerID,
|
||||
RenterID: row.RenterID,
|
||||
OwnerPhone: row.OwnerPhone,
|
||||
RenterPhone: row.RenterPhone,
|
||||
InitiatorID: row.InitiatorID,
|
||||
InitiatorType: effectiveInitiatorType(row.Dispute),
|
||||
InitiatorAdminID: row.InitiatorAdminID,
|
||||
TargetUserID: row.TargetUserID,
|
||||
Type: row.Type,
|
||||
Status: row.Status,
|
||||
Description: row.Description,
|
||||
EvidenceURLS: row.EvidenceURLS,
|
||||
PreviousOrderStatus: row.PreviousOrderStatus,
|
||||
PreviousHandoffStatus: row.PreviousHandoffStatus,
|
||||
PreviousSettlementStatus: row.PreviousSettlementStatus,
|
||||
CheckoutID: row.CheckoutID,
|
||||
CheckoutCoinConsumedM: row.CheckoutCoinConsumedM,
|
||||
CheckoutConsumableAmountCent: row.CheckoutConsumableAmountCent,
|
||||
CheckoutDepositDeductAmountCent: row.CheckoutDepositDeductAmountCent,
|
||||
PreviousCheckoutStatus: row.PreviousCheckoutStatus,
|
||||
ArbitrationResult: row.ArbitrationResult,
|
||||
ArbitrationRemark: row.ArbitrationRemark,
|
||||
HandledBy: row.HandledBy,
|
||||
HandledAt: row.HandledAt,
|
||||
CreatedAt: row.CreatedAt,
|
||||
UpdatedAt: row.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func toDTOs(rows []disputeRow) []DisputeDTO {
|
||||
items := make([]DisputeDTO, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
items = append(items, row.toDTO())
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func marshalEvidence(urls []string) (datatypes.JSON, error) {
|
||||
if len(urls) == 0 {
|
||||
return datatypes.JSON([]byte("[]")), nil
|
||||
}
|
||||
raw, err := json.Marshal(urls)
|
||||
return datatypes.JSON(raw), err
|
||||
}
|
||||
Reference in New Issue
Block a user