feat: history-order-list
This commit is contained in:
@@ -296,3 +296,39 @@ func (s *OrderService) updateWalletBalance(ctx context.Context, tx *gorm.DB, par
|
||||
_, err = s.wallet.Update(ctx, tx, wallet)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *OrderService) GetAllHistoryOrders(ctx context.Context, req entity.HistoryOrderSearch) ([]*entity.HistoryOrder, int, error) {
|
||||
historyOrders, total, err := s.repo.GetAllHystoryOrders(ctx, req)
|
||||
if err != nil {
|
||||
logger.ContextLogger(ctx).Error("error when get all history orders", zap.Error(err))
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
data := historyOrders.ToHistoryOrderList()
|
||||
|
||||
// resultsMap := make(map[int64]*entity.MergedHistoryOrder)
|
||||
|
||||
// for _, d := range data {
|
||||
// if _, exists := resultsMap[d.ID]; !exists {
|
||||
// resultsMap[d.ID] = &entity.MergedHistoryOrder{
|
||||
// ID: d.ID,
|
||||
// Employee: d.Employee,
|
||||
// Site: d.Site,
|
||||
// Timestamp: d.Timestamp.Format(time.RFC3339),
|
||||
// BookingTime: d.BookingTime.Format(time.RFC3339),
|
||||
// Tickets: []string{},
|
||||
// PaymentType: d.PaymentType,
|
||||
// Status: d.Status,
|
||||
// Amount: d.Amount,
|
||||
// }
|
||||
// }
|
||||
// resultsMap[d.ID].Tickets = append(resultsMap[d.ID].Tickets, fmt.Sprintf("%s x%d", d.Ticket, d.Quantity))
|
||||
// }
|
||||
|
||||
// var results []*entity.MergedHistoryOrder
|
||||
// for _, v := range resultsMap {
|
||||
// results = append(results, v)
|
||||
// }
|
||||
|
||||
return data, total, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user