fix
This commit is contained in:
parent
c79a1aab49
commit
bfe0ee0652
@ -180,7 +180,7 @@ func (l *GetProductDetailLogic) GetProductDetail(req *types.GetProductDetailReq,
|
|||||||
}
|
}
|
||||||
var modelInfoRsp types.ModelInfo
|
var modelInfoRsp types.ModelInfo
|
||||||
var TemplateInfoRsp interface{}
|
var TemplateInfoRsp interface{}
|
||||||
var FittingListRsp = make([]types.FittingInfo, 0, 10)
|
var FittingListRsp []types.FittingInfo
|
||||||
if modelIndex, ok := mapSizeKeyModel[sizeInfo.Id]; ok {
|
if modelIndex, ok := mapSizeKeyModel[sizeInfo.Id]; ok {
|
||||||
modelInfo := modelList[modelIndex]
|
modelInfo := modelList[modelIndex]
|
||||||
//模板信息
|
//模板信息
|
||||||
@ -221,55 +221,9 @@ func (l *GetProductDetailLogic) GetProductDetail(req *types.GetProductDetailReq,
|
|||||||
optionalFittingIdsStr := strings.Trim(*modelInfo.PartList, " ")
|
optionalFittingIdsStr := strings.Trim(*modelInfo.PartList, " ")
|
||||||
optionalFittingIdsStr = strings.Trim(optionalFittingIdsStr, ",")
|
optionalFittingIdsStr = strings.Trim(optionalFittingIdsStr, ",")
|
||||||
//配件信息
|
//配件信息
|
||||||
if optionalFittingIdsStr != "" {
|
FittingListRsp, err = l.GetModelOptionalFittings(l.ctx, optionalFittingIdsStr, mapFitting, mapPublicFittingOptionTemplate, mapNotPublicFittingOptionTemplateMaterialImage, modelInfo, modelList)
|
||||||
optionalFittingIds, err := format.StrSlicToInt64Slice(strings.Split(optionalFittingIdsStr, ","))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error())
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to split optional fitting list")
|
|
||||||
}
|
|
||||||
//可选配件
|
|
||||||
for _, optionFittingId := range optionalFittingIds {
|
|
||||||
fittingIndex, ok := mapFitting[optionFittingId]
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fittingInfo := modelList[fittingIndex]
|
|
||||||
var fittingDesignInfo interface{}
|
|
||||||
if fittingInfo.ModelInfo == nil || *fittingInfo.ModelInfo == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err = json.Unmarshal([]byte(*fittingInfo.ModelInfo), &fittingDesignInfo); err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse fitting design info")
|
|
||||||
}
|
|
||||||
//是否默认显示配件
|
|
||||||
isDefault := int64(0)
|
|
||||||
if optionFittingId == *modelInfo.PartId {
|
|
||||||
isDefault = 1
|
|
||||||
}
|
|
||||||
//配件贴图
|
|
||||||
FittingMaterialImg := ""
|
|
||||||
//贴图,如果绑定了公共模板,则获取公共模板的贴图数据(待优化)
|
|
||||||
if *fittingInfo.OptionTemplate > 0 {
|
|
||||||
if image, ok := mapPublicFittingOptionTemplate[*fittingInfo.OptionTemplate]; ok {
|
|
||||||
FittingMaterialImg = image
|
|
||||||
}
|
|
||||||
} else { //否则取该配件下的模板贴图
|
|
||||||
if image, ok := mapNotPublicFittingOptionTemplateMaterialImage[fittingInfo.Id]; ok {
|
|
||||||
FittingMaterialImg = image
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FittingListRsp = append(FittingListRsp, types.FittingInfo{
|
|
||||||
Id: fittingInfo.Id,
|
|
||||||
IsHot: *fittingInfo.IsHot,
|
|
||||||
MaterialImage: FittingMaterialImg,
|
|
||||||
DesignInfo: fittingDesignInfo,
|
|
||||||
Price: format.CentitoDollar(*fittingInfo.Price, 3),
|
|
||||||
Name: *fittingInfo.Name,
|
|
||||||
IsDefault: isDefault,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isDefaultSize := int64(0)
|
isDefaultSize := int64(0)
|
||||||
@ -305,6 +259,62 @@ func (l *GetProductDetailLogic) GetProductDetail(req *types.GetProductDetailReq,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取模型可选配件列表
|
||||||
|
func (l *GetProductDetailLogic) GetModelOptionalFittings(ctx context.Context, optionalFittingIdsStr string, mapFitting map[int64]int, mapPublicFittingOptionTemplate, mapNotPublicFittingOptionTemplateMaterialImage map[int64]string, modelInfo gmodel.FsProductModel3d, modelList []gmodel.FsProductModel3d) (resp []types.FittingInfo, err error) {
|
||||||
|
if optionalFittingIdsStr == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
optionalFittingIds, err := format.StrSlicToInt64Slice(strings.Split(optionalFittingIdsStr, ","))
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, errors.New("failed to split optional fitting list")
|
||||||
|
}
|
||||||
|
resp = make([]types.FittingInfo, 0, len(optionalFittingIds))
|
||||||
|
//可选配件
|
||||||
|
for _, optionFittingId := range optionalFittingIds {
|
||||||
|
fittingIndex, ok := mapFitting[optionFittingId]
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fittingInfo := modelList[fittingIndex]
|
||||||
|
var fittingDesignInfo interface{}
|
||||||
|
if fittingInfo.ModelInfo == nil || *fittingInfo.ModelInfo == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal([]byte(*fittingInfo.ModelInfo), &fittingDesignInfo); err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return nil, errors.New("failed to parse fitting design info")
|
||||||
|
}
|
||||||
|
//是否默认显示配件
|
||||||
|
isDefault := int64(0)
|
||||||
|
if optionFittingId == *modelInfo.PartId {
|
||||||
|
isDefault = 1
|
||||||
|
}
|
||||||
|
//配件贴图
|
||||||
|
FittingMaterialImg := ""
|
||||||
|
//贴图,如果绑定了公共模板,则获取公共模板的贴图数据(待优化)
|
||||||
|
if *fittingInfo.OptionTemplate > 0 {
|
||||||
|
if image, ok := mapPublicFittingOptionTemplate[*fittingInfo.OptionTemplate]; ok {
|
||||||
|
FittingMaterialImg = image
|
||||||
|
}
|
||||||
|
} else { //否则取该配件下的模板贴图
|
||||||
|
if image, ok := mapNotPublicFittingOptionTemplateMaterialImage[fittingInfo.Id]; ok {
|
||||||
|
FittingMaterialImg = image
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resp = append(resp, types.FittingInfo{
|
||||||
|
Id: fittingInfo.Id,
|
||||||
|
IsHot: *fittingInfo.IsHot,
|
||||||
|
MaterialImage: FittingMaterialImg,
|
||||||
|
DesignInfo: fittingDesignInfo,
|
||||||
|
Price: format.CentitoDollar(*fittingInfo.Price, 3),
|
||||||
|
Name: *fittingInfo.Name,
|
||||||
|
IsDefault: isDefault,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
// 获取列表页默认渲染的尺寸(同列表页)
|
// 获取列表页默认渲染的尺寸(同列表页)
|
||||||
func (l *GetProductDetailLogic) getRenderDefaultSize(productId int64, templateTag string) (sizeId int64, err error) {
|
func (l *GetProductDetailLogic) getRenderDefaultSize(productId int64, templateTag string) (sizeId int64, err error) {
|
||||||
//获取模板
|
//获取模板
|
||||||
|
Loading…
x
Reference in New Issue
Block a user