diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index b635422a4..a47b5e540 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -783,8 +783,10 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa if err != nil { return 0, err } - if err = checkStoreHaveLinkedStore(storeID); err != nil { - return 0, err + if linkStoreID != 0 { + if err = checkStoreHaveLinkedStore(storeID); err != nil { + return 0, err + } } valid["linkStoreID"] = linkStoreID // globals.SugarLogger.Debug(linkStoreID) @@ -1011,16 +1013,14 @@ func EnableHaveRestStores(ctx *jxcontext.Context, isAsync, isContinueWhenError b } func checkStoreHaveLinkedStore(storeID int) (err error) { - if storeID != 0 { - storeList, err := dao.GetStoreLinkStores(dao.GetDB(), storeID) - if err == nil { - if len(storeList) > 0 { - var storeInfo []string - for _, v := range storeList { - storeInfo = append(storeInfo, utils.Int2Str(v.ID)) - } - err = fmt.Errorf("门店%d已经被其它门店(%s)关联,不能再关联至其它门店", storeID, strings.Join(storeInfo, ",")) + storeList, err := dao.GetStoreLinkStores(dao.GetDB(), storeID) + if err == nil { + if len(storeList) > 0 { + var storeInfo []string + for _, v := range storeList { + storeInfo = append(storeInfo, utils.Int2Str(v.ID)) } + err = fmt.Errorf("门店%d已经被其它门店(%s)关联,不能再关联至其它门店", storeID, strings.Join(storeInfo, ",")) } } return err @@ -1045,8 +1045,10 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i if err != nil { return 0, err } - if err = checkStoreHaveLinkedStore(storeExt.ID); err != nil { - return 0, err + if realLinkStoreID != 0 { + if err = checkStoreHaveLinkedStore(storeExt.ID); err != nil { + return 0, err + } } storeExt.LinkStoreID = realLinkStoreID