优化客服群聊订单信息展示
This commit is contained in:
@@ -32,6 +32,19 @@ func (h *Handler) AdminDetail(c *gin.Context) {
|
||||
response.OK(c, item)
|
||||
}
|
||||
|
||||
func (h *Handler) AdminLatestByListing(c *gin.Context) {
|
||||
id, ok := parseID(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
item, err := h.service.FindLatestAdminByListing(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
writeOrderError(c, err)
|
||||
return
|
||||
}
|
||||
response.OK(c, item)
|
||||
}
|
||||
|
||||
func (h *Handler) AdminHandoffRecords(c *gin.Context) {
|
||||
id, ok := parseID(c)
|
||||
if !ok {
|
||||
|
||||
@@ -80,6 +80,22 @@ func (r *Repository) FindAdmin(ctx context.Context, orderID uint64) (*OrderDTO,
|
||||
return &dto, nil
|
||||
}
|
||||
|
||||
func (r *Repository) FindLatestAdminByListing(ctx context.Context, listingID uint64) (*OrderDTO, error) {
|
||||
var row orderRow
|
||||
db := r.db.WithContext(ctx)
|
||||
if err := r.adminQuery(ctx).
|
||||
Where("o.listing_id = ?", listingID).
|
||||
Order("o.id DESC").
|
||||
First(&row).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dto := row.toAdminDTO()
|
||||
applyPaymentDeadline(&dto, row.RentalOrder, pendingPaymentTimeoutMinutes(db))
|
||||
dto.ActiveDispute = r.activeDisputeDTO(ctx, row.ID)
|
||||
dto.Checkout = r.latestCheckoutAdminDTO(ctx, row.ID)
|
||||
return &dto, nil
|
||||
}
|
||||
|
||||
func (r *Repository) FindForUser(ctx context.Context, userID uint64, orderID uint64) (*OrderDTO, error) {
|
||||
var row orderRow
|
||||
db := r.db.WithContext(ctx)
|
||||
|
||||
@@ -159,6 +159,16 @@ func (s *Service) FindAdmin(ctx context.Context, orderID uint64) (*OrderDTO, err
|
||||
return s.repo.FindAdmin(ctx, orderID)
|
||||
}
|
||||
|
||||
func (s *Service) FindLatestAdminByListing(ctx context.Context, listingID uint64) (*OrderDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
if listingID == 0 {
|
||||
return nil, ErrListingUnavailable
|
||||
}
|
||||
return s.repo.FindLatestAdminByListing(ctx, listingID)
|
||||
}
|
||||
|
||||
func (s *Service) HandoffRecordsAdmin(ctx context.Context, orderID uint64) ([]HandoffRecordDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
|
||||
Reference in New Issue
Block a user