diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index d05e17c76..082cabe58 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "mime/multipart" + "net/http" "regexp" "strconv" "strings" @@ -1410,6 +1411,21 @@ func SortCategorySkus(ctx *jxcontext.Context, catID int, skuIDList []int) (err e return err } +func GetJdUpcCodeByCode(ctx *jxcontext.Context, upcCode string) (productInfos []*jdapi.ProductInfo, err error) { + productInfo, err := api.JdAPI.GetJdUpcCodeByName("", upcCode, 1, 30) + if err != nil { + return nil, 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 + } + return productInfo, err +} + func GetJdUpcCodeByName(ctx *jxcontext.Context, name, upcCode string) (productInfos []*jdapi.ProductInfo, err error) { var ( pageNo = 5 @@ -1853,7 +1869,7 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader) (hint stri createUpcSkuByExcelErrList = append(createUpcSkuByExcelErrList, buildCreateUpcSkuByExcelErr(v, "商品在京西库中已存在!")) continue } - productInfos, err := GetJdUpcCodeByName(ctx, "", *v.Upc) + productInfos, err := GetJdUpcCodeByCode(ctx, *v.Upc) if err != nil { createUpcSkuByExcelErrList = append(createUpcSkuByExcelErrList, buildCreateUpcSkuByExcelErr(v, err.Error())) continue @@ -1985,9 +2001,15 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader) (hint stri if !strings.Contains(skuName.Img, "image.jxc4.com") { 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 resBinary2, _, err := jxutils.DownloadFileByURL(downloadURL + model.SkuNameImgStandard); err == nil { - if downloadURL2, err := jxutils.UploadExportContent(resBinary2, utils.Int64ToStr(time.Now().Unix())+skuName.Img[strings.LastIndex(skuName.Img, "/")+1:len(skuName.Img)]); err == nil { - skuName.Img = downloadURL2 + if img, _, err := datares.Binary2Image(resBinary, http.DetectContentType(resBinary)); err == nil { + if img.Bounds().Dx() != datares.MainImgWidth || img.Bounds().Dy() != datares.MainImgHeight { + if resBinary2, _, err := jxutils.DownloadFileByURL(downloadURL + model.SkuNameImgStandard); err == nil { + if downloadURL2, err := jxutils.UploadExportContent(resBinary2, utils.Int64ToStr(time.Now().Unix())+skuName.Img[strings.LastIndex(skuName.Img, "/")+1:len(skuName.Img)]); err == nil { + skuName.Img = downloadURL2 + } + } + } else { + skuName.Img = downloadURL } } } diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 9cbd4c970..0f94c9f07 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -1233,12 +1233,14 @@ func GetOrdersForJxPay(db *DaoDB, finishTimeBegin, finishTimeEnd time.Time) (goo AND a.order_finished_at <= ? AND a.status = ? AND c.parent_mobile <> '' + AND a.store_id <> ? ` sqlParams := []interface{}{ model.VendorIDJX, finishTimeBegin, finishTimeEnd, model.OrderStatusFinished, + model.MatterStoreID, } err = GetRows(db, &goods, sql, sqlParams...) return goods, err