fix
This commit is contained in:
parent
cdbc82f689
commit
c51a034a9f
|
@ -7,6 +7,7 @@ import (
|
||||||
"fusenapi/model/gmodel"
|
"fusenapi/model/gmodel"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
|
"fusenapi/utils/format"
|
||||||
"fusenapi/utils/s3url_to_s3id"
|
"fusenapi/utils/s3url_to_s3id"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -86,7 +87,33 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
||||||
mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map
|
mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map
|
||||||
mapProductTemplate = make(map[int64]int64) //产品模板map
|
mapProductTemplate = make(map[int64]int64) //产品模板map
|
||||||
mapResourceMetadata = make(map[string]map[string]interface{}) //资源元数据
|
mapResourceMetadata = make(map[string]map[string]interface{}) //资源元数据
|
||||||
|
merchantInfo *gmodel.FsMerchantCategory
|
||||||
)
|
)
|
||||||
|
//选了商家类型
|
||||||
|
if req.MerchantType > 0 {
|
||||||
|
merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindOne(l.ctx, req.MerchantType)
|
||||||
|
} else {
|
||||||
|
//获取默认的那个
|
||||||
|
merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindDefualtOne(l.ctx)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeOK, "the merchant category is not exists", []interface{}{})
|
||||||
|
}
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get merchant category")
|
||||||
|
}
|
||||||
|
mapRecommendProduct := make(map[int64]struct{})
|
||||||
|
if *merchantInfo.RecommendProduct != "" {
|
||||||
|
ids, err := format.StrSlicToInt64Slice(strings.Split(*merchantInfo.RecommendProduct, ","))
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to parse merchant recommend product")
|
||||||
|
}
|
||||||
|
for _, v := range ids {
|
||||||
|
mapRecommendProduct[v] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
//携带产品
|
//携带产品
|
||||||
if req.WithProduct {
|
if req.WithProduct {
|
||||||
productList, err = l.getProductRelationInfo(getProductRelationInfoReq{
|
productList, err = l.getProductRelationInfo(getProductRelationInfoReq{
|
||||||
|
@ -115,6 +142,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
||||||
WithProduct: req.WithProduct,
|
WithProduct: req.WithProduct,
|
||||||
ProductList: productList,
|
ProductList: productList,
|
||||||
MapTagProduct: mapTagProduct,
|
MapTagProduct: mapTagProduct,
|
||||||
|
MapRecommendProduct: mapRecommendProduct,
|
||||||
MapTagProp: mapTagProp,
|
MapTagProp: mapTagProp,
|
||||||
MapProductMinPrice: mapProductMinPrice,
|
MapProductMinPrice: mapProductMinPrice,
|
||||||
MapProductTemplate: mapProductTemplate,
|
MapProductTemplate: mapProductTemplate,
|
||||||
|
@ -265,6 +293,7 @@ type dealWithTagMenuDataReq struct {
|
||||||
WithProduct bool
|
WithProduct bool
|
||||||
ProductList []gmodel.FsProduct
|
ProductList []gmodel.FsProduct
|
||||||
MapTagProduct map[int64]types.TagProduct
|
MapTagProduct map[int64]types.TagProduct
|
||||||
|
MapRecommendProduct map[int64]struct{}
|
||||||
MapTagProp map[int64][]types.CoverDefaultItem
|
MapTagProp map[int64][]types.CoverDefaultItem
|
||||||
ProductTagPropList []gmodel.FsProductTagProp
|
ProductTagPropList []gmodel.FsProductTagProp
|
||||||
MapProductMinPrice map[int64]int64
|
MapProductMinPrice map[int64]int64
|
||||||
|
@ -300,6 +329,7 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq)
|
||||||
TagId: tagInfo.Id,
|
TagId: tagInfo.Id,
|
||||||
ProductList: req.ProductList,
|
ProductList: req.ProductList,
|
||||||
MapTagProp: req.MapTagProp,
|
MapTagProp: req.MapTagProp,
|
||||||
|
MapRecommendProduct: req.MapRecommendProduct,
|
||||||
MapProductMinPrice: req.MapProductMinPrice,
|
MapProductMinPrice: req.MapProductMinPrice,
|
||||||
MapProductTemplate: req.MapProductTemplate,
|
MapProductTemplate: req.MapProductTemplate,
|
||||||
MapProductSizeCount: req.MapProductSizeCount,
|
MapProductSizeCount: req.MapProductSizeCount,
|
||||||
|
@ -386,6 +416,7 @@ type getTagProductsReq struct {
|
||||||
TagId int64
|
TagId int64
|
||||||
ProductList []gmodel.FsProduct
|
ProductList []gmodel.FsProduct
|
||||||
MapTagProp map[int64][]types.CoverDefaultItem
|
MapTagProp map[int64][]types.CoverDefaultItem
|
||||||
|
MapRecommendProduct map[int64]struct{}
|
||||||
MapProductMinPrice map[int64]int64
|
MapProductMinPrice map[int64]int64
|
||||||
MapProductTemplate map[int64]int64
|
MapProductTemplate map[int64]int64
|
||||||
MapProductSizeCount map[int64]int64
|
MapProductSizeCount map[int64]int64
|
||||||
|
@ -419,6 +450,10 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
||||||
if _, ok = req.MapProductHaveOptionFitting[productInfo.Id]; ok {
|
if _, ok = req.MapProductHaveOptionFitting[productInfo.Id]; ok {
|
||||||
haveOptionalFitting = true
|
haveOptionalFitting = true
|
||||||
}
|
}
|
||||||
|
isRecommend := false
|
||||||
|
if _, ok = req.MapRecommendProduct[productInfo.Id]; ok {
|
||||||
|
isRecommend = true
|
||||||
|
}
|
||||||
item := types.TagProduct{
|
item := types.TagProduct{
|
||||||
Id: productInfo.Id,
|
Id: productInfo.Id,
|
||||||
Sn: *productInfo.Sn,
|
Sn: *productInfo.Sn,
|
||||||
|
@ -427,7 +462,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
||||||
CoverDefault: []types.CoverDefaultItem{},
|
CoverDefault: []types.CoverDefaultItem{},
|
||||||
MinPrice: minPrice,
|
MinPrice: minPrice,
|
||||||
HaveOptionalFitting: haveOptionalFitting,
|
HaveOptionalFitting: haveOptionalFitting,
|
||||||
Recommended: *productInfo.IsRecommend > 0,
|
Recommended: isRecommend,
|
||||||
Cover: *productInfo.Cover,
|
Cover: *productInfo.Cover,
|
||||||
CoverMetadata: req.MapResourceMetadata[*productInfo.Cover],
|
CoverMetadata: req.MapResourceMetadata[*productInfo.Cover],
|
||||||
IsCustomization: *productInfo.IsCustomization,
|
IsCustomization: *productInfo.IsCustomization,
|
||||||
|
|
|
@ -29,9 +29,10 @@ type GetRecommandProductListRsp struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetTagProductListReq struct {
|
type GetTagProductListReq struct {
|
||||||
Cid int64 `form:"cid,optional"` //分类id
|
Cid int64 `form:"cid,optional"` //分类id
|
||||||
TemplateTag string `form:"template_tag,optional"` //模板标签
|
MerchantType int64 `form:"merchant_type,optional"` //商户类型
|
||||||
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
|
TemplateTag string `form:"template_tag,optional"` //模板标签
|
||||||
|
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetTagProductListRsp struct {
|
type GetTagProductListRsp struct {
|
||||||
|
|
|
@ -72,9 +72,10 @@ type GetRecommandProductListRsp {
|
||||||
}
|
}
|
||||||
//获取分类产品列表
|
//获取分类产品列表
|
||||||
type GetTagProductListReq {
|
type GetTagProductListReq {
|
||||||
Cid int64 `form:"cid,optional"` //分类id
|
Cid int64 `form:"cid,optional"` //分类id
|
||||||
TemplateTag string `form:"template_tag,optional"` //模板标签
|
MerchantType int64 `form:"merchant_type,optional"` //商户类型
|
||||||
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
|
TemplateTag string `form:"template_tag,optional"` //模板标签
|
||||||
|
WithProduct bool `form:"with_product,optional"` //是否携带分类下的产品
|
||||||
}
|
}
|
||||||
type GetTagProductListRsp {
|
type GetTagProductListRsp {
|
||||||
TotalCategoryProduct int `json:"total_category_product"`
|
TotalCategoryProduct int `json:"total_category_product"`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user