11
This commit is contained in:
@@ -91,7 +91,6 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
||||
mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map
|
||||
mapProductTemplate = make(map[int64]int64) //产品模板map
|
||||
mapResourceMetadata = make(map[string]map[string]interface{}) //资源元数据
|
||||
mapProductDefaultSize = make(map[int64]int64)
|
||||
)
|
||||
//携带产品
|
||||
if req.WithProduct {
|
||||
@@ -104,7 +103,6 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
||||
MapProductMinPrice: mapProductMinPrice,
|
||||
MapProductSizeCount: mapProductSizeCount,
|
||||
MapProductTemplate: mapProductTemplate,
|
||||
MapProductDefaultSize: mapProductDefaultSize,
|
||||
MapResourceMetadata: mapResourceMetadata,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -127,7 +125,6 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
||||
MapTagLevel: mapTagLevel,
|
||||
MapProductHaveOptionFitting: mapProductHaveOptionFitting,
|
||||
MapResourceMetadata: mapResourceMetadata,
|
||||
MapProductDefaultSize: mapProductDefaultSize,
|
||||
Size: req.Size,
|
||||
User: user,
|
||||
MinLevel: &minLevel,
|
||||
@@ -154,7 +151,6 @@ type getProductRelationInfoReq struct {
|
||||
MapProductSizeCount map[int64]int64
|
||||
MapProductTemplate map[int64]int64
|
||||
MapResourceMetadata map[string]map[string]interface{}
|
||||
MapProductDefaultSize map[int64]int64
|
||||
}
|
||||
|
||||
func (l *GetTagProductListLogic) getProductRelationInfo(req getProductRelationInfoReq) (productList []gmodel.FsProduct, err error) {
|
||||
@@ -276,35 +272,15 @@ func (l *GetTagProductListLogic) getProductRelationInfo(req getProductRelationIn
|
||||
logx.Error(err)
|
||||
return nil, errors.New("failed to get product templates")
|
||||
}
|
||||
mapDefaultModelId := make(map[int64]struct{})
|
||||
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 {
|
||||
continue
|
||||
} else { //否则设置一个值
|
||||
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)
|
||||
if err != nil {
|
||||
@@ -330,7 +306,6 @@ type dealWithTagMenuDataReq struct {
|
||||
MapTagLevel map[string]*types.TagItem
|
||||
MapProductHaveOptionFitting map[int64]struct{}
|
||||
MapResourceMetadata map[string]map[string]interface{}
|
||||
MapProductDefaultSize map[int64]int64
|
||||
Size uint32
|
||||
User gmodel.FsUser
|
||||
MinLevel *int //层级最小的
|
||||
@@ -364,7 +339,6 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq)
|
||||
MapProductSizeCount: req.MapProductSizeCount,
|
||||
MapProductHaveOptionFitting: req.MapProductHaveOptionFitting,
|
||||
MapResourceMetadata: req.MapResourceMetadata,
|
||||
MapProductDefaultSize: req.MapProductDefaultSize,
|
||||
Size: req.Size,
|
||||
User: req.User,
|
||||
})
|
||||
@@ -442,7 +416,6 @@ type getTagProductsReq struct {
|
||||
MapProductSizeCount map[int64]int64
|
||||
MapProductHaveOptionFitting map[int64]struct{}
|
||||
MapResourceMetadata map[string]map[string]interface{}
|
||||
MapProductDefaultSize map[int64]int64
|
||||
Size uint32
|
||||
User gmodel.FsUser
|
||||
}
|
||||
@@ -457,7 +430,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
||||
continue
|
||||
}
|
||||
minPrice, ok := req.MapProductMinPrice[productInfo.Id]
|
||||
templateId, tmpOk := req.MapProductTemplate[productInfo.Id]
|
||||
_, tmpOk := req.MapProductTemplate[productInfo.Id]
|
||||
//无最小价格则不显示 || 没有模板也不显示
|
||||
if !ok || !tmpOk {
|
||||
continue
|
||||
@@ -471,19 +444,12 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
||||
if _, ok = req.MapProductHaveOptionFitting[productInfo.Id]; ok {
|
||||
haveOptionalFitting = true
|
||||
}
|
||||
//默认尺寸id
|
||||
defaultSizeId := int64(0)
|
||||
if sizeId, ok := req.MapProductDefaultSize[productInfo.Id]; ok {
|
||||
defaultSizeId = sizeId
|
||||
}
|
||||
item := types.TagProduct{
|
||||
ProductId: productInfo.Id,
|
||||
Sn: *productInfo.Sn,
|
||||
Title: *productInfo.Title,
|
||||
SizeNum: uint32(sizeNum),
|
||||
CoverDefault: []types.CoverDefaultItem{},
|
||||
DefaultTemplateId: templateId,
|
||||
DefaultSizeId: defaultSizeId,
|
||||
MinPrice: minPrice,
|
||||
HaveOptionalFitting: haveOptionalFitting,
|
||||
Recommended: *productInfo.IsRecommend > 0,
|
||||
|
||||
Reference in New Issue
Block a user