aa
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user