fix
This commit is contained in:
parent
5bc6f411be
commit
35b02302eb
|
@ -113,14 +113,27 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//获取用户信息(不用判断存在)
|
//获取用户信息(不用判断存在)
|
||||||
user, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId)
|
/*user, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId)
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get user")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get user")
|
||||||
|
}*/
|
||||||
|
//获取产品标签相关属性
|
||||||
|
productTagPropList, err := l.svcCtx.AllModels.FsProductTagProp.GetTagPropByProductIdsWithProductTag(l.ctx, productIds)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product tag property")
|
||||||
|
}
|
||||||
|
mapTagProp := make(map[int64][]types.CoverDefaultItem)
|
||||||
|
for _, v := range productTagPropList {
|
||||||
|
mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{
|
||||||
|
Tag: v.Title,
|
||||||
|
Cover: *v.Cover,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
list := make([]types.GetRecommandProductListRsp, 0, len(recommendProductList))
|
list := make([]types.GetRecommandProductListRsp, 0, len(recommendProductList))
|
||||||
for _, v := range recommendProductList {
|
for _, v := range recommendProductList {
|
||||||
r := image.ThousandFaceImageFormatReq{
|
/*r := image.ThousandFaceImageFormatReq{
|
||||||
Size: int(req.Size),
|
Size: int(req.Size),
|
||||||
IsThousandFace: 0,
|
IsThousandFace: 0,
|
||||||
Cover: *v.Cover,
|
Cover: *v.Cover,
|
||||||
|
@ -133,7 +146,7 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
||||||
r.IsThousandFace = int(*user.IsThousandFace)
|
r.IsThousandFace = int(*user.IsThousandFace)
|
||||||
}
|
}
|
||||||
//千人前面处理
|
//千人前面处理
|
||||||
image.ThousandFaceImageFormat(&r)
|
image.ThousandFaceImageFormat(&r)*/
|
||||||
isRecommend := int64(0)
|
isRecommend := int64(0)
|
||||||
if _, ok := mapRecommend[v.Id]; ok {
|
if _, ok := mapRecommend[v.Id]; ok {
|
||||||
isRecommend = 1
|
isRecommend = 1
|
||||||
|
@ -142,18 +155,21 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
||||||
if minVal, ok := mapProductMinPrice[v.Id]; ok {
|
if minVal, ok := mapProductMinPrice[v.Id]; ok {
|
||||||
minPrice = minVal
|
minPrice = minVal
|
||||||
}
|
}
|
||||||
list = append(list, types.GetRecommandProductListRsp{
|
item := types.GetRecommandProductListRsp{
|
||||||
Id: v.Id,
|
Id: v.Id,
|
||||||
Sn: *v.Sn,
|
Sn: *v.Sn,
|
||||||
Title: *v.Title,
|
Title: *v.Title,
|
||||||
TitleCn: *v.TitleCn,
|
TitleCn: *v.TitleCn,
|
||||||
Cover: r.Cover,
|
Cover: *productInfo.Cover,
|
||||||
CoverImg: r.CoverImg,
|
CoverImg: *productInfo.CoverImg,
|
||||||
CoverDefault: r.CoverDefault,
|
Intro: *v.Intro,
|
||||||
Intro: *v.Intro,
|
IsRecommend: isRecommend,
|
||||||
IsRecommend: isRecommend,
|
MinPrice: minPrice,
|
||||||
MinPrice: minPrice,
|
}
|
||||||
})
|
if _, ok := mapTagProp[productInfo.Id]; ok {
|
||||||
|
item.CoverDefault = mapTagProp[productInfo.Id]
|
||||||
|
}
|
||||||
|
list = append(list, item)
|
||||||
}
|
}
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", list)
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,19 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
||||||
for _, v := range productSizeCountList {
|
for _, v := range productSizeCountList {
|
||||||
mapProductSizeCount[v.ProductId] = v.Num
|
mapProductSizeCount[v.ProductId] = v.Num
|
||||||
}
|
}
|
||||||
|
//获取产品标签相关属性
|
||||||
|
productTagPropList, err := l.svcCtx.AllModels.FsProductTagProp.GetTagPropByProductIdsWithProductTag(l.ctx, productIds)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product tag property")
|
||||||
|
}
|
||||||
|
mapTagProp := make(map[int64][]types.CoverDefaultItem)
|
||||||
|
for _, v := range productTagPropList {
|
||||||
|
mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{
|
||||||
|
Tag: v.Title,
|
||||||
|
Cover: *v.Cover,
|
||||||
|
})
|
||||||
|
}
|
||||||
//组装返回
|
//组装返回
|
||||||
listRsp := make([]types.HomePageRecommendProductListRsp, 0, len(recommendProductList))
|
listRsp := make([]types.HomePageRecommendProductListRsp, 0, len(recommendProductList))
|
||||||
for _, productInfo := range recommendProductList {
|
for _, productInfo := range recommendProductList {
|
||||||
|
@ -170,11 +183,13 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
||||||
Sn: *productInfo.Sn,
|
Sn: *productInfo.Sn,
|
||||||
Title: *productInfo.Title,
|
Title: *productInfo.Title,
|
||||||
Cover: *productInfo.Cover,
|
Cover: *productInfo.Cover,
|
||||||
CoverDefault: *productInfo.Cover,
|
|
||||||
SizeNum: uint32(sizeNum),
|
SizeNum: uint32(sizeNum),
|
||||||
MinPrice: minPrice,
|
MinPrice: minPrice,
|
||||||
HaveOptionalFitting: haveOptionalFitting,
|
HaveOptionalFitting: haveOptionalFitting,
|
||||||
}
|
}
|
||||||
|
if _, ok = mapTagProp[productInfo.Id]; ok {
|
||||||
|
item.CoverDefault = mapTagProp[productInfo.Id]
|
||||||
|
}
|
||||||
//千人千面处理
|
//千人千面处理
|
||||||
/*r := image.ThousandFaceImageFormatReq{
|
/*r := image.ThousandFaceImageFormatReq{
|
||||||
Size: int(req.Size),
|
Size: int(req.Size),
|
||||||
|
|
|
@ -234,16 +234,16 @@ type GetRecommandProductListReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetRecommandProductListRsp struct {
|
type GetRecommandProductListRsp struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Sn string `json:"sn"`
|
Sn string `json:"sn"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
TitleCn string `json:"title_cn"`
|
TitleCn string `json:"title_cn"`
|
||||||
Cover string `json:"cover"`
|
Cover string `json:"cover"`
|
||||||
CoverImg string `json:"cover_img"`
|
CoverImg string `json:"cover_img"`
|
||||||
CoverDefault string `json:"cover_default"`
|
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||||
Intro string `json:"intro"`
|
Intro string `json:"intro"`
|
||||||
IsRecommend int64 `json:"is_recommend"`
|
IsRecommend int64 `json:"is_recommend"`
|
||||||
MinPrice int64 `json:"min_price"`
|
MinPrice int64 `json:"min_price"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetTagProductListReq struct {
|
type GetTagProductListReq struct {
|
||||||
|
@ -395,14 +395,14 @@ type HomePageRecommendProductListReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type HomePageRecommendProductListRsp struct {
|
type HomePageRecommendProductListRsp struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Sn string `json:"sn"`
|
Sn string `json:"sn"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Cover string `json:"cover"`
|
Cover string `json:"cover"`
|
||||||
SizeNum uint32 `json:"size_num"`
|
SizeNum uint32 `json:"size_num"`
|
||||||
MinPrice int64 `json:"min_price"`
|
MinPrice int64 `json:"min_price"`
|
||||||
CoverDefault string `json:"cover_default"`
|
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Request struct {
|
type Request struct {
|
||||||
|
|
|
@ -286,16 +286,16 @@ type GetRecommandProductListReq {
|
||||||
Sn string `form:"sn"`
|
Sn string `form:"sn"`
|
||||||
}
|
}
|
||||||
type GetRecommandProductListRsp {
|
type GetRecommandProductListRsp {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Sn string `json:"sn"`
|
Sn string `json:"sn"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
TitleCn string `json:"title_cn"`
|
TitleCn string `json:"title_cn"`
|
||||||
Cover string `json:"cover"`
|
Cover string `json:"cover"`
|
||||||
CoverImg string `json:"cover_img"`
|
CoverImg string `json:"cover_img"`
|
||||||
CoverDefault string `json:"cover_default"`
|
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||||
Intro string `json:"intro"`
|
Intro string `json:"intro"`
|
||||||
IsRecommend int64 `json:"is_recommend"`
|
IsRecommend int64 `json:"is_recommend"`
|
||||||
MinPrice int64 `json:"min_price"`
|
MinPrice int64 `json:"min_price"`
|
||||||
}
|
}
|
||||||
//获取分类产品列表
|
//获取分类产品列表
|
||||||
type GetTagProductListReq {
|
type GetTagProductListReq {
|
||||||
|
@ -437,12 +437,12 @@ type HomePageRecommendProductListReq {
|
||||||
MerchantType int64 `form:"merchant_type"`
|
MerchantType int64 `form:"merchant_type"`
|
||||||
}
|
}
|
||||||
type HomePageRecommendProductListRsp {
|
type HomePageRecommendProductListRsp {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Sn string `json:"sn"`
|
Sn string `json:"sn"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Cover string `json:"cover"`
|
Cover string `json:"cover"`
|
||||||
SizeNum uint32 `json:"size_num"`
|
SizeNum uint32 `json:"size_num"`
|
||||||
MinPrice int64 `json:"min_price"`
|
MinPrice int64 `json:"min_price"`
|
||||||
CoverDefault string `json:"cover_default"`
|
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user