This commit is contained in:
laodaming
2023-07-20 18:04:50 +08:00
parent 2f5ce8dd77
commit 0e752e31fd
2 changed files with 15 additions and 17 deletions

View File

@@ -47,24 +47,18 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get detail product info")
}
//随机取产品列表(不包含详情产品)
recommendList, err := l.svcCtx.AllModels.FsProductRecommend.GetIgnoreRandomRecommendProductList(l.ctx, int(req.Num), int64(constants.PRODUCT_DETAIL_RECOMMEND_CATEGORY), []int64{productInfo.Id})
recommendProductList, err := l.svcCtx.AllModels.FsProductRecommend.GetIgnoreRandomRecommendProductList(l.ctx, int(req.Num), int64(constants.PRODUCT_DETAIL_RECOMMEND_CATEGORY), []int64{productInfo.Id})
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get random recommend list")
}
//需要填充时需要忽略的id
ignoreProductIds := make([]int64, 0, len(recommendList)+1)
ignoreProductIds := make([]int64, 0, len(recommendProductList)+1)
ignoreProductIds = append(ignoreProductIds, productInfo.Id)
productIds := make([]int64, 0, len(recommendList))
for _, v := range recommendList {
ignoreProductIds = append(ignoreProductIds, *v.ProductId)
productIds = append(productIds, *v.ProductId)
}
//获取推荐产品列表
recommendProductList, err := l.svcCtx.AllModels.FsProduct.GetProductListByIds(l.ctx, productIds, "")
if err != nil {
logx.Error(err)
return resp.SetStatus(basic.CodeDbSqlErr, "failed to get recommend product list")
productIds := make([]int64, 0, len(recommendProductList))
for _, v := range recommendProductList {
ignoreProductIds = append(ignoreProductIds, v.Id)
productIds = append(productIds, v.Id)
}
//在合并之前记住推荐的产品
mapRecommend := make(map[int64]struct{})