feat 获取已保存的运费
All checks were successful
Build image / build (push) Successful in 2m45s

This commit is contained in:
timerzz 2024-05-15 13:59:07 +08:00
parent 8762164388
commit c93cfcf381
3 changed files with 10 additions and 4 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.22.2
toolchain go1.22.3 toolchain go1.22.3
require ( require (
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240514123648-99c3e85dbc18 gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240515055453-202f8a89111a
github.com/go-resty/resty/v2 v2.13.1 github.com/go-resty/resty/v2 v2.13.1
github.com/gofiber/fiber/v3 v3.0.0-beta.2 github.com/gofiber/fiber/v3 v3.0.0-beta.2
github.com/golang/glog v1.2.1 github.com/golang/glog v1.2.1

4
go.sum
View File

@ -1,6 +1,6 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240514123648-99c3e85dbc18 h1:lTARBVopKcR47VJGzumhNDTmxc0QUpzHnk9AuD/6kfs= gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240515055453-202f8a89111a h1:D1yaUoTNJ1GyPzrVzrqFr8MBrOS/IpfyMg5kjE8diwk=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240514123648-99c3e85dbc18/go.mod h1:cgLy4gB0z2UZD3kBp1IAemt28dkaKNdt4RC0LNkE1I8= gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240515055453-202f8a89111a/go.mod h1:cgLy4gB0z2UZD3kBp1IAemt28dkaKNdt4RC0LNkE1I8=
github.com/3andne/restls-client-go v0.1.6 h1:tRx/YilqW7iHpgmEL4E1D8dAsuB0tFF3uvncS+B6I08= github.com/3andne/restls-client-go v0.1.6 h1:tRx/YilqW7iHpgmEL4E1D8dAsuB0tFF3uvncS+B6I08=
github.com/3andne/restls-client-go v0.1.6/go.mod h1:iEdTZNt9kzPIxjIGSMScUFSBrUH6bFRNg0BWlP4orEY= github.com/3andne/restls-client-go v0.1.6/go.mod h1:iEdTZNt9kzPIxjIGSMScUFSBrUH6bFRNg0BWlP4orEY=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

View File

@ -83,6 +83,12 @@ func (c *Controller) saveRespData(list []coach_client.Product) error {
price, _ := lo.Find(resp.VariantsOnSale, func(item coach_client.Variant) bool { price, _ := lo.Find(resp.VariantsOnSale, func(item coach_client.Variant) bool {
return item.Id == color.VgId 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
}
products = append(products, productv1.Product{ products = append(products, productv1.Product{
Name: resp.Name, Name: resp.Name,
Pid: color.VgId, Pid: color.VgId,
@ -102,6 +108,6 @@ func (c *Controller) saveRespData(list []coach_client.Product) error {
}) })
return c.db.Clauses(clause.OnConflict{ return c.db.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "pid"}}, Columns: []clause.Column{{Name: "pid"}},
DoUpdates: clause.AssignmentColumns([]string{"name", "color", "link", "orderable", "us_price", "cny_price", "cal_mark", "freight", "rate"}), DoUpdates: clause.AssignmentColumns([]string{"name", "color", "link", "orderable", "us_price", "cny_price", "cal_mark", "rate"}),
}).Create(products).Error }).Create(products).Error
} }