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