This commit is contained in:
苏尹岚
2021-03-30 17:39:07 +08:00
parent b9f7d7f53a
commit 0dd7235485
49 changed files with 579 additions and 582 deletions

View File

@@ -495,32 +495,32 @@ func UpdateConfig(ctx *jxcontext.Context, key, configType, value string) (hint s
hint = "1"
db := dao.GetDB()
dao.Begin(db)
txDB , _ := dao.Begin(db)
defer func() {
if r := recover(); r != nil {
dao.Rollback(db)
dao.Rollback(db, txDB)
panic(r)
}
}()
configList, err := dao.QueryConfigs(db, key, configType, "")
if err != nil {
dao.Rollback(db)
dao.Rollback(db, txDB)
return "", err
}
if _, err = dao.UpdateEntityLogically(db, configList[0], map[string]interface{}{
"Value": value,
}, ctx.GetUserName(), nil); err != nil {
dao.Rollback(db)
dao.Rollback(db, txDB)
return "", err
}
switch configType {
case model.ConfigTypePricePack:
storeMapList, err := dao.GetStoresMapList(db, nil, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, key, "", "")
if err != nil {
dao.Rollback(db)
dao.Rollback(db, txDB)
return "", err
}
dao.Commit(db)
dao.Commit(db, txDB)
vendorStoreMap := make(map[int][]int)
for _, v := range storeMapList {
vendorStoreMap[v.VendorID] = append(vendorStoreMap[v.VendorID], v.StoreID)
@@ -533,7 +533,7 @@ func UpdateConfig(ctx *jxcontext.Context, key, configType, value string) (hint s
}
}
case model.ConfigTypeFreightPack:
dao.Commit(db)
dao.Commit(db, txDB)
storeMapList, err := dao.GetStoresMapList(db, nil, nil, nil, model.StoreStatusAll, model.StoreIsSyncYes, "", "", "")
if err != nil {
return "", err
@@ -559,7 +559,7 @@ func UpdateConfig(ctx *jxcontext.Context, key, configType, value string) (hint s
}
}
default:
dao.Commit(db)
dao.Commit(db, txDB)
}
if configType == model.ConfigTypeSys && err == nil {
err = onSysConfigChanged(key, value)