From 2d884794a19ee4f1de0da2128affc9968fce166d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Sun, 26 Apr 2020 17:29:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81=E5=BA=93?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sku.go | 139 +++++++++++++++++++--------- business/jxstore/cms/store_sku.go | 121 ------------------------- business/jxstore/cms/sync.go | 146 ++++++++++++++++++++++++++++++ business/model/const.go | 2 + 4 files changed, 244 insertions(+), 164 deletions(-) diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index a60628423..f5c0e8b10 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -25,6 +25,7 @@ import ( "git.rosy.net.cn/baseapi/platformapi/jdapi" "git.rosy.net.cn/jx-callback/globals/api" + "git.rosy.net.cn/jx-callback/globals/refutil" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils/errlist" @@ -876,7 +877,7 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf if err = dao.GetEntity(db, skuName); err != nil { return 0, err } - + var beforSkuName = *skuName if payload["name"] != nil { newSkuName := utils.TrimBlankChar(utils.Interface2String(payload["name"])) if hasSensitiveWord, err := CheckHasSensitiveWord(newSkuName); hasSensitiveWord { @@ -999,6 +1000,10 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf _, err = CurVendorSync.SyncSku(ctx, db, nameID, -1, false, false, userName) errList.AddErr(err) err = errList.GetErrListAsOne() + if globals.IsAddEvent { + mapBefore := refutil.FindMapAndStructMixed(valid, beforSkuName) + err = AddEventDetail(db, ctx, model.OperateUpdate, nameID, model.ThingTypeSkuName, 0, BuildDiffData(mapBefore), BuildDiffData(valid)) + } } return num, err } @@ -1126,6 +1131,7 @@ func UpdateSku(ctx *jxcontext.Context, skuID int, payload map[string]interface{} if err = dao.GetEntity(db, sku); err != nil { return 0, err } + var beforSku = *sku valid := dao.StrictMakeMapByStructObject(payload, sku, userName) if len(valid) > 0 { // globals.SugarLogger.Debug(utils.Format4Output(valid, false)) @@ -1179,6 +1185,10 @@ func UpdateSku(ctx *jxcontext.Context, skuID int, payload map[string]interface{} _, err = CurVendorSync.SyncSku(ctx, db, -1, sku.ID, false, false, userName) errList.AddErr(err) err = errList.GetErrListAsOne() + if globals.IsAddEvent { + mapBefore := refutil.FindMapAndStructMixed(valid, beforSku) + err = AddEventDetail(db, ctx, model.OperateUpdate, skuID, model.ThingTypeSku, 0, BuildDiffData(mapBefore), BuildDiffData(valid)) + } } return num, err } @@ -1906,24 +1916,30 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID return retVal, err } if result.Img != "" { - if resBinary, _, err := jxutils.DownloadFileByURL(result.Img); err == nil { - if downloadURL, err := jxutils.UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix())+"origin"+result.Img[strings.LastIndex(result.Img, "/")+1:len(result.Img)]); err == nil { - resBinary2, _, err := jxutils.DownloadFileByURL(downloadURL + model.SkuNameImgStandard) - downloadURL2, err := jxutils.UploadExportContent(resBinary2, utils.Int64ToStr(time.Now().Unix())+downloadURL[strings.LastIndex(downloadURL, "/")+1:len(downloadURL)]) - if err == nil { - skuName.Img = downloadURL2 - } else { - retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} - return retVal, err - } - } else { - retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} - return retVal, err - } - } else { + downloadURL, err := uploadImgStandard(skuName.Img) + if err != nil { retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} return retVal, err } + skuName.Img = downloadURL + // if resBinary, _, err := jxutils.DownloadFileByURL(result.Img); err == nil { + // if downloadURL, err := jxutils.UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix())+"origin"+result.Img[strings.LastIndex(result.Img, "/")+1:len(result.Img)]); err == nil { + // resBinary2, _, err := jxutils.DownloadFileByURL(downloadURL + model.SkuNameImgStandard) + // downloadURL2, err := jxutils.UploadExportContent(resBinary2, utils.Int64ToStr(time.Now().Unix())+downloadURL[strings.LastIndex(downloadURL, "/")+1:len(downloadURL)]) + // if err == nil { + // skuName.Img = downloadURL2 + // } else { + // retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} + // return retVal, err + // } + // } else { + // retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} + // return retVal, err + // } + // } else { + // retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} + // return retVal, err + // } } else { skuName.Img = model.NOSkuNameImg } @@ -2106,36 +2122,42 @@ func CreateUpcSkuByExcelBin(ctx *jxcontext.Context, reader io.Reader, categoryID } //需要把图片传到七牛云上 if !strings.Contains(skuName.Img, "image.jxc4.com") { - if resBinary, _, err := jxutils.DownloadFileByURL(skuName.Img); err == nil { - if downloadURL, err := jxutils.UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix())+"origin"+skuName.Img[strings.LastIndex(skuName.Img, "/")+1:len(skuName.Img)]); err == nil { - 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 { - retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} - return retVal, err - } - } else { - retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} - return retVal, err - } - } else { - skuName.Img = downloadURL - } - } else { - retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} - return retVal, err - } - } else { - retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} - return retVal, err - } - } else { + downloadURL, err := uploadImgStandard(skuName.Img) + if err != nil { retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} return retVal, err } + skuName.Img = downloadURL + // if resBinary, _, err := jxutils.DownloadFileByURL(skuName.Img); err == nil { + // if downloadURL, err := jxutils.UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix())+"origin"+skuName.Img[strings.LastIndex(skuName.Img, "/")+1:len(skuName.Img)]); err == nil { + // 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 { + // retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} + // return retVal, err + // } + // } else { + // retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} + // return retVal, err + // } + // } else { + // skuName.Img = downloadURL + // } + // } else { + // retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} + // return retVal, err + // } + // } else { + // retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} + // return retVal, err + // } + // } else { + // retVal = []*CreateUpcSkuByExcelErr{buildCreateUpcSkuByExcelErr(v, err.Error())} + // return retVal, err + // } } skuName.Status = model.SkuStatusNormal skuName.IsGlobal = model.YES @@ -2242,3 +2264,34 @@ func RefreshJdDepot(ctx *jxcontext.Context) (err error) { } return err } + +//标准化上传图片。 +//图片是非京西图片上传到七牛云转换为京西图片 +func uploadImgStandard(imgUrl string) (downloadResult string, err error) { + if resBinary, _, err := jxutils.DownloadFileByURL(imgUrl); err == nil { + if downloadURL, err := jxutils.UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix())+"origin"+imgUrl[strings.LastIndex(imgUrl, "/")+1:len(imgUrl)]); err == nil { + if img, _, err := datares.Binary2Image(resBinary, http.DetectContentType(resBinary)); err == nil { + if img.Bounds().Dx() != datares.MainImgWidth || img.Bounds().Dy() != datares.MainImgHeight { //如果不是标准的800x800就再把图片格式化上传 + if resBinary2, _, err := jxutils.DownloadFileByURL(downloadURL + model.SkuNameImgStandard); err == nil { + if downloadURL2, err := jxutils.UploadExportContent(resBinary2, utils.Int64ToStr(time.Now().Unix())+imgUrl[strings.LastIndex(imgUrl, "/")+1:len(imgUrl)]); err == nil { + downloadResult = downloadURL2 + } else { + return downloadResult, err + } + } else { + return downloadResult, err + } + } else { + downloadResult = downloadURL + } + } else { + return downloadResult, err + } + } else { + return downloadResult, err + } + } else { + return downloadResult, err + } + return downloadResult, err +} diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 0634be47f..5e2cd26c9 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -4058,127 +4058,6 @@ func RefreshMatterStock(ctx *jxcontext.Context, skuID int) (err error) { return err } -func CreateSkusAndFocusFromYb(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) { - var ( - vendorID = model.VendorIDYB - db = dao.GetDB() - ) - storeMaps, err := dao.GetStoresMapList2(db, []int{vendorID}, nil, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", false) - handler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler) - for _, storeMap := range storeMaps { - store, _ := dao.GetStoreDetail(db, storeMap.StoreID, vendorID) - - localSkuList, err := dao.GetStoreSkus2(db, vendorID, storeMap.StoreID, nil, false) - if err != nil { - return "", err - } - localSkuMap := make(map[string]*dao.StoreSkuSyncInfo) - for _, v := range localSkuList { - localSkuMap[v.VendorSkuID] = v - } - remoteSkuList, err := handler.GetStoreSkusFullInfo(ctx, nil, storeMap.StoreID, storeMap.VendorStoreID, nil) - if err != nil { - return "", err - } - task := tasksch.NewParallelTask("银豹平台拉取标品", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx, - func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { - var ( - pricePercentagePack []*model.PricePercentageItem - v = batchItemList[0].(*partner.SkuNameInfo) - ) - //长度大于7就可能是标品,非标品一般是7位,前三位是yb_store_prefix后4位是yb_name_suffix - if len(v.YbBarCode) > 7 { - if localSkuMap[v.SkuList[0].VendorSkuID] == nil { - skuNames, err := dao.GetSkuNames(db, nil, []string{v.YbBarCode}, "", false) - if err != nil { - return retVal, err - } - //表示我们商品库中没有这个upc商品,如果有就直接关注上 - if len(skuNames) == 0 { - //我们商品库中有这个商品,但是upc没有填,则尝试用upc去查一下 - productInfos, err2 := GetJdUpcCodeByName(ctx, "", v.YbBarCode) - err = err2 - //表示用upc也没有找到这个商品,则再尝试用银豹上的名字去查 - if len(productInfos) == 0 { - skuNames2, err := dao.GetSkuNames(db, nil, nil, v.Name, false) - if err != nil { - return retVal, err - } - if len(skuNames2) > 1 { - return retVal, fmt.Errorf("此商品名在京西库中查询出了大于1个商品,[%v]", v.Name) - } - //表示查到了,需要把upc更新上去,没查到就要新建(//TODO新建不起,没得规格这些) - if len(skuNames2) == 1 { - skuNames2[0].Upc = &v.YbBarCode - dao.UpdateEntity(db, skuNames2[0], "Upc") - buildStoreSkuBindInfosAndFocus(ctx, db, store, v, skuNames2[0].ID, pricePercentagePack) - } - } else { - productInfo := productInfos[0] - skuNames2, err := dao.GetSkuNames(db, nil, nil, productInfo.Name, false) - if err != nil { - return retVal, err - } - if len(skuNames2) > 1 { - return retVal, fmt.Errorf("此商品名在京西库中查询出了大于1个商品,[%v]", productInfo.Name) - } - //表示查到了,需要把upc更新上去,没查到就要新建 - if len(skuNames2) == 1 && (productInfo.SpecQuality == skuNames2[0].SpecQuality && productInfo.SpecUnit == skuNames2[0].SpecUnit) { - skuNames2[0].Upc = &v.YbBarCode - dao.UpdateEntity(db, skuNames2[0], "Upc") - buildStoreSkuBindInfosAndFocus(ctx, db, store, v, skuNames2[0].ID, pricePercentagePack) - } else { - skuNameExt := &model.SkuNameExt{ - SkuName: model.SkuName{ - Name: productInfo.Name, - Upc: &productInfo.UpcCode, - Status: model.SkuStatusNormal, - CategoryID: model.NoCatCatgoryID, - IsGlobal: model.YES, - Unit: productInfo.Unit, - }, - Skus: []*model.SkuWithVendor{ - &model.SkuWithVendor{ - Sku: &model.Sku{}, - }, - }, - // Places: []int{510100}, //默认成都 - } - if len(v.SkuList) > 0 { - skuNameExt.Price = int(v.SkuList[0].VendorPrice) - skuNameExt.Skus[0].SpecQuality = productInfo.SpecQuality - skuNameExt.Skus[0].SpecUnit = productInfo.SpecUnit - skuNameExt.Skus[0].Weight = int(utils.Str2Int64(utils.Float64ToStr(float64(productInfo.Weight)))) - skuNameExt.Skus[0].Status = model.SkuStatusNormal - } - if len(productInfo.ImgList) > 0 { - skuNameExt.Img = productInfo.ImgList[0] - } - outSkuNameExt, err := AddSkuName(ctx, skuNameExt, ctx.GetUserName()) - if err != nil { - return retVal, err - } - buildStoreSkuBindInfosAndFocus(ctx, db, store, v, outSkuNameExt.ID, pricePercentagePack) - } - } - } else { - buildStoreSkuBindInfosAndFocus(ctx, db, store, v, skuNames[0].ID, pricePercentagePack) - } - } - } - return retVal, err - }, remoteSkuList) - tasksch.HandleTask(task, nil, true).Run() - if isAsync { - hint = task.GetID() - } else { - _, err = task.GetResult(0) - hint = "1" - } - } - return hint, err -} - func buildStoreSkuBindInfosAndFocus(ctx *jxcontext.Context, db *dao.DaoDB, store *dao.StoreDetail, v *partner.SkuNameInfo, nameID int, pricePercentagePack []*model.PricePercentageItem) (err error) { skus, _ := dao.GetSkus(db, nil, []int{nameID}, nil, nil, nil) err = jxutils.Strings2Objs(store.PricePercentagePackStr, &pricePercentagePack) diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index 44c16785f..36cd478f6 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -884,3 +884,149 @@ func (d *SyncErrResultLock) AppendData(syncErrResult SyncErrResult) { defer d.locker.Unlock() d.syncErrResult = append(d.syncErrResult, syncErrResult) } + +func (v *VendorSync) SyncStoreSkusFromYb(ctx *jxcontext.Context, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { + var ( + vendorID = model.VendorIDYB + db = dao.GetDB() + ) + hint, err = v.LoopStoresMap(ctx, db, fmt.Sprintf("从银豹平台同步商品到京西:%v", storeIDs), isAsync, true, []int{vendorID}, storeIDs, + func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { + loopMapInfo := batchItemList[0].(*LoopStoreMapInfo) + if len(loopMapInfo.StoreMapList) > 1 { + loopStoreTask := tasksch.NewParallelTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]), + tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError).SetParallelCount(5), ctx, + func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { + storeMap := batchItemList[0].(*model.StoreMap) + _, err = syncStoreSkusFromYb(ctx, storeMap.StoreID, vendorID, storeMap.VendorStoreID, isAsync, isContinueWhenError) + return nil, err + }, loopMapInfo.StoreMapList) + t.AddChild(loopStoreTask).Run() + _, err = loopStoreTask.GetResult(0) + } else { + _, err = syncStoreSkusFromYb(ctx, loopMapInfo.StoreMapList[0].StoreID, vendorID, loopMapInfo.StoreMapList[0].VendorStoreID, isAsync, isContinueWhenError) + } + return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID) + }, isContinueWhenError) + return hint, makeSyncError(err) +} + +func syncStoreSkusFromYb(ctx *jxcontext.Context, storeID, vendorID int, vendorStoreID string, isAsync, isContinueWhenError bool) (hint string, err error) { + var ( + db = dao.GetDB() + ) + handler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler) + store, _ := dao.GetStoreDetail(db, storeID, vendorID) + + localSkuList, err := dao.GetStoreSkus2(db, vendorID, storeID, nil, false) + if err != nil { + return "", err + } + localSkuMap := make(map[string]*dao.StoreSkuSyncInfo) + for _, v := range localSkuList { + localSkuMap[v.VendorSkuID] = v + } + remoteSkuList, err := handler.GetStoreSkusFullInfo(ctx, nil, storeID, vendorStoreID, nil) + if err != nil { + return "", err + } + task := tasksch.NewParallelTask("银豹平台拉取标品", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx, + func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { + var ( + pricePercentagePack []*model.PricePercentageItem + v = batchItemList[0].(*partner.SkuNameInfo) + ) + //长度大于7就可能是标品,非标品一般是7位,前三位是yb_store_prefix后4位是yb_name_suffix + if len(v.YbBarCode) > 7 { + if localSkuMap[v.SkuList[0].VendorSkuID] == nil { + skuNames, err := dao.GetSkuNames(db, nil, []string{v.YbBarCode}, "", false) + if err != nil { + return retVal, err + } + //表示我们商品库中没有这个upc商品,如果有就直接关注上 + if len(skuNames) == 0 { + //我们商品库中有这个商品,但是upc没有填,则尝试用upc去查一下 + productInfos, err2 := GetJdUpcCodeByName(ctx, "", v.YbBarCode) + err = err2 + //表示用upc也没有找到这个商品,则再尝试用银豹上的名字去查 + if len(productInfos) == 0 { + skuNames2, err := dao.GetSkuNames(db, nil, nil, v.Name, false) + if err != nil { + return retVal, err + } + if len(skuNames2) > 1 { + return retVal, fmt.Errorf("此商品名在京西库中查询出了大于1个商品,[%v]", v.Name) + } + //表示查到了,需要把upc更新上去,没查到就要新建(//TODO新建不起,没得规格这些) + if len(skuNames2) == 1 { + skuNames2[0].Upc = &v.YbBarCode + dao.UpdateEntity(db, skuNames2[0], "Upc") + buildStoreSkuBindInfosAndFocus(ctx, db, store, v, skuNames2[0].ID, pricePercentagePack) + } + if len(skuNames2) == 0 { + + } + } else { + productInfo := productInfos[0] + skuNames2, err := dao.GetSkuNames(db, nil, nil, productInfo.Name, false) + if err != nil { + return retVal, err + } + if len(skuNames2) > 1 { + return retVal, fmt.Errorf("此商品名在京西库中查询出了大于1个商品,[%v]", productInfo.Name) + } + //表示查到了,需要把upc更新上去,没查到就要新建 + if len(skuNames2) == 1 && (productInfo.SpecQuality == skuNames2[0].SpecQuality && productInfo.SpecUnit == skuNames2[0].SpecUnit) { + skuNames2[0].Upc = &v.YbBarCode + dao.UpdateEntity(db, skuNames2[0], "Upc") + buildStoreSkuBindInfosAndFocus(ctx, db, store, v, skuNames2[0].ID, pricePercentagePack) + } else { + skuNameExt := &model.SkuNameExt{ + SkuName: model.SkuName{ + Name: productInfo.Name, + Upc: &productInfo.UpcCode, + Status: model.SkuStatusNormal, + CategoryID: model.NoCatCatgoryID, + IsGlobal: model.YES, + Unit: productInfo.Unit, + }, + Skus: []*model.SkuWithVendor{ + &model.SkuWithVendor{ + Sku: &model.Sku{}, + }, + }, + // Places: []int{510100}, //默认成都 + } + if len(v.SkuList) > 0 { + skuNameExt.Price = int(v.SkuList[0].VendorPrice) + skuNameExt.Skus[0].SpecQuality = productInfo.SpecQuality + skuNameExt.Skus[0].SpecUnit = productInfo.SpecUnit + skuNameExt.Skus[0].Weight = int(utils.Str2Int64(utils.Float64ToStr(float64(productInfo.Weight)))) + skuNameExt.Skus[0].Status = model.SkuStatusNormal + } + if len(productInfo.ImgList) > 0 { + skuNameExt.Img = productInfo.ImgList[0] + } + outSkuNameExt, err := AddSkuName(ctx, skuNameExt, ctx.GetUserName()) + if err != nil { + return retVal, err + } + buildStoreSkuBindInfosAndFocus(ctx, db, store, v, outSkuNameExt.ID, pricePercentagePack) + } + } + } else { + buildStoreSkuBindInfosAndFocus(ctx, db, store, v, skuNames[0].ID, pricePercentagePack) + } + } + } + return retVal, err + }, remoteSkuList) + tasksch.HandleTask(task, nil, true).Run() + if isAsync { + hint = task.GetID() + } else { + _, err = task.GetResult(0) + hint = "1" + } + return hint, err +} diff --git a/business/model/const.go b/business/model/const.go index bf657e366..700f6d71d 100644 --- a/business/model/const.go +++ b/business/model/const.go @@ -140,6 +140,8 @@ var ( "AutoPayForPopluarMan": "每日订单打款", "SyncStoresQualify": "上传门店营业资质", "CancelOrder": "取消订单", + "UpdateSku": "修改sku", + "UpdateSkuName": "修改skuName", } MultiStoresVendorMap = map[int]int{