根据excel创建标品优化
This commit is contained in:
@@ -1427,38 +1427,43 @@ func GetJdUpcCodeByCode(ctx *jxcontext.Context, upcCode string) (productInfos []
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productInfos []*jdapi.ProductInfo, err error) {
|
func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productInfos []*jdapi.ProductInfo, err error) {
|
||||||
var (
|
if name != "" {
|
||||||
pageNo = 5
|
var (
|
||||||
pageSize = 30
|
pageNo = 5
|
||||||
pageNoList []int
|
pageSize = 30
|
||||||
)
|
pageNoList []int
|
||||||
if name == "" && upcCode == "" {
|
)
|
||||||
return nil, fmt.Errorf("至少输入一个条件查询,商品名或者upc码!")
|
if name == "" && upcCode == "" {
|
||||||
}
|
return nil, fmt.Errorf("至少输入一个条件查询,商品名或者upc码!")
|
||||||
for i := 1; i < pageNo+1; i++ {
|
}
|
||||||
pageNoList = append(pageNoList, i)
|
for i := 1; i < pageNo+1; i++ {
|
||||||
}
|
pageNoList = append(pageNoList, i)
|
||||||
task := tasksch.NewParallelTask("获取京东商品", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
}
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
task := tasksch.NewParallelTask("获取京东商品", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||||
pageNum := batchItemList[0].(int)
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
productInfo, err := api.JdAPI.GetJdUpcCodeByName(name, upcCode, pageNum, pageSize)
|
pageNum := batchItemList[0].(int)
|
||||||
if err != nil {
|
productInfo, err := api.JdAPI.GetJdUpcCodeByName(name, upcCode, pageNum, pageSize)
|
||||||
|
if err != nil {
|
||||||
|
return retVal, err
|
||||||
|
}
|
||||||
|
for _, v := range productInfo {
|
||||||
|
_, name, _, specUnit, unit, specQuality := jxutils.SplitSkuName(v.OriginalName)
|
||||||
|
v.Name = name
|
||||||
|
v.SpecQuality = specQuality
|
||||||
|
v.SpecUnit = specUnit
|
||||||
|
v.Unit = unit
|
||||||
|
}
|
||||||
|
retVal = productInfo
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}
|
}, pageNoList)
|
||||||
for _, v := range productInfo {
|
tasksch.HandleTask(task, nil, true).Run()
|
||||||
_, name, _, specUnit, unit, specQuality := jxutils.SplitSkuName(v.OriginalName)
|
productInfoInterface, err2 := task.GetResult(0)
|
||||||
v.Name = name
|
err = err2
|
||||||
v.SpecQuality = specQuality
|
for _, v := range productInfoInterface {
|
||||||
v.SpecUnit = specUnit
|
productInfos = append(productInfos, v.(*jdapi.ProductInfo))
|
||||||
v.Unit = unit
|
}
|
||||||
}
|
} else {
|
||||||
retVal = productInfo
|
productInfos, err = GetJdUpcCodeByCode(ctx, upcCode)
|
||||||
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 productInfos, err
|
return productInfos, err
|
||||||
}
|
}
|
||||||
@@ -1998,6 +2003,7 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader) (hint stri
|
|||||||
createUpcSkuByExcelErrList = append(createUpcSkuByExcelErrList, buildCreateUpcSkuByExcelErr(v, fmt.Sprintf("暂不支持的图片格式:[%v]", skuName.Img)))
|
createUpcSkuByExcelErrList = append(createUpcSkuByExcelErrList, buildCreateUpcSkuByExcelErr(v, fmt.Sprintf("暂不支持的图片格式:[%v]", skuName.Img)))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
//需要把图片传到七牛云上
|
||||||
if !strings.Contains(skuName.Img, "image.jxc4.com") {
|
if !strings.Contains(skuName.Img, "image.jxc4.com") {
|
||||||
if resBinary, _, err := jxutils.DownloadFileByURL(skuName.Img); err == nil {
|
if resBinary, _, err := jxutils.DownloadFileByURL(skuName.Img); err == nil {
|
||||||
if downloadURL, err := jxutils.UploadExportContent(resBinary, skuName.Img[strings.LastIndex(skuName.Img, "/")+1:len(skuName.Img)]); err == nil {
|
if downloadURL, err := jxutils.UploadExportContent(resBinary, skuName.Img[strings.LastIndex(skuName.Img, "/")+1:len(skuName.Img)]); err == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user