Update Status

This commit is contained in:
aditya.siregar 2024-08-13 23:53:01 +07:00
parent e544ef8f71
commit 7cc4f1d152

View File

@ -133,6 +133,10 @@ func (s *OrderService) CheckInInquiry(ctx mycontext.Context, qrCode string, part
return nil, errors2.ErrorBadRequest return nil, errors2.ErrorBadRequest
} }
if order.Status != "PAID" {
return nil, errors2.ErrorInvalidRequest
}
if order.TicketStatus == "USED" { if order.TicketStatus == "USED" {
return nil, errors2.ErrorTicketInvalidOrAlreadyUsed return nil, errors2.ErrorTicketInvalidOrAlreadyUsed
} }
@ -179,11 +183,11 @@ func (s *OrderService) CheckInExecute(ctx mycontext.Context,
Order: order, Order: order,
} }
if order.Status != "UNUSED" { if order.TicketStatus != "UNUSED" {
return resp, nil return resp, nil
} }
order.Status = "USED" order.TicketStatus = "USED"
order, err = s.repo.Update(ctx, order) order, err = s.repo.Update(ctx, order)
if err != nil { if err != nil {
logger.ContextLogger(ctx).Error("error when updating order status", zap.Error(err)) logger.ContextLogger(ctx).Error("error when updating order status", zap.Error(err))