models

package
v0.0.0-...-50396a8 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB *gorm.DB
)

DB 数据库实例

Functions

This section is empty.

Types

type Amount

type Amount struct {
	ID             int64   `json:"id" gorm:"primaryKey"`
	Period         string  `json:"period,omitempty" gorm:"size:256;uniqueIndex:idx_pershop"`
	ShopCode       string  `json:"shop_code" gorm:"size:256;uniqueIndex:idx_pershop"`
	ShopName       string  `json:"shop_name" gorm:"size:256"`
	OrderNum       uint    `json:"order_num"`
	OrderAmount    float64 `json:"order_amount"`
	OrderAvgAmount float64 `json:"order_avg_amount"`
}

Amount represents each shop sales amount.

func GetAmountBy

func GetAmountBy(month, shopCode string) ([]Amount, error)

GetAmountBy returns the report of each shop sales amount for a specified month.

type Delivery

type Delivery struct {
	ID            int64          `json:"id" gorm:"primaryKey"`
	Delivery      bool           `json:"delivery" gorm:"comment:发货状态"`
	Code          string         `json:"code" gorm:"size:256;comment:发货单据号"`
	WarehouseName string         `json:"warehouse_name" gorm:"size:256"`
	WarehouseCode string         `json:"warehouse_code" gorm:"size:256;index"`
	ExpressName   string         `json:"express_name" gorm:"size:256"`
	ExpressCode   string         `json:"express_code" gorm:"size:256"`
	MailNo        string         `json:"mail_no" gorm:"size:256"`
	OrderCode     string         `json:"order_code" gorm:"size:256;index"`
	CreatedAt     time.Time      `json:"created_at"`
	UpdatedAt     time.Time      `json:"updated_at" gorm:"index"`
	DeletedAt     gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

Delivery struct to map the Entity of the Delivery.

type Detail

type Detail struct {
	ID               int64          `json:"id" gorm:"primaryKey"`
	OID              string         `json:"oid" gorm:"size:256;comment:子订单号"`
	Qty              float64        `json:"qty"`
	Price            float64        `json:"price" gorm:"comment:实际单价"`
	Amount           float64        `json:"amount" gorm:"comment:实际金额"`
	Refund           int            `json:"refund" gorm:"comment:退款状态,0:未退款,1:退款成功,2:退款中"`
	Note             string         `json:"note"`
	PlatformItemName string         `json:"platform_item_name" gorm:"size:256;comment:平台规格名称"`
	PlatformSkuName  string         `json:"platform_sku_name" gorm:"size:256;comment:平台规格代码"`
	ItemCode         string         `json:"item_code" gorm:"size:256;index;comment:商品代码"`
	ItemName         string         `json:"item_name" gorm:"size:256;comment:商品名称"`
	ItemSimpleName   string         `json:"item_simple_name" gorm:"size:256;comment:商品简称"`
	PostFee          float64        `json:"post_fee" gorm:"comment:物流费用"`
	DiscountFee      float64        `json:"discount_fee" gorm:"comment:让利金额"`
	AmountAfter      float64        `json:"amount_after" gorm:"comment:让利后金额"`
	OrderCode        string         `json:"order_code" gorm:"size:256;index"`
	CreatedAt        time.Time      `json:"created_at"`
	UpdatedAt        time.Time      `json:"updated_at" gorm:"index"`
	DeletedAt        gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

Detail struct to map the Entity of the item details.

type Order

type Order struct {
	ID                   int64          `json:"id" gorm:"unique"`
	Code                 string         `json:"code" gorm:"primaryKey;size:256;comment:单据编号"`
	PlatformCode         string         `json:"platform_code" gorm:"size:256;index;comment:平台单号"`
	OrderTypeName        string         `json:"order_type_name" gorm:"size:256;index;comment:订单类型"`
	ShopName             string         `json:"shop_name" gorm:"size:256;index"`
	ShopCode             string         `json:"shop_code" gorm:"size:256;index"`
	VIPName              string         `json:"vip_name" gorm:"size:256;column:vip_name;comment:会员名称"`
	VIPCode              string         `json:"vip_code" gorm:"size:256;column:vip_code;index;comment:会员代码"`
	VIPRealName          string         `json:"vip_real_name" gorm:"size:256;column:vip_real_name"`
	AccountStatus        string         `json:"account_status" gorm:"size:256;index"`
	AccountAmount        float64        `json:"account_amount" gorm:"comment:到账金额"`
	BusinessMan          string         `json:"business_man" gorm:"size:256"`
	Qty                  int8           `json:"qty"`
	Amount               float64        `json:"amount" gorm:"comment:订单金额"`
	Payment              float64        `json:"payment" gorm:"comment:支付金额"`
	WarehouseName        string         `json:"warehouse_name" gorm:"size:256"`
	WarehouseCode        string         `json:"warehouse_code" gorm:"size:256"`
	DeliveryState        int8           `json:"delivery_state" gorm:"index"`
	ExpressName          string         `json:"express_name" gorm:"size:256"`
	ExpressCode          string         `json:"express_code" gorm:"size:256;index"`
	ReceiverName         string         `json:"receiver_name" gorm:"size:256;index"`
	ReceiverMobile       string         `json:"receiver_mobile" gorm:"size:256;index"`
	ReceiverArea         string         `json:"receiver_area" gorm:"size:256"`
	ReceiverAddress      string         `json:"receiver_address" gorm:"size:512"`
	PlatformTradingState string         `json:"platform_trading_state" gorm:"size:256"`
	Deliverys            []Delivery     `json:"deliverys" gorm:"foreignKey:OrderCode;references:Code"`
	Details              []Detail       `json:"details" gorm:"foreignKey:OrderCode;references:Code"`
	Payments             []Payment      `json:"payments" gorm:"foreignKey:OrderCode;references:Code"`
	Paytime              time.Time      `json:"paytime" gorm:"index"`
	DealTime             time.Time      `json:"deal_time" gorm:"comment:拍单时间"`
	CreateTime           time.Time      `json:"create_time" gorm:"comment:创建时间"`
	ModifyTime           time.Time      `json:"modify_date" gorm:"comment:修改时间"`
	CreatedAt            time.Time      `json:"created_at"`
	UpdatedAt            time.Time      `json:"updated_at" gorm:"index"`
	DeletedAt            gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

A Order struct to map the Entity Order

func (*Order) GetLastUpdatedAt

func (o *Order) GetLastUpdatedAt(shopCode string) (time.Time, error)

GetLastUpdatedAt get the last updated timestamp of the order.

func (*Order) GetOrderCreatedMon

func (o *Order) GetOrderCreatedMon() ([]string, error)

GetOrderCreatedMon returns the list of orders created date, formatted as "YYYY-MM"

func (*Order) SaveAll

func (o *Order) SaveAll(orders *[]Order) (*[]Order, error)

SaveAll stores all specified the orders in the database.

type Payment

type Payment struct {
	ID          int64          `json:"id" gorm:"primaryKey"`
	Payment     float64        `json:"payment" gorm:"comment:支付金额"`
	PayCode     string         `json:"pay_code" gorm:"size:256;comment:支付交易号"`
	PayTypeName string         `json:"pay_type_name" gorm:"size:256;comment:支付方式名称"`
	PayTime     time.Time      `json:"pay_time" gorm:"comment:支付时间"`
	OrderCode   string         `json:"order_code" gorm:"size:256;index"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at" gorm:"index"`
	DeletedAt   gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

Payment struct to map the Entity of the payment.

type Shop

type Shop struct {
	ID         int64          `json:"id" gorm:"unique"`
	ShopID     int            `json:"shop_id" gorm:"primaryKey"`
	Nick       string         `json:"nick" gorm:"size:256"`
	Code       string         `json:"code" gorm:"unique"`
	Name       string         `json:"name" gorm:"size:256"`
	Note       string         `json:"note" gorm:"size:256"`
	TypeName   string         `json:"type_name" gorm:"size:256;index"`
	CreateDate time.Time      `json:"create_date"`
	ModifyDate time.Time      `json:"modify_date"`
	CreatedAt  time.Time      `json:"created_at"`
	UpdatedAt  time.Time      `json:"updated_at" gorm:"index"`
	DeletedAt  gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}

A Shop struct to map every shop information.

func (*Shop) GetAllShops

func (s *Shop) GetAllShops() (*[]Shop, error)

GetAllShops returns all shop from database.

func (*Shop) GetAmountByShop

func (s *Shop) GetAmountByShop(start, end string) ([]Amount, error)

GetAmountByShop returns sales amount for each shop.

func (*Shop) GetLastUpdatedAt

func (s *Shop) GetLastUpdatedAt() (time.Time, error)

GetLastUpdatedAt get the datetime of last updated of shop.

func (*Shop) Save

func (s *Shop) Save() (*Shop, error)

Save create a new Shop

func (*Shop) SaveAll

func (s *Shop) SaveAll(shops *[]Shop) (*[]Shop, error)

SaveAll save all shop to database.

Jump to

Keyboard shortcuts

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