From 983492f7b1250df3e6803cb6e5f5090aa2bc3ba2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 12 Sep 2023 15:35:09 +0800 Subject: [PATCH] 11 --- .../internal/logic/getsizebypidlogic.go | 39 +++++-------------- server/product/internal/types/types.go | 1 - server_api/product.api | 1 - 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/server/product/internal/logic/getsizebypidlogic.go b/server/product/internal/logic/getsizebypidlogic.go index 7548a407..3f508762 100644 --- a/server/product/internal/logic/getsizebypidlogic.go +++ b/server/product/internal/logic/getsizebypidlogic.go @@ -38,9 +38,6 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a if req.Pid == "" { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:pid is empty") } - if req.TemplateTag == "" { - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:template_tag is empty") - } //获取产品信息(只是获取id) productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid, "id") if err != nil { @@ -69,26 +66,6 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product min price list") } mapProductMinPrice := make(map[int64]int64) - //根据尺寸id集合获取模型列表 - modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL, "id") - if err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get model list") - } - mapSizeModel := make(map[int64]int) //size id为key - for k, v := range modelList { - mapSizeModel[*v.SizeId] = k - } - modelIds := make([]int64, 0, len(modelList)) - templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, req.TemplateTag, "sort ASC", "id") - if err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list") - } - mapTemplate := make(map[int64]int64) - for _, v := range templateList { - mapTemplate[*v.ModelId] = v.Id - } //存储产品最小价格 for _, v := range productPriceList { priceStrSlic := strings.Split(v.Price, ",") @@ -110,7 +87,16 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a mapProductMinPrice[v.ProductId] = int64(priceSlice[0]) } } - + //获取对应模型数据 + modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL, "id,size_id") + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get model list") + } + mapSizeModel := make(map[int64]int) //size id为key + for k, v := range modelList { + mapSizeModel[*v.SizeId] = k + } //处理 listRsp := make([]types.GetSizeByPidRsp, 0, len(sizeList)) for _, sizeInfo := range sizeList { @@ -125,10 +111,6 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a if price, ok := mapProductMinPrice[*sizeInfo.ProductId]; ok { minPrice = price } - templateId := int64(0) - if tid, ok := mapTemplate[modelList[modelIndex].Id]; ok { - templateId = tid - } listRsp = append(listRsp, types.GetSizeByPidRsp{ Id: sizeInfo.Id, Title: title, @@ -138,7 +120,6 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a ModelId: modelList[modelIndex].Id, IsPopular: *sizeInfo.IsHot > 0, MinPrice: float64(minPrice) / 100, - TemplateId: templateId, }) } return resp.SetStatusWithMessage(basic.CodeOK, "success", listRsp) diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index 942c245d..4ce8f513 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -345,7 +345,6 @@ type GetSizeByPidRsp struct { ModelId int64 `json:"model_id"` //产品主模型id IsPopular bool `json:"is_popular"` //是否受欢迎 MinPrice float64 `json:"min_price"` //最小价格 - TemplateId int64 `json:"template_id"` } type GetTemplateByPidReq struct { diff --git a/server_api/product.api b/server_api/product.api index 3e1408cf..9602fea9 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -390,7 +390,6 @@ type GetSizeByPidRsp { ModelId int64 `json:"model_id"` //产品主模型id IsPopular bool `json:"is_popular"` //是否受欢迎 MinPrice float64 `json:"min_price"` //最小价格 - TemplateId int64 `json:"template_id"` } //获取产品模板 type GetTemplateByPidReq {