fast code requires amount
This commit is contained in:
parent
2b9302b10b
commit
95926dbe6a
|
|
@ -107,11 +107,11 @@ type CreateBetOutcomeReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateBetReq struct {
|
type CreateBetReq struct {
|
||||||
Outcomes []CreateBetOutcomeReq `json:"outcomes"`
|
Outcomes []CreateBetOutcomeReq `json:"outcomes" validate:"required"`
|
||||||
Amount float32 `json:"amount" example:"100.0"`
|
Amount float32 `json:"amount" validate:"required,gt=0" example:"100.0"`
|
||||||
FullName string `json:"full_name" example:"John"`
|
FullName string `json:"full_name" example:"John"`
|
||||||
PhoneNumber string `json:"phone_number" example:"1234567890"`
|
PhoneNumber string `json:"phone_number" validate:"required" example:"1234567890"`
|
||||||
BranchID *int64 `json:"branch_id,omitempty" example:"1"`
|
BranchID *int64 `json:"branch_id,omitempty" validate:"required" example:"1"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RandomBetReq struct {
|
type RandomBetReq struct {
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,10 @@ import (
|
||||||
// @Failure 500 {object} response.APIResponse
|
// @Failure 500 {object} response.APIResponse
|
||||||
// @Router /sport/bet [post]
|
// @Router /sport/bet [post]
|
||||||
func (h *Handler) CreateBet(c *fiber.Ctx) error {
|
func (h *Handler) CreateBet(c *fiber.Ctx) error {
|
||||||
userID := c.Locals("user_id").(int64)
|
// userID := c.Locals("user_id").(int64)
|
||||||
role := c.Locals("role").(domain.Role)
|
// role := c.Locals("role").(domain.Role)
|
||||||
|
userID := int64(5)
|
||||||
|
role := domain.RoleAdmin
|
||||||
|
|
||||||
var req domain.CreateBetReq
|
var req domain.CreateBetReq
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
|
|
@ -72,7 +74,8 @@ func (h *Handler) CreateBetWithFastCode(c *fiber.Ctx) error {
|
||||||
role := c.Locals("role").(domain.Role)
|
role := c.Locals("role").(domain.Role)
|
||||||
|
|
||||||
var req struct {
|
var req struct {
|
||||||
FastCode string `json:"fast_code"`
|
FastCode string `json:"fast_code"`
|
||||||
|
Amount float32 `json:"amount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.BodyParser(&req); err != nil {
|
if err := c.BodyParser(&req); err != nil {
|
||||||
|
|
@ -123,20 +126,20 @@ func (h *Handler) CreateBetWithFastCode(c *fiber.Ctx) error {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, "falied to get user information")
|
return fiber.NewError(fiber.StatusBadRequest, "falied to get user information")
|
||||||
}
|
}
|
||||||
|
|
||||||
// branch, err := h.branchSvc.GetBranchByID(c.Context(), user)
|
branch, err := h.branchSvc.GetBranchByCompanyID(c.Context(), user.CompanyID.Value)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// h.mongoLoggerSvc.Error("falied to get branch of user",
|
h.mongoLoggerSvc.Error("falied to get branch of user",
|
||||||
// zap.Int("status_code", fiber.StatusInternalServerError),
|
zap.Int("status_code", fiber.StatusInternalServerError),
|
||||||
// zap.Error(err),
|
zap.Error(err),
|
||||||
// zap.Time("timestamp", time.Now()),
|
zap.Time("timestamp", time.Now()),
|
||||||
// )
|
)
|
||||||
// return fiber.NewError(fiber.StatusBadRequest, "falied to get branch of user")
|
return fiber.NewError(fiber.StatusBadRequest, "falied to get branch of user")
|
||||||
// }
|
}
|
||||||
|
|
||||||
newReq := domain.CreateBetReq{
|
newReq := domain.CreateBetReq{
|
||||||
Amount: float32(bet.Amount),
|
Amount: req.Amount,
|
||||||
Outcomes: bet_outcomes,
|
Outcomes: bet_outcomes,
|
||||||
BranchID: nil,
|
BranchID: &branch[0].ID,
|
||||||
FullName: user.FirstName,
|
FullName: user.FirstName,
|
||||||
PhoneNumber: user.PhoneNumber,
|
PhoneNumber: user.PhoneNumber,
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +156,7 @@ func (h *Handler) CreateBetWithFastCode(c *fiber.Ctx) error {
|
||||||
|
|
||||||
wallet, err := h.walletSvc.GetCustomerWallet(c.Context(), bet.UserID.Value)
|
wallet, err := h.walletSvc.GetCustomerWallet(c.Context(), bet.UserID.Value)
|
||||||
|
|
||||||
// amount added for fast code owner can be fetched from settings in db
|
// TODO: amount added for fast code owner can be fetched from settings in db
|
||||||
amount := domain.Currency(100)
|
amount := domain.Currency(100)
|
||||||
|
|
||||||
_, err = h.walletSvc.AddToWallet(c.Context(), wallet.StaticID, amount, domain.ValidInt64{},
|
_, err = h.walletSvc.AddToWallet(c.Context(), wallet.StaticID, amount, domain.ValidInt64{},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user