fix
This commit is contained in:
parent
bbf5cb03ad
commit
05ec312127
|
@ -90,6 +90,32 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||
recommendProductList = append(recommendProductList, v)
|
||||
}
|
||||
}
|
||||
//获取商品可选配件
|
||||
productOptionalPartList, err := l.svcCtx.AllModels.FsProductModel3d.GetGroupPartListByProductIds(l.ctx, productIds)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product part list")
|
||||
}
|
||||
//存储有配件的map
|
||||
mapProductHaveOptionFitting := make(map[int64]struct{})
|
||||
for _, partList := range productOptionalPartList {
|
||||
partList.PartList = strings.Trim(partList.PartList, " ")
|
||||
partList.PartList = strings.Trim(partList.PartList, ",")
|
||||
if partList.PartList == "" {
|
||||
continue
|
||||
}
|
||||
mapProductHaveOptionFitting[partList.ProductId] = struct{}{}
|
||||
}
|
||||
//获取产品尺寸数量
|
||||
productSizeCountList, err := l.svcCtx.AllModels.FsProductSize.GetGroupProductSizeByStatus(l.ctx, productIds, 1)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get ")
|
||||
}
|
||||
mapProductSizeCount := make(map[int64]int64)
|
||||
for _, v := range productSizeCountList {
|
||||
mapProductSizeCount[v.ProductId] = v.Num
|
||||
}
|
||||
//获取产品最低价
|
||||
mapProductMinPrice := make(map[int64]int64)
|
||||
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllByProductIdsTags(l.ctx, []int64{productInfo.Id}, []int{constants.TAG_MODEL, constants.TAG_PARTS}, "id,size_id,product_id,price,tag,part_id,step_price")
|
||||
|
@ -142,20 +168,30 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||
if minVal, ok := mapProductMinPrice[v.Id]; ok {
|
||||
minPrice = minVal
|
||||
}
|
||||
sizeCount := int64(0)
|
||||
if sc, ok := mapProductSizeCount[v.Id]; ok {
|
||||
sizeCount = sc
|
||||
}
|
||||
haveOptionalFitting := int64(0)
|
||||
if _, ok := mapProductHaveOptionFitting[v.Id]; ok {
|
||||
haveOptionalFitting = 1
|
||||
}
|
||||
item := types.GetRecommandProductListRsp{
|
||||
Id: v.Id,
|
||||
Sn: *v.Sn,
|
||||
Title: *v.Title,
|
||||
TitleCn: *v.TitleCn,
|
||||
Cover: *v.Cover,
|
||||
CoverMetadata: mapResourceMetadata[*v.Cover],
|
||||
CoverImg: *v.CoverImg,
|
||||
CoverImgMetadata: mapResourceMetadata[*v.CoverImg],
|
||||
CoverDefault: []types.CoverDefaultItem{},
|
||||
Intro: *v.Intro,
|
||||
Recommend: recommend,
|
||||
MinPrice: minPrice,
|
||||
IsCustomization: *v.IsCustomization,
|
||||
Id: v.Id,
|
||||
Sn: *v.Sn,
|
||||
Title: *v.Title,
|
||||
TitleCn: *v.TitleCn,
|
||||
Cover: *v.Cover,
|
||||
CoverMetadata: mapResourceMetadata[*v.Cover],
|
||||
CoverImg: *v.CoverImg,
|
||||
CoverImgMetadata: mapResourceMetadata[*v.CoverImg],
|
||||
CoverDefault: []types.CoverDefaultItem{},
|
||||
Intro: *v.Intro,
|
||||
Recommend: recommend,
|
||||
MinPrice: minPrice,
|
||||
IsCustomization: *v.IsCustomization,
|
||||
SizeCount: sizeCount,
|
||||
HaveOptionalFitting: haveOptionalFitting,
|
||||
}
|
||||
if _, ok := mapTagProp[productInfo.Id]; ok {
|
||||
item.CoverDefault = mapTagProp[productInfo.Id]
|
||||
|
|
|
@ -11,19 +11,21 @@ type GetRecommandProductListReq struct {
|
|||
}
|
||||
|
||||
type GetRecommandProductListRsp struct {
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
TitleCn string `json:"title_cn"`
|
||||
Cover string `json:"cover"`
|
||||
CoverMetadata interface{} `json:"cover_metadata"`
|
||||
CoverImg string `json:"cover_img"`
|
||||
CoverImgMetadata interface{} `json:"cover_img_metadata"`
|
||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
Intro string `json:"intro"`
|
||||
Recommend bool `json:"recommend"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
TitleCn string `json:"title_cn"`
|
||||
Cover string `json:"cover"`
|
||||
CoverMetadata interface{} `json:"cover_metadata"`
|
||||
CoverImg string `json:"cover_img"`
|
||||
CoverImgMetadata interface{} `json:"cover_img_metadata"`
|
||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
Intro string `json:"intro"`
|
||||
Recommend bool `json:"recommend"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
SizeCount int64 `json:"size_count"`
|
||||
HaveOptionalFitting int64 `json:"have_optional_fitting"`
|
||||
}
|
||||
|
||||
type GetTagProductListReq struct {
|
||||
|
|
|
@ -57,19 +57,21 @@ type GetRecommandProductListReq {
|
|||
ProductId int64 `form:"product_id"`
|
||||
}
|
||||
type GetRecommandProductListRsp {
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
TitleCn string `json:"title_cn"`
|
||||
Cover string `json:"cover"`
|
||||
CoverMetadata interface{} `json:"cover_metadata"`
|
||||
CoverImg string `json:"cover_img"`
|
||||
CoverImgMetadata interface{} `json:"cover_img_metadata"`
|
||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
Intro string `json:"intro"`
|
||||
Recommend bool `json:"recommend"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
TitleCn string `json:"title_cn"`
|
||||
Cover string `json:"cover"`
|
||||
CoverMetadata interface{} `json:"cover_metadata"`
|
||||
CoverImg string `json:"cover_img"`
|
||||
CoverImgMetadata interface{} `json:"cover_img_metadata"`
|
||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
Intro string `json:"intro"`
|
||||
Recommend bool `json:"recommend"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
SizeCount int64 `json:"size_count"`
|
||||
HaveOptionalFitting int64 `json:"have_optional_fitting"`
|
||||
}
|
||||
//获取分类产品列表
|
||||
type GetTagProductListReq {
|
||||
|
|
Loading…
Reference in New Issue
Block a user