fix
This commit is contained in:
parent
c34811df83
commit
a7f21da8da
|
@ -2,24 +2,28 @@ package gmodel
|
|||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// fs_address 用户地址表
|
||||
type FsAddress struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||
Name *string `gorm:"default:'';" json:"name"` // 地址名称
|
||||
FirstName *string `gorm:"default:'';" json:"first_name"` // FirstName
|
||||
LastName *string `gorm:"default:'';" json:"last_name"` // LastName
|
||||
Mobile *string `gorm:"default:'';" json:"mobile"` // 手机号码
|
||||
Street *string `gorm:"default:'';" json:"street"` // 街道
|
||||
Suite *string `gorm:"default:'';" json:"suite"` // 房号
|
||||
City *string `gorm:"default:'';" json:"city"` // 城市
|
||||
State *string `gorm:"default:'';" json:"state"` //
|
||||
Country *string `gorm:"default:'';" json:"country"` //
|
||||
ZipCode *string `gorm:"default:'';" json:"zip_code"` //
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 1正常 0异常
|
||||
IsDefault *int64 `gorm:"index;default:0;" json:"is_default"` // 1默认地址,0非默认地址
|
||||
AddressId int64 `gorm:"primary_key;default:0;auto_increment;" json:"address_id"` //
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID
|
||||
AddressName *string `gorm:"default:'';" json:"address_name"` //
|
||||
FirstName *string `gorm:"default:'';" json:"first_name"` // FirstName
|
||||
LastName *string `gorm:"default:'';" json:"last_name"` // LastName
|
||||
Mobile *string `gorm:"default:'';" json:"mobile"` // 手机号码
|
||||
Street *string `gorm:"default:'';" json:"street"` // 街道
|
||||
Suite *string `gorm:"default:'';" json:"suite"` // 房号
|
||||
City *string `gorm:"default:'';" json:"city"` // 城市
|
||||
State *string `gorm:"default:'';" json:"state"` //
|
||||
Country *string `gorm:"default:'';" json:"country"` //
|
||||
ZipCode *string `gorm:"default:'';" json:"zip_code"` //
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 1正常 0异常
|
||||
IsDefault *int64 `gorm:"index;default:0;" json:"is_default"` // 1默认地址,0非默认地址
|
||||
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"` // 更新时间
|
||||
Ltime *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"ltime"` // 上次被使用的时间
|
||||
}
|
||||
type FsAddressModel struct {
|
||||
db *gorm.DB
|
||||
|
|
|
@ -24,19 +24,19 @@ func (a *FsAddressModel) CreateOne(ctx context.Context, address *FsAddress) (res
|
|||
err = a.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
// now := time.Now().UTC().Unix()
|
||||
result = &FsAddress{
|
||||
UserId: address.UserId,
|
||||
Name: address.Name,
|
||||
FirstName: address.FirstName,
|
||||
LastName: address.LastName,
|
||||
Mobile: address.Mobile,
|
||||
Street: address.Street,
|
||||
Suite: address.Suite,
|
||||
City: address.City,
|
||||
State: address.State,
|
||||
Country: address.Country,
|
||||
ZipCode: address.ZipCode,
|
||||
Status: address.Status,
|
||||
IsDefault: address.IsDefault,
|
||||
UserId: address.UserId,
|
||||
AddressName: address.AddressName,
|
||||
FirstName: address.FirstName,
|
||||
LastName: address.LastName,
|
||||
Mobile: address.Mobile,
|
||||
Street: address.Street,
|
||||
Suite: address.Suite,
|
||||
City: address.City,
|
||||
State: address.State,
|
||||
Country: address.Country,
|
||||
ZipCode: address.ZipCode,
|
||||
Status: address.Status,
|
||||
IsDefault: address.IsDefault,
|
||||
}
|
||||
|
||||
return tx.Create(result).Error
|
||||
|
@ -57,7 +57,7 @@ func (a *FsAddressModel) UpdateAddAddress(ctx context.Context, address *FsAddres
|
|||
return err
|
||||
}
|
||||
}
|
||||
return tx.Model(&FsAddress{}).Where("id = ? and user_id = ?", address.Id, address.UserId).Omit("id", "user_id").Updates(address).Error
|
||||
return tx.Model(&FsAddress{}).Where("id = ? and user_id = ?", address.AddressId, address.UserId).Omit("id", "user_id").Updates(address).Error
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -2,17 +2,18 @@ package gmodel
|
|||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// fs_change_code 忘记密码code表
|
||||
type FsChangeCode struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
||||
Email *string `gorm:"default:'';" json:"email"` //
|
||||
Code *string `gorm:"default:'';" json:"code"` //
|
||||
CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // 创建时间
|
||||
IsUse *int64 `gorm:"default:0;" json:"is_use"` // 是否使用 1已使用 0未使用
|
||||
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
|
||||
Module *string `gorm:"default:'logo';" json:"module"` //
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
|
||||
Email *string `gorm:"default:'';" json:"email"` //
|
||||
Code *string `gorm:"default:'';" json:"code"` //
|
||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
|
||||
IsUse *int64 `gorm:"default:0;" json:"is_use"` // 是否使用 1已使用 0未使用
|
||||
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
|
||||
Module *string `gorm:"default:'logo';" json:"module"` //
|
||||
}
|
||||
type FsChangeCodeModel struct {
|
||||
db *gorm.DB
|
||||
|
|
|
@ -36,6 +36,7 @@ type FsProduct struct {
|
|||
RecommendProductSort *string `gorm:"default:'';" json:"recommend_product_sort"` //
|
||||
SceneIds *string `gorm:"default:'';" json:"scene_ids"` //
|
||||
IsCustomization *int64 `gorm:"default:0;" json:"is_customization"` // 是否可定制
|
||||
Unit *string `gorm:"default:'';" json:"unit"` //
|
||||
}
|
||||
type FsProductModel struct {
|
||||
db *gorm.DB
|
||||
|
|
|
@ -2,30 +2,32 @@ package gmodel
|
|||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// fs_product_model3d 产品模型表
|
||||
type FsProductModel3d struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
||||
Tag *int64 `gorm:"default:1;" json:"tag"` // 类别(1:模型,2:配件,3:场景)
|
||||
Title *string `gorm:"default:'';" json:"title"` // 标题
|
||||
Name *string `gorm:"default:'';" json:"name"` // 详情页展示名称
|
||||
ModelInfo *string `gorm:"default:'';" json:"model_info"` // 模型详情
|
||||
MaterialId *int64 `gorm:"default:0;" json:"material_id"` // 材质ID
|
||||
SizeId *int64 `gorm:"default:0;" json:"size_id"` // 尺寸ID
|
||||
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
||||
Light *int64 `gorm:"default:0;" json:"light"` // 灯光组
|
||||
LightList *string `gorm:"default:'';" json:"light_list"` // 灯光备选项
|
||||
PartId *int64 `gorm:"default:0;" json:"part_id"` // 配件选项id(配件就是模型的id)
|
||||
PartList *string `gorm:"default:'';" json:"part_list"` //
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 显示 删除
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
OptionTemplate *int64 `gorm:"default:0;" json:"option_template"` // 配件绑定的公共模板
|
||||
Price *int64 `gorm:"default:0;" json:"price"` // 仅配件用,配件的价格, 单位:美分
|
||||
Sku *string `gorm:"default:'';" json:"sku"` // sku
|
||||
IsHot *int64 `gorm:"default:0;" json:"is_hot"` // 是否热门
|
||||
IsCloudRender *int64 `gorm:"default:0;" json:"is_cloud_render"` // 是否设置为云渲染模型
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
|
||||
ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID
|
||||
Tag *int64 `gorm:"default:1;" json:"tag"` // 类别(1:模型,2:配件,3:场景)
|
||||
Title *string `gorm:"default:'';" json:"title"` // 标题
|
||||
Name *string `gorm:"default:'';" json:"name"` // 详情页展示名称
|
||||
ModelInfo *string `gorm:"default:'';" json:"model_info"` // 模型详情
|
||||
MaterialId *int64 `gorm:"default:0;" json:"material_id"` // 材质ID
|
||||
SizeId *int64 `gorm:"default:0;" json:"size_id"` // 尺寸ID
|
||||
Sort *int64 `gorm:"default:0;" json:"sort"` // 排序
|
||||
Light *int64 `gorm:"default:0;" json:"light"` // 灯光组
|
||||
LightList *string `gorm:"default:'';" json:"light_list"` // 灯光备选项
|
||||
PartId *int64 `gorm:"default:0;" json:"part_id"` // 配件选项id(配件就是模型的id)
|
||||
PartList *string `gorm:"default:'';" json:"part_list"` //
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 显示 删除
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
OptionTemplate *int64 `gorm:"default:0;" json:"option_template"` // 配件绑定的公共模板
|
||||
FittingPrice *int64 `gorm:"default:0;" json:"fitting_price"` // 仅配件用,配件的价格, 单位:美分
|
||||
Sku *string `gorm:"default:'';" json:"sku"` // sku
|
||||
IsHot *int64 `gorm:"default:0;" json:"is_hot"` // 是否热门
|
||||
IsCloudRender *int64 `gorm:"default:0;" json:"is_cloud_render"` // 是否设置为云渲染模型
|
||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
|
||||
}
|
||||
type FsProductModel3dModel struct {
|
||||
db *gorm.DB
|
||||
|
|
|
@ -111,7 +111,7 @@ func (l *GetFittingByPidLogic) GetFittingByPid(req *types.GetFittingByPidReq, us
|
|||
Id: fitting.Id,
|
||||
MaterialImg: materialImg,
|
||||
Title: *fitting.Title,
|
||||
Price: *fitting.Price,
|
||||
Price: *fitting.FittingPrice,
|
||||
ModelInfo: modelInfo,
|
||||
IsPopular: *fitting.IsHot > 0,
|
||||
})
|
||||
|
|
|
@ -93,7 +93,7 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
|||
}
|
||||
mapFitting := make(map[int64]int64)
|
||||
for _, v := range fittingList {
|
||||
mapFitting[v.Id] = *v.Price
|
||||
mapFitting[v.Id] = *v.FittingPrice
|
||||
}
|
||||
//开始计算价格
|
||||
calculateResultList := make([]types.CalculateResultItem, 0, len(req.CalculateList))
|
||||
|
|
|
@ -109,7 +109,7 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo
|
|||
fittingPrice := int64(0)
|
||||
if *cart.FittingId > 0 {
|
||||
if curFittingInfo, ok := mapModel[*cart.FittingId]; ok {
|
||||
fittingPrice = *curFittingInfo.Price
|
||||
fittingPrice = *curFittingInfo.FittingPrice
|
||||
} else {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, fmt.Sprintf("cart contain some one witch lose fitting:%d", *cart.FittingId))
|
||||
}
|
||||
|
|
|
@ -838,7 +838,7 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||
}
|
||||
|
||||
/* 计算价格 */
|
||||
productPrice, productTotalPrice, stepNum, stepPrice, err := NewShoppingCart(tx, nil, nil).CaculateCartPrice(*shoppingCart.PurchaseQuantity, shoppingCartProductPrice, *shoppingCart.ShoppingCartProductModel3dFitting.Price)
|
||||
productPrice, productTotalPrice, stepNum, stepPrice, err := NewShoppingCart(tx, nil, nil).CaculateCartPrice(*shoppingCart.PurchaseQuantity, shoppingCartProductPrice, *shoppingCart.ShoppingCartProductModel3dFitting.FittingPrice)
|
||||
if err != nil {
|
||||
errorCode = *basic.CodeErrOrderCreatProductPriceAbsent
|
||||
errorCode.Message = "create order failed, step price of product '" + shoppingCartSnapshot.ProductInfo.ProductName + "'is failed"
|
||||
|
|
Loading…
Reference in New Issue
Block a user