marketing

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coupon

type Coupon struct {
	ID                 string         `gorm:"primaryKey" json:"id"`
	Code               string         `gorm:"uniqueIndex;not null" json:"code"`
	DiscountPercentage float64        `gorm:"not null" json:"discount_percentage"`
	Active             bool           `gorm:"default:true" json:"active"`
	CreatedAt          time.Time      `json:"created_at"`
	UpdatedAt          time.Time      `json:"updated_at"`
	DeletedAt          gorm.DeletedAt `gorm:"index" json:"-"`
}

Coupon represents a discount code.

type IdempotencyKey

type IdempotencyKey struct {
	ID        string `gorm:"primaryKey"`
	Scope     string `gorm:"index:idx_scope_key,unique"`
	Key       string `gorm:"index:idx_scope_key,unique"`
	CreatedAt time.Time
}

IdempotencyKey prevents duplicate processing of the same operation.

type LoyaltyPoints

type LoyaltyPoints struct {
	ID         string         `gorm:"primaryKey" json:"id"`
	CustomerID string         `gorm:"uniqueIndex;not null" json:"customer_id"`
	Balance    int            `gorm:"default:0" json:"balance"`
	CreatedAt  time.Time      `json:"created_at"`
	UpdatedAt  time.Time      `json:"updated_at"`
	DeletedAt  gorm.DeletedAt `gorm:"index" json:"-"`
}

LoyaltyPoints represents a customer's rewards balance.

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module implements the mdk.Module interface for Marketing.

func NewModule

func NewModule() *Module

func (*Module) AddLoyaltyPoints

func (m *Module) AddLoyaltyPoints(ctx context.Context, input any) (any, error)

AddLoyaltyPoints adds points based on the order total.

func (*Module) AddLoyaltyPointsStep

func (m *Module) AddLoyaltyPointsStep(sCtx mdk.StepContext) mdk.StepResult

AddLoyaltyPointsStep wraps AddLoyaltyPoints to mdk.StepHandler.

func (*Module) ApplyCouponToCart

func (m *Module) ApplyCouponToCart(ctx context.Context, cartID string, couponCode string) (*cart.Cart, error)

func (*Module) FieldResolvers

func (m *Module) FieldResolvers() map[string]any

func (*Module) GetCoupon

func (m *Module) GetCoupon(ctx context.Context, code string) (*Coupon, error)

func (*Module) GetLoyaltyBalance

func (m *Module) GetLoyaltyBalance(ctx context.Context, customerID string) (int, error)

func (*Module) ID

func (m *Module) ID() string

func (*Module) Init

func (m *Module) Init(ctx context.Context, rt mdk.Runtime) error

func (*Module) Models

func (m *Module) Models() []any

func (*Module) Mutations

func (m *Module) Mutations() map[string]any

func (*Module) Queries

func (m *Module) Queries() map[string]any

func (*Module) Repo

func (m *Module) Repo() *Repository

func (*Module) Routes

func (m *Module) Routes() []mdk.Route

func (*Module) Shutdown

func (m *Module) Shutdown(ctx context.Context) error

func (*Module) ValidateCoupon

func (m *Module) ValidateCoupon(ctx context.Context, input any) (any, error)

ValidateCoupon checks if a coupon is valid and returns it.

func (*Module) ValidateCouponStep

func (m *Module) ValidateCouponStep(sCtx mdk.StepContext) mdk.StepResult

ValidateCouponStep wraps ValidateCoupon to mdk.StepHandler.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(database *gorm.DB) *Repository

func (*Repository) GetCouponByCode

func (r *Repository) GetCouponByCode(ctx context.Context, code string) (*Coupon, error)

func (*Repository) GetLoyaltyPointsByCustomerID

func (r *Repository) GetLoyaltyPointsByCustomerID(ctx context.Context, customerID string) (*LoyaltyPoints, error)

func (*Repository) SaveCoupon

func (r *Repository) SaveCoupon(ctx context.Context, c *Coupon) error

func (*Repository) SaveLoyaltyPoints

func (r *Repository) SaveLoyaltyPoints(ctx context.Context, lp *LoyaltyPoints) error

Jump to

Keyboard shortcuts

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