- only handle dirty sku in SyncSku
This commit is contained in:
@@ -246,9 +246,17 @@ func (v *VendorSync) SyncSku(ctx *jxcontext.Context, db *dao.DaoDB, nameID, skuI
|
||||
cond[model.FieldID] = skuID
|
||||
}
|
||||
err := dao.GetEntitiesByKV(db, &skuList, cond, true)
|
||||
if err == nil && len(skuList) > 0 {
|
||||
sort.Sort(jxutils.SkuList(skuList))
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(skuList, false))
|
||||
if err == nil {
|
||||
var dirtySkuList []*model.Sku
|
||||
for _, v := range skuList {
|
||||
syncStatus := jxutils.GetObjFieldByName(v, syncStatusFieldName).(int8)
|
||||
if syncStatus != 0 {
|
||||
dirtySkuList = append(dirtySkuList, v)
|
||||
}
|
||||
}
|
||||
if len(dirtySkuList) > 0 {
|
||||
sort.Sort(jxutils.SkuList(dirtySkuList))
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(dirtySkuList, false))
|
||||
// todo 这里SetParallelCount(1)的原因是京东SPU特殊类型必须要序列化同步才能正常处理, db可能会有多线程问题
|
||||
task := tasksch.NewParallelTask("SyncSku loop sku", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), userName, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
||||
sku := batchItemList[0].(*model.Sku)
|
||||
@@ -278,10 +286,11 @@ func (v *VendorSync) SyncSku(ctx *jxcontext.Context, db *dao.DaoDB, nameID, skuI
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}, skuList)
|
||||
}, dirtySkuList)
|
||||
t.AddChild(task).Run()
|
||||
_, err = task.GetResult(0)
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user