From d4b2d1596c0d75d50a1689141ba58158d5c7713b Mon Sep 17 00:00:00 2001 From: timerzz Date: Thu, 16 May 2024 12:52:06 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=B7=BB=E5=8A=A0=E5=BE=97=E7=89=A9?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E4=BB=B7=E6=A0=BC=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/product/model.go | 32 +++++++++++++++++++++----------- model/product/model_test.go | 16 ++++++++++++++++ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/model/product/model.go b/model/product/model.go index 3c9d327..d56bb7c 100644 --- a/model/product/model.go +++ b/model/product/model.go @@ -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"` +} diff --git a/model/product/model_test.go b/model/product/model_test.go index 0317cbf..73d407f 100644 --- a/model/product/model_test.go +++ b/model/product/model_test.go @@ -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) +}