definitions

package
v0.0.0-...-cae665e Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ORDER_STATUS_PENDING   int8 = 0
	ORDER_STATUS_PURCHASED int8 = 1
	ORDER_STATUS_PREPARING int8 = 2
	ORDER_STATUS_SHIPPING  int8 = 3
	ORDER_STATUS_RECEIVED  int8 = 4
	ORDER_STATUS_CANCELLED int8 = 5
)
View Source
const (
	ORDER_PAYMENT_METHOD_CASH          int8 = 0
	ORDER_PAYMENT_METHOD_BANK_TRANSFER int8 = 1
	ORDER_PAYMENT_METHOD_CREDIT_CARD   int8 = 2
	ORDER_PAYMENT_METHOD_PAYPAL        int8 = 3
)

Variables

This section is empty.

Functions

func ValidateNextOrderState

func ValidateNextOrderState(prveState int8, nextState int8) error

Types

type Article

type Article struct {
	ID          primitive.ObjectID   `bson:"_id,omitempty" json:"id,omitempty"`
	Name        string               `bson:"name" json:"name"`
	Description string               `bson:"description" json:"description"`
	Price       float64              `bson:"price" json:"price"`
	Images      []primitive.ObjectID `bson:"images" json:"images"`
	Category    string               `bson:"category" json:"category"`
	Rating      int8                 `bson:"rating" json:"rating"`
	Stock       []Stock              `bson:"stock,omitempty" json:"stock"`
	CreatedAt   int32                `bson:"createdAt,omitempty" json:"createdAt"`
	UpdatedAt   int32                `bson:"updatedAt,omitempty" json:"updatedAt"`
	Disabled    bool                 `bson:"disabled"`
	Available   bool                 `bson:"available"`
}

Article definition

func NewArticle

func NewArticle(
	name string,
	description string,
	price float64,
	images []primitive.ObjectID,
	category string,
	rating int8,
) (*Article, error)

NewArticle with validations

type File

type File struct {
	File     io.Reader
	Filename string
	Size     int64
}

type Order

type Order struct {
	ID            primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	Stock         primitive.ObjectID `bson:"stock,omitempty" json:"stock"`
	User          primitive.ObjectID `bson:"user,omitempty" json:"user"`
	State         int8               `bson:"state" json:"state"`
	Notes         string             `bson:"notes" json:"notes"`
	PaymentMethod int8               `bson:"paymentMethod" json:"paymentMethod"`
	PaymentRef    string             `bson:"paymentRef" json:"paymentRef"`
	TrackingRef   string             `bson:"trackingRef" json:"trackingRef"`
	CreatedAt     int32              `bson:"createdAt,omitempty" json:"createdAt"`
	UpdatedAt     int32              `bson:"updatedAt,omitempty" json:"updatedAt"`
}

Order definition

func CancelOrder

func CancelOrder(order *Order) (*Order, error)

func ConfirmReceivedOrder

func ConfirmReceivedOrder(order *Order) (*Order, error)

func NewOrder

func NewOrder(stock primitive.ObjectID, user primitive.ObjectID, notes string) (*Order, error)

func PrepareOrder

func PrepareOrder(order *Order) (*Order, error)

func PurchaseOrder

func PurchaseOrder(order *Order, paymentMethod int8, paymentRef string) (*Order, error)

func ShipOrder

func ShipOrder(order *Order, trackingRef string) (*Order, error)

func UpdateStateOrder

func UpdateStateOrder(order *Order, state int8) (*Order, error)

func (*Order) Cancel

func (order *Order) Cancel() error

func (*Order) ConfirmReceived

func (order *Order) ConfirmReceived() error

func (*Order) Prepare

func (order *Order) Prepare() error

func (*Order) Purchase

func (order *Order) Purchase(paymentMethod int8, paymentRef string) error

func (*Order) Ship

func (order *Order) Ship(trackingRef string) error

func (*Order) UpdateState

func (order *Order) UpdateState(state int8) error

type Stock

type Stock struct {
	ID        primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	Size      string             `bson:"size" json:"size"`
	CreatedAt int32              `bson:"createdAt" json:"createdAt"`
}

Stock definition

func NewStock

func NewStock(size string) (*Stock, error)

func (*Stock) SetID

func (s *Stock) SetID(id primitive.ObjectID)

type StockArticle

type StockArticle struct {
	ID        primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	Size      string             `bson:"size" json:"size"`
	CreatedAt int32              `bson:"createdAt" json:"createdAt"`
	Article   *Article           `bson:"article" json:"article"`
}

type StockOrderArticle

type StockOrderArticle struct {
	Refs  []StockOrderArticleItem `bson:"refs,omitempty" json:"refs,omitempty"`
	Size  string                  `bson:"size" json:"size"`
	Count int32                   `bson:"count" json:"count"`
}

type StockOrderArticleItem

type StockOrderArticleItem struct {
	ID    primitive.ObjectID `bson:"id,omitempty" json:"id,omitempty"`
	Order primitive.ObjectID `bson:"order,omitempty" json:"order,omitempty"`
	State int8               `bson:"state,omitempty" json:"state,omitempty"`
}

type User

type User struct {
	ID      primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
	Name    string             `bson:"name" json:"name"`
	Surname string             `bson:"surname" json:"surname"`
	Email   string             `bson:"email" json:"email"`
	Phone   string             `bson:"phone" json:"phone"`
	Address string             `bson:"address" json:"address"`
}

User definition

func NewUser

func NewUser(name string, surname string, email string, phone string, address string) (*User, error)

Jump to

Keyboard shortcuts

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