This commit is contained in:
laodaming 2023-10-19 11:51:49 +08:00
parent bbf5cb03ad
commit 05ec312127
3 changed files with 79 additions and 39 deletions

View File

@ -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,6 +168,14 @@ 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,
@ -156,6 +190,8 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
Recommend: recommend,
MinPrice: minPrice,
IsCustomization: *v.IsCustomization,
SizeCount: sizeCount,
HaveOptionalFitting: haveOptionalFitting,
}
if _, ok := mapTagProp[productInfo.Id]; ok {
item.CoverDefault = mapTagProp[productInfo.Id]

View File

@ -24,6 +24,8 @@ type GetRecommandProductListRsp struct {
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 {

View File

@ -70,6 +70,8 @@ type GetRecommandProductListRsp {
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 {