2024-08-03 14:12:44 +08:00
|
|
|
package v2
|
|
|
|
|
2024-08-05 17:21:58 +08:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
2024-08-03 14:12:44 +08:00
|
|
|
|
|
|
|
type ProviderId string
|
|
|
|
|
2024-08-05 17:21:58 +08:00
|
|
|
type Provider struct {
|
|
|
|
ID uint `gorm:"primary_key" json:"-"`
|
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
|
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
|
|
|
|
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ProviderOption struct {
|
|
|
|
Interval time.Duration `yaml:"interval" json:"interval"` //抓取间隔
|
|
|
|
ExchangeRate float64 `yaml:"exchangeRate" json:"exchangeRate"` //汇率
|
|
|
|
Freight float64 `yaml:"freight" json:"freight"` //运费
|
|
|
|
}
|
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"` //计算优惠的过程
|
|
|
|
}
|