model

package
v0.0.0-...-58d7c3d Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OrderStatusPending 未支付
	OrderStatusPending = 0

	// OrderStatusPaid 已支付
	OrderStatusPaid = 1
)
View Source
const (
	// ProductUpShelf 商品已上架
	ProductUpShelf = 1

	// ProductDownShelf 商品已下架
	ProductDownShelf = 2

	// ProductPending 商品��未上架
	ProductPending = 3
)
View Source
const CategoryStatusClose = 2

CategoryStatusClose 关闭

View Source
const CategoryStatusOpen = 1

CategoryStatusOpen 开启

Variables

View Source
var DB *gorm.DB

DB 数据库连接

View Source
var ErrorCode = errorCode{
	SUCCESS:    0,
	ERROR:      1,
	NotFound:   404,
	LoginError: 1000,
}

ErrorCode �错误码

Functions

This section is empty.

Types

type AmountPerDay

type AmountPerDay []struct {
	Amount float64 `json:"amount"`
	PayAt  string  `gorm:"column:payAt" json:"payAt"`
}

AmountPerDay 每天的销售额

func (AmountPerDay) AmountLatest30Day

func (amount AmountPerDay) AmountLatest30Day() AmountPerDay

AmountLatest30Day 近30天,每天的销售额

type Cart

type Cart struct {
	ID        uint       `gorm:"primary_key" json:"id"`
	OpenID    string     `json:"openId"`
	ProductID uint       `json:"productId"`
	Count     int        `json:"count"`
	CreatedAt time.Time  `json:"createdAt"`
	UpdatedAt time.Time  `json:"updatedAt"`
	DeletedAt *time.Time `sql:"index" json:"deletedAt"`
}

Cart 购物车

type Category

type Category struct {
	ID        uint       `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"createdAt"`
	UpdatedAt time.Time  `json:"updatedAt"`
	DeletedAt *time.Time `sql:"index" json:"deletedAt"`
	Name      string     `json:"name"`
	Sequence  int        `json:"sequence"`
	ParentID  int        `json:"parentId"`
	Status    int        `json:"status"`
	Remark    string     `json:"remark"`
}

Category 商品分类

type Image

type Image struct {
	ID           uint   `gorm:"primary_key" json:"id"`
	Title        string `json:"title"`
	OrignalTitle string `json:"orignalTitle"`
	URL          string `json:"url"`
	Width        uint   `json:"width"`
	Height       uint   `json:"height"`
	Mime         string `json:"mime"`
}

Image 图片

type Inventory

type Inventory struct {
	ID             uint            `gorm:"primary_key" json:"id"`
	CreatedAt      time.Time       `json:"createdAt"`
	UpdatedAt      time.Time       `json:"updatedAt"`
	DeletedAt      *time.Time      `sql:"index" json:"deletedAt"`
	ProductID      uint            `json:"productID"`
	Count          uint            `json:"count"`
	PropertyValues []PropertyValue `gorm:"many2many:inventory_property_value;ForeignKey:ID;AssociationForeignKey:ID" json:"propertyValues"`
}

Inventory 商品库存

type Order

type Order struct {
	ID           uint       `gorm:"primary_key" json:"id"`
	CreatedAt    time.Time  `json:"createdAt"`
	UpdatedAt    time.Time  `json:"updatedAt"`
	DeletedAt    *time.Time `sql:"index" json:"deletedAt"`
	UserID       uint       `json:"userId"`
	TotalPrice   float64    `json:"totalPrice"`
	Payment      float64    `json:"payment"`
	Freight      float64    `json:"freight"`
	Remark       string     `json:"remark"`
	Discount     int        `json:"discount"`
	DeliverStart time.Time  `json:"deliverStart"`
	DeliverEnd   time.Time  `json:"deliverEnd"`
	Status       int        `json:"status"`
	PayAt        time.Time  `json:"payAt"`
}

Order 订单

func (Order) CountByDate

func (order Order) CountByDate(date time.Time) int

CountByDate 指定日期的订单数

func (Order) Total

func (order Order) Total() int

Total 总的订单数

func (Order) TotalSale

func (order Order) TotalSale() float64

TotalSale 总的销售额

func (Order) TotalSaleByDate

func (order Order) TotalSaleByDate(date time.Time) float64

TotalSaleByDate 指定日期的�销售额

type OrderPerDay

type OrderPerDay []struct {
	Count     int    `json:"count"`
	CreatedAt string `gorm:"column:createdAt" json:"createdAt"`
}

OrderPerDay 每天的订单数

func (OrderPerDay) Latest30Day

func (orders OrderPerDay) Latest30Day() OrderPerDay

Latest30Day 近30天,每天的订单数

type PVPerDay

type PVPerDay []struct {
	PV   int    `json:"pv"`
	Date string `gorm:"column:date" json:"date"`
}

PVPerDay 每天的�pv

type Product

type Product struct {
	ID             uint        `gorm:"primary_key" json:"id"`
	CreatedAt      time.Time   `json:"createdAt"`
	UpdatedAt      time.Time   `json:"updatedAt"`
	DeletedAt      *time.Time  `sql:"index" json:"deletedAt"`
	Name           string      `json:"name"`
	BrowseCount    int         `json:"browseCount"`
	BuyCount       int         `json:"buyCount"`
	TotalSale      float64     `json:"totalSale"`
	Price          float64     `json:"price"`
	OriginalPrice  float64     `json:"originalPrice"`
	Status         int         `json:"status"`
	ImageID        uint        `json:"imageID"`
	Image          Image       `json:"image"`
	ImageIDs       string      `json:"imageIDs"`
	Images         []Image     `json:"images"`
	HasProperty    bool        `json:"hasProperty"`
	Properties     []Property  `json:"properties"`
	Inventories    []Inventory `json:"inventories"`
	TotalInventory uint        `json:"totalInventory"`
	Remark         string      `json:"remark"`
	Detail         string      `json:"detail"`
	Categories     []Category  `gorm:"many2many:product_category;ForeignKey:ID;AssociationForeignKey:ID" json:"categories"`
}

Product 商品

type Property

type Property struct {
	ID             uint            `gorm:"primary_key" json:"id"`
	CreatedAt      time.Time       `json:"createdAt"`
	UpdatedAt      time.Time       `json:"updatedAt"`
	DeletedAt      *time.Time      `sql:"index" json:"deletedAt"`
	Name           string          `json:"name"`
	ProductID      uint            `json:"productID"`
	PropertyValues []PropertyValue `json:"values"`
}

Property 商品属性

type PropertyValue

type PropertyValue struct {
	ID         uint       `gorm:"primary_key" json:"id"`
	CreatedAt  time.Time  `json:"createdAt"`
	UpdatedAt  time.Time  `json:"updatedAt"`
	DeletedAt  *time.Time `sql:"index" json:"deletedAt"`
	Name       string     `json:"name"`
	Note       string     `json:"note"`
	ProductID  uint       `json:"productID"`
	PropertyID uint       `json:"propertyID"`
}

PropertyValue 商品属性值

type User

type User struct {
	ID        uint       `gorm:"primary_key" json:"id"`
	CreatedAt time.Time  `json:"createdAt"`
	UpdatedAt time.Time  `json:"updatedAt"`
	DeletedAt *time.Time `sql:"index" json:"deletedAt"`
	ContactID string     `json:"contactId"` //默认地址
	OpenID    string     `json:"openId"`
	Nickname  string     `json:"nickname"`
	Username  string     `json:"username"`
	Email     string     `json:"email"`
	Phone     string     `json:"phone"`
	Password  string     `json:"password"`
	Token     string     `json:"token"`
	Sex       bool       `json:"sex"`
	Subscribe bool       `json:"subscribe"`
	Status    int        `json:"status"`
	Lastip    string     `json:"lastip"`
}

User 用户

func (User) PurchaseUserByDate

func (user User) PurchaseUserByDate(date time.Time) int

PurchaseUserByDate 指定日期有消费形为的用户数

func (User) TodayRegisterUser

func (user User) TodayRegisterUser() int

TodayRegisterUser 今日注册的用户数

func (User) YesterdayRegisterUser

func (user User) YesterdayRegisterUser() int

YesterdayRegisterUser 昨日注册的用户数

type UserPerDay

type UserPerDay []struct {
	Count     int    `json:"count"`
	CreatedAt string `gorm:"column:createdAt" json:"createdAt"`
}

UserPerDay 每天的�用户数

func (UserPerDay) Latest30Day

func (users UserPerDay) Latest30Day() UserPerDay

Latest30Day 近30天,每天注册的新用户数

type UserVisit

type UserVisit struct {
	ID             uint      `gorm:"primary_key" json:"id"`
	URL            string    `json:"url"`
	Referrer       string    `json:"referrer"`
	ClientID       string    `json:"clientID"`
	UserID         uint      `json:"userID"`
	VisitTime      time.Time `json:"visitTime"`
	IP             string    `json:"ip"`
	DeviceWidth    int       `json:"deviceWidth"`
	DeviceHeight   int       `json:"deviceHeight"`
	BrowserName    string    `json:"browserName"`
	BrowserVersion string    `json:"browserVersion"`
	DeviceModel    string    `json:"deviceModel"`
	Country        string    `json:"country"`
	Language       string    `json:"language"`
	OSName         string    `json:"osName"`
	OSVersion      string    `json:"osVersion"`
}

UserVisit 访客记录

func (UserVisit) Latest30DayPV

func (userVisit UserVisit) Latest30DayPV() PVPerDay

Latest30DayPV 近30天的PV

type WeAppUser

type WeAppUser struct {
	OpenID    string `json:"openId"`
	Nickname  string `json:"nickName"`
	Gender    int    `json:"gender"`
	AvatarURL string `json:"avatarUrl"`
}

WeAppUser 微信用户

Jump to

Keyboard shortcuts

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