设置分类或商品可售时,不需要事务

This commit is contained in:
gazebo
2019-10-19 00:28:02 +08:00
parent 2c5c4b2326
commit 3fa818d5ab
2 changed files with 26 additions and 24 deletions

View File

@@ -163,15 +163,15 @@ func UpdateCategory(ctx *jxcontext.Context, categoryID int, payload map[string]i
}
func SetStoreCategorySyncStatus2(db *dao.DaoDB, storeIDs []int, catIDs []int, syncStatus int) (num int64, err error) {
dao.Begin(db)
defer func() {
if r := recover(); r != nil || err != nil {
dao.Rollback(db)
if r != nil {
panic(r)
}
}
}()
// dao.Begin(db)
// defer func() {
// if r := recover(); r != nil || err != nil {
// dao.Rollback(db)
// if r != nil {
// panic(r)
// }
// }
// }()
for _, vendorID := range partner.GetSingleStoreVendorIDs() {
num2, err2 := dao.SetStoreCategorySyncStatus(db, vendorID, storeIDs, catIDs, syncStatus)
if err = err2; err != nil {
@@ -179,7 +179,7 @@ func SetStoreCategorySyncStatus2(db *dao.DaoDB, storeIDs []int, catIDs []int, sy
}
num += num2
}
dao.Commit(db)
// dao.Commit(db)
return num, nil
}
@@ -773,15 +773,15 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
}
func SetStoreSkuSyncStatus2(db *dao.DaoDB, storeIDs []int, vendorIDs, skuIDs []int, syncStatus int) (num int64, err error) {
dao.Begin(db)
defer func() {
if r := recover(); r != nil || err != nil {
dao.Rollback(db)
if r != nil {
panic(r)
}
}
}()
// dao.Begin(db)
// defer func() {
// if r := recover(); r != nil || err != nil {
// dao.Rollback(db)
// if r != nil {
// panic(r)
// }
// }
// }()
for _, vendorID := range vendorIDs {
num2, err2 := dao.SetStoreSkuSyncStatus(db, vendorID, storeIDs, skuIDs, syncStatus)
if err = err2; err != nil {
@@ -789,7 +789,7 @@ func SetStoreSkuSyncStatus2(db *dao.DaoDB, storeIDs []int, vendorIDs, skuIDs []i
}
num += num2
}
dao.Commit(db)
// dao.Commit(db)
return num, nil
}

View File

@@ -564,7 +564,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
func checkRemoteCatExist(localCatMap map[string]*dao.SkuStoreCatInfo, catList []*partner.BareCategoryInfo) (cat2Delete []*partner.BareCategoryInfo) {
for _, v := range catList {
if localCatMap[v.VendorCatID] == nil {
if localCatMap[v.VendorCatID] == nil && localCatMap[v.Name] == nil {
cat2Delete = append(cat2Delete, v)
}
cat2Delete = append(cat2Delete, checkRemoteCatExist(localCatMap, v.Children)...)
@@ -626,6 +626,8 @@ func PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, ven
localCatMap := make(map[string]*dao.SkuStoreCatInfo)
for _, v := range localCatList {
localCatMap[v.VendorCatID] = v
localCatMap[v.Name] = v
localCatMap[utils.Int2Str(v.ID)] = v
}
remoteCatList, err2 := handler.GetStoreAllCategories(ctx, storeID, vendorStoreID)
@@ -686,14 +688,14 @@ func AddCreateFlagForJxStoreSku(ctx *jxcontext.Context, parentTask tasksch.ITask
case 0:
remoteSkuList, err2 := handler.GetStoreSkusFullInfo(ctx, task, storeID, vendorStoreID, nil)
if err = err2; err == nil {
remoteSkuMap := make(map[int]*partner.SkuNameInfo)
remoteSkuMap := make(map[int]int)
for _, value := range remoteSkuList {
for _, skuInfo := range value.SkuList {
remoteSkuMap[skuInfo.SkuID] = value
remoteSkuMap[skuInfo.SkuID] = 1
}
}
for _, v := range localSkuList {
if remoteSkuMap[v.SkuID] == nil && !model.IsSyncStatusNew(v.StoreSkuSyncStatus) && !model.IsSyncStatusDelete(v.StoreSkuSyncStatus) && v.BindID != 0 {
if remoteSkuMap[v.SkuID] == 0 && !model.IsSyncStatusNew(v.StoreSkuSyncStatus) && !model.IsSyncStatusDelete(v.StoreSkuSyncStatus) && v.BindID != 0 {
storeSkuBindIDs = append(storeSkuBindIDs, v.BindID)
}
}