fix
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/file"
|
||||
"fusenapi/utils/hash"
|
||||
"fusenapi/utils/s3url_to_s3id"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -54,6 +55,20 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
||||
if cartCount >= 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
|
||||
if !strings.Contains(req.RenderImage, "https://") {
|
||||
//上传base64文件
|
||||
@@ -206,9 +221,10 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
|
||||
sizeKeyInfo.Capacity = *sizeInfo.Capacity
|
||||
//快照数据
|
||||
snapshot := gmodel.CartSnapshot{
|
||||
Logo: req.Logo,
|
||||
CombineImage: req.CombineImage,
|
||||
RenderImage: req.RenderImage,
|
||||
Logo: req.Logo,
|
||||
LogoMaterialMetadata: logoMaterialMetadata,
|
||||
CombineImage: req.CombineImage,
|
||||
RenderImage: req.RenderImage,
|
||||
TemplateInfo: gmodel.TemplateInfo{
|
||||
TemplateJson: templateJson,
|
||||
TemplateTag: templateTag,
|
||||
@@ -268,7 +284,7 @@ func (l *AddToCartLogic) AddToCartParamVerify(req *types.AddToCartReq) error {
|
||||
return errors.New("product_id is required")
|
||||
}
|
||||
if req.SizeId <= 0 {
|
||||
return errors.New("product size is required")
|
||||
return errors.New("product size id is required")
|
||||
}
|
||||
if req.PurchaseQuantity <= 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 {
|
||||
return errors.New("invalid select color index")
|
||||
}
|
||||
if req.Logo == "" {
|
||||
return errors.New("logo is required")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user