From 86712582f263ea7433351c51119baf72c03e8b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 25 Mar 2021 17:55:03 +0800 Subject: [PATCH] aa --- business/jxstore/cms/store_sku.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 02923b294..c5676504b 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -302,10 +302,8 @@ func GetStoresSkusForStore(ctx *jxcontext.Context, storeID int, isFocus, isAct b sqlParams = append(sqlParams, status) } sql += ` - LEFT JOIN sku_category d ON d.id = a.category_id AND d.deleted_at = ? LEFT JOIN sku_name_place_bind f ON a.id = f.name_id AND e.city_code = f.place_code ` - sqlParams = append(sqlParams, utils.DefaultTimeValue) if isAct { sql += ` JOIN ( @@ -342,8 +340,17 @@ func GetStoresSkusForStore(ctx *jxcontext.Context, storeID int, isFocus, isAct b ` sqlParams = append(sqlParams, utils.DefaultTimeValue, utils.Bool2Int(isFocus), storeID) if categoryID != 0 { - sql += " AND d.id = ?" - sqlParams = append(sqlParams, categoryID) + cat := &model.SkuCategory{} + cat.ID = categoryID + if err = dao.GetEntity(db, cat); err == nil { + sql += " AND (a.category_id = ?" + sqlParams = append(sqlParams, cat.ID) + if cat.Level == 1 { + sql += " OR a.category_id IN (SELECT id FROM sku_category WHERE parent_id = ?)" + sqlParams = append(sqlParams, cat.ID) + } + sql += ")" + } } if isFocus { sql += " AND ((a.status = ? AND b.status = ?) OR c.status = ?)"