feat 获取详情时获取图片
All checks were successful
Build image / build (push) Successful in 4m15s

This commit is contained in:
timerzz 2024-11-29 16:01:12 +08:00
parent eb0b51c2f3
commit 1367b729b0
3 changed files with 9 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-20241120131415-18ceb8a07738 gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241129074538-3eb2ed0d82fb
github.com/gofiber/fiber/v3 v3.0.0-beta.3 github.com/gofiber/fiber/v3 v3.0.0-beta.3
github.com/golang/glog v1.2.1 github.com/golang/glog v1.2.1
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1

2
go.sum
View File

@ -1,6 +1,8 @@
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-20241120131415-18ceb8a07738 h1:H9qFYOZuFamcvNYBDiQ8AIXSu7oBujon3Vd3wndFyqg= gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241120131415-18ceb8a07738 h1:H9qFYOZuFamcvNYBDiQ8AIXSu7oBujon3Vd3wndFyqg=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241120131415-18ceb8a07738/go.mod h1:BIz+IMGznPiyLnV1+Ntw1zf8rEIcbymmGq+EfvDsSgE= gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241120131415-18ceb8a07738/go.mod h1:BIz+IMGznPiyLnV1+Ntw1zf8rEIcbymmGq+EfvDsSgE=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241129074538-3eb2ed0d82fb h1:TRUAHaoTMr9DIxtnOJHouObMfh1vcaKHK3XnMiwRd8o=
gitea.timerzz.com/kedaya_haitao/common v0.0.0-20241129074538-3eb2ed0d82fb/go.mod h1:BIz+IMGznPiyLnV1+Ntw1zf8rEIcbymmGq+EfvDsSgE=
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

@ -164,6 +164,7 @@ func (c *Controller) productsToArticles(products []coach_client.Product) (articl
Pid: color.VgId, Pid: color.VgId,
SkuID: color.VgId, SkuID: color.VgId,
Available: color.Orderable, Available: color.Orderable,
Image: color.Media.Thumbnail.Src,
Link: fmt.Sprintf("%s/%s", "https://www.coachoutlet.com", color.Url), Link: fmt.Sprintf("%s/%s", "https://www.coachoutlet.com", color.Url),
} }
// 拿到现在的价格 // 拿到现在的价格
@ -287,6 +288,9 @@ func (c *Controller) FetchArticleDetail(ctx context.Context, pid string) error {
Pid: resp.Id, Pid: resp.Id,
Brand: v2.Brand_Coach, Brand: v2.Brand_Coach,
} }
if len(resp.ImageGroups) > 0 {
article.Image = resp.ImageGroups[0].Images[0].Src
}
pArticle := v2.ProviderArticle{ pArticle := v2.ProviderArticle{
ProviderId: c.providerId, ProviderId: c.providerId,
Brand: v2.Brand_Coach, Brand: v2.Brand_Coach,
@ -294,6 +298,7 @@ func (c *Controller) FetchArticleDetail(ctx context.Context, pid string) error {
SkuID: pid, SkuID: pid,
Available: resp.Inventory.Orderable, Available: resp.Inventory.Orderable,
Ast: resp.Inventory.Ats, Ast: resp.Inventory.Ats,
Image: article.Image,
Link: fmt.Sprintf("%s/%s", "https://www.coachoutlet.com", resp.Url), Link: fmt.Sprintf("%s/%s", "https://www.coachoutlet.com", resp.Url),
Cost: utils.CalculateProviderPrice( Cost: utils.CalculateProviderPrice(
append(c.provider.CalculateProcess, old.CalculateProcess...), append(c.provider.CalculateProcess, old.CalculateProcess...),
@ -305,9 +310,7 @@ func (c *Controller) FetchArticleDetail(ctx context.Context, pid string) error {
} }
pArticle.HistoryPrice = append(pArticle.HistoryPrice, pArticle.Cost) pArticle.HistoryPrice = append(pArticle.HistoryPrice, pArticle.Cost)
article.Providers = append(article.Providers, pArticle) article.Providers = append(article.Providers, pArticle)
if len(resp.ImageGroups) > 0 {
article.Image = resp.ImageGroups[0].Images[0].Src
}
c.saveProducts([]v2.Article{article}) c.saveProducts([]v2.Article{article})
return nil return nil
} }