From 18ad339e0cb6edc488fa6891651ef3e1b6a61213 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 13 Aug 2019 19:56:06 +0800 Subject: [PATCH] =?UTF-8?q?-=20AddStoreVendorMap=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=90=8E=E5=9B=9E=E6=BB=9A=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store.go | 3 ++- business/jxstore/cms/sync.go | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 28effeecb..4f8686350 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -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 { diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index d608aa56e..06cc581e2 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -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