修复归还逾期订单重置
This commit is contained in:
@@ -173,6 +173,7 @@ type adminResetTarget struct {
|
||||
RenterContent string
|
||||
AuditAction string
|
||||
RefreshStageTime bool
|
||||
RecalculateEnd bool
|
||||
}
|
||||
|
||||
// AdminResetHandoff 将超时卡住的订单恢复到对应待办阶段,并刷新阶段计时,
|
||||
@@ -195,6 +196,21 @@ func (r *Repository) AdminResetHandoff(ctx context.Context, adminID uint64, orde
|
||||
if target.RefreshStageTime {
|
||||
order.HandoffStartedAt = &now
|
||||
}
|
||||
if target.RecalculateEnd {
|
||||
durationHours := estimateOrderDurationHours(order.AccountSnapshot)
|
||||
if durationHours > 0 {
|
||||
order.EstimatedDurationHours = durationHours
|
||||
}
|
||||
if order.RentedAt == nil {
|
||||
order.RentedAt = &now
|
||||
}
|
||||
if order.RentedAt != nil {
|
||||
estimatedEndAt := order.RentedAt.Add(time.Duration(order.EstimatedDurationHours) * time.Hour)
|
||||
if !estimatedEndAt.After(now) {
|
||||
order.RentedAt = &now
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := notification.Append(tx,
|
||||
notification.Entry{
|
||||
UserID: order.OwnerID,
|
||||
@@ -272,6 +288,19 @@ func resetTargetForOrder(order model.RentalOrder) (adminResetTarget, bool) {
|
||||
RefreshStageTime: true,
|
||||
}, true
|
||||
}
|
||||
if order.Status == orderStatusOverdue && order.HandoffStatus == handoffStatusReturnOverdue {
|
||||
return adminResetTarget{
|
||||
OrderStatus: orderStatusRenting,
|
||||
HandoffStatus: handoffStatusReceived,
|
||||
Label: "重置归还逾期",
|
||||
OwnerTitle: "订单归还逾期已重置",
|
||||
OwnerContent: "客服已重置归还逾期状态,订单恢复为使用中。",
|
||||
RenterTitle: "请及时发起结账",
|
||||
RenterContent: "客服已重置归还逾期状态,请尽快发起结账。",
|
||||
AuditAction: "order.reset_return_overdue",
|
||||
RecalculateEnd: true,
|
||||
}, true
|
||||
}
|
||||
return adminResetTarget{}, false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user