2024-08-03 14:12:44 +08:00
|
|
|
package v2
|
|
|
|
|
2024-08-05 17:21:58 +08:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
2024-08-03 14:12:44 +08:00
|
|
|
|
|
|
|
type ProviderId string
|
|
|
|
|
2024-08-05 17:21:58 +08:00
|
|
|
type Provider struct {
|
2024-08-27 14:19:31 +08:00
|
|
|
ID uint `gorm:"primary_key" json:"id"`
|
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
2024-08-05 17:21:58 +08:00
|
|
|
|
|
|
|
ProviderId ProviderId `gorm:"unique" json:"providerId"`
|
|
|
|
// 供应商的名称
|
|
|
|
Name string `json:"name"`
|
|
|
|
// 供应商配置
|
|
|
|
Config ProviderOption `gorm:"type:json;serializer:json" json:"config"`
|
|
|
|
//计算过程
|
|
|
|
CalculateProcess []CalculateProcess `json:"calculateProcess" gorm:"polymorphicType:Kind;polymorphicId:OwnerID;polymorphicValue:provider"`
|
2024-08-23 18:12:31 +08:00
|
|
|
// 备注
|
|
|
|
Mark string `json:"mark,omitempty"`
|
2024-08-05 17:21:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type ProviderOption struct {
|
2024-08-23 18:12:31 +08:00
|
|
|
Ticker string `yaml:"ticker" json:"ticker"` //每天几点抓取
|
|
|
|
ExchangeRate float64 `yaml:"exchangeRate" json:"exchangeRate"` //汇率
|
|
|
|
Freight float64 `yaml:"freight" json:"freight"` //运费
|
2024-08-05 17:21:58 +08:00
|
|
|
}
|
2024-08-03 17:07:10 +08:00
|
|
|
|
2024-08-03 14:12:44 +08:00
|
|
|
// ProviderArticle 供应商商品信息
|
|
|
|
type ProviderArticle struct {
|
|
|
|
ID uint `gorm:"primary_key" json:"-"`
|
|
|
|
|
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
// 对应的商品ID
|
|
|
|
ArticleID uint
|
|
|
|
// 货号
|
2024-08-03 17:07:10 +08:00
|
|
|
Pid string `gorm:"index" json:"pid"`
|
2024-08-03 14:12:44 +08:00
|
|
|
// 品牌
|
2024-08-03 17:07:10 +08:00
|
|
|
Brand Brand `gorm:"index" json:"brand"`
|
2024-08-03 14:12:44 +08:00
|
|
|
// 供应商商品链接链接
|
|
|
|
Link string `json:"link"`
|
|
|
|
// 供应商id
|
|
|
|
ProviderId ProviderId `gorm:"index:providerId_sku,unique" json:"providerId"`
|
|
|
|
// 供应商的sku
|
|
|
|
SkuID string `gorm:"index:providerId_sku,unique" json:"skuID"`
|
|
|
|
// 当前成本价
|
|
|
|
Cost ProviderPrice `json:"cost" gorm:"type:json;serializer:json"`
|
|
|
|
// 历史成本价格
|
|
|
|
HistoryPrice []ProviderPrice `json:"historyPrice"`
|
2024-08-05 17:21:58 +08:00
|
|
|
// 计算过程
|
|
|
|
CalculateProcess []CalculateProcess `json:"calculateProcess" gorm:"polymorphicType:Kind;polymorphicId:OwnerID;polymorphicValue:providerArticle"`
|
2024-08-03 14:12:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// ProviderPrice 供应商成本价格
|
|
|
|
type ProviderPrice struct {
|
|
|
|
ID uint `gorm:"primary_key" json:"-"`
|
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
|
|
|
|
ProviderArticleID uint `gorm:"index"`
|
|
|
|
// 供应商原始价格,美元、人名币、加元,单位为分
|
|
|
|
OriginalPrice int `json:"originalPrice"`
|
|
|
|
// 计算优惠后最终价格,人名币,单位为分
|
|
|
|
FinalPrice int `json:"finalPrice"` // 计算完优惠的最终的价格
|
|
|
|
CalMark string `json:"calMark"` //计算优惠的过程
|
|
|
|
}
|