package gmodel

import (
	"fusenapi/constants"
	"time"
)

// TODO: 使用model的属性做你想做的

// 订单详情
type OrderDetail struct {
	DeliveryAddress *OrderAddress                `json:"delivery_address"` // 收货地址
	OrderAmount     OrderAmount                  `json:"order_amount"`     // 订单金额
	OrderInfo       OrderInfo                    `json:"order_info"`       // 订单信息
	OrderProduct    []OrderProduct               `json:"order_product"`    // 订单商品
	PayStatus       constants.OrderPayStatusCode `json:"pay_status"`       // 支付状态
	PayTimeout      time.Duration                `json:"pay_timeout"`      // 支付状态
}

// 收货地址
type OrderAddress struct {
	Street    string `json:"street"`     // 详细地址
	City      string `json:"city"`       // 城市
	FirstName string `json:"first_name"` // 姓
	LastName  string `json:"last_name"`  // 名
	Mobile    string `json:"mobile"`     // 手机
	State     string `json:"state"`      // 州
	Suite     string `json:"suite"`      // 房号
	ZipCode   string `json:"zip_code"`   // 邮编号码
}

// 订单金额
type OrderAmount struct {
	Deposit          PayInfo    `json:"deposit"`           // 定金
	RemainingBalance PayInfo    `json:"remaining_balance"` // 尾款
	Discount         AmountInfo `json:"discount"`          // 折扣
	ShippingFee      AmountInfo `json:"shipping_fee"`      // 邮费
	Tax              AmountInfo `json:"tax"`               // 税费
	Subtotal         AmountInfo `json:"subtotal"`          // 商品总金额
	Total            AmountInfo `json:"total"`             // 订单总金额
}

// 支付明细
type PayInfo struct {
	Metadata   map[string]interface{} `json:"metadata"`    // 额外参数
	PayAmount  AmountInfo             `json:"pay_amount"`  // 金额明细
	PayMethod  string                 `json:"pay_method"`  // 交易方式
	PayTime    *time.Time             `json:"pay_time"`    // 支付时间
	Status     PayStatus              `json:"status"`      // 当前状态
	StatusLink []PayStatus            `json:"status_link"` // 状态链路
	TradeNo    string                 `json:"trade_no"`    // 支付交易号
}

// 金额明细
type AmountInfo struct {
	Change       AmountCurrency         `json:"change"`        // 变动金额
	ChangeRemark string                 `json:"change_remark"` // 变动备注
	Current      AmountCurrency         `json:"current"`       // 当前金额
	Initiate     AmountCurrency         `json:"initiate"`      // 初始金额
	Metadata     map[string]interface{} `json:"metadata"`      // 额外明细
	IsUpdate     int64                  `json:"is_update"`
}

// 金额货币
type AmountCurrency struct {
	ExchangeRate     constants.ExchangeRateUnit `json:"exchange_rate"`     // 换算汇率
	CurrentCurrency  string                     `json:"current_currency"`  // 当前货币
	CurrentAmount    constants.AmountUnit       `json:"current_amount"`    // 当前金额
	OriginalCurrency string                     `json:"original_currency"` // 原始货币
	OriginalAmount   constants.AmountUnit       `json:"original_amount"`   // 原始金额
	IsUpdate         int64                      `json:"is_update"`
}

// 支付状态
type PayStatus struct {
	Metadata    map[string]interface{} `json:"metadata"`     // 额外参数
	StatusCode  int64                  `json:"status_code"`  // 状态编码
	StatusTitle string                 `json:"status_title"` // 状态名称
}

// 订单信息
type OrderInfo struct {
	UserId         int64         `json:"user_id"`         // 物流类型
	Ctime          *time.Time    `json:"ctime"`           // 创建日期
	DeliveryMethod int64         `json:"delivery_method"` // 物流类型
	Metadata       OrderMetadata `json:"metadata"`        // 额外参数
	OrderSn        string        `json:"order_sn"`        // 订单编号
	Status         OrderStatus   `json:"status"`          // 当前状态
	StatusLink     []OrderStatus `json:"status_link"`     // 状态链路
	Utime          *time.Time    `json:"utime"`           // 更新时间
}

// 订单状态--用户
type OrderStatus struct {
	Children     []*OrderStatus            `json:"children"`      // 子状态,管理人员的处理状态, 用户不可见
	Ctime        *time.Time                `json:"ctime"`         // 创建时间
	ExpectedTime *time.Time                `json:"expected_time"` // 预计时间
	Metadata     map[string]interface{}    `json:"metadata"`      // 额外参数
	StatusCode   constants.OrderStatusCode `json:"status_code"`   // 状态编码
	StatusTitle  string                    `json:"status_title"`  // 状态名称
	Utime        *time.Time                `json:"utime"`         // 更新时间
}

// 订单商品
type OrderProduct struct {
	TotalPrice           AmountInfo             `json:"total_price"`            // 商品总价
	ItemPrice            AmountInfo             `json:"item_price"`             // 商品单价
	ExpectedDeliveryTime *time.Time             `json:"expected_delivery_time"` // 预计到货时间
	PurchaseQuantity     PurchaseQuantity       `json:"purchase_quantity"`      // 购买数量
	ProductId            int64                  `json:"product_id"`             // 商品ID
	ProductSn            string                 `json:"product_sn"`             // 商品编码
	ProductWebsiteUnit   *ProductWebsiteUnit    `json:"product_website_unit"`   //产品前台网站单位
	ProductName          string                 `json:"product_name"`           // 商品名称
	ProductCover         string                 `json:"product_cover"`          // 商品封面
	ProductCoverMetadata map[string]interface{} `json:"product_cover_metadata"` // 商品封面
	ProductSnapshot      interface{}            `json:"product_snapshot"`       // 商品快照
	ShoppingCartSnapshot *FsShoppingCartData    `json:"shopping_cart_snapshot"` // 购物车快照

	DiyInformation     *UserDiyInformation      `json:"diy_information"`
	SizeInfo           *OrderProductSizeInfo    `json:"size_info"`
	FittingInfo        *OrderProductFittingInfo `json:"fitting_info"`
	IsHighlyCustomized int64                    `json:"is_highly_customized"`
	RenderImage        string                   `json:"render_image"`
	SelectColorIndex   int64                    `json:"select_color_index"`
}
type PurchaseQuantity struct {
	Current  interface{} `json:"current"`
	Initiate interface{} `json:"initiate"`
	IsUpdate int64       `json:"is_update"`
}

type OrderProductSizeInfo struct {
	SizeID   int64                     `json:"size_id"`
	Capacity string                    `json:"capacity"`
	Title    OrderProductSizeInfoTitle `json:"title"`
}

type OrderProductSizeInfoTitle struct {
	Inch string `json:"inch"`
	Cm   string `json:"cm"`
}

type OrderProductFittingInfo struct {
	FittingID   int64  `json:"fitting_id"`   //配件ID
	FittingName string `json:"fitting_name"` //配件名称
}

type ExpectedDelivery struct {
	Current  time.Time `json:"current"`
	Initiate time.Time `json:"initiate"`
	IsUpdate int64     `json:"is_update"`
}

type OrderProductInter struct {
	CartId               int64                    `json:"cart_id"`                // 购物车ID
	TotalPrice           AmountInfo               `json:"total_price"`            // 商品总价
	ItemPrice            AmountInfo               `json:"item_price"`             // 商品单价
	PurchaseQuantity     *PurchaseQuantity        `json:"purchase_quantity"`      // 购买数量
	ProductId            int64                    `json:"product_id"`             // 商品ID
	ProductName          string                   `json:"product_name"`           // 商品名称
	ProductCover         string                   `json:"product_cover"`          // 商品封面
	ProductCoverMetadata map[string]interface{}   `json:"product_cover_metadata"` // 商品封面
	ProductSn            string                   `json:"product_sn"`             // 商品编码
	ProductWebsiteUnit   *ProductWebsiteUnit      `json:"product_website_unit"`   //产品前台网站单位
	DiyInformation       *UserDiyInformation      `json:"diy_information"`
	SizeInfo             *OrderProductSizeInfo    `json:"size_info"`
	FittingInfo          *OrderProductFittingInfo `json:"fitting_info"`
	IsHighlyCustomized   int64                    `json:"is_highly_customized"`
	RenderImage          string                   `json:"render_image"`
	ExpectedDeliveryTime *ExpectedDelivery        `json:"expected_delivery_time"` // 预计到货时间
	ActualDeliveryTime   *ExpectedDelivery        `json:"actual_delivery_time"`   // 实际到货时间
}
type OrderMetadata struct {
	ExpectedDeliveryTime *ExpectedDelivery `json:"expected_delivery_time"` // 预计到货时间
	ActualDeliveryTime   *ExpectedDelivery `json:"actual_delivery_time"`   // 实际到货时间
}