This commit is contained in:
苏尹岚
2021-03-25 17:55:03 +08:00
parent 51d70c03d1
commit 86712582f2

View File

@@ -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 = ?)"