- AddStoreVendorMap同步失败后回滚本地数据

This commit is contained in:
gazebo
2019-08-13 19:56:06 +08:00
parent f8a5e1bc8d
commit 18ad339e0c
2 changed files with 8 additions and 3 deletions

View File

@@ -796,7 +796,6 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID
}
}()
if err = dao.CreateEntity(db, storeMap); err == nil {
dao.Commit(db)
outStoreMap = storeMap
if store != nil {
_, err = CurVendorSync.SyncStore(ctx, db, storeMap.VendorID, storeID, false, userName)
@@ -804,6 +803,8 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID
}
if err != nil {
dao.Rollback(db)
} else {
dao.Commit(db)
}
}
} else {

View File

@@ -221,9 +221,13 @@ func (v *VendorSync) SyncStore(ctx *jxcontext.Context, db *dao.DaoDB, vendorID,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
var resultList []interface{}
storeMap := batchItemList[0].(*model.StoreMap)
if err = handler.UpdateStore(db, storeMap.StoreID, userName); err == nil {
db2 := db
if len(loopMapInfo.StoreMapList) > 1 {
db2 = dao.GetDB()
}
if err = handler.UpdateStore(db2, storeMap.StoreID, userName); err == nil {
storeMap.SyncStatus = 0
_, err = dao.UpdateEntity(db, storeMap, model.FieldSyncStatus)
_, err = dao.UpdateEntity(db2, storeMap, model.FieldSyncStatus)
resultList = append(resultList, 1)
}
return resultList, err