This commit is contained in:
laodaming
2023-10-07 10:13:15 +08:00
parent 7c0b1107f8
commit cc6da9a648
2 changed files with 25 additions and 16 deletions

View File

@@ -88,12 +88,12 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product info")
}
var (
templateJson string //模板表的记录中的json设计信息
templateTag string //模板表的模板标签
fittingJson string //配件的json设计信息
fittingName string //配件名
lightJson string //灯光设计数据
lightName string //灯光名字
templateJson interface{} //模板表的记录中的json设计信息
templateTag string //模板表的模板标签
fittingJson interface{} //配件的json设计信息
fittingName string //配件名
lightJson interface{} //灯光设计数据
lightName string //灯光名字
)
//有模板
if req.TemplateId > 0 {
@@ -114,7 +114,10 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
if templateInfo.TemplateInfo == nil || *templateInfo.TemplateInfo == "" {
return resp.SetStatusWithMessage(basic.CodeServiceErr, "the template`s design info is empty")
}
templateJson = *templateInfo.TemplateInfo
if err = json.Unmarshal([]byte(*templateInfo.TemplateInfo), &templateJson); err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse template design info")
}
templateTag = *templateInfo.TemplateTag
}
//有配件
@@ -133,7 +136,10 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
if fittingInfo.ModelInfo == nil || *fittingInfo.ModelInfo == "" {
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "the fitting`s design info is empty")
}
fittingJson = *fittingInfo.ModelInfo
if err = json.Unmarshal([]byte(*fittingInfo.ModelInfo), &fittingJson); err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse fitting design info")
}
fittingName = *fittingInfo.Title
}
//获取尺寸信息
@@ -180,7 +186,10 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
}
lightName = *lightInfo.Name
if lightInfo.Info != nil && *lightInfo.Info != "" {
lightJson = *lightInfo.Info
if err = json.Unmarshal([]byte(*lightInfo.Info), &lightJson); err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse light design info")
}
}
}
var sizeKeyInfo gmodel.SizeInfo