- change sync.SyncSku to Serializable because of jd.spu

This commit is contained in:
gazebo
2018-12-11 16:21:27 +08:00
parent cfbde3b615
commit c72e3bc128
2 changed files with 6 additions and 5 deletions

View File

@@ -244,9 +244,10 @@ 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 {
if err == nil && len(skuList) > 0 {
// globals.SugarLogger.Debug(utils.Format4Output(skuList, false))
task := tasksch.NewParallelTask("SyncSku loop sku", nil, userName, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
// todo 这里SetParallelCount(1)的原因是京东SPU特殊类型必须要序列化同步才能正常处理, db可能会有多线程问题
task := tasksch.NewParallelTask("SyncSku loop sku", tasksch.NewParallelConfig().SetParallelCount(1), userName, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
sku := batchItemList[0].(*model.Sku)
syncStatus := jxutils.GetObjFieldByName(sku, syncStatusFieldName).(int8)
if (skuID == -1 || skuID == sku.ID) && (syncStatus != 0) {