修复平台代管订单流程
This commit is contained in:
@@ -9,16 +9,46 @@ import (
|
||||
)
|
||||
|
||||
func adminActionsForOrder(order model.RentalOrder) *AdminActionsDTO {
|
||||
actions := &AdminActionsDTO{}
|
||||
target, ok := resetTargetForOrder(order)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return &AdminActionsDTO{
|
||||
ResetHandoff: &AdminActionDTO{
|
||||
if ok {
|
||||
actions.ResetHandoff = &AdminActionDTO{
|
||||
Enabled: true,
|
||||
Label: target.Label,
|
||||
},
|
||||
}
|
||||
}
|
||||
if canAdminPlatformHandoff(order) {
|
||||
actions.PlatformHandoff = &AdminActionDTO{
|
||||
Enabled: true,
|
||||
Label: "客服代交接",
|
||||
}
|
||||
}
|
||||
if canAdminPlatformCheckoutConfirm(order) {
|
||||
actions.PlatformCheckoutConfirm = &AdminActionDTO{
|
||||
Enabled: true,
|
||||
Label: "客服确认结账",
|
||||
}
|
||||
actions.PlatformCheckoutCounter = &AdminActionDTO{
|
||||
Enabled: true,
|
||||
Label: "客服修改结账方案",
|
||||
}
|
||||
actions.PlatformCheckoutDispute = &AdminActionDTO{
|
||||
Enabled: true,
|
||||
Label: "发起结账争议",
|
||||
}
|
||||
}
|
||||
if canAdminMarkOfflineSettlement(order) {
|
||||
actions.PlatformOfflineSettlement = &AdminActionDTO{
|
||||
Enabled: true,
|
||||
Label: "确认线下结算",
|
||||
}
|
||||
}
|
||||
if actions.ResetHandoff == nil && actions.PlatformHandoff == nil &&
|
||||
actions.PlatformCheckoutConfirm == nil && actions.PlatformCheckoutCounter == nil &&
|
||||
actions.PlatformCheckoutDispute == nil && actions.PlatformOfflineSettlement == nil {
|
||||
return nil
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
func (row orderRow) toAdminDTO() OrderDTO {
|
||||
@@ -29,43 +59,51 @@ func (row orderRow) toAdminDTO() OrderDTO {
|
||||
ownerRentAmountCent := row.OwnerRentAmountCent
|
||||
platformFeeCent := row.PlatformFeeCent
|
||||
return OrderDTO{
|
||||
ID: row.ID,
|
||||
OrderNo: row.OrderNo,
|
||||
ListingID: row.ListingID,
|
||||
ListingNo: row.ListingNo,
|
||||
AccountID: row.AccountID,
|
||||
OwnerID: row.OwnerID,
|
||||
RenterID: row.RenterID,
|
||||
OwnerPhone: row.OwnerPhone,
|
||||
RenterPhone: row.RenterPhone,
|
||||
Title: row.Title,
|
||||
ServerRegion: row.ServerRegion,
|
||||
LoginPlatform: row.LoginPlatform,
|
||||
RentedAt: rentedAt,
|
||||
EstimatedDurationHours: durationHours,
|
||||
EstimatedEndAt: estimatedEndAt,
|
||||
PriceRole: "admin",
|
||||
DisplayAmountCent: row.RentAmountCent,
|
||||
RentAmountCent: &rentAmountCent,
|
||||
OwnerRentAmountCent: &ownerRentAmountCent,
|
||||
DepositAmountCent: row.DepositAmountCent,
|
||||
DepositOriginalAmountCent: effectiveDepositOriginalAmountCent(row.RentalOrder),
|
||||
DepositWaivedAmountCent: row.DepositWaivedAmountCent,
|
||||
PlatformFeeCent: &platformFeeCent,
|
||||
AccountSnapshot: row.AccountSnapshot,
|
||||
Status: row.Status,
|
||||
HandoffStatus: row.HandoffStatus,
|
||||
SettlementStatus: row.SettlementStatus,
|
||||
RefundStatus: row.RefundStatus,
|
||||
RefundAmountCent: row.RefundAmountCent,
|
||||
DepositHoldStatus: row.DepositHoldStatus,
|
||||
DepositHoldAmountCent: row.DepositHoldAmountCent,
|
||||
DepositHoldReason: row.DepositHoldReason,
|
||||
DepositHeldAt: row.DepositHeldAt,
|
||||
DepositHoldReleasedAt: row.DepositHoldReleasedAt,
|
||||
AdminActions: adminActionsForOrder(row.RentalOrder),
|
||||
CreatedAt: row.CreatedAt,
|
||||
UpdatedAt: row.UpdatedAt,
|
||||
ID: row.ID,
|
||||
OrderNo: row.OrderNo,
|
||||
ListingID: row.ListingID,
|
||||
ListingNo: row.ListingNo,
|
||||
AccountID: row.AccountID,
|
||||
OwnerID: row.OwnerID,
|
||||
RenterID: row.RenterID,
|
||||
OwnerPhone: row.OwnerPhone,
|
||||
RenterPhone: row.RenterPhone,
|
||||
Title: row.Title,
|
||||
ServerRegion: row.ServerRegion,
|
||||
LoginPlatform: row.LoginPlatform,
|
||||
RentedAt: rentedAt,
|
||||
EstimatedDurationHours: durationHours,
|
||||
EstimatedEndAt: estimatedEndAt,
|
||||
PriceRole: "admin",
|
||||
DisplayAmountCent: row.RentAmountCent,
|
||||
RentAmountCent: &rentAmountCent,
|
||||
OwnerRentAmountCent: &ownerRentAmountCent,
|
||||
DepositAmountCent: row.DepositAmountCent,
|
||||
DepositOriginalAmountCent: effectiveDepositOriginalAmountCent(row.RentalOrder),
|
||||
DepositWaivedAmountCent: row.DepositWaivedAmountCent,
|
||||
PlatformFeeCent: &platformFeeCent,
|
||||
AccountSnapshot: row.AccountSnapshot,
|
||||
Status: row.Status,
|
||||
HandoffStatus: row.HandoffStatus,
|
||||
HandoffMode: effectiveHandoffMode(row.RentalOrder),
|
||||
SettlementMode: effectiveSettlementMode(row.RentalOrder),
|
||||
ManagedAdminID: row.ManagedAdminID,
|
||||
SettlementStatus: row.SettlementStatus,
|
||||
OfflineSettlementStatus: effectiveOfflineSettlementStatus(row.RentalOrder),
|
||||
OfflineSettlementAmountCent: row.OfflineSettlementAmountCent,
|
||||
OfflineSettlementRemark: row.OfflineSettlementRemark,
|
||||
OfflineSettledBy: row.OfflineSettledBy,
|
||||
OfflineSettledAt: row.OfflineSettledAt,
|
||||
RefundStatus: row.RefundStatus,
|
||||
RefundAmountCent: row.RefundAmountCent,
|
||||
DepositHoldStatus: row.DepositHoldStatus,
|
||||
DepositHoldAmountCent: row.DepositHoldAmountCent,
|
||||
DepositHoldReason: row.DepositHoldReason,
|
||||
DepositHeldAt: row.DepositHeldAt,
|
||||
DepositHoldReleasedAt: row.DepositHoldReleasedAt,
|
||||
AdminActions: adminActionsForOrder(row.RentalOrder),
|
||||
CreatedAt: row.CreatedAt,
|
||||
UpdatedAt: row.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,10 +116,37 @@ func (row orderRow) toDTOForUser(userID uint64) OrderDTO {
|
||||
dto.DepositHoldReason = ""
|
||||
dto.DepositHeldAt = nil
|
||||
dto.DepositHoldReleasedAt = nil
|
||||
dto.ManagedAdminID = nil
|
||||
dto.OfflineSettlementStatus = ""
|
||||
dto.OfflineSettlementAmountCent = 0
|
||||
dto.OfflineSettlementRemark = ""
|
||||
dto.OfflineSettledBy = nil
|
||||
dto.OfflineSettledAt = nil
|
||||
applyOrderPriceView(&dto, row.RentalOrder, userID)
|
||||
return dto
|
||||
}
|
||||
|
||||
func effectiveHandoffMode(order model.RentalOrder) string {
|
||||
if order.HandoffMode != "" {
|
||||
return order.HandoffMode
|
||||
}
|
||||
return handoffModeOwner
|
||||
}
|
||||
|
||||
func effectiveSettlementMode(order model.RentalOrder) string {
|
||||
if order.SettlementMode != "" {
|
||||
return order.SettlementMode
|
||||
}
|
||||
return settlementModeOwnerWallet
|
||||
}
|
||||
|
||||
func effectiveOfflineSettlementStatus(order model.RentalOrder) string {
|
||||
if order.OfflineSettlementStatus != "" {
|
||||
return order.OfflineSettlementStatus
|
||||
}
|
||||
return offlineSettlementStatusNone
|
||||
}
|
||||
|
||||
func effectiveDepositOriginalAmountCent(order model.RentalOrder) int64 {
|
||||
if order.DepositOriginalAmountCent > 0 {
|
||||
return order.DepositOriginalAmountCent
|
||||
|
||||
Reference in New Issue
Block a user