fix
This commit is contained in:
parent
3e1d4d2e4f
commit
b8333ecaf8
|
@ -75,3 +75,18 @@ func (d *FsProductModel3dModel) GetAll(ctx context.Context) (resp []FsProductMod
|
|||
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
type GetGroupPartListByProductIdsRsp struct {
|
||||
PartList string `json:"part_list"`
|
||||
ProductId int64 `json:"product_id"`
|
||||
}
|
||||
|
||||
func (d *FsProductModel3dModel) GetGroupPartListByProductIds(ctx context.Context, productIds []int64) (resp []GetGroupPartListByProductIdsRsp, err error) {
|
||||
if len(productIds) == 0 {
|
||||
return
|
||||
}
|
||||
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).
|
||||
Select("product_id,group_concat(part_list) as part_list").
|
||||
Group("product_id").Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
|
|
@ -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 字段需要看查询的地方)
|
||||
|
@ -108,6 +110,20 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR
|
|||
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)
|
||||
if err != nil {
|
||||
|
@ -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{
|
||||
|
|
|
@ -279,6 +279,7 @@ type TagProduct struct {
|
|||
SizeNum uint32 `json:"size_num"`
|
||||
MiniPrice int64 `json:"mini_price"`
|
||||
CoverDefault string `json:"cover_default"`
|
||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||
}
|
||||
|
||||
type GetRenderDesignReq struct {
|
||||
|
|
|
@ -322,6 +322,7 @@ type TagProduct {
|
|||
SizeNum uint32 `json:"size_num"`
|
||||
MiniPrice int64 `json:"mini_price"`
|
||||
CoverDefault string `json:"cover_default"`
|
||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||
}
|
||||
//获取云渲染设计方案信息
|
||||
type GetRenderDesignReq {
|
||||
|
|
Loading…
Reference in New Issue
Block a user