diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index dbf28770..e74f78eb 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -11,6 +11,7 @@ import ( "fusenapi/service/repositories" "fusenapi/utils/curl" "fusenapi/utils/hash" + "fusenapi/utils/template_switch_info" "fusenapi/utils/websocket_data" "strconv" "time" @@ -187,7 +188,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe return } //获取信息 - productSize, productTemplate, model3dInfo, err := w.getProductRelationInfo(&renderImageData) + productSize, productTemplate, model3dInfo, switchInfo, err := w.getProductRelationInfo(&renderImageData) if err != nil { logx.Error(err) return @@ -215,11 +216,6 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe ProductTemplateV2Info: productTemplate, ProductTemplateTagGroups: renderImageData.RenderData.TemplateTagGroups, TemplateTag: renderImageData.RenderData.TemplateTag, - Slogan: &renderImageData.RenderData.Slogan, - Website: &renderImageData.RenderData.Website, - Address: &renderImageData.RenderData.Address, - Phone: &renderImageData.RenderData.Phone, - Qrcode: &renderImageData.RenderData.Qrcode, LogoUrl: renderImageData.RenderData.Logo, TemplateTagColor: repositories.TemplateTagColor{ Color: renderImageData.RenderData.TemplateTagColor.Colors, @@ -228,6 +224,45 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe Resolution: renderImageData.RenderData.Resolution, Debug: w.debug, } + //qrcode不需要依赖合图组开关 + if switchInfo.SwitchInfo.QRcode.IfShow { + combineReq.Qrcode = &switchInfo.SwitchInfo.QRcode.DefaultValue + } + //合图组开关开启 + if switchInfo.CombineIsVisible { + //开启slogan + if switchInfo.SwitchInfo.Slogan.IfShow { + if renderImageData.RenderData.Slogan == "" { + combineReq.Slogan = &switchInfo.SwitchInfo.Slogan.DefaultValue + } else { + combineReq.Slogan = &renderImageData.RenderData.Slogan + } + } + //开启website + if switchInfo.SwitchInfo.Website.IfShow { + if renderImageData.RenderData.Website == "" { + combineReq.Website = &switchInfo.SwitchInfo.Website.DefaultValue + } else { + combineReq.Website = &renderImageData.RenderData.Website + } + } + //开启address + if switchInfo.SwitchInfo.Address.IfShow { + if renderImageData.RenderData.Address == "" { + combineReq.Address = &switchInfo.SwitchInfo.Address.DefaultValue + } else { + combineReq.Address = &renderImageData.RenderData.Address + } + } + //开启Phone + if switchInfo.SwitchInfo.Phone.IfShow { + if renderImageData.RenderData.Phone == "" { + combineReq.Phone = &switchInfo.SwitchInfo.Phone.DefaultValue + } else { + combineReq.Phone = &renderImageData.RenderData.Phone + } + } + } res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &combineReq) if err != nil { //发送渲染错误消息 @@ -289,50 +324,51 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe } // 获取模板相关信息 -func (w *wsConnectItem) getProductRelationInfo(renderImageData *websocket_data.RenderImageReqMsg) (productSize *gmodel.FsProductSize, productTemplate *gmodel.FsProductTemplateV2, model3d *gmodel.FsProductModel3d, err error) { +func (w *wsConnectItem) getProductRelationInfo(renderImageData *websocket_data.RenderImageReqMsg) (productSize *gmodel.FsProductSize, productTemplate *gmodel.FsProductTemplateV2, model3d *gmodel.FsProductModel3d, switchInfo template_switch_info.GetTemplateSwitchInfoRsp, err error) { //获取模板 productTemplate, err = w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneCloudRenderByProductIdTemplateTag(w.logic.ctx, renderImageData.RenderData.ProductId, renderImageData.RenderData.TemplateTag, "sort ASC") if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "找不到对应开启云渲染模板", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0) - return nil, nil, nil, errors.New("找不到对应开启云渲染模板") + return nil, nil, nil, template_switch_info.GetTemplateSwitchInfoRsp{}, errors.New("找不到对应开启云渲染模板") } logx.Error(err) w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取对应开启云渲染模板失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0) - return nil, nil, nil, errors.New("获取对应开启云渲染模板失败") + return nil, nil, nil, template_switch_info.GetTemplateSwitchInfoRsp{}, errors.New("获取对应开启云渲染模板失败") } //判断设计信息是否为空 if productTemplate.TemplateInfo == nil || *productTemplate.TemplateInfo == "" { w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "模板设计信息是空的", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0) - return nil, nil, nil, errors.New("模板设计信息是空的") + return nil, nil, nil, template_switch_info.GetTemplateSwitchInfoRsp{}, errors.New("模板设计信息是空的") } //根据模板找到模型 model3d, err = w.logic.svcCtx.AllModels.FsProductModel3d.FindOne(w.logic.ctx, *productTemplate.ModelId) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "找不到对应模型", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0) - return nil, nil, nil, errors.New("找不到对应模型") + return nil, nil, nil, template_switch_info.GetTemplateSwitchInfoRsp{}, errors.New("找不到对应模型") } logx.Error(err) w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取对应模型失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0) - return nil, nil, nil, errors.New("获取对应模型失败") + return nil, nil, nil, template_switch_info.GetTemplateSwitchInfoRsp{}, errors.New("获取对应模型失败") } //判断设计信息是否为空 if model3d.ModelInfo == nil || *model3d.ModelInfo == "" { w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "模型设计信息是空的", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0) - return nil, nil, nil, errors.New("模型设计信息是空的") + return nil, nil, nil, template_switch_info.GetTemplateSwitchInfoRsp{}, errors.New("模型设计信息是空的") } //根据模型id获取尺寸信息 productSize, err = w.logic.svcCtx.AllModels.FsProductSize.FindOne(w.logic.ctx, *model3d.SizeId) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "找不到对应尺寸", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0) - return nil, nil, nil, errors.New("找不到对应尺寸") + return nil, nil, nil, template_switch_info.GetTemplateSwitchInfoRsp{}, errors.New("找不到对应尺寸") } logx.Error(err) w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "获取对应尺寸失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0) - return nil, nil, nil, errors.New("获取对应尺寸失败") + return nil, nil, nil, template_switch_info.GetTemplateSwitchInfoRsp{}, errors.New("获取对应尺寸失败") } + switchInfo = template_switch_info.GetTemplateSwitchInfo(productTemplate.Id, productTemplate.TemplateInfo, *productTemplate.MaterialImg) return }