diff --git a/internal/.DS_Store b/internal/.DS_Store new file mode 100644 index 0000000..2841480 Binary files /dev/null and b/internal/.DS_Store differ diff --git a/internal/common/.DS_Store b/internal/common/.DS_Store new file mode 100644 index 0000000..ce4c8f3 Binary files /dev/null and b/internal/common/.DS_Store differ diff --git a/internal/constants/.DS_Store b/internal/constants/.DS_Store new file mode 100644 index 0000000..1d3a8c8 Binary files /dev/null and b/internal/constants/.DS_Store differ diff --git a/internal/entity/order.go b/internal/entity/order.go index bbccf01..87910b8 100644 --- a/internal/entity/order.go +++ b/internal/entity/order.go @@ -117,6 +117,9 @@ type HistoryOrder struct { PaymentType string `gorm:"type:varchar;column:payment_type"` Status string `gorm:"type:varchar;column:status"` Amount float64 `gorm:"type:numeric;column:amount"` + VisitDate time.Time `gorm:"type:date;column:visit_date"` + TicketStatus string `gorm:"type:varchar;column:ticket_status"` + Source string `gorm:"type:numeric;column:source"` } type HistoryOrderDB struct { @@ -136,6 +139,7 @@ type OrderSearch struct { EndDate string Period string IsCustomer bool + Source string } type HistoryOrderList []*HistoryOrderDB @@ -158,6 +162,9 @@ func (e *HistoryOrderDB) ToHistoryOrder() *HistoryOrder { PaymentType: e.PaymentType, Status: e.Status, Amount: e.Amount, + VisitDate: e.VisitDate, + TicketStatus: e.TicketStatus, + Source: e.Source, } } diff --git a/internal/handlers/.DS_Store b/internal/handlers/.DS_Store new file mode 100644 index 0000000..2999c9d Binary files /dev/null and b/internal/handlers/.DS_Store differ diff --git a/internal/handlers/http/.DS_Store b/internal/handlers/http/.DS_Store new file mode 100644 index 0000000..64a768a Binary files /dev/null and b/internal/handlers/http/.DS_Store differ diff --git a/internal/handlers/http/order/order.go b/internal/handlers/http/order/order.go index b2d9343..7b68550 100644 --- a/internal/handlers/http/order/order.go +++ b/internal/handlers/http/order/order.go @@ -173,6 +173,9 @@ func (h *Handler) toHistoryOrderResponse(resp *entity.HistoryOrder) response.His PaymentType: resp.PaymentType, Status: resp.Status, Amount: resp.Amount, + VisitDate: resp.VisitDate.Format(time.RFC3339), + TicketStatus: resp.TicketStatus, + Source: resp.Source, } } diff --git a/internal/handlers/request/order.go b/internal/handlers/request/order.go index b49ba0f..65769c2 100644 --- a/internal/handlers/request/order.go +++ b/internal/handlers/request/order.go @@ -44,6 +44,7 @@ type OrderParam struct { Limit int `form:"limit" json:"limit" example:"10"` Offset int `form:"offset" json:"offset" example:"0"` Period string `form:"period" json:"period" example:"1d,7d,1m"` + Source string `form:"source" json:"source" example:"tes"` } func (o *OrderParam) ToOrderEntity(ctx mycontext.Context) entity.OrderSearch { @@ -58,6 +59,7 @@ func (o *OrderParam) ToOrderEntity(ctx mycontext.Context) entity.OrderSearch { EndDate: o.EndDate, Status: o.Status, Period: o.Period, + Source: o.Source, } } diff --git a/internal/handlers/response/order.go b/internal/handlers/response/order.go index 5bda2ef..c4c6019 100644 --- a/internal/handlers/response/order.go +++ b/internal/handlers/response/order.go @@ -35,6 +35,9 @@ type HistoryOrder struct { PaymentType string `json:"payment_type"` Status string `json:"status"` Amount float64 `json:"amount"` + VisitDate string `json:"visit_date"` + TicketStatus string `json:"ticket_status"` + Source string `json:"source"` } type OrderItem struct { diff --git a/internal/repository/.DS_Store b/internal/repository/.DS_Store new file mode 100644 index 0000000..347dec1 Binary files /dev/null and b/internal/repository/.DS_Store differ diff --git a/internal/repository/orders/order.go b/internal/repository/orders/order.go index 6e969d8..4dd1efc 100644 --- a/internal/repository/orders/order.go +++ b/internal/repository/orders/order.go @@ -94,12 +94,13 @@ func (b *OrderRepository) GetAllHystoryOrders(ctx context.Context, req entity.Or var total int64 query := b.db.Table("orders"). - Select("orders.id as id, users.name as employee, sites.name as site, orders.created_at as timestamp, orders.created_at as booking_time, STRING_AGG(ticket_summary.name || ' x' || ticket_summary.total_qty, ', ') AS tickets, orders.payment_type as payment_type, orders.status as status, orders.amount as amount"). + Select("orders.id as id, users.name as employee, sites.name as site, orders.created_at as timestamp, orders.created_at as booking_time, STRING_AGG(ticket_summary.name || ' x' || ticket_summary.total_qty, ', ') AS tickets, orders.payment_type as payment_type, orders.status as status, orders.amount as amount, orders.visit_date as visit_date, orders.ticket_status as ticket_status, orders.source as source"). Joins("left join (SELECT items.order_id, products.name, SUM(items.qty) AS total_qty FROM order_items items LEFT JOIN products ON items.item_id = products.id GROUP BY items.order_id, products.name) AS ticket_summary ON orders.id = ticket_summary.order_id"). Joins("left join users on orders.created_by = users.id"). - Joins("left join sites on orders.site_id = sites.id") + Joins("left join sites on orders.site_id = sites.id"). + Where("orders.status != ?", "NEW") - if req.PaymentType != "" { + if req.PaymentType != "" { query = query.Where("orders.payment_type = ?", req.PaymentType) } @@ -131,6 +132,10 @@ func (b *OrderRepository) GetAllHystoryOrders(ctx context.Context, req entity.Or query = query.Where("orders.site_id = ?", req.SiteID) } + if req.Source != "" { + query = query.Where("orders.source = ?", req.Source) + } + query = query.Group("orders.id, users.name, sites.name, orders.created_at, orders.payment_type, orders.status") query = query.Order("orders.created_at DESC") diff --git a/internal/services/.DS_Store b/internal/services/.DS_Store new file mode 100644 index 0000000..75e88fa Binary files /dev/null and b/internal/services/.DS_Store differ diff --git a/internal/utils/.DS_Store b/internal/utils/.DS_Store new file mode 100644 index 0000000..8f31184 Binary files /dev/null and b/internal/utils/.DS_Store differ diff --git a/k8s/.DS_Store b/k8s/.DS_Store new file mode 100644 index 0000000..b86c50b Binary files /dev/null and b/k8s/.DS_Store differ