根据excel创建标品优化

This commit is contained in:
苏尹岚
2020-04-14 11:21:36 +08:00
parent 3313d52f39
commit f9cd7cdffe

View File

@@ -1427,6 +1427,7 @@ 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) {
if name != "" {
var ( var (
pageNo = 5 pageNo = 5
pageSize = 30 pageSize = 30
@@ -1456,10 +1457,14 @@ func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productIn
return retVal, err return retVal, err
}, pageNoList) }, pageNoList)
tasksch.HandleTask(task, nil, true).Run() tasksch.HandleTask(task, nil, true).Run()
productInfoInterface, err := task.GetResult(0) productInfoInterface, err2 := task.GetResult(0)
err = err2
for _, v := range productInfoInterface { for _, v := range productInfoInterface {
productInfos = append(productInfos, v.(*jdapi.ProductInfo)) productInfos = append(productInfos, v.(*jdapi.ProductInfo))
} }
} else {
productInfos, err = GetJdUpcCodeByCode(ctx, upcCode)
}
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 {