根据名字查询京东upc
This commit is contained in:
@@ -7,6 +7,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -1292,16 +1296,29 @@ func SortCategorySkus(ctx *jxcontext.Context, catID int, skuIDList []int) (err e
|
||||
return err
|
||||
}
|
||||
|
||||
func GetJdUpcCodeByName(ctx *jxcontext.Context, name string) (pagedInfo *model.PagedInfo, err error) {
|
||||
pageNo := 1
|
||||
pageSize := 30
|
||||
jdSkus, totalCount, err := api.JdAPI.GetJdUpcCodeByName(name, pageNo, pageSize)
|
||||
for _, v := range jdSkus {
|
||||
fmt.Println(v)
|
||||
func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productInfos []*jdapi.ProductInfo, err error) {
|
||||
var (
|
||||
pageNo = 5
|
||||
pageSize = 30
|
||||
pageNoList []int
|
||||
)
|
||||
for i := 1; i < pageNo+1; i++ {
|
||||
pageNoList = append(pageNoList, i)
|
||||
}
|
||||
pagedInfo = &model.PagedInfo{
|
||||
Data: jdSkus,
|
||||
TotalCount: totalCount,
|
||||
task := tasksch.NewParallelTask("获取京东商品", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
pageNum := batchItemList[0].(int)
|
||||
productInfo, err := api.JdAPI.GetJdUpcCodeByName(name, upcCode, pageNum, pageSize)
|
||||
if err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
retVal = productInfo
|
||||
return retVal, err
|
||||
}, pageNoList)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
productInfoInterface, err := task.GetResult(0)
|
||||
for _, v := range productInfoInterface {
|
||||
productInfos = append(productInfos, v.(*jdapi.ProductInfo))
|
||||
}
|
||||
return pagedInfo, err
|
||||
return productInfos, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user