11
This commit is contained in:
parent
33a3c22b69
commit
b9532ebe86
|
@ -91,7 +91,6 @@ 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{}) //资源元数据
|
||||||
mapProductDefaultSize = make(map[int64]int64)
|
|
||||||
)
|
)
|
||||||
//携带产品
|
//携带产品
|
||||||
if req.WithProduct {
|
if req.WithProduct {
|
||||||
|
@ -104,7 +103,6 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
||||||
MapProductMinPrice: mapProductMinPrice,
|
MapProductMinPrice: mapProductMinPrice,
|
||||||
MapProductSizeCount: mapProductSizeCount,
|
MapProductSizeCount: mapProductSizeCount,
|
||||||
MapProductTemplate: mapProductTemplate,
|
MapProductTemplate: mapProductTemplate,
|
||||||
MapProductDefaultSize: mapProductDefaultSize,
|
|
||||||
MapResourceMetadata: mapResourceMetadata,
|
MapResourceMetadata: mapResourceMetadata,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -127,7 +125,6 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
||||||
MapTagLevel: mapTagLevel,
|
MapTagLevel: mapTagLevel,
|
||||||
MapProductHaveOptionFitting: mapProductHaveOptionFitting,
|
MapProductHaveOptionFitting: mapProductHaveOptionFitting,
|
||||||
MapResourceMetadata: mapResourceMetadata,
|
MapResourceMetadata: mapResourceMetadata,
|
||||||
MapProductDefaultSize: mapProductDefaultSize,
|
|
||||||
Size: req.Size,
|
Size: req.Size,
|
||||||
User: user,
|
User: user,
|
||||||
MinLevel: &minLevel,
|
MinLevel: &minLevel,
|
||||||
|
@ -154,7 +151,6 @@ type getProductRelationInfoReq struct {
|
||||||
MapProductSizeCount map[int64]int64
|
MapProductSizeCount map[int64]int64
|
||||||
MapProductTemplate map[int64]int64
|
MapProductTemplate map[int64]int64
|
||||||
MapResourceMetadata map[string]map[string]interface{}
|
MapResourceMetadata map[string]map[string]interface{}
|
||||||
MapProductDefaultSize map[int64]int64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *GetTagProductListLogic) getProductRelationInfo(req getProductRelationInfoReq) (productList []gmodel.FsProduct, err error) {
|
func (l *GetTagProductListLogic) getProductRelationInfo(req getProductRelationInfoReq) (productList []gmodel.FsProduct, err error) {
|
||||||
|
@ -276,35 +272,15 @@ func (l *GetTagProductListLogic) getProductRelationInfo(req getProductRelationIn
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return nil, errors.New("failed to get product templates")
|
return nil, errors.New("failed to get product templates")
|
||||||
}
|
}
|
||||||
mapDefaultModelId := make(map[int64]struct{})
|
|
||||||
for _, v := range productTemplatesV2List {
|
for _, v := range productTemplatesV2List {
|
||||||
//标签符合不为空且遍历等于传入的模板标签
|
|
||||||
if *v.TemplateTag == req.TemplateTag && req.TemplateTag != "" {
|
|
||||||
req.MapProductTemplate[*v.ProductId] = v.Id
|
|
||||||
mapDefaultModelId[*v.ModelId] = struct{}{}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
//如果已经有了则不用管
|
//如果已经有了则不用管
|
||||||
if _, ok := req.MapProductTemplate[*v.ProductId]; ok {
|
if _, ok := req.MapProductTemplate[*v.ProductId]; ok {
|
||||||
continue
|
continue
|
||||||
} else { //否则设置一个值
|
} else { //否则设置一个值
|
||||||
req.MapProductTemplate[*v.ProductId] = v.Id
|
req.MapProductTemplate[*v.ProductId] = v.Id
|
||||||
mapDefaultModelId[*v.ModelId] = struct{}{}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modelIds := make([]int64, 0, len(mapDefaultModelId))
|
|
||||||
for modelId, _ := range mapDefaultModelId {
|
|
||||||
modelIds = append(modelIds, modelId)
|
|
||||||
}
|
|
||||||
//根据modelIds查询尺寸
|
|
||||||
defaultSizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByModelIdsJoinModeld(l.ctx, modelIds)
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return nil, errors.New("get product default model3d list err")
|
|
||||||
}
|
|
||||||
for _, v := range defaultSizeList {
|
|
||||||
req.MapProductDefaultSize[*v.ProductId] = v.Id
|
|
||||||
}
|
|
||||||
//获取产品尺寸数量
|
//获取产品尺寸数量
|
||||||
productSizeCountList, err = l.svcCtx.AllModels.FsProductSize.GetGroupProductSizeByStatus(l.ctx, productIds, 1)
|
productSizeCountList, err = l.svcCtx.AllModels.FsProductSize.GetGroupProductSizeByStatus(l.ctx, productIds, 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -330,7 +306,6 @@ type dealWithTagMenuDataReq struct {
|
||||||
MapTagLevel map[string]*types.TagItem
|
MapTagLevel map[string]*types.TagItem
|
||||||
MapProductHaveOptionFitting map[int64]struct{}
|
MapProductHaveOptionFitting map[int64]struct{}
|
||||||
MapResourceMetadata map[string]map[string]interface{}
|
MapResourceMetadata map[string]map[string]interface{}
|
||||||
MapProductDefaultSize map[int64]int64
|
|
||||||
Size uint32
|
Size uint32
|
||||||
User gmodel.FsUser
|
User gmodel.FsUser
|
||||||
MinLevel *int //层级最小的
|
MinLevel *int //层级最小的
|
||||||
|
@ -364,7 +339,6 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq)
|
||||||
MapProductSizeCount: req.MapProductSizeCount,
|
MapProductSizeCount: req.MapProductSizeCount,
|
||||||
MapProductHaveOptionFitting: req.MapProductHaveOptionFitting,
|
MapProductHaveOptionFitting: req.MapProductHaveOptionFitting,
|
||||||
MapResourceMetadata: req.MapResourceMetadata,
|
MapResourceMetadata: req.MapResourceMetadata,
|
||||||
MapProductDefaultSize: req.MapProductDefaultSize,
|
|
||||||
Size: req.Size,
|
Size: req.Size,
|
||||||
User: req.User,
|
User: req.User,
|
||||||
})
|
})
|
||||||
|
@ -442,7 +416,6 @@ type getTagProductsReq struct {
|
||||||
MapProductSizeCount map[int64]int64
|
MapProductSizeCount map[int64]int64
|
||||||
MapProductHaveOptionFitting map[int64]struct{}
|
MapProductHaveOptionFitting map[int64]struct{}
|
||||||
MapResourceMetadata map[string]map[string]interface{}
|
MapResourceMetadata map[string]map[string]interface{}
|
||||||
MapProductDefaultSize map[int64]int64
|
|
||||||
Size uint32
|
Size uint32
|
||||||
User gmodel.FsUser
|
User gmodel.FsUser
|
||||||
}
|
}
|
||||||
|
@ -457,7 +430,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
minPrice, ok := req.MapProductMinPrice[productInfo.Id]
|
minPrice, ok := req.MapProductMinPrice[productInfo.Id]
|
||||||
templateId, tmpOk := req.MapProductTemplate[productInfo.Id]
|
_, tmpOk := req.MapProductTemplate[productInfo.Id]
|
||||||
//无最小价格则不显示 || 没有模板也不显示
|
//无最小价格则不显示 || 没有模板也不显示
|
||||||
if !ok || !tmpOk {
|
if !ok || !tmpOk {
|
||||||
continue
|
continue
|
||||||
|
@ -471,19 +444,12 @@ 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
|
||||||
}
|
}
|
||||||
//默认尺寸id
|
|
||||||
defaultSizeId := int64(0)
|
|
||||||
if sizeId, ok := req.MapProductDefaultSize[productInfo.Id]; ok {
|
|
||||||
defaultSizeId = sizeId
|
|
||||||
}
|
|
||||||
item := types.TagProduct{
|
item := types.TagProduct{
|
||||||
ProductId: productInfo.Id,
|
ProductId: productInfo.Id,
|
||||||
Sn: *productInfo.Sn,
|
Sn: *productInfo.Sn,
|
||||||
Title: *productInfo.Title,
|
Title: *productInfo.Title,
|
||||||
SizeNum: uint32(sizeNum),
|
SizeNum: uint32(sizeNum),
|
||||||
CoverDefault: []types.CoverDefaultItem{},
|
CoverDefault: []types.CoverDefaultItem{},
|
||||||
DefaultTemplateId: templateId,
|
|
||||||
DefaultSizeId: defaultSizeId,
|
|
||||||
MinPrice: minPrice,
|
MinPrice: minPrice,
|
||||||
HaveOptionalFitting: haveOptionalFitting,
|
HaveOptionalFitting: haveOptionalFitting,
|
||||||
Recommended: *productInfo.IsRecommend > 0,
|
Recommended: *productInfo.IsRecommend > 0,
|
||||||
|
|
|
@ -277,8 +277,6 @@ type TagProduct struct {
|
||||||
SizeNum uint32 `json:"size_num"`
|
SizeNum uint32 `json:"size_num"`
|
||||||
MinPrice int64 `json:"min_price"`
|
MinPrice int64 `json:"min_price"`
|
||||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||||
DefaultTemplateId int64 `json:"default_template_id"`
|
|
||||||
DefaultSizeId int64 `json:"default_size_id"`
|
|
||||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||||
Recommended bool `json:"recommended"`
|
Recommended bool `json:"recommended"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,8 +327,6 @@ type TagProduct {
|
||||||
MinPrice int64 `json:"min_price"`
|
MinPrice int64 `json:"min_price"`
|
||||||
//彩膜列表
|
//彩膜列表
|
||||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||||
DefaultTemplateId int64 `json:"default_template_id"`
|
|
||||||
DefaultSizeId int64 `json:"default_size_id"`
|
|
||||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||||
Recommended bool `json:"recommended"`
|
Recommended bool `json:"recommended"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user