This commit is contained in:
laodaming 2023-07-19 19:41:35 +08:00
parent 3bd08c8c2b
commit 47e22e6891

View File

@ -257,83 +257,6 @@ func (l *GetTagProductListLogic) organizationLevelRelation(mapTagLevel map[strin
})
return rspList
}
// 获取tag推荐产品列表
type getTagRecommendProductsReq struct {
TagInfo gmodel.FsTags
ProductList []gmodel.FsProduct
MapProduct map[int64]int
MapProductMinPrice map[int64]int64
MapProductTemplate map[int64]struct{}
MapProductSizeCount map[int64]int64
RecommendProductIds []int64
RecommendProductIdsSort []int64
Size uint32
User gmodel.FsUser
}
func (l *GetTagProductListLogic) getTagRecommendProducts(req getTagRecommendProductsReq) (productListRsp []types.TagProduct) {
//排序
sortList := make([]sortRecommendProduct, 0, len(req.RecommendProductIds))
for sortIndex, pid := range req.RecommendProductIds {
sortList = append(sortList, sortRecommendProduct{
ProductId: pid,
Sort: req.RecommendProductIdsSort[sortIndex],
})
}
sort.SliceStable(sortList, func(i, j int) bool {
return sortList[i].Sort < sortList[j].Sort
})
productListRsp = make([]types.TagProduct, 0, len(sortList))
for _, sortVal := range sortList {
productIndex, ok := req.MapProduct[sortVal.ProductId]
if !ok {
continue
}
productInfo := req.ProductList[productIndex]
minPrice, ok := req.MapProductMinPrice[productInfo.Id]
_, tmpOk := req.MapProductTemplate[productInfo.Id]
//无最小价格则不显示 || 没有模板也不显示
if !ok || !tmpOk {
continue
}
sizeNum := int64(0)
if mapSizeNum, ok := req.MapProductSizeCount[productInfo.Id]; ok {
sizeNum = mapSizeNum
}
item := types.TagProduct{
ProductId: productInfo.Id,
Sn: *productInfo.Sn,
Title: *productInfo.Title,
Intro: *productInfo.Intro,
IsEnv: *productInfo.IsProtection,
IsMicro: *productInfo.IsMicrowave,
SizeNum: uint32(sizeNum),
MiniPrice: minPrice,
}
//千人千面处理
r := image.ThousandFaceImageFormatReq{
Size: int(req.Size),
IsThousandFace: 0,
Cover: *productInfo.Cover,
CoverImg: *productInfo.CoverImg,
CoverDefault: *productInfo.CoverImg,
ProductId: productInfo.Id,
UserId: req.User.Id,
}
if req.User.Id != 0 {
r.IsThousandFace = int(*req.User.IsThousandFace)
}
image.ThousandFaceImageFormat(&r)
item.Cover = r.Cover
item.CoverImg = r.CoverImg
item.CoverDefault = r.CoverDefault
//加入切片
productListRsp = append(productListRsp, item)
}
return productListRsp
}
// 获取对应tag的产品列表
type getTagProductsReq struct {
TagId int64