This commit is contained in:
parent
f539ecb8e4
commit
74fe8195b5
@ -4,13 +4,13 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: https://gitea.timerzz.com/timerzz/setup-go@v4
|
- uses: http://192.168.31.55:13000/timerzz/setup-go@v4
|
||||||
env:
|
env:
|
||||||
HTTPS_PROXY: http://192.168.31.55:10809
|
HTTPS_PROXY: http://192.168.31.55:10809
|
||||||
with:
|
with:
|
||||||
go-version: '1.22.x'
|
go-version: '1.22.x'
|
||||||
- uses: https://gitea.timerzz.com/timerzz/checkout@v4
|
- uses: http://192.168.31.55:13000/timerzz/checkout@v4
|
||||||
- uses: https://gitea.timerzz.com/timerzz/setup-ko@v0.6
|
- uses: http://192.168.31.55:13000/timerzz/setup-ko@v0.6
|
||||||
with:
|
with:
|
||||||
version: v0.15.4
|
version: v0.15.4
|
||||||
env:
|
env:
|
||||||
|
@ -3,6 +3,8 @@ package spider
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"gitea.timerzz.com/kedaya_haitao/cn-coach-spider/pkg/options"
|
"gitea.timerzz.com/kedaya_haitao/cn-coach-spider/pkg/options"
|
||||||
"gitea.timerzz.com/kedaya_haitao/common/model/product"
|
"gitea.timerzz.com/kedaya_haitao/common/model/product"
|
||||||
coach_client "gitea.timerzz.com/kedaya_haitao/common/pkg/coach-client"
|
coach_client "gitea.timerzz.com/kedaya_haitao/common/pkg/coach-client"
|
||||||
@ -10,7 +12,6 @@ import (
|
|||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"gorm.io/gorm/clause"
|
"gorm.io/gorm/clause"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Controller struct {
|
type Controller struct {
|
||||||
@ -97,12 +98,18 @@ func (c *Controller) saveRespData(list []coach_client.CNItem) error {
|
|||||||
for _, item := range list {
|
for _, item := range list {
|
||||||
var savedProduct productv1.Product
|
var savedProduct productv1.Product
|
||||||
c.db.Model(&savedProduct).Where("pid = ?", item.Code).Select("dw_price").Scan(&savedProduct)
|
c.db.Model(&savedProduct).Where("pid = ?", item.Code).Select("dw_price").Scan(&savedProduct)
|
||||||
|
var img string
|
||||||
|
if len(item.Images) > 0 && len(item.Images[0].Imgs) > 0 {
|
||||||
|
img = item.Images[0].Imgs[0].Img
|
||||||
|
} else {
|
||||||
|
glog.Warningf("%s img不存在 %v", item.Code, item)
|
||||||
|
}
|
||||||
p := productv1.Product{
|
p := productv1.Product{
|
||||||
UpdatedAt: time.Now(),
|
UpdatedAt: time.Now(),
|
||||||
Name: item.Title,
|
Name: item.Title,
|
||||||
Pid: item.Code,
|
Pid: item.Code,
|
||||||
Link: fmt.Sprintf("%s%s", c.linkPrefix, item.Code),
|
Link: fmt.Sprintf("%s%s", c.linkPrefix, item.Code),
|
||||||
Image: item.Images[0].Imgs[0].Img,
|
Image: img,
|
||||||
Orderable: item.Stock > 0,
|
Orderable: item.Stock > 0,
|
||||||
DiscPercent: 100 - int(item.DiscountRateMin*100),
|
DiscPercent: 100 - int(item.DiscountRateMin*100),
|
||||||
OriginalPrice: item.SkuMaxPrice,
|
OriginalPrice: item.SkuMaxPrice,
|
||||||
|
Loading…
Reference in New Issue
Block a user