package model

import (
	"time"

	"go.mongodb.org/mongo-driver/bson/primitive"
)

// 包装
type Pack struct {
	Id        primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
	Name      string             `bson:"name,omitempty" json:"name"`
	Thumbnail string             `bson:"thumbnail,omitempty" json:"thumbnail"`
	// 部件数量
	CompCounts int `bson:"compCounts,omitempty" json:"compCounts"`
	// 设计师
	Designer string `bson:"designer,omitempty" json:"designer"`
	// 组成包装的部件
	Components []*PackComponent `bson:"components,omitempty" json:"components"`
	CreateTime time.Time        `bson:"createTime,omitempty" json:"createTime"`
	UpdateTime time.Time        `bson:"updateTime,omitempty" json:"updateTime"`
}

type PackComponent struct {
	Id        string `bson:"id,omitempty" json:"id"`
	Name      string `bson:"name,omitempty" json:"name"`
	Thumbnail string `bson:"thumbnail,omitempty" json:"thumbnail"`
	//数量
	Count int `bson:"count,omitempty" json:"count"`

	//刀版图
	Uv string `bson:"uv,omitempty" json:"uv"`

	//部件尺寸
	UvSize string `bson:"uvSize,omitempty" json:"uvSize"`

	//所有材料
	Stages []*ComponentStage `bson:"stages,omitempty" json:"stages"`

	Remark string `bson:"remark,omitempty" json:"remark"`

	//部件总价
	TotalPrice float64 `bson:"totalPrice,omitempty" json:"totalPrice"`
}

type ComponentStage struct {
	Id     string             `bson:"id,omitempty" json:"id"`
	TypeId primitive.ObjectID `bson:"typeId,omitempty" json:"typeId"`

	// 下单单价
	OrderPrice float64 `bson:"orderPrice,omitempty" json:"orderPrice"`

	// 下单数量
	OrderCount int `bson:"orderCount,omitempty" json:"orderCount"`

	// 是否固定价格 如果是:为预算总价,不是:为实际总价
	IsFix *bool `bson:"isFix,omitempty" json:"isFix"`

	//实际价格 OrderPrice*ConfirmCount
	//预算价格 OrderPrice*OrderCount

	//确认收货数量
	ConfirmCount int `bson:"confirmCount,omitempty" json:"confirmCount"`

	// 供应相关信息
	// 交货时间
	DeliveryTime time.Time `bson:"deliveryTime,omitempty" json:"deliveryTime"`

	// 供应商信息
	SupplierInfo *Supplier `bson:"supplierInfo,omitempty" json:"supplierInfo"`

	BatchCount      *float64 `bson:"batchCount,omitempty" json:"batchCount"`           //拼版数量
	BatchSizeWidth  int      `bson:"batchSizeWidth,omitempty" json:"batchSizeWidth"`   //平板尺寸
	BatchSizeHeight int      `bson:"batchSizeHeight,omitempty" json:"batchSizeHeight"` //平板尺寸

	Remark     string    `bson:"remark,omitempty" json:"remark"`     //备注
	Size       string    `bson:"size,omitempty" json:"size"`         //工艺尺寸
	Name       string    `bson:"name,omitempty" json:"name"`         //名称
	Category   string    `bson:"category,omitempty" json:"category"` //分类
	Price      float64   `bson:"price,omitempty" json:"price"`       //单价
	Unit       string    `bson:"unit,omitempty" json:"unit"`         //单位
	Norm       string    `bson:"norm,omitempty" json:"norm"`         // 规格
	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
	Type       int       `bson:"type,omitempty" json:"type"`         //1-材料 2-工艺 3-成品
	Group      string    `bson:"group,omitempty" json:"group"`       //工序合标记,相同Group的数据合并成一个单据
	BillId     string    `bson:"billId,omitempty" json:"billId"`     //订单Id
	BillType   int       `bson:"billType,omitempty" json:"billType"` //订单type // 1,2,3
}