11
This commit is contained in:
parent
3e714a5db6
commit
983492f7b1
|
@ -38,9 +38,6 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a
|
||||||
if req.Pid == "" {
|
if req.Pid == "" {
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:pid is empty")
|
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)
|
//获取产品信息(只是获取id)
|
||||||
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid, "id")
|
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid, "id")
|
||||||
if err != nil {
|
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")
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product min price list")
|
||||||
}
|
}
|
||||||
mapProductMinPrice := make(map[int64]int64)
|
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 {
|
for _, v := range productPriceList {
|
||||||
priceStrSlic := strings.Split(v.Price, ",")
|
priceStrSlic := strings.Split(v.Price, ",")
|
||||||
|
@ -110,7 +87,16 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a
|
||||||
mapProductMinPrice[v.ProductId] = int64(priceSlice[0])
|
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))
|
listRsp := make([]types.GetSizeByPidRsp, 0, len(sizeList))
|
||||||
for _, sizeInfo := range 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 {
|
if price, ok := mapProductMinPrice[*sizeInfo.ProductId]; ok {
|
||||||
minPrice = price
|
minPrice = price
|
||||||
}
|
}
|
||||||
templateId := int64(0)
|
|
||||||
if tid, ok := mapTemplate[modelList[modelIndex].Id]; ok {
|
|
||||||
templateId = tid
|
|
||||||
}
|
|
||||||
listRsp = append(listRsp, types.GetSizeByPidRsp{
|
listRsp = append(listRsp, types.GetSizeByPidRsp{
|
||||||
Id: sizeInfo.Id,
|
Id: sizeInfo.Id,
|
||||||
Title: title,
|
Title: title,
|
||||||
|
@ -138,7 +120,6 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a
|
||||||
ModelId: modelList[modelIndex].Id,
|
ModelId: modelList[modelIndex].Id,
|
||||||
IsPopular: *sizeInfo.IsHot > 0,
|
IsPopular: *sizeInfo.IsHot > 0,
|
||||||
MinPrice: float64(minPrice) / 100,
|
MinPrice: float64(minPrice) / 100,
|
||||||
TemplateId: templateId,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", listRsp)
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", listRsp)
|
||||||
|
|
|
@ -345,7 +345,6 @@ type GetSizeByPidRsp struct {
|
||||||
ModelId int64 `json:"model_id"` //产品主模型id
|
ModelId int64 `json:"model_id"` //产品主模型id
|
||||||
IsPopular bool `json:"is_popular"` //是否受欢迎
|
IsPopular bool `json:"is_popular"` //是否受欢迎
|
||||||
MinPrice float64 `json:"min_price"` //最小价格
|
MinPrice float64 `json:"min_price"` //最小价格
|
||||||
TemplateId int64 `json:"template_id"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetTemplateByPidReq struct {
|
type GetTemplateByPidReq struct {
|
||||||
|
|
|
@ -390,7 +390,6 @@ type GetSizeByPidRsp {
|
||||||
ModelId int64 `json:"model_id"` //产品主模型id
|
ModelId int64 `json:"model_id"` //产品主模型id
|
||||||
IsPopular bool `json:"is_popular"` //是否受欢迎
|
IsPopular bool `json:"is_popular"` //是否受欢迎
|
||||||
MinPrice float64 `json:"min_price"` //最小价格
|
MinPrice float64 `json:"min_price"` //最小价格
|
||||||
TemplateId int64 `json:"template_id"`
|
|
||||||
}
|
}
|
||||||
//获取产品模板
|
//获取产品模板
|
||||||
type GetTemplateByPidReq {
|
type GetTemplateByPidReq {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user