根据excel创建标品优化

This commit is contained in:
苏尹岚
2020-04-10 18:28:59 +08:00
parent 56d577a65e
commit 31aac2e7b1

View File

@@ -1865,9 +1865,9 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader) (hint stri
}
if result.Img != "" {
if resBinary, _, err := jxutils.DownloadFileByURL(result.Img); err == nil {
if downloadURL, err := jxutils.UploadExportContent(resBinary, result.Img[strings.LastIndex(result.Img, "/"):len(result.Img)]); err == nil {
if downloadURL, err := jxutils.UploadExportContent(resBinary, result.Img[strings.LastIndex(result.Img, "/")+1:len(result.Img)]); err == nil {
resBinary2, _, err := jxutils.DownloadFileByURL(downloadURL + model.SkuNameImgStandard)
downloadURL2, err := jxutils.UploadExportContent(resBinary2, downloadURL[strings.LastIndex(downloadURL, "/"):len(downloadURL)]+utils.Int64ToStr(time.Now().Unix()))
downloadURL2, err := jxutils.UploadExportContent(resBinary2, utils.Int64ToStr(time.Now().Unix())+downloadURL[strings.LastIndex(downloadURL, "/")+1:len(downloadURL)])
if err == nil {
skuName.Img = downloadURL2
} else {
@@ -1926,6 +1926,14 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader) (hint stri
skuName.Skus[0].SpecUnit = model.SpecialSpecUnit
} else {
productInfo := productInfos[0]
if productInfo.Name == "" {
if v.Name != "" {
productInfo.Name = v.Name
} else {
createUpcSkuByExcelErrList = append(createUpcSkuByExcelErrList, buildCreateUpcSkuByExcelErr(v, "需要填上一个合适的商品名!"))
continue
}
}
skuNames2, _ := dao.GetSkuNames(db, nil, nil, productInfo.Name)
if len(skuNames2) > 1 {
createUpcSkuByExcelErrList = append(createUpcSkuByExcelErrList, buildCreateUpcSkuByExcelErr(v, "此商品名在京西库中查询出了大于1个商品"))