diff --git a/model/gmodel/fs_shopping_cart_logic.go b/model/gmodel/fs_shopping_cart_logic.go index 219b5649..03999452 100644 --- a/model/gmodel/fs_shopping_cart_logic.go +++ b/model/gmodel/fs_shopping_cart_logic.go @@ -33,7 +33,6 @@ type FsShoppingCartData struct { Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` // } -// 快照json数据结构 // 购物车快照数据结构 type CartSnapshot struct { Logo string `json:"logo"` //logo地址 @@ -60,8 +59,9 @@ type FittingInfo struct { } type TemplateInfo struct { - TemplateJson interface{} `json:"template_json"` //模板设计json数据 - TemplateTag string `json:"template_tag"` //模板标签 + TemplateJson interface{} `json:"template_json"` //模板设计json数据 + TemplateTag string `json:"template_tag"` //模板标签 + SelectColorIndex int64 `json:"select_color_index"` //颜色选择索引 } type SizeInfo struct { Inch string `json:"inch"` diff --git a/server/shopping-cart/internal/logic/addtocartlogic.go b/server/shopping-cart/internal/logic/addtocartlogic.go index 2e28b3ef..3552107e 100644 --- a/server/shopping-cart/internal/logic/addtocartlogic.go +++ b/server/shopping-cart/internal/logic/addtocartlogic.go @@ -210,8 +210,9 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI CombineImage: req.CombineImage, RenderImage: req.RenderImage, TemplateInfo: gmodel.TemplateInfo{ - TemplateJson: templateJson, - TemplateTag: templateTag, + TemplateJson: templateJson, + TemplateTag: templateTag, + SelectColorIndex: req.SelectColorIndex, }, ModelInfo: gmodel.ModelInfo{ ModelJson: modelJson, @@ -275,6 +276,9 @@ func (l *AddToCartLogic) AddToCartParamVerify(req *types.AddToCartReq) error { if req.RenderImage == "" { return errors.New("render image is required") } + if req.SelectColorIndex < 0 { + return errors.New("invalid select color index") + } return nil } diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index 220cbf02..08693e07 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -202,6 +202,7 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo TemplateTag: templateTag, Logo: snapShot.Logo, RenderImage: snapShot.RenderImage, + SelectColorIndex: snapShot.TemplateInfo.SelectColorIndex, } //是否有失效的 if description, ok := mapCartChange[cart.Id]; ok { diff --git a/server/shopping-cart/internal/types/types.go b/server/shopping-cart/internal/types/types.go index 00a1f942..e9d40970 100644 --- a/server/shopping-cart/internal/types/types.go +++ b/server/shopping-cart/internal/types/types.go @@ -8,6 +8,7 @@ import ( type AddToCartReq struct { ProductId int64 `json:"product_id"` //产品id TemplateId int64 `json:"template_id,optional"` //模板id(不可定制的不传) + SelectColorIndex int64 `json:"select_color_index"` //选择的颜色索引 SizeId int64 `json:"size_id"` //尺寸id FittingId int64 `json:"fitting_id,optional"` //配件id(没有可以不传) PurchaseQuantity int64 `json:"purchase_quantity"` //购买数量 @@ -54,6 +55,7 @@ type CartItem struct { InvalidDescription string `json:"invalid_description"` //无效原因 IsSelected bool `json:"is_selected"` //是否选中 TemplateTag string `json:"template_tag"` //模板标签 + SelectColorIndex int64 `json:"select_color_index"` //选择的颜色索引 Logo string `json:"logo"` RenderImage string `json:"render_image"` //渲染结果图 } diff --git a/server_api/shopping-cart.api b/server_api/shopping-cart.api index a16732a5..f280c418 100644 --- a/server_api/shopping-cart.api +++ b/server_api/shopping-cart.api @@ -27,6 +27,7 @@ service shopping-cart { type AddToCartReq { ProductId int64 `json:"product_id"` //产品id TemplateId int64 `json:"template_id,optional"` //模板id(不可定制的不传) + SelectColorIndex int64 `json:"select_color_index"` //选择的颜色索引 SizeId int64 `json:"size_id"` //尺寸id FittingId int64 `json:"fitting_id,optional"` //配件id(没有可以不传) PurchaseQuantity int64 `json:"purchase_quantity"` //购买数量 @@ -71,6 +72,7 @@ type CartItem { InvalidDescription string `json:"invalid_description"` //无效原因 IsSelected bool `json:"is_selected"` //是否选中 TemplateTag string `json:"template_tag"` //模板标签 + SelectColorIndex int64 `json:"select_color_index"` //选择的颜色索引 Logo string `json:"logo"` RenderImage string `json:"render_image"` //渲染结果图 }