orders

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

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

Go to latest
Published: Oct 19, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// OrderState order's state machine
	OrderState = transition.New(&Order{})

	// ItemState order item's state machine
	ItemState = transition.New(&OrderItem{})
)
View Source
var (
	DraftState = "draft"
)
View Source
var (
	ORDER_TYPES = []string{"配送", "安装", "送装一体", "维修", "清洗", "销售", "物流"}
)
View Source
var (
	SOURCES = []string{
		"京东物流", "苏宁帮客", "美的安得",
	}
)

Functions

This section is empty.

Types

type Condition

type Condition struct {
	gorm.Model

	RuleID uint
	Rule   Rule

	Name string
	// 运算符
	Operator string
	Value    string
}

type DeliveryMethod

type DeliveryMethod struct {
	gorm.Model

	Name  string
	Price float32
}

type Execution

type Execution struct {
	gorm.Model

	RuleID uint
	Rule   Rule

	Name  string
	Value string
}

type Order

type Order struct {
	gorm.Model
	audited.AuditedModel

	UserID            *uint
	User              users.User
	PaymentAmount     float32
	PaymentTotal      float32
	AbandonedReason   string
	DiscountValue     uint
	DeliveryMethodID  uint `form:"delivery-method"`
	DeliveryMethod    DeliveryMethod
	PaymentMethod     string
	TrackingNumber    *string
	ShippedAt         *time.Time
	ReturnedAt        *time.Time
	CancelledAt       *time.Time
	ShippingAddressID uint `form:"shippingaddress"`
	ShippingAddress   users.Address
	BillingAddressID  uint `form:"billingaddress"`
	BillingAddress    users.Address
	OrderItems        []OrderItem `json:"order_items"`
	// AmazonAddressAccessToken string
	// AmazonOrderReferenceID   string
	// AmazonAuthorizationID    string
	// AmazonCaptureID          string
	// AmazonRefundID           string
	PaymentLog string `gorm:"size:655250"`

	// 订单来源 0 自家商城, 1 京东
	Source string

	// 订单号 面单号
	OrderNo string `gorm:"unique;not null" json:"order_no"`

	// -- ORDER_TYPE starts with Q 退货的取件单
	OrderType string

	// 客户信息, 从京东后台导入或者扫描枪扫入的
	CustomerAddress string `json:"customer_address"`
	CustomerName    string `json:"customer_name"`
	CustomerPhone   string `json:"customer_phone"`

	// 预约配送时间
	ReservedDeliveryTime string `gorm:"reserved_delivery_time" json:"reserved_delivery_time"`

	// 预约安装时间
	ReservedSetupTime string `gorm:"reserved_setup_time" json:"reserved_setup_time"`

	// 预约取件时间
	ReservedPickupTime string `gorm:"reserved_pickup_time" json:"reserved_pickup_time"`

	// 是否送装一体(这个jd页面抓下来的是什么就存什么, 但是实际上有的订单是非送装一体,如果客户要求,也需要派人安装的,有些订单是取件单)
	// 所以这个字段保持和京东抓下来的一致,另外还要个OrderType, 根据规则或者人工去改OrderType
	IsDeliveryAndSetup string

	// 应收款项
	Receivables float32 `json:"receivables"`

	// 配送员
	ManToDeliverID string     `l10n:"sync"`
	ManToDeliver   users.User `l10n:"sync"`

	// 配送员
	ManToSetupID string
	ManToSetup   users.User `l10n:"sync"`

	// 取件员
	ManToPickupID string     `l10n:"sync"`
	ManToPickup   users.User `l10n:"sync"`

	// 取件费
	PickupFee float32

	// 配送费
	ShippingFee float32

	// 安装费
	SetupFee float32

	transition.Transition
}

func (*Order) AfterCreate

func (order *Order) AfterCreate(scope *gorm.Scope) error

AfterCreate 初始状态

func (Order) Amount

func (order Order) Amount() (amount float32)

func (Order) DeliveryFee

func (order Order) DeliveryFee() (amount float32)

DeliveryFee delivery fee

func (Order) ExternalID

func (order Order) ExternalID() string

func (Order) IsCart

func (order Order) IsCart() bool

func (Order) Total

func (order Order) Total() (total float32)

func (Order) UniqueExternalID

func (order Order) UniqueExternalID() string

type OrderFollowUp

type OrderFollowUp struct {
	gorm.Model
	audited.AuditedModel
	transition.Transition

	OrderID uint
	OrderNo string `gorm:"unique;not null" json:"order_no"`

	// 对配送时效是否满意
	SatisfactionOfTimeliness string `json:"satisfaction_of_timeliness"`

	// 对服务态度是否满意
	SatisfactionOfServices string `json:"satisfaction_of_services"`

	// 是否有开箱验货
	InspectTheGoods string `json:"inspect_the_goods"`

	// 师傅是否邀评
	RequestFeedback string `json:"request_feedback"`

	// 是否有留下联系方式 方便后期有问题联系
	LeaveContactInfomation string `json:"leave_contact_information"`

	// 师傅是否有介绍延保
	IntroduceWarrantyExtension string `json:"introduce_warranty_extension"`

	// 是否有把商品放到指定位置
	PositionProperly string `json:"position_properly"`

	// 有无问题要反馈
	Feedback string `json:"feedback"`

	// 异常处理结果
	ExceptionHandling string `json:"exception_handling"`
}

OrderFollowUp 订单回访

func (*OrderFollowUp) AfterCreate

func (o *OrderFollowUp) AfterCreate(scope *gorm.DB) error

AfterCreate callback

type OrderItem

type OrderItem struct {
	gorm.Model
	OrderID          uint `json: "order_id`
	Order            Order
	SizeVariationID  uint `cartitem:"SizeVariationID"`
	SizeVariation    *products.SizeVariation
	ColorVariationID uint `cartitem:"ColorVariationID"`
	ColorVariation   *products.ColorVariation
	Quantity         uint    `cartitem:"Quantity"`
	Price            float32 `json:"price"`
	DiscountRate     uint

	ProductNo string `json:"product_no"`
	OrderNo   string `json:"order_no"`
	ItemName  string `json:"product_name"`
	Install   string `json:"install"`

	Range     int    `json:"range"`
	Category  string `json:"category"`
	Dimension string `json:"dimension"`

	// 单件商品的配送费 根据规则推断出来的
	DeliveryFee float64 `json:"delivery_fee"`

	transition.Transition
}

func (*OrderItem) AfterCreate

func (item *OrderItem) AfterCreate(scope *gorm.Scope) error

AfterCreate 初始状态

func (OrderItem) Amount

func (item OrderItem) Amount() float32

Amount order item's amount

func (*OrderItem) Color

func (item *OrderItem) Color() products.Color

func (*OrderItem) GetLengthUnit

func (item *OrderItem) GetLengthUnit() int64

GetLengthUnit 获取长度单位(x英寸)中的数字 电视机

func (*OrderItem) GetPowerUnit

func (item *OrderItem) GetPowerUnit() int64

GetPowerUnit 获取功率单位(x匹)中的数字 空调

func (*OrderItem) GetUnit

func (item *OrderItem) GetUnit() int64

GetUnit 获取单位

func (*OrderItem) GetVolumeUnit

func (item *OrderItem) GetVolumeUnit() int64

GetVolumeUnit 获取重量单位(x升/L)中的数字 冰箱 冰柜 热水器

func (*OrderItem) GetWeightUnit

func (item *OrderItem) GetWeightUnit() int64

GetWeightUnit 获取重量单位(x公斤/kg)中的数字 洗衣机

func (OrderItem) IsCart

func (item OrderItem) IsCart() bool

IsCart order item's state is cart

func (*OrderItem) IsService

func (item *OrderItem) IsService() bool

IsService 是否是增值服务

func (*OrderItem) ProductName

func (item *OrderItem) ProductName() string

ProductName order item's color name

func (*OrderItem) ProductPath

func (item *OrderItem) ProductPath() string

ProductPath order item's product name

func (*OrderItem) SellingPrice

func (item *OrderItem) SellingPrice() float32

SellingPrice order item's selling price

func (*OrderItem) SetCategory

func (item *OrderItem) SetCategory(c string)

func (*OrderItem) SetDeliveryFee

func (item *OrderItem) SetDeliveryFee(f float64)

func (*OrderItem) SetDimension

func (item *OrderItem) SetDimension(d string)

func (*OrderItem) SetRange

func (item *OrderItem) SetRange(i int64)

func (*OrderItem) Size

func (item *OrderItem) Size() products.Size

type OrderType

type OrderType string
const (
	Delivery         OrderType = "配送"
	Logistics        OrderType = "物流"
	Setup            OrderType = "安装"
	Repair           OrderType = "维修"
	Clean            OrderType = "清洗"
	Sale             OrderType = "销售"
	DeliveryAndSetup OrderType = "送装一体"
)

type PaymentMethod

type PaymentMethod = string
const (
	COD        PaymentMethod = "COD"
	AmazonPay  PaymentMethod = "AmazonPay"
	CreditCard PaymentMethod = "CreditCard"
)

type Pricing

type Pricing struct {
	gorm.Model

	// 针对哪个分类的 (冰洗空)
	Category string
	// 件型大小
	VolumeType string
	// 配送范围
	DeliveryArea string
	// 费用
	Fee float64
}

Pricing 运费定价 https://cl.ly/c1c76e6a4776 eg. 超小件的电脑配送到县城10元,配送到乡下15元 运费根据规则引擎计算 grool.go

type Rating

type Rating struct {
	gorm.Model

	OrderID uint
	Order   Order

	// 好评还是差评
	Type string

	// 具体原因
	Reason string

	// 奖励或罚款金额
	Amount int

	Remark string

	audited.AuditedModel
}

Rating 记录好评差评模块

type Rule

type Rule struct {
	gorm.Model
	sorting.Sorting

	Name string

	// 针对哪个分类的
	Category string
	// 作用 (判断大小还是判断分类的、范围、定价)
	Effect string

	Description string
	Priority    int

	Conditions []Condition
	Executions []Execution
}

type Source

type Source string
const (
	JD     Source = "京东物流"
	Suning Source = "苏宁帮客"
	Midea  Source = "美的安得"
)

Jump to

Keyboard shortcuts

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