Update Error Message Scan

This commit is contained in:
aditya.siregar 2024-08-27 23:02:33 +07:00
parent aae740c77f
commit f7e5e493fa

View File

@ -167,15 +167,24 @@ func (s *OrderService) CheckInInquiry(ctx mycontext.Context, qrCode string, part
return nil, errors2.ErrorInvalidRequest
}
if order.TicketStatus == "USED" {
return nil, errors2.ErrorTicketInvalidOrAlreadyUsed
location, _ := time.LoadLocation("Asia/Jakarta")
today := time.Now().In(location).Format("2006-01-02")
visitDate := time.Date(
order.VisitDate.Year(),
order.VisitDate.Month(),
order.VisitDate.Day(),
0, 0, 0, 0,
location,
).Format("2006-01-02")
if order.TicketStatus == "USED" || visitDate < today {
return nil, errors2.NewErrorMessage(errors2.ErrorTicketInvalidOrAlreadyUsed,
"Maaf! Tiket ini tidak valid karena sudah terpakai atau sudah kadaluwarsa")
}
today := time.Now().Format("2006-01-02")
visitDate := order.VisitDate.Format("2006-01-02")
if visitDate != today {
return nil, errors2.ErrorTicketInvalidOrAlreadyUsed
return nil, errors2.NewErrorMessage(errors2.ErrorTicketInvalidOrAlreadyUsed,
"Maaf Tiket ini tidak valid karena tidak sesuai dengan tanggal tiket")
}
token, err := s.crypt.GenerateJWTOrder(order)