feat 添加得物历史价格字段

This commit is contained in:
timerzz 2024-05-16 12:52:06 +08:00
parent 570e19d76c
commit d4b2d1596c
2 changed files with 37 additions and 11 deletions

View File

@ -34,17 +34,19 @@ type Product struct {
Image string `json:"image"`
Orderable bool `json:"orderable"`
USPrice float64 `json:"usPrice"`
DiscPercent int `json:"discPercent" gorm:"index"` //折扣力度
CNYPrice float64 `json:"cnyPrice"`
CalMark string `json:"calMark"` //计算价格的过程
DWPrice float64 `json:"dwPrice"`
Freight float64 `json:"freight"` //运费
ExchangeRate float64 `json:"exchangeRate" gorm:"-"` //汇率
Rate float64 `json:"rate" gorm:"index"` //利润率
PriceStatus PriceStatus `json:"priceStatus"` //价格状态
Remark string `json:"remark"` //备注
HistoryPrices []HistoryPrice `gorm:"foreignKey:Pid;references:Pid" json:"historyPrices"`
USPrice float64 `json:"usPrice"`
DiscPercent int `json:"discPercent" gorm:"index"` //折扣力度
CNYPrice float64 `json:"cnyPrice"`
CalMark string `json:"calMark"` //计算价格的过程
DWPrice float64 `json:"dwPrice"`
Freight float64 `json:"freight"` //运费
ExchangeRate float64 `json:"exchangeRate" gorm:"-"` //汇率
Rate float64 `json:"rate" gorm:"index"` //利润率
PriceStatus PriceStatus `json:"priceStatus"` //价格状态
Remark string `json:"remark"` //备注
HistoryPrices []HistoryPrice `gorm:"foreignKey:Pid;references:Pid" json:"historyPrices"`
DWHistoryPrices []DWHistoryPrice `gorm:"foreignKey:Pid;references:Pid" json:"dwHistoryPrices"`
}
func (p *Product) TableName() string {
@ -118,3 +120,11 @@ type HistoryPrice struct {
Pid string `gorm:"index" json:"pid"`
USPrice float64 `json:"usPrice"`
}
type DWHistoryPrice struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
Pid string `gorm:"index" json:"pid"`
DWPrice float64 `json:"dwPrice"`
}

View File

@ -56,3 +56,19 @@ func TestUpdate(t *testing.T) {
t.Fatal(err)
}
}
func TestGetConfig(t *testing.T) {
db, err := database.InitDatabase(&database.DBOption{
Host: "192.168.31.55",
User: "timerzz",
Password: "zhhg1997",
Port: "5432",
DBName: "kedaya_dev",
})
if err != nil {
t.Fatal(err)
}
var exchangeRate float64
db.Table("options").Select("exchange_rate").Where("id = ?", 1).Scan(&exchangeRate)
t.Log(exchangeRate)
}