mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 23:35:43 +00:00
Feat[BE]:: adjust marketing report API
This commit is contained in:
@@ -135,7 +135,19 @@ func (r *MarketingDeliveryProductRepositoryImpl) GetAllWithFilters(ctx context.C
|
||||
}
|
||||
|
||||
if filters.FilterBy != "" && (filters.StartDate != "" || filters.EndDate != "") {
|
||||
if filters.FilterBy == "delivery_date" {
|
||||
if filters.FilterBy == "so_date" {
|
||||
if filters.StartDate != "" {
|
||||
if startDate, err := utils.ParseDateString(filters.StartDate); err == nil {
|
||||
db = db.Where("marketings.so_date >= ?", startDate)
|
||||
}
|
||||
}
|
||||
if filters.EndDate != "" {
|
||||
if endDate, err := utils.ParseDateString(filters.EndDate); err == nil {
|
||||
nextDate := endDate.AddDate(0, 0, 1)
|
||||
db = db.Where("marketings.so_date < ?", nextDate)
|
||||
}
|
||||
}
|
||||
} else if filters.FilterBy == "realization_date" {
|
||||
if filters.StartDate != "" {
|
||||
if startDate, err := utils.ParseDateString(filters.StartDate); err == nil {
|
||||
db = db.Where("marketing_delivery_products.delivery_date >= ?", startDate)
|
||||
@@ -147,18 +159,6 @@ func (r *MarketingDeliveryProductRepositoryImpl) GetAllWithFilters(ctx context.C
|
||||
db = db.Where("marketing_delivery_products.delivery_date < ?", nextDate)
|
||||
}
|
||||
}
|
||||
} else if filters.FilterBy == "realization_date" {
|
||||
if filters.StartDate != "" {
|
||||
if startDate, err := utils.ParseDateString(filters.StartDate); err == nil {
|
||||
db = db.Where("marketings.created_at >= ?", startDate)
|
||||
}
|
||||
}
|
||||
if filters.EndDate != "" {
|
||||
if endDate, err := utils.ParseDateString(filters.EndDate); err == nil {
|
||||
nextDate := endDate.AddDate(0, 0, 1)
|
||||
db = db.Where("marketings.created_at < ?", nextDate)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,9 @@ func (r *MarketingDeliveryProductRepositoryImpl) GetAllWithFilters(ctx context.C
|
||||
|
||||
if filters.SortBy != "" {
|
||||
switch filters.SortBy {
|
||||
case "delivery_date":
|
||||
case "so_date":
|
||||
sortColumn = "marketings.so_date"
|
||||
case "realization_date":
|
||||
sortColumn = "marketing_delivery_products.delivery_date"
|
||||
case "customer":
|
||||
sortColumn = "customers.name"
|
||||
|
||||
Reference in New Issue
Block a user