order

package
v0.0.0-...-8f0a619 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitHTTPHandler

func InitHTTPHandler(router *mux.Router, customerSession *middleware.CustomerSession, validate *validator.Validate, orderUseCase OrderUseCase)

Types

type ExpireOrderEvent

type ExpireOrderEvent struct {
	ID            string
	TransactionID string
}

type GetByOrderIDResponse

type GetByOrderIDResponse PlaceOrderResponse

type GetManyOrderRequest

type GetManyOrderRequest struct {
	Page int64 `validate:"required"`
	Size int64 `validate:"required"`
}

type GetManyOrderResponse

type GetManyOrderResponse struct {
	Total  int64                `json:"total"`
	Orders []PlaceOrderResponse `json:"orders"`
}

type HTTPHandler

type HTTPHandler struct {
	SessionMiddleware *middleware.CustomerSession
	Validate          *validator.Validate
	OrderUseCase      OrderUseCase
}

func (HTTPHandler) GetManyOrder

func (handler HTTPHandler) GetManyOrder(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) OnExpireOrder

func (handler HTTPHandler) OnExpireOrder(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) OnPaymentNotification

func (handler HTTPHandler) OnPaymentNotification(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) PlaceOrder

func (handler HTTPHandler) PlaceOrder(w http.ResponseWriter, r *http.Request)

type Item

type Item struct {
	ID            int64
	OrderID       string
	TicketStockID string
	ShowID        string
	EventID       string
	EventName     string
	ShowVenue     string
	Tier          string
	Price         float64
	Quantity      int64
}

type ItemRepository

type ItemRepository interface {
	FindManyByOrderID(ctx context.Context, orderID string, tx *sql.Tx) ([]Item, error)
	Save(ctx context.Context, i Item, tx *sql.Tx) error
}

func NewItemRepository

func NewItemRepository(logger *logrus.Logger, db *sql.DB) ItemRepository

type ItemRequest

type ItemRequest struct {
	EventID       string `json:"event_id" validate:"required"`
	ShowID        string `json:"show_id" validate:"required"`
	TicketStockID string `json:"ticket_stock_id" validate:"required"`
	Quantity      int64  `json:"quantity" validate:"required"`
}

type ItemResponse

type ItemResponse struct {
	OrderID       string  `json:"order_id"`
	TicketStockID string  `json:"ticket_stock_id"`
	ShowID        string  `json:"show_id"`
	EventID       string  `json:"event_id"`
	EventName     string  `json:"event_name"`
	ShowVenue     string  `json:"show_venue"`
	Tier          string  `json:"tier"`
	Price         float64 `json:"price"`
	Quantity      int64   `json:"quantity"`
}

type Order

type Order struct {
	ID                      string
	PaymentMethod           string
	VirtualAccount          *string
	TransactionID           *string
	Status                  string
	CustomerID              int64
	CustomerName            string
	CustomerEmail           string
	TaxPercentage           float64
	ServiceChargePercentage float64
	DiscountPercentage      float64
	ServiceCharge           float64
	Tax                     float64
	Discount                float64
	Items                   []Item
	Subtotal                float64
	TotalAmount             float64
	CreatedAt               time.Time
	UpdatedAt               time.Time
}

type OrderRepository

type OrderRepository interface {
	BeginTx(ctx context.Context) (*sql.Tx, error)
	CommitTx(ctx context.Context, tx *sql.Tx) error
	Rollback(ctx context.Context, tx *sql.Tx) error

	Save(ctx context.Context, o Order, tx *sql.Tx) error
	FindByID(ctx context.Context, ID string, tx *sql.Tx) (Order, error)
	FindMany(ctx context.Context, customerID int64, offset, limit int64, tx *sql.Tx) ([]Order, error)
	Count(ctx context.Context, customerID int64, tx *sql.Tx) (int64, error)
	Update(ctx context.Context, ID string, o Order, tx *sql.Tx) error
	CountActiveOrderByCustomerID(ctx context.Context, customerID int64, tx *sql.Tx) (int64, error)
}

func NewOrderRepository

func NewOrderRepository(logger *logrus.Logger, db *sql.DB) OrderRepository

type OrderRuleDay

type OrderRuleDay struct {
	EventID string
	Day     int64
}

type OrderRuleDayRepository

type OrderRuleDayRepository interface {
	FindManyByEventID(ctx context.Context, eventID string, tx *sql.Tx) ([]OrderRuleDay, error)
}

func NewOrderRuleDayRepository

func NewOrderRuleDayRepository(logger *logrus.Logger, db *sql.DB) OrderRuleDayRepository

type OrderRuleRangeDate

type OrderRuleRangeDate struct {
	EventID   string
	StartDate time.Time
	EndDate   time.Time
}

type OrderRuleRangeDateRepository

type OrderRuleRangeDateRepository interface {
	FindByEventID(ctx context.Context, eventID string, tx *sql.Tx) (OrderRuleRangeDate, error)
}

func NewOrderRuleRangeDateRepository

func NewOrderRuleRangeDateRepository(logger *logrus.Logger, db *sql.DB) OrderRuleRangeDateRepository

type OrderUseCase

type OrderUseCase interface {
	PlaceOrder(ctx context.Context, req PlaceOrderRequest) (PlaceOrderResponse, error)
	OnPaymentNotification(ctx context.Context, e PaymentNotificationEvent) error
	OnExpireOrder(ctx context.Context, e ExpireOrderEvent) error
	GetManyOrder(ctx context.Context, req GetManyOrderRequest) (GetManyOrderResponse, error)
}

func NewOrderUseCase

func NewOrderUseCase(props OrderUseCaseProperty) OrderUseCase

type OrderUseCaseProperty

type OrderUseCaseProperty struct {
	Logger                       *logrus.Logger
	Timeout                      time.Duration
	BaseURL                      string
	OrderExpireDuration          time.Duration
	ServiceChargePercentage      float64
	TaxPercentage                float64
	EventRepository              event.EventRepository
	ShowRepository               event.ShowRepository
	TicketStockRepository        ticket.TicketStockRepository
	OrderRuleRangeDateRepository OrderRuleRangeDateRepository
	OrderRuleDay                 OrderRuleDayRepository
	OrderRepository              OrderRepository
	ItemRepository               ItemRepository
	Publisher                    pubsub.Publisher
	MidtransRepository           midtrans.MidtransRepository
	CloudTask                    gctasks.Client
	AcquiredTicketRepository     ticket.AcquiredTicketRepository
}

type PaymentNotificationEvent

type PaymentNotificationEvent struct {
	TransactionID     string `json:"transaction_id"`
	TransactionStatus string `json:"transaction_status"`
	OrderID           string `json:"order_id"`
}

type PlaceOrderRequest

type PlaceOrderRequest struct {
	PaymentMethod string `json:"payment_method" validate:"oneof=bca bri bni"`
	EventID       string `json:"event_id" validate:"required"`
	ShowID        string `json:"show_id" validate:"required"`
	TicketStockID string `json:"ticket_stock_id" validate:"required"`
	Quantity      int64  `json:"quantity" validate:"eq=1"`
}

type PlaceOrderResponse

type PlaceOrderResponse struct {
	ID                      string         `json:"id"`
	PaymentMethod           string         `json:"payment_method"`
	TransactionID           *string        `json:"transaction_id"`
	VirtualAccount          *string        `json:"virtual_account"`
	Status                  string         `json:"status"`
	CustomerID              int64          `json:"customer_id"`
	CustomerName            string         `json:"customer_name"`
	CustomerEmail           string         `json:"customer_email"`
	TaxPercentage           float64        `json:"tax_percentage"`
	ServiceChargePercentage float64        `json:"service_charge_percentage"`
	DiscountPercentage      float64        `json:"discount_percentage"`
	ServiceCharge           float64        `json:"service_charge"`
	Tax                     float64        `json:"tax"`
	Discount                float64        `json:"discount"`
	Items                   []ItemResponse `json:"items"`
	Subtotal                float64        `json:"subtotal"`
	TotalAmount             float64        `json:"total_amount"`
	CreatedAt               time.Time      `json:"created_at"`
	UpdatedAt               time.Time      `json:"updated_at"`
}

func (*PlaceOrderResponse) PopulateFromEntity

func (r *PlaceOrderResponse) PopulateFromEntity(o Order)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL