fix
This commit is contained in:
@@ -42,6 +42,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get user info err")
|
||||
}
|
||||
var (
|
||||
merchantInfo *gmodel.FsMerchantCategory
|
||||
recommendProductList []gmodel.FsProduct //产品列表(select 字段需要看查询的地方)
|
||||
productOptionalPartList []gmodel.GetGroupPartListByProductIdsRsp //产品配件列表
|
||||
mapProductHaveOptionFitting = make(map[int64]struct{})
|
||||
@@ -52,13 +53,34 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
||||
mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map
|
||||
mapProductTemplate = make(map[int64]struct{}) //产品模板map
|
||||
)
|
||||
//选了商家类型
|
||||
if req.MerchantType > 0 {
|
||||
merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindOne(l.ctx, req.MerchantType)
|
||||
} else {
|
||||
//随机获取一个商家类型
|
||||
merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindRandOne(l.ctx)
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "none of merchant type found")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get merchant type info")
|
||||
}
|
||||
if *merchantInfo.RecommendProduct == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{})
|
||||
}
|
||||
recommendProductIds, err := format.StrSlicToInt64Slice(strings.Split(*merchantInfo.RecommendProduct, ","))
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to parse recommend product")
|
||||
}
|
||||
//获取列表推荐产品
|
||||
recommendProductList, _, err = l.svcCtx.AllModels.FsProductRecommend.GetRecommendProductList(gmodel.GetRecommendProductListReq{
|
||||
Ctx: l.ctx,
|
||||
MerchantType: req.MerchantType,
|
||||
Page: 1,
|
||||
Limit: 500, //设置最大500
|
||||
})
|
||||
recommendProductList, err = l.svcCtx.AllModels.FsProduct.GetProductListByIds(l.ctx, recommendProductIds, "sort-desc")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product list")
|
||||
}
|
||||
if len(recommendProductList) == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{})
|
||||
}
|
||||
|
||||
@@ -341,6 +341,7 @@ type GetSizeByPidRsp struct {
|
||||
|
||||
type GetTemplateByPidReq struct {
|
||||
Pid string `form:"pid"`
|
||||
ProductSizeId int64 `form:"product_size_id,optional"`
|
||||
ProductTemplateTagId int64 `form:"product_template_tag_id"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user