fix 修复拉取后没有利润率的bug
Some checks failed
Build image / build (push) Failing after 14s

This commit is contained in:
timerzz 2024-05-21 19:46:34 +08:00
parent 8f70b150b0
commit 29c79beb5f

View File

@ -86,10 +86,10 @@ func (c *Controller) saveRespData(list []coach_client.Product) error {
return item.Id == color.VgId
})
// 获取已经存的运费
var saveFreight float64
c.db.Model(&productv1.Product{}).Where("pid = ?", color.VgId).Select("freight").Scan(&saveFreight)
if saveFreight > 0 {
c.Freight = saveFreight
var savedProduct productv1.Product
c.db.Model(&savedProduct).Where("pid = ?", color.VgId).Select("freight", "dw_price").Scan(&savedProduct)
if savedProduct.Freight == 0 {
savedProduct.Freight = c.Freight
}
products = append(products, productv1.Product{
UpdatedAt: time.Now(),
@ -101,8 +101,9 @@ func (c *Controller) saveRespData(list []coach_client.Product) error {
Orderable: color.Orderable,
DiscPercent: price.Price.MarkdownDiscPercent,
USPrice: price.Price.Sales.Value,
Freight: c.Freight,
Freight: savedProduct.Freight,
ExchangeRate: c.ExchangeRate,
DWPrice: savedProduct.DWPrice,
})
}
}