删除无用的服务
This commit is contained in:
parent
a495e4e459
commit
3e714a5db6
|
@ -38,6 +38,9 @@ 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 {
|
||||
|
@ -66,6 +69,26 @@ 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, ",")
|
||||
|
@ -87,16 +110,7 @@ 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 {
|
||||
|
@ -111,6 +125,10 @@ 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,
|
||||
|
@ -120,6 +138,7 @@ 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)
|
||||
|
|
|
@ -332,7 +332,8 @@ type PriceItem struct {
|
|||
}
|
||||
|
||||
type GetSizeByPidReq struct {
|
||||
Pid string `form:"pid"`
|
||||
Pid string `form:"pid"`
|
||||
TemplateTag string `form:"template_tag"`
|
||||
}
|
||||
|
||||
type GetSizeByPidRsp struct {
|
||||
|
@ -344,6 +345,7 @@ 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 {
|
||||
|
|
|
@ -378,7 +378,8 @@ type PriceItem {
|
|||
}
|
||||
//获取产品尺寸列表
|
||||
type GetSizeByPidReq {
|
||||
Pid string `form:"pid"`
|
||||
Pid string `form:"pid"`
|
||||
TemplateTag string `form:"template_tag"`
|
||||
}
|
||||
type GetSizeByPidRsp {
|
||||
Id int64 `json:"id"` //尺寸id
|
||||
|
@ -389,6 +390,7 @@ 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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user