From 0242da3d45b55d184daa251fd22ec25837725527 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:48:10 +0800 Subject: [PATCH] aa --- business/jxstore/tempop/tempop.go | 55 +++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/business/jxstore/tempop/tempop.go b/business/jxstore/tempop/tempop.go index 50fc06ea0..8aed636c3 100644 --- a/business/jxstore/tempop/tempop.go +++ b/business/jxstore/tempop/tempop.go @@ -1827,10 +1827,17 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) { // }) // } var ( - db = dao.GetDB() + db = dao.GetDB() + vendorThingIDs []int64 ) 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"}) + thingIDmap := make(map[int64]string) + + for _, v := range things { + vendorThingIDs = append(vendorThingIDs, utils.Str2Int64(v.VendorThingID)) + thingIDmap[utils.Str2Int64(v.VendorThingID)] = utils.Int64ToStr(v.ThingID) + } // for i := 0; i < len(things); i += 50 { // // var idList []*jdapi.SkuIdEntity // var idList2 []int64 @@ -1853,23 +1860,19 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) { 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) - priceInfo, _ := api.JdAPI.GetStationInfoList(storeMap.VendorStoreID, []int64{utils.Str2Int64(thing.VendorThingID)}) - for _, vv := range priceInfo { - if vv.VipPrice != 0 { - err = api.JdAPI.DelVipPrice(utils.Int2Str(storeMap.StoreID), []*jdapi.SkuIdEntity{ - &jdapi.SkuIdEntity{ - OutSkuId: utils.Int64ToStr(thing.ThingID), - }, - }) - } + FreeBatchInfo("uuuuu", func(task tasksch.ITask, batchedStoreSkuList []int64) (result interface{}, successCount int, err error) { + priceInfo, _ := api.JdAPI.GetStationInfoList(storeMap.VendorStoreID, batchedStoreSkuList) + for _, vv := range priceInfo { + if vv.VipPrice != 0 { + err = api.JdAPI.DelVipPrice(utils.Int2Str(storeMap.StoreID), []*jdapi.SkuIdEntity{ + &jdapi.SkuIdEntity{ + OutSkuId: thingIDmap[vv.SkuID], + }, + }) } - return retVal, err - }, things) - tasksch.HandleTask(task2, nil, true).Run() - _, err = task2.GetResult(0) + } + return nil, 0, err + }, ctx, task, vendorThingIDs, 50, true) return retVal, err }, storeMaps) tasksch.HandleTask(task, nil, true).Run() @@ -1877,6 +1880,24 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) { return err } +func FreeBatchInfo(name string, handler func(tasksch.ITask, []int64) (interface{}, int, error), ctx *jxcontext.Context, parentTask tasksch.ITask, storeSkuList []int64, batchSize int, isContinueWhenError bool) (resultList []interface{}, err error) { + task := tasksch.NewParallelTask2(fmt.Sprintf("FreeBatchInfo:%s", name), tasksch.NewParallelConfig().SetParallelCount(1).SetBatchSize(batchSize).SetIsContinueWhenError(isContinueWhenError), ctx, + func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, successCount int, err error) { + batchStoreSkuList := make([]int64, len(batchItemList)) + for k, v := range batchItemList { + batchStoreSkuList[k] = v.(int64) + } + retVal, successCount, err = handler(task, batchStoreSkuList) + if err != nil { + retVal = nil + } + return retVal, successCount, err + }, storeSkuList) + tasksch.HandleTask(task, parentTask, false).Run() + resultList, err = task.GetResult(0) + return resultList, err +} + func int2TimeStr(time int) (str string) { str += utils.Int2Str(time / 1000) str += utils.Int2Str(time % 1000 / 100)