添加购物车新增灯光信息保存
This commit is contained in:
parent
78558bb74d
commit
86c39263be
|
@ -2,6 +2,10 @@ package gmodel
|
||||||
|
|
||||||
import "context"
|
import "context"
|
||||||
|
|
||||||
|
func (l *FsProductModel3dLightModel) FindOne(ctx context.Context, id int64) (resp *FsProductModel3dLight, err error) {
|
||||||
|
err = l.db.WithContext(ctx).Model(&FsProductModel3dLight{}).Where("`id` = ? and `status` = ?", id, 1).Take(&resp).Error
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
func (l *FsProductModel3dLightModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3dLight, err error) {
|
func (l *FsProductModel3dLightModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3dLight, err error) {
|
||||||
if len(ids) == 0 {
|
if len(ids) == 0 {
|
||||||
return
|
return
|
||||||
|
|
|
@ -13,9 +13,11 @@ type FsShoppingCart struct {
|
||||||
TemplateId *int64 `gorm:"default:0;" json:"template_id"` // 模板id
|
TemplateId *int64 `gorm:"default:0;" json:"template_id"` // 模板id
|
||||||
ModelId *int64 `gorm:"default:0;" json:"model_id"` // 模型id
|
ModelId *int64 `gorm:"default:0;" json:"model_id"` // 模型id
|
||||||
SizeId *int64 `gorm:"default:0;" json:"size_id"` // 尺寸id
|
SizeId *int64 `gorm:"default:0;" json:"size_id"` // 尺寸id
|
||||||
|
LightId *int64 `gorm:"default:0;" json:"light_id"` // 灯光id
|
||||||
FittingId *int64 `gorm:"default:0;" json:"fitting_id"` // 配件id
|
FittingId *int64 `gorm:"default:0;" json:"fitting_id"` // 配件id
|
||||||
PurchaseQuantity *int64 `gorm:"default:0;" json:"purchase_quantity"` // 购买数量
|
PurchaseQuantity *int64 `gorm:"default:0;" json:"purchase_quantity"` // 购买数量
|
||||||
Snapshot *string `gorm:"default:'';" json:"snapshot"` //
|
Snapshot *string `gorm:"default:'';" json:"snapshot"` //
|
||||||
|
IsSelected *int64 `gorm:"default:0;" json:"is_selected"` // 是否被选中 0非 1是
|
||||||
IsHighlyCustomized *int64 `gorm:"default:0;" json:"is_highly_customized"` // 是否高度定制 0非 1是(针对客人高度定制只能后台增加如购物车)
|
IsHighlyCustomized *int64 `gorm:"default:0;" json:"is_highly_customized"` // 是否高度定制 0非 1是(针对客人高度定制只能后台增加如购物车)
|
||||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||||
|
|
|
@ -66,6 +66,8 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
||||||
templateTag string //模板表的模板标签
|
templateTag string //模板表的模板标签
|
||||||
fittingJson string //配件的json设计信息
|
fittingJson string //配件的json设计信息
|
||||||
fittingName string //配件名
|
fittingName string //配件名
|
||||||
|
lightJson string //灯光设计数据
|
||||||
|
lightName string //灯光名字
|
||||||
)
|
)
|
||||||
//有模板
|
//有模板
|
||||||
if req.TemplateId > 0 {
|
if req.TemplateId > 0 {
|
||||||
|
@ -140,6 +142,21 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
||||||
if modelInfo.ModelInfo == nil || *modelInfo.ModelInfo == "" {
|
if modelInfo.ModelInfo == nil || *modelInfo.ModelInfo == "" {
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "the model`s design info is empty")
|
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
|
var sizeKeyInfo shopping_cart.SizeInfo
|
||||||
if err = json.Unmarshal([]byte(*sizeInfo.Title), &sizeKeyInfo); err != nil {
|
if err = json.Unmarshal([]byte(*sizeInfo.Title), &sizeKeyInfo); err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
|
@ -174,6 +191,10 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
||||||
Qrcode: req.DiyInfo.Qrcode,
|
Qrcode: req.DiyInfo.Qrcode,
|
||||||
Slogan: req.DiyInfo.Slogan,
|
Slogan: req.DiyInfo.Slogan,
|
||||||
},
|
},
|
||||||
|
LightInfo: shopping_cart.LightInfo{
|
||||||
|
LightJson: lightJson,
|
||||||
|
LightName: lightName,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
snapshotJsonBytes, _ := json.Marshal(snapshot)
|
snapshotJsonBytes, _ := json.Marshal(snapshot)
|
||||||
snapshotJsonStr := string(snapshotJsonBytes)
|
snapshotJsonStr := string(snapshotJsonBytes)
|
||||||
|
@ -183,6 +204,7 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
||||||
ProductId: &req.ProductId,
|
ProductId: &req.ProductId,
|
||||||
TemplateId: &req.TemplateId,
|
TemplateId: &req.TemplateId,
|
||||||
ModelId: &modelInfo.Id,
|
ModelId: &modelInfo.Id,
|
||||||
|
LightId: modelInfo.Light,
|
||||||
SizeId: &req.SizeId,
|
SizeId: &req.SizeId,
|
||||||
FittingId: &req.FittingId,
|
FittingId: &req.FittingId,
|
||||||
PurchaseQuantity: &req.PurchaseQuantity,
|
PurchaseQuantity: &req.PurchaseQuantity,
|
||||||
|
|
|
@ -11,6 +11,7 @@ type CartSnapshot struct {
|
||||||
SizeInfo SizeInfo `json:"size_info"` //尺寸基本信息
|
SizeInfo SizeInfo `json:"size_info"` //尺寸基本信息
|
||||||
ProductInfo ProductInfo `json:"product_info"` //产品基本信息(只记录不要使用)
|
ProductInfo ProductInfo `json:"product_info"` //产品基本信息(只记录不要使用)
|
||||||
UserDiyInformation UserDiyInformation `json:"user_diy_information"` //用户diy数据
|
UserDiyInformation UserDiyInformation `json:"user_diy_information"` //用户diy数据
|
||||||
|
LightInfo LightInfo `json:"light_info"` //灯光数据
|
||||||
}
|
}
|
||||||
type ProductInfo struct {
|
type ProductInfo struct {
|
||||||
ProductName string `json:"product_name"`
|
ProductName string `json:"product_name"`
|
||||||
|
@ -39,3 +40,7 @@ type UserDiyInformation struct {
|
||||||
Qrcode string `json:"qrcode"` //二维码
|
Qrcode string `json:"qrcode"` //二维码
|
||||||
Slogan string `json:"slogan"` //slogan
|
Slogan string `json:"slogan"` //slogan
|
||||||
}
|
}
|
||||||
|
type LightInfo struct {
|
||||||
|
LightJson string `json:"light_json"` //灯光设计json数据
|
||||||
|
LightName string `json:"light_name"` //名称
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user