From c93cfcf3819e69fa875eb1eeeeadac6e3240c519 Mon Sep 17 00:00:00 2001 From: timerzz Date: Wed, 15 May 2024 13:59:07 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E8=8E=B7=E5=8F=96=E5=B7=B2=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E7=9A=84=E8=BF=90=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 ++-- product/controller.go | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 55dd572..d90d7dc 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.2 toolchain go1.22.3 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/gofiber/fiber/v3 v3.0.0-beta.2 github.com/golang/glog v1.2.1 diff --git a/go.sum b/go.sum index 312dd2e..cfd2ba0 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ 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-20240514123648-99c3e85dbc18/go.mod h1:cgLy4gB0z2UZD3kBp1IAemt28dkaKNdt4RC0LNkE1I8= +gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240515055453-202f8a89111a h1:D1yaUoTNJ1GyPzrVzrqFr8MBrOS/IpfyMg5kjE8diwk= +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/go.mod h1:iEdTZNt9kzPIxjIGSMScUFSBrUH6bFRNg0BWlP4orEY= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= diff --git a/product/controller.go b/product/controller.go index d094165..4f6a277 100644 --- a/product/controller.go +++ b/product/controller.go @@ -83,6 +83,12 @@ func (c *Controller) saveRespData(list []coach_client.Product) error { price, _ := lo.Find(resp.VariantsOnSale, func(item coach_client.Variant) bool { 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{ Name: resp.Name, Pid: color.VgId, @@ -102,6 +108,6 @@ func (c *Controller) saveRespData(list []coach_client.Product) error { }) return c.db.Clauses(clause.OnConflict{ 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 }