aa
This commit is contained in:
@@ -2946,6 +2946,29 @@ func UpdateVendorCategoryMap(ctx *jxcontext.Context, ID int, vendorCategoryMap *
|
||||
}
|
||||
}
|
||||
}
|
||||
var countInfos []*struct{ Ct int }
|
||||
db := dao.GetDB()
|
||||
if err = dao.GetRows(db, &countInfos, `
|
||||
SELECT COUNT(*) ct
|
||||
FROM sku t1
|
||||
WHERE t1.category_id = ? AND t1.deleted_at = ?
|
||||
UNION ALL
|
||||
SELECT COUNT(*) ct
|
||||
FROM sku_name t1
|
||||
WHERE t1.category_id = ? AND t1.deleted_at = ?
|
||||
UNION ALL
|
||||
SELECT COUNT(*) ct
|
||||
FROM sku_category t1
|
||||
WHERE t1.parent_id = ? AND t1.deleted_at = ?
|
||||
`, vendorCategoryMap2.CategoryID, utils.DefaultTimeValue, vendorCategoryMap2.CategoryID, utils.DefaultTimeValue, vendorCategoryMap2.CategoryID, utils.DefaultTimeValue, &countInfos); err == nil {
|
||||
if countInfos[0].Ct != 0 {
|
||||
return 0, errors.New("还有商品使用此类别,不能删除")
|
||||
} else if countInfos[1].Ct != 0 {
|
||||
return 0, errors.New("还有商品名使用此类别,不能删除")
|
||||
} else if countInfos[2].Ct != 0 {
|
||||
return 0, errors.New("还有商品类别使用此类别,不能删除")
|
||||
}
|
||||
}
|
||||
}
|
||||
vendorOrgCodes, err := dao.GetVendorOrgCode(db, vendorCategoryMap2.VendorID, vendorCategoryMap2.VendorOrgCode, model.VendorOrgTypePlatform)
|
||||
dao.Begin(db)
|
||||
@@ -3016,6 +3039,9 @@ func LoadStoreVendorCategories(ctx *jxcontext.Context, vendorOrgCode string, ven
|
||||
return fmt.Errorf("未查询到该门店有门店分类,请重新选择! [%v]", storeID)
|
||||
}
|
||||
vendorOrgCodes, _ := dao.GetVendorOrgCode(db, vendorID, vendorOrgCode, model.VendorOrgTypePlatform)
|
||||
if vendorCatMap, _ := dao.GetVendorCategoryMap(db, -1, 0, vendorID, vendorOrgCode, 0); len(vendorCatMap) > 0 {
|
||||
return fmt.Errorf("该账号下已有分类,请在这里修改!")
|
||||
}
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
|
||||
Reference in New Issue
Block a user