diff --git a/business/partner/purchase/jdshop/store_sku.go b/business/partner/purchase/jdshop/store_sku.go index 09501d8f7..74e4b844a 100644 --- a/business/partner/purchase/jdshop/store_sku.go +++ b/business/partner/purchase/jdshop/store_sku.go @@ -74,18 +74,18 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v } var desc string if v.DescImg != "" { - pic3, err2 := uploadImg(v.DescImg, name, "desc") + pic3, err2 := uploadImg2(v.DescImg, name, "desc") err = err2 desc = `



` } updateWareParam.Introduction = desc updateWareParam.MobileDesc = desc if v.Img != "" { - pic1, err2 := uploadImg(v.Img, name, "1") + pic1, err2 := uploadImg2(v.Img, name, "1") err = err2 err = api.JdShopAPI.ImageUpdate(v.JdsWareID, 1, pic1) if v.Img2 != "" { - pic2, err2 := uploadImg(v.Img2, name, "2") + pic2, err2 := uploadImg2(v.Img2, name, "2") err = err2 err = api.JdShopAPI.ImageUpdate(v.JdsWareID, 2, pic2) } else { @@ -512,6 +512,19 @@ func uploadImg(img, name, index string) (imgURL string, err error) { return imgURL, err } +func uploadImg2(img, name, index string) (imgURL string, err error) { + data, _, err := jxutils.DownloadFileByURL(img) + if err != nil { + return imgURL, err + } + uploadResult, err := api.JdShopAPI.UploadPicture(data, 0, name+index) + if err != nil { + return imgURL, err + } + imgURL = uploadResult.PictureURL + return imgURL, err +} + func filterSensitiveWord(name string) (result string) { for _, v := range jdshopapi.SensitiveWordMap { if strings.Contains(name, v) {