fix
This commit is contained in:
parent
ee37c10399
commit
6c7ef6e92e
@ -4,7 +4,7 @@ import (
|
|||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// fs_product_template_v2 产品-模型-模板表
|
// fs_product_template_v2 产品-模型- 模板表
|
||||||
type FsProductTemplateV2 struct {
|
type FsProductTemplateV2 struct {
|
||||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
||||||
@ -17,14 +17,16 @@ type FsProductTemplateV2 struct {
|
|||||||
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
||||||
LogoWidth *int64 `gorm:"default:0;" json:"logo_width"` // logo图最大宽度
|
LogoWidth *int64 `gorm:"default:0;" json:"logo_width"` // logo图最大宽度
|
||||||
LogoHeight *int64 `gorm:"default:0;" json:"logo_height"` // logo图最大高度
|
LogoHeight *int64 `gorm:"default:0;" json:"logo_height"` // logo图最大高度
|
||||||
IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以)
|
IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以,仅供模型关联)
|
||||||
|
IsPublicTemplate *int64 `gorm:"default:0;" json:"is_public_template"` // 是否是公共模板0非1是(仅针对模板之间)
|
||||||
|
RelativePublicTemplateLevelPrefix *string `gorm:"default:'';" json:"relative_public_template_level_prefix"` //
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常
|
Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常
|
||||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
|
||||||
TemplateTag *string `gorm:"default:'';" json:"template_tag"` //
|
TemplateTag *string `gorm:"default:'';" json:"template_tag"` //
|
||||||
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
|
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
|
||||||
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // 开关信息
|
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // 开关信息
|
||||||
Version *int64 `gorm:"default:0;" json:"version"` // 默认1
|
Version *int64 `gorm:"default:0;" json:"version"` // 默认1
|
||||||
ElementModelId *int64 `gorm:"default:0;" json:"element_model_id"` // 云渲染对应模型id
|
ElementModelId *int64 `gorm:"default:0;" json:"element_model_id"` // 云渲染对应模型id
|
||||||
|
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||||
}
|
}
|
||||||
type FsProductTemplateV2Model struct {
|
type FsProductTemplateV2Model struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
@ -36,6 +36,7 @@ type FsShoppingCartData struct {
|
|||||||
// 购物车快照数据结构
|
// 购物车快照数据结构
|
||||||
type CartSnapshot struct {
|
type CartSnapshot struct {
|
||||||
Logo string `json:"logo"` //logo地址
|
Logo string `json:"logo"` //logo地址
|
||||||
|
LogoMaterialMetadata interface{} `json:"logo_material_metadata"` //logo素材信息
|
||||||
CombineImage string `json:"combine_image"` //刀版图地址
|
CombineImage string `json:"combine_image"` //刀版图地址
|
||||||
RenderImage string `json:"render_image"` //渲染结果图
|
RenderImage string `json:"render_image"` //渲染结果图
|
||||||
TemplateInfo TemplateInfo `json:"template_info"` //模板数据
|
TemplateInfo TemplateInfo `json:"template_info"` //模板数据
|
||||||
|
@ -53,6 +53,7 @@ type AllModelsGen struct {
|
|||||||
FsGuest *FsGuestModel // fs_guest 游客表
|
FsGuest *FsGuestModel // fs_guest 游客表
|
||||||
FsLog *FsLogModel // fs_log 日志表
|
FsLog *FsLogModel // fs_log 日志表
|
||||||
FsLogoCartoon *FsLogoCartoonModel // fs_logo_cartoon logo底图表
|
FsLogoCartoon *FsLogoCartoonModel // fs_logo_cartoon logo底图表
|
||||||
|
FsLogoPreprocess *FsLogoPreprocessModel // fs_logo_preprocess
|
||||||
FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库
|
FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库
|
||||||
FsMenu *FsMenuModel // fs_menu 后台菜单
|
FsMenu *FsMenuModel // fs_menu 后台菜单
|
||||||
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
|
FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表
|
||||||
@ -72,6 +73,7 @@ type AllModelsGen struct {
|
|||||||
FsProductCopy1 *FsProductCopy1Model // fs_product_copy1 产品表
|
FsProductCopy1 *FsProductCopy1Model // fs_product_copy1 产品表
|
||||||
FsProductDesign *FsProductDesignModel // fs_product_design 产品设计表
|
FsProductDesign *FsProductDesignModel // fs_product_design 产品设计表
|
||||||
FsProductDesignGather *FsProductDesignGatherModel // fs_product_design_gather
|
FsProductDesignGather *FsProductDesignGatherModel // fs_product_design_gather
|
||||||
|
FsProductHistoryTemplate *FsProductHistoryTemplateModel // fs_product_history_template 模板历史表
|
||||||
FsProductModel3d *FsProductModel3dModel // fs_product_model3d 产品模型表
|
FsProductModel3d *FsProductModel3dModel // fs_product_model3d 产品模型表
|
||||||
FsProductModel3dLight *FsProductModel3dLightModel // fs_product_model3d_light 模型-灯光组表
|
FsProductModel3dLight *FsProductModel3dLightModel // fs_product_model3d_light 模型-灯光组表
|
||||||
FsProductOption *FsProductOptionModel // fs_product_option 产品选项表(已废弃)
|
FsProductOption *FsProductOptionModel // fs_product_option 产品选项表(已废弃)
|
||||||
@ -83,7 +85,6 @@ type AllModelsGen struct {
|
|||||||
FsProductTemplate *FsProductTemplateModel // fs_product_template 产品模板表(已废弃)
|
FsProductTemplate *FsProductTemplateModel // fs_product_template 产品模板表(已废弃)
|
||||||
FsProductTemplateBasemap *FsProductTemplateBasemapModel // fs_product_template_basemap 模板底图表
|
FsProductTemplateBasemap *FsProductTemplateBasemapModel // fs_product_template_basemap 模板底图表
|
||||||
FsProductTemplateElement *FsProductTemplateElementModel // fs_product_template_element 云渲染配置表
|
FsProductTemplateElement *FsProductTemplateElementModel // fs_product_template_element 云渲染配置表
|
||||||
FsProductTemplateElement22 *FsProductTemplateElement22Model // fs_product_template_element_22
|
|
||||||
FsProductTemplateTags *FsProductTemplateTagsModel // fs_product_template_tags 模板标签表
|
FsProductTemplateTags *FsProductTemplateTagsModel // fs_product_template_tags 模板标签表
|
||||||
FsProductTemplateV2 *FsProductTemplateV2Model // fs_product_template_v2 产品-模型-模板表
|
FsProductTemplateV2 *FsProductTemplateV2Model // fs_product_template_v2 产品-模型-模板表
|
||||||
FsProductV2Tmp *FsProductV2TmpModel // fs_product_v2_tmp 产品表
|
FsProductV2Tmp *FsProductV2TmpModel // fs_product_v2_tmp 产品表
|
||||||
@ -166,6 +167,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||||||
FsGuest: NewFsGuestModel(gdb),
|
FsGuest: NewFsGuestModel(gdb),
|
||||||
FsLog: NewFsLogModel(gdb),
|
FsLog: NewFsLogModel(gdb),
|
||||||
FsLogoCartoon: NewFsLogoCartoonModel(gdb),
|
FsLogoCartoon: NewFsLogoCartoonModel(gdb),
|
||||||
|
FsLogoPreprocess: NewFsLogoPreprocessModel(gdb),
|
||||||
FsMapLibrary: NewFsMapLibraryModel(gdb),
|
FsMapLibrary: NewFsMapLibraryModel(gdb),
|
||||||
FsMenu: NewFsMenuModel(gdb),
|
FsMenu: NewFsMenuModel(gdb),
|
||||||
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
|
FsMerchantCategory: NewFsMerchantCategoryModel(gdb),
|
||||||
@ -185,6 +187,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||||||
FsProductCopy1: NewFsProductCopy1Model(gdb),
|
FsProductCopy1: NewFsProductCopy1Model(gdb),
|
||||||
FsProductDesign: NewFsProductDesignModel(gdb),
|
FsProductDesign: NewFsProductDesignModel(gdb),
|
||||||
FsProductDesignGather: NewFsProductDesignGatherModel(gdb),
|
FsProductDesignGather: NewFsProductDesignGatherModel(gdb),
|
||||||
|
FsProductHistoryTemplate: NewFsProductHistoryTemplateModel(gdb),
|
||||||
FsProductModel3d: NewFsProductModel3dModel(gdb),
|
FsProductModel3d: NewFsProductModel3dModel(gdb),
|
||||||
FsProductModel3dLight: NewFsProductModel3dLightModel(gdb),
|
FsProductModel3dLight: NewFsProductModel3dLightModel(gdb),
|
||||||
FsProductOption: NewFsProductOptionModel(gdb),
|
FsProductOption: NewFsProductOptionModel(gdb),
|
||||||
@ -196,7 +199,6 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
|
|||||||
FsProductTemplate: NewFsProductTemplateModel(gdb),
|
FsProductTemplate: NewFsProductTemplateModel(gdb),
|
||||||
FsProductTemplateBasemap: NewFsProductTemplateBasemapModel(gdb),
|
FsProductTemplateBasemap: NewFsProductTemplateBasemapModel(gdb),
|
||||||
FsProductTemplateElement: NewFsProductTemplateElementModel(gdb),
|
FsProductTemplateElement: NewFsProductTemplateElementModel(gdb),
|
||||||
FsProductTemplateElement22: NewFsProductTemplateElement22Model(gdb),
|
|
||||||
FsProductTemplateTags: NewFsProductTemplateTagsModel(gdb),
|
FsProductTemplateTags: NewFsProductTemplateTagsModel(gdb),
|
||||||
FsProductTemplateV2: NewFsProductTemplateV2Model(gdb),
|
FsProductTemplateV2: NewFsProductTemplateV2Model(gdb),
|
||||||
FsProductV2Tmp: NewFsProductV2TmpModel(gdb),
|
FsProductV2Tmp: NewFsProductV2TmpModel(gdb),
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
"fusenapi/utils/file"
|
"fusenapi/utils/file"
|
||||||
"fusenapi/utils/hash"
|
"fusenapi/utils/hash"
|
||||||
|
"fusenapi/utils/s3url_to_s3id"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -54,6 +55,20 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
|||||||
if cartCount >= 100 {
|
if cartCount >= 100 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "sorry,the count of your carts can`t greater than 100")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "sorry,the count of your carts can`t greater than 100")
|
||||||
}
|
}
|
||||||
|
logoResourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(req.Logo)
|
||||||
|
//获取用户素材信息
|
||||||
|
userMaterialInfo, err := l.svcCtx.AllModels.FsUserMaterial.FindOneByLogoResourceId(l.ctx, logoResourceId)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return resp.SetStatusAddMessage(basic.CodeDbRecordNotFoundErr, "the user logo material info is not found")
|
||||||
|
}
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusAddMessage(basic.CodeDbSqlErr, "failed to get user logo material info")
|
||||||
|
}
|
||||||
|
var logoMaterialMetadata interface{}
|
||||||
|
if userMaterialInfo.Metadata != nil && len(*userMaterialInfo.Metadata) != 0 {
|
||||||
|
_ = json.Unmarshal(*userMaterialInfo.Metadata, &logoMaterialMetadata)
|
||||||
|
}
|
||||||
//不是传路径则就是传base64
|
//不是传路径则就是传base64
|
||||||
if !strings.Contains(req.RenderImage, "https://") {
|
if !strings.Contains(req.RenderImage, "https://") {
|
||||||
//上传base64文件
|
//上传base64文件
|
||||||
@ -207,6 +222,7 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
|||||||
//快照数据
|
//快照数据
|
||||||
snapshot := gmodel.CartSnapshot{
|
snapshot := gmodel.CartSnapshot{
|
||||||
Logo: req.Logo,
|
Logo: req.Logo,
|
||||||
|
LogoMaterialMetadata: logoMaterialMetadata,
|
||||||
CombineImage: req.CombineImage,
|
CombineImage: req.CombineImage,
|
||||||
RenderImage: req.RenderImage,
|
RenderImage: req.RenderImage,
|
||||||
TemplateInfo: gmodel.TemplateInfo{
|
TemplateInfo: gmodel.TemplateInfo{
|
||||||
@ -268,7 +284,7 @@ func (l *AddToCartLogic) AddToCartParamVerify(req *types.AddToCartReq) error {
|
|||||||
return errors.New("product_id is required")
|
return errors.New("product_id is required")
|
||||||
}
|
}
|
||||||
if req.SizeId <= 0 {
|
if req.SizeId <= 0 {
|
||||||
return errors.New("product size is required")
|
return errors.New("product size id is required")
|
||||||
}
|
}
|
||||||
if req.PurchaseQuantity <= 0 {
|
if req.PurchaseQuantity <= 0 {
|
||||||
return errors.New("purchase quantity can not less than 0 or equal 0")
|
return errors.New("purchase quantity can not less than 0 or equal 0")
|
||||||
@ -280,6 +296,9 @@ func (l *AddToCartLogic) AddToCartParamVerify(req *types.AddToCartReq) error {
|
|||||||
if req.SelectColorIndex < 0 {
|
if req.SelectColorIndex < 0 {
|
||||||
return errors.New("invalid select color index")
|
return errors.New("invalid select color index")
|
||||||
}
|
}
|
||||||
|
if req.Logo == "" {
|
||||||
|
return errors.New("logo is required")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user