fix
This commit is contained in:
parent
cf59a03129
commit
2fa77828b4
@ -66,7 +66,7 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//尺寸列表[这里要处理数据中的title]
|
//尺寸列表
|
||||||
sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByStatus(l.ctx, int64(constants.FAQ_STATUS_ON), 1, "id,title,capacity,cover,sort,parts_can_deleted")
|
sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByStatus(l.ctx, int64(constants.FAQ_STATUS_ON), 1, "id,title,capacity,cover,sort,parts_can_deleted")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
@ -93,10 +93,10 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product 3d model list")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product 3d model list")
|
||||||
}
|
}
|
||||||
model3dIds := make([]int64, 0, len(model3dList))
|
model3dIds := make([]int64, 0, len(model3dList))
|
||||||
mapModel3dWithSizeIdIndex := make(map[int64]int) //sizeid为key
|
mapModel3dWithSizeIdIndex := make(map[int64]gmodel.FsProductModel3d) //sizeid为key
|
||||||
for k, v := range model3dList {
|
for _, v := range model3dList {
|
||||||
model3dIds = append(model3dIds, v.Id)
|
model3dIds = append(model3dIds, v.Id)
|
||||||
mapModel3dWithSizeIdIndex[*v.SizeId] = k
|
mapModel3dWithSizeIdIndex[*v.SizeId] = v
|
||||||
}
|
}
|
||||||
//通过产品id和模型id获取模板信息
|
//通过产品id和模型id获取模板信息
|
||||||
productTemplateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIdModelIds(l.ctx, model3dIds, productInfo.Id)
|
productTemplateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIdModelIds(l.ctx, model3dIds, productInfo.Id)
|
||||||
@ -108,7 +108,7 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
mapTemplateModelId := make(map[int64]struct{})
|
mapTemplateModelId := make(map[int64]struct{})
|
||||||
tagIds := make([]int64, 0, len(productTemplateList))
|
tagIds := make([]int64, 0, len(productTemplateList))
|
||||||
for _, v := range productTemplateList {
|
for _, v := range productTemplateList {
|
||||||
mapTemplateModelId[v.Id] = struct{}{}
|
mapTemplateModelId[*v.ModelId] = struct{}{}
|
||||||
if v.Tag != nil && *v.Tag != "" {
|
if v.Tag != nil && *v.Tag != "" {
|
||||||
tagId, err := strconv.ParseInt(*v.Tag, 10, 64)
|
tagId, err := strconv.ParseInt(*v.Tag, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -121,21 +121,24 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
//过滤没有模板的尺寸数据
|
//过滤没有模板的尺寸数据
|
||||||
sizeListRsp := make([]types.SizeItem, 0, len(sizeList))
|
sizeListRsp := make([]types.SizeItem, 0, len(sizeList))
|
||||||
for _, v := range sizeList {
|
for _, v := range sizeList {
|
||||||
model3dIndex, ok := mapModel3dWithSizeIdIndex[v.Id]
|
model3dInfo, ok := mapModel3dWithSizeIdIndex[v.Id]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
fmt.Println("没有模型:", v.Id)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, ok = mapTemplateModelId[model3dList[model3dIndex].Id]; !ok {
|
if _, ok = mapTemplateModelId[model3dInfo.Id]; !ok {
|
||||||
|
fmt.Println("没有模板:", v.Id)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
fmt.Println("剩下的:", v.Id)
|
||||||
var title types.SizeTitle
|
var title types.SizeTitle
|
||||||
if err = json.Unmarshal([]byte(*v.Title), &title); err != nil {
|
if err = json.Unmarshal([]byte(*v.Title), &title); err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse size info`s title")
|
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse size info`s title")
|
||||||
}
|
}
|
||||||
var modelInfo map[string]interface{}
|
var modelInfo map[string]interface{}
|
||||||
if model3dList[model3dIndex].ModelInfo != nil && *model3dList[model3dIndex].ModelInfo != "" {
|
if model3dInfo.ModelInfo != nil && *model3dInfo.ModelInfo != "" {
|
||||||
if err = json.Unmarshal([]byte(*model3dList[model3dIndex].ModelInfo), &modelInfo); err != nil {
|
if err = json.Unmarshal([]byte(*model3dInfo.ModelInfo), &modelInfo); err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse model info")
|
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse model info")
|
||||||
}
|
}
|
||||||
@ -163,9 +166,9 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get tag list")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get tag list")
|
||||||
}
|
}
|
||||||
mapTag := make(map[string]int)
|
mapTag := make(map[string]gmodel.FsTags)
|
||||||
for k, v := range tagList {
|
for _, v := range tagList {
|
||||||
mapTag[fmt.Sprintf("%d", v.Id)] = k
|
mapTag[fmt.Sprintf("%d", v.Id)] = v
|
||||||
}
|
}
|
||||||
//获取全部模型信息
|
//获取全部模型信息
|
||||||
allModel3dList, err := l.svcCtx.AllModels.FsProductModel3d.GetAll(l.ctx)
|
allModel3dList, err := l.svcCtx.AllModels.FsProductModel3d.GetAll(l.ctx)
|
||||||
@ -173,11 +176,11 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get all 3d model list")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get all 3d model list")
|
||||||
}
|
}
|
||||||
mapAllmodel3d := make(map[int64]int)
|
mapAllmodel3d := make(map[int64]gmodel.FsProductModel3d)
|
||||||
optionTemplateIds := make([]int64, 0, len(allModel3dList))
|
optionTemplateIds := make([]int64, 0, len(allModel3dList))
|
||||||
lightIds := make([]int64, 0, len(allModel3dList))
|
lightIds := make([]int64, 0, len(allModel3dList))
|
||||||
for k, v := range allModel3dList {
|
for _, v := range allModel3dList {
|
||||||
mapAllmodel3d[v.Id] = k
|
mapAllmodel3d[v.Id] = v
|
||||||
optionTemplateIds = append(optionTemplateIds, *v.OptionTemplate)
|
optionTemplateIds = append(optionTemplateIds, *v.OptionTemplate)
|
||||||
lightIds = append(lightIds, *v.Light)
|
lightIds = append(lightIds, *v.Light)
|
||||||
}
|
}
|
||||||
@ -187,9 +190,9 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get option template list")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get option template list")
|
||||||
}
|
}
|
||||||
mapOptionTemplate := make(map[int64]int)
|
mapOptionTemplate := make(map[int64]gmodel.FsProductTemplateV2)
|
||||||
for k, v := range optionTemplateList {
|
for _, v := range optionTemplateList {
|
||||||
mapOptionTemplate[v.Id] = k
|
mapOptionTemplate[v.Id] = v
|
||||||
}
|
}
|
||||||
//获取灯光信息
|
//获取灯光信息
|
||||||
lightList, err := l.svcCtx.AllModels.FsProductModel3dLight.GetAllByIdsWithoutStatus(l.ctx, lightIds)
|
lightList, err := l.svcCtx.AllModels.FsProductModel3dLight.GetAllByIdsWithoutStatus(l.ctx, lightIds)
|
||||||
@ -197,9 +200,9 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get light list")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get light list")
|
||||||
}
|
}
|
||||||
mapLight := make(map[int64]int)
|
mapLight := make(map[int64]gmodel.FsProductModel3dLight)
|
||||||
for k, v := range lightList {
|
for _, v := range lightList {
|
||||||
mapLight[v.Id] = k
|
mapLight[v.Id] = v
|
||||||
}
|
}
|
||||||
//材料尺寸模板
|
//材料尺寸模板
|
||||||
mapMaterialSizeTmp := make(map[string][]interface{})
|
mapMaterialSizeTmp := make(map[string][]interface{})
|
||||||
@ -212,19 +215,18 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
mapMaterialSizePrice := make(map[string]*MaterialSizePrice)
|
mapMaterialSizePrice := make(map[string]*MaterialSizePrice)
|
||||||
//循环处理组装模板信息
|
//循环处理组装模板信息
|
||||||
for _, tmp := range productTemplateList {
|
for _, tmp := range productTemplateList {
|
||||||
allModel3dIndex, ok := mapAllmodel3d[*tmp.ModelId]
|
model3dInfo, ok := mapAllmodel3d[*tmp.ModelId]
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//如果是配件信息就跳过,不返回
|
//如果是配件信息就跳过,不返回
|
||||||
if *allModel3dList[allModel3dIndex].Tag == constants.TAG_PARTS {
|
if *model3dInfo.Tag == constants.TAG_PARTS {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//未编辑模板信息的数据跳过
|
//未编辑模板信息的数据跳过
|
||||||
if tmp.TemplateInfo == nil || *tmp.TemplateInfo == "" {
|
if tmp.TemplateInfo == nil || *tmp.TemplateInfo == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
model3dInfo := allModel3dList[allModel3dIndex]
|
|
||||||
//解码template info
|
//解码template info
|
||||||
var templateInfoRsp map[string]interface{}
|
var templateInfoRsp map[string]interface{}
|
||||||
if tmp.TemplateInfo != nil && *tmp.TemplateInfo != "" {
|
if tmp.TemplateInfo != nil && *tmp.TemplateInfo != "" {
|
||||||
@ -251,12 +253,12 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse model info")
|
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse model info")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modelInfoRsp["id"] = allModel3dList[allModel3dIndex].Id
|
modelInfoRsp["id"] = model3dInfo.Id
|
||||||
//解码灯光数据
|
//解码灯光数据
|
||||||
var lightInfoRsp interface{}
|
var lightInfoRsp interface{}
|
||||||
lightIndex, ok := mapLight[*model3dInfo.Light]
|
lightInfo, ok := mapLight[*model3dInfo.Light]
|
||||||
if ok && lightList[lightIndex].Info != nil && *lightList[lightIndex].Info != "" {
|
if ok && lightInfo.Info != nil && *lightInfo.Info != "" {
|
||||||
if err = json.Unmarshal([]byte(*lightList[lightIndex].Info), &lightInfoRsp); err != nil {
|
if err = json.Unmarshal([]byte(*lightInfo.Info), &lightInfoRsp); err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse light info")
|
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse light info")
|
||||||
}
|
}
|
||||||
@ -270,17 +272,17 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
partListRsp := make([]interface{}, 0, len(modelPartIds))
|
partListRsp := make([]interface{}, 0, len(modelPartIds))
|
||||||
for _, partId := range modelPartIds {
|
for _, partId := range modelPartIds {
|
||||||
//判断配件信息是否正常
|
//判断配件信息是否正常
|
||||||
key, ok := mapAllmodel3d[partId]
|
temModelInfo, ok := mapAllmodel3d[partId]
|
||||||
if !ok || *allModel3dList[key].Status != 1 {
|
if !ok || *temModelInfo.Status != 1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var thisInfo map[string]interface{}
|
var thisInfo map[string]interface{}
|
||||||
temBytes, _ := json.Marshal(allModel3dList[key])
|
temBytes, _ := json.Marshal(temModelInfo)
|
||||||
_ = json.Unmarshal(temBytes, &thisInfo)
|
_ = json.Unmarshal(temBytes, &thisInfo)
|
||||||
thisInfo["material_img"] = ""
|
thisInfo["material_img"] = ""
|
||||||
if *allModel3dList[key].OptionTemplate != 0 {
|
if *temModelInfo.OptionTemplate != 0 {
|
||||||
if optionTemplateIndex, ok := mapOptionTemplate[*allModel3dList[key].OptionTemplate]; ok {
|
if optionTemplateInfo, ok := mapOptionTemplate[*temModelInfo.OptionTemplate]; ok {
|
||||||
thisInfo["material_img"] = *optionTemplateList[optionTemplateIndex].MaterialImg
|
thisInfo["material_img"] = *optionTemplateInfo.MaterialImg
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tmpv2, err := l.svcCtx.AllModels.FsProductTemplateV2.FindOneByModelId(l.ctx, partId)
|
tmpv2, err := l.svcCtx.AllModels.FsProductTemplateV2.FindOneByModelId(l.ctx, partId)
|
||||||
@ -297,8 +299,8 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
partListRsp = append(partListRsp, thisInfo)
|
partListRsp = append(partListRsp, thisInfo)
|
||||||
}
|
}
|
||||||
tagName := ""
|
tagName := ""
|
||||||
if tagIndex, ok := mapTag[*tmp.Tag]; ok {
|
if tagData, ok := mapTag[*tmp.Tag]; ok {
|
||||||
tagName = *tagList[tagIndex].Title
|
tagName = *tagData.Title
|
||||||
}
|
}
|
||||||
//按照材质和尺寸来存放模板信息
|
//按照材质和尺寸来存放模板信息
|
||||||
mapMaterialSizeTmpKey := l.getMapMaterialSizeTmpKey(*productInfo.MaterialIds, *model3dInfo.SizeId)
|
mapMaterialSizeTmpKey := l.getMapMaterialSizeTmpKey(*productInfo.MaterialIds, *model3dInfo.SizeId)
|
||||||
@ -407,7 +409,7 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri
|
|||||||
Materials: materials,
|
Materials: materials,
|
||||||
Sizes: sizeListRsp,
|
Sizes: sizeListRsp,
|
||||||
Templates: mapMaterialSizeTmp,
|
Templates: mapMaterialSizeTmp,
|
||||||
Price: mapMaterialSizePrice,
|
Prices: mapMaterialSizePrice,
|
||||||
LastDesign: lastDesign,
|
LastDesign: lastDesign,
|
||||||
RenderDesign: renderDesign,
|
RenderDesign: renderDesign,
|
||||||
Colors: color_list.GetColor(),
|
Colors: color_list.GetColor(),
|
||||||
|
@ -121,7 +121,7 @@ type GetProductInfoRsp struct {
|
|||||||
Materials []MaterialItem `json:"materials"`
|
Materials []MaterialItem `json:"materials"`
|
||||||
Sizes []SizeItem `json:"sizes"`
|
Sizes []SizeItem `json:"sizes"`
|
||||||
Templates interface{} `json:"templates"`
|
Templates interface{} `json:"templates"`
|
||||||
Price interface{} `json:"price"`
|
Prices interface{} `json:"prices"`
|
||||||
LastDesign interface{} `json:"last_design"`
|
LastDesign interface{} `json:"last_design"`
|
||||||
RenderDesign interface{} `json:"render_design"`
|
RenderDesign interface{} `json:"render_design"`
|
||||||
Colors interface{} `json:"colors"`
|
Colors interface{} `json:"colors"`
|
||||||
|
@ -147,7 +147,7 @@ type GetProductInfoRsp {
|
|||||||
Materials []MaterialItem `json:"materials"`
|
Materials []MaterialItem `json:"materials"`
|
||||||
Sizes []SizeItem `json:"sizes"`
|
Sizes []SizeItem `json:"sizes"`
|
||||||
Templates interface{} `json:"templates"`
|
Templates interface{} `json:"templates"`
|
||||||
Price interface{} `json:"price"`
|
Prices interface{} `json:"prices"`
|
||||||
LastDesign interface{} `json:"last_design"`
|
LastDesign interface{} `json:"last_design"`
|
||||||
RenderDesign interface{} `json:"render_design"`
|
RenderDesign interface{} `json:"render_design"`
|
||||||
Colors interface{} `json:"colors"`
|
Colors interface{} `json:"colors"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user