Merge branch 'main' into ticket-bet
This commit is contained in:
commit
156f83ddc5
|
|
@ -236,7 +236,43 @@ func (h *Handler) CreateBetInternal(c *fiber.Ctx, req domain.CreateBetReq, userI
|
||||||
return domain.CreateBetRes{}, err
|
return domain.CreateBetRes{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// create raffle ticket here
|
// create raffle tickets
|
||||||
|
raffles, err := h.raffleSvc.GetRafflesOfCompany(c.Context(), int32(companyID))
|
||||||
|
if err != nil {
|
||||||
|
h.mongoLoggerSvc.Error("Failed to fetch raffle of company",
|
||||||
|
zap.Int("status_code", fiber.StatusInternalServerError),
|
||||||
|
zap.Int64("userID", userID),
|
||||||
|
zap.Int64("companyID", companyID),
|
||||||
|
zap.String("role", string(role)),
|
||||||
|
zap.Error(err),
|
||||||
|
zap.Time("timestamp", time.Now()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, raffle := range raffles {
|
||||||
|
// TODO: only fetch pending raffles from db
|
||||||
|
if raffle.Status == "completed" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
raffleTicket := domain.CreateRaffleTicket{
|
||||||
|
RaffleID: raffle.ID,
|
||||||
|
UserID: int32(userID),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := h.raffleSvc.CreateRaffleTicket(c.Context(), raffleTicket)
|
||||||
|
if err != nil {
|
||||||
|
h.mongoLoggerSvc.Error("Failed to create raffle ticket",
|
||||||
|
zap.Int("status_code", fiber.StatusInternalServerError),
|
||||||
|
zap.Int64("raffleID", int64(raffle.ID)),
|
||||||
|
zap.Int64("userID", userID),
|
||||||
|
zap.Int64("companyID", companyID),
|
||||||
|
zap.String("role", string(role)),
|
||||||
|
zap.Error(err),
|
||||||
|
zap.Time("timestamp", time.Now()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user