fix
This commit is contained in:
parent
8f8419b8c1
commit
77cb259124
|
@ -113,10 +113,12 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
||||||
mapTagLevel := make(map[string]*types.TagItem)
|
mapTagLevel := make(map[string]*types.TagItem)
|
||||||
//处理tags数据
|
//处理tags数据
|
||||||
minLevel := 0 //层级最高层(即prefix层级路径最短)
|
minLevel := 0 //层级最高层(即prefix层级路径最短)
|
||||||
|
mapTagProduct := make(map[int64]types.TagProduct)
|
||||||
if err = l.dealWithTagMenuData(dealWithTagMenuDataReq{
|
if err = l.dealWithTagMenuData(dealWithTagMenuDataReq{
|
||||||
TagList: tagList,
|
TagList: tagList,
|
||||||
WithProduct: req.WithProduct,
|
WithProduct: req.WithProduct,
|
||||||
ProductList: productList,
|
ProductList: productList,
|
||||||
|
MapTagProduct: mapTagProduct,
|
||||||
MapTagProp: mapTagProp,
|
MapTagProp: mapTagProp,
|
||||||
MapProductMinPrice: mapProductMinPrice,
|
MapProductMinPrice: mapProductMinPrice,
|
||||||
MapProductTemplate: mapProductTemplate,
|
MapProductTemplate: mapProductTemplate,
|
||||||
|
@ -132,7 +134,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
||||||
return resp.SetStatusAddMessage(basic.CodeServiceErr, "failed to deal with tag data")
|
return resp.SetStatusAddMessage(basic.CodeServiceErr, "failed to deal with tag data")
|
||||||
}
|
}
|
||||||
//组装等级从属关系
|
//组装等级从属关系
|
||||||
rspTagList, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel)
|
rspTagList, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel, productList, mapTagProduct)
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{
|
||||||
TotalCategoryProduct: TotalCategoryProduct,
|
TotalCategoryProduct: TotalCategoryProduct,
|
||||||
TagList: rspTagList,
|
TagList: rspTagList,
|
||||||
|
@ -262,6 +264,7 @@ type dealWithTagMenuDataReq struct {
|
||||||
TagList []gmodel.FsTags
|
TagList []gmodel.FsTags
|
||||||
WithProduct bool
|
WithProduct bool
|
||||||
ProductList []gmodel.FsProduct
|
ProductList []gmodel.FsProduct
|
||||||
|
MapTagProduct map[int64]types.TagProduct
|
||||||
MapTagProp map[int64][]types.CoverDefaultItem
|
MapTagProp map[int64][]types.CoverDefaultItem
|
||||||
ProductTagPropList []gmodel.FsProductTagProp
|
ProductTagPropList []gmodel.FsProductTagProp
|
||||||
MapProductMinPrice map[int64]int64
|
MapProductMinPrice map[int64]int64
|
||||||
|
@ -308,7 +311,7 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq)
|
||||||
})
|
})
|
||||||
//tag中产品
|
//tag中产品
|
||||||
for _, tmpProduct := range productListRsp {
|
for _, tmpProduct := range productListRsp {
|
||||||
tagTem.TagProductList = append(tagTem.TagProductList, tmpProduct)
|
tagTem.TagProductList = append(tagTem.TagProductList, tmpProduct.ProductId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//加入分类
|
//加入分类
|
||||||
|
@ -318,7 +321,7 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 组织等级从属关系
|
// 组织等级从属关系
|
||||||
func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem) (rspTagList []types.TagItem, productCount int) {
|
func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem, productList []gmodel.FsProduct, mapTagProduct map[int64]types.TagProduct) (rspTagList []types.TagItem, productCount int) {
|
||||||
mapTop := make(map[string]struct{})
|
mapTop := make(map[string]struct{})
|
||||||
//设置归属关系
|
//设置归属关系
|
||||||
for prefix, tagItem := range mapTagLevel {
|
for prefix, tagItem := range mapTagLevel {
|
||||||
|
@ -346,11 +349,24 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL
|
||||||
if _, ok := mapTop[v.LevelPrefix]; ok {
|
if _, ok := mapTop[v.LevelPrefix]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
topPrefixSlic := strings.Split(v.LevelPrefix, "/")[:minLevel]
|
//初始化
|
||||||
topPrefix := strings.Join(topPrefixSlic, "/")
|
v.TagProductList = make([]interface{}, 0, 20)
|
||||||
for k, tmpProduct := range v.TagProductList {
|
mapTypeId := make(map[int64]struct{})
|
||||||
v.TagProductList[k] = tmpProduct.(types.TagProduct).ProductId
|
for _, v2 := range mapTagLevel {
|
||||||
mapTagLevel[topPrefix].TagProductList = append(mapTagLevel[topPrefix].TagProductList, tmpProduct)
|
if strings.Contains(v2.LevelPrefix, v.LevelPrefix) {
|
||||||
|
mapTypeId[v.TypeId] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, p := range productList {
|
||||||
|
_, ok := mapTypeId[*p.Type]
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tagProduct, ok := mapTagProduct[p.Id]
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
v.TagProductList = append(v.TagProductList, tagProduct)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//最终值提取最高级别那一层出来
|
//最终值提取最高级别那一层出来
|
||||||
|
|
Loading…
Reference in New Issue
Block a user