@@ -60,7 +60,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
return resp . SetStatusWithMessage ( basic . CodeDbRecordNotFoundErr , "param cid is invalid:record not found" )
}
logx . Error ( err )
return resp . SetStatusWithMessage ( basic . CodeDbSqlErr , "failed to get tag info" )
return resp . SetStatusWithMessage ( basic . CodeDbSqlErr , "failed to get tag info" )
}
tReq . LevelPrefixLeftLike = * tagData . LevelPrefix
}
@@ -78,6 +78,8 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
}
var (
productList [ ] gmodel . FsProduct //产品列表( select 字段需要看查询的地方)
productOptionalPartList [ ] gmodel . GetGroupPartListByProductIdsRsp //产品配件列表
mapProductHaveOptionFitting = make ( map [ int64 ] struct { } )
productPriceList [ ] gmodel . GetPriceListByProductIdsRsp //产品价格列表( select 字段需要看查询的地方)
mapProductMinPrice = make ( map [ int64 ] int64 ) //产品最小价格map
productTemplatesV2 [ ] gmodel . FsProductTemplateV2 //产品模板列表( select 字段需要看查询的地方)
@@ -104,9 +106,23 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
logx . Error ( err )
return resp . SetStatusWithMessage ( basic . CodeServiceErr , "failed to get product list" )
}
productIds := make ( [ ] int64 , 0 , len ( productList ) )
for _ , product := range productList {
productIds = append ( productIds , product . Id )
productIds := make ( [ ] int64 , 0 , len ( productList ) )
for _ , product := range productList {
productIds = append ( productIds , product . Id )
}
//获取商品可选配件
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" )
}
for _ , partList := range productOptionalPartList {
partList . PartList = strings . Trim ( partList . PartList , " " )
partList . PartList = strings . Trim ( partList . PartList , "," )
if partList . PartList == "" {
continue
}
mapProductHaveOptionFitting [ partList . ProductId ] = struct { } { }
}
//获取产品价格列表
productPriceList , err = l . svcCtx . AllModels . FsProductPrice . GetSimplePriceListByProductIds ( l . ctx , productIds )
@@ -158,6 +174,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
MapProductTemplate : mapProductTemplate ,
MapProductSizeCount : mapProductSizeCount ,
MapTagLevel : mapTagLevel ,
MapProductHaveOptionFitting : mapProductHaveOptionFitting ,
Size : req . Size ,
user : user ,
} ) ; err != nil {
@@ -185,6 +202,7 @@ type dealWithTagMenuDataReq struct {
MapProductTemplate map [ int64 ] struct { }
MapProductSizeCount map [ int64 ] int64
MapTagLevel map [ string ] * types . TagItem
MapProductHaveOptionFitting map [ int64 ] struct { }
Size uint32
user gmodel . FsUser
}
@@ -211,6 +229,7 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq)
MapProductMinPrice : req . MapProductMinPrice ,
MapProductTemplate : req . MapProductTemplate ,
MapProductSizeCount : req . MapProductSizeCount ,
MapProductHaveOptionFitting : req . MapProductHaveOptionFitting ,
Size : req . Size ,
User : req . user ,
} )
@@ -257,6 +276,7 @@ func (l *GetTagProductListLogic) organizationLevelRelation(mapTagLevel map[strin
} )
return rspList
}
// 获取对应tag的产品列表
type getTagProductsReq struct {
TagId int64
@@ -264,6 +284,7 @@ type getTagProductsReq struct {
MapProductMinPrice map [ int64 ] int64
MapProductTemplate map [ int64 ] struct { }
MapProductSizeCount map [ int64 ] int64
MapProductHaveOptionFitting map [ int64 ] struct { }
Size uint32
User gmodel . FsUser
}
@@ -286,6 +307,11 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
if mapSizeNum , ok := req . MapProductSizeCount [ productInfo . Id ] ; ok {
sizeNum = mapSizeNum
}
//有无可选配件
haveOptionalFitting := false
if _ , ok = req . MapProductHaveOptionFitting [ productInfo . Id ] ; ok {
haveOptionalFitting = true
}
item := types . TagProduct {
ProductId : productInfo . Id ,
Sn : * productInfo . Sn ,
@@ -295,6 +321,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
IsMicro : * productInfo . IsMicrowave ,
SizeNum : uint32 ( sizeNum ) ,
MiniPrice : minPrice ,
HaveOptionalFitting : haveOptionalFitting ,
}
//千人千面处理
r := image . ThousandFaceImageFormatReq {