From 6004f8937b1f3e79bf8c35c172ba350a3fb214e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 8 Feb 2021 15:08:41 +0800 Subject: [PATCH] aa --- business/jxstore/tempop/tempop.go | 44 ++++++++++++++++++------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/business/jxstore/tempop/tempop.go b/business/jxstore/tempop/tempop.go index 913ddada7..f89d7e932 100644 --- a/business/jxstore/tempop/tempop.go +++ b/business/jxstore/tempop/tempop.go @@ -1827,30 +1827,38 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) { // }) // } var ( - db = dao.GetDB() + db = dao.GetDB() + idLists [][]*jdapi.SkuIdEntity ) storeMaps, _ := dao.GetStoresMapList(db, []int{model.VendorIDJD}, []int{667281}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", "320406") things, _ := dao.GetThingMapList(db, model.ThingTypeSku, []int{model.VendorIDJD}, nil, []string{"320406"}) - task := tasksch.NewParallelTask("uuuuu", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx, + for i := 0; i < len(things); i += 50 { + var idList []*jdapi.SkuIdEntity + j := i + 50 + if j > len(things)-1 { + j = len(things) - 1 + } + for _, v := range things[i:j] { + if v.VendorThingID != "" { + idList = append(idList, &jdapi.SkuIdEntity{ + OutSkuId: utils.Int64ToStr(v.ThingID), + }) + } + } + idLists = append(idLists, idList) + } + + task := tasksch.NewParallelTask("uuuuu", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { storeMap := batchItemList[0].(*model.StoreMap) - task2 := tasksch.NewParallelTask("uuuuu2", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, - func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { - thing := batchItemList[0].(*model.ThingMap) - if thing.VendorThingID != "" { - err = api.JdAPI.DelVipPrice(utils.Int2Str(storeMap.StoreID), []*jdapi.SkuIdEntity{ - &jdapi.SkuIdEntity{ - OutSkuId: utils.Int64ToStr(thing.ThingID), - }, - }) - if strings.Contains(err.Error(), "没有会员价") { - err = nil - } + for _, v := range idLists { + if v != nil && storeMap != nil { + err = api.JdAPI.DelVipPrice(utils.Int2Str(storeMap.StoreID), v) + if strings.Contains(err.Error(), "没有会员价") { + err = nil } - return retVal, err - }, things) - tasksch.HandleTask(task2, nil, true).Run() - _, err = task2.GetResult(0) + } + } return retVal, err }, storeMaps) tasksch.HandleTask(task, nil, true).Run()