添加购物车新增灯光信息保存
This commit is contained in:
@@ -66,6 +66,8 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
||||
templateTag string //模板表的模板标签
|
||||
fittingJson string //配件的json设计信息
|
||||
fittingName string //配件名
|
||||
lightJson string //灯光设计数据
|
||||
lightName string //灯光名字
|
||||
)
|
||||
//有模板
|
||||
if req.TemplateId > 0 {
|
||||
@@ -140,6 +142,21 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
||||
if modelInfo.ModelInfo == nil || *modelInfo.ModelInfo == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "the model`s design info is empty")
|
||||
}
|
||||
//获取灯光信息
|
||||
if *modelInfo.Light > 0 {
|
||||
lightInfo, err := l.svcCtx.AllModels.FsProductModel3dLight.FindOne(l.ctx, *modelInfo.Light)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the model`s light info is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get light info")
|
||||
}
|
||||
lightName = *lightInfo.Name
|
||||
if lightInfo.Info != nil && *lightInfo.Info != "" {
|
||||
lightJson = *lightInfo.Info
|
||||
}
|
||||
}
|
||||
var sizeKeyInfo shopping_cart.SizeInfo
|
||||
if err = json.Unmarshal([]byte(*sizeInfo.Title), &sizeKeyInfo); err != nil {
|
||||
logx.Error(err)
|
||||
@@ -174,6 +191,10 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
||||
Qrcode: req.DiyInfo.Qrcode,
|
||||
Slogan: req.DiyInfo.Slogan,
|
||||
},
|
||||
LightInfo: shopping_cart.LightInfo{
|
||||
LightJson: lightJson,
|
||||
LightName: lightName,
|
||||
},
|
||||
}
|
||||
snapshotJsonBytes, _ := json.Marshal(snapshot)
|
||||
snapshotJsonStr := string(snapshotJsonBytes)
|
||||
@@ -183,6 +204,7 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
||||
ProductId: &req.ProductId,
|
||||
TemplateId: &req.TemplateId,
|
||||
ModelId: &modelInfo.Id,
|
||||
LightId: modelInfo.Light,
|
||||
SizeId: &req.SizeId,
|
||||
FittingId: &req.FittingId,
|
||||
PurchaseQuantity: &req.PurchaseQuantity,
|
||||
|
||||
Reference in New Issue
Block a user