master
howell 4 years ago
parent 6601d242fd
commit f3e8346fbd

@ -4,12 +4,6 @@ import (
"archive/zip"
"bytes"
"fmt"
mysql2 "git.oa00.com/go/mysql"
"github.com/corona10/goimagehash"
"github.com/gin-gonic/gin"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
"gorm.io/gorm"
"image"
"image/jpeg"
"image/png"
@ -29,6 +23,13 @@ import (
"recook/tools"
"strconv"
"strings"
mysql2 "git.oa00.com/go/mysql"
"github.com/corona10/goimagehash"
"github.com/gin-gonic/gin"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
"gorm.io/gorm"
)
type Goods struct {
@ -231,7 +232,8 @@ func CalHash(model goods.RecookGoodsMainPhotoModel) (string, error) {
}
func (g *Goods) Sync(c *gin.Context) {
go SyncAllSku()
b := c.Query("brand")
go SyncAllSku(b)
c.String(200, "suc")
}
@ -240,7 +242,7 @@ func (g *Goods) Fix(c *gin.Context) {
c.String(200, "suc")
}
func (g *Goods)AttrSync(c *gin.Context){
func (g *Goods) AttrSync(c *gin.Context) {
go AttrSync()
c.String(200, "suc")
}
}

@ -58,7 +58,7 @@ func AttrSync() {
}
}
func SyncAllSku() {
func SyncAllSku(brand string) {
defer func() {
if err := recover(); err != nil {
log.Println(err)
@ -73,7 +73,7 @@ func SyncAllSku() {
// fmt.Println(err)
//}
for {
if err := SyncPageData(page, size, cate); err != nil {
if err := SyncPageData(page, size, brand, cate); err != nil {
if err == empty {
break
}
@ -82,12 +82,12 @@ func SyncAllSku() {
}
}
func SyncPageData(page, size uint, categories []RecookJCookCategory) error {
func SyncPageData(page, size uint, brand string, categories []RecookJCookCategory) error {
c := jcook.GetClient()
r := jcook.SkuListReq{
Page: page,
PageSize: size,
Brand: brand,
}
var skuEntries jcook.SkuListResp

@ -7,7 +7,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/shopspring/decimal"
"io"
"log"
"net/http"
@ -19,6 +18,8 @@ import (
"strings"
"sync"
"time"
"github.com/shopspring/decimal"
)
type client struct {
@ -73,8 +74,9 @@ type Response struct {
}
type SkuListReq struct {
Page uint `json:"page"`
PageSize uint `json:"page_size"`
Page uint `json:"page"`
PageSize uint `json:"page_size"`
Brand string `json:"brand"`
}
func (o SkuListReq) GetApiName() string {

Loading…
Cancel
Save