From a7f21da8da4f8356f9f43087e28587ff68203533 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 25 Sep 2023 11:16:55 +0800 Subject: [PATCH 1/3] fix --- model/gmodel/fs_address_gen.go | 32 +++++++------- model/gmodel/fs_address_logic.go | 28 ++++++------- model/gmodel/fs_change_code_gen.go | 15 +++---- model/gmodel/fs_product_gen.go | 1 + model/gmodel/fs_product_model3d_gen.go | 42 ++++++++++--------- .../internal/logic/getfittingbypidlogic.go | 2 +- .../internal/logic/calculatecartpricelogic.go | 2 +- .../internal/logic/getcartslogic.go | 2 +- service/repositories/order.go | 2 +- 9 files changed, 67 insertions(+), 59 deletions(-) diff --git a/model/gmodel/fs_address_gen.go b/model/gmodel/fs_address_gen.go index 17988dd6..b6085c7d 100644 --- a/model/gmodel/fs_address_gen.go +++ b/model/gmodel/fs_address_gen.go @@ -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 diff --git a/model/gmodel/fs_address_logic.go b/model/gmodel/fs_address_logic.go index c346c507..08b747f2 100755 --- a/model/gmodel/fs_address_logic.go +++ b/model/gmodel/fs_address_logic.go @@ -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 } diff --git a/model/gmodel/fs_change_code_gen.go b/model/gmodel/fs_change_code_gen.go index 780107b5..e11f8524 100644 --- a/model/gmodel/fs_change_code_gen.go +++ b/model/gmodel/fs_change_code_gen.go @@ -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 diff --git a/model/gmodel/fs_product_gen.go b/model/gmodel/fs_product_gen.go index 52b458ba..c9010248 100644 --- a/model/gmodel/fs_product_gen.go +++ b/model/gmodel/fs_product_gen.go @@ -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 diff --git a/model/gmodel/fs_product_model3d_gen.go b/model/gmodel/fs_product_model3d_gen.go index 51b4e511..527e4b4d 100644 --- a/model/gmodel/fs_product_model3d_gen.go +++ b/model/gmodel/fs_product_model3d_gen.go @@ -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 diff --git a/server/product/internal/logic/getfittingbypidlogic.go b/server/product/internal/logic/getfittingbypidlogic.go index 53db5460..30d1c9d8 100644 --- a/server/product/internal/logic/getfittingbypidlogic.go +++ b/server/product/internal/logic/getfittingbypidlogic.go @@ -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, }) diff --git a/server/shopping-cart/internal/logic/calculatecartpricelogic.go b/server/shopping-cart/internal/logic/calculatecartpricelogic.go index fc461746..4747760e 100644 --- a/server/shopping-cart/internal/logic/calculatecartpricelogic.go +++ b/server/shopping-cart/internal/logic/calculatecartpricelogic.go @@ -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)) diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index 1f798027..bd87a7ac 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -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)) } diff --git a/service/repositories/order.go b/service/repositories/order.go index e9aa19d8..4e5b135d 100644 --- a/service/repositories/order.go +++ b/service/repositories/order.go @@ -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" From d8d91e92707d7845cc4e2eb0b6d3d0c28301405f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 25 Sep 2023 11:34:53 +0800 Subject: [PATCH 2/3] fix --- model/gmodel/fs_product_model3d_gen.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/model/gmodel/fs_product_model3d_gen.go b/model/gmodel/fs_product_model3d_gen.go index 527e4b4d..51024e2c 100644 --- a/model/gmodel/fs_product_model3d_gen.go +++ b/model/gmodel/fs_product_model3d_gen.go @@ -21,13 +21,14 @@ type FsProductModel3d struct { 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"` // 添加时间 + Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" 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"` // + StepPrice *[]byte `gorm:"default:'';" json:"step_price"` // } type FsProductModel3dModel struct { db *gorm.DB From 29c7dc54e32a6b0f298fda2d2dd16e54ce252e39 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 25 Sep 2023 15:49:59 +0800 Subject: [PATCH 3/3] fix --- model/gmodel/fs_product_model3d_gen.go | 3 ++- server/product/internal/logic/getfittingbypidlogic.go | 2 +- server/shopping-cart/internal/logic/calculatecartpricelogic.go | 2 +- server/shopping-cart/internal/logic/getcartslogic.go | 2 +- service/repositories/order.go | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/model/gmodel/fs_product_model3d_gen.go b/model/gmodel/fs_product_model3d_gen.go index 51024e2c..884d73e4 100644 --- a/model/gmodel/fs_product_model3d_gen.go +++ b/model/gmodel/fs_product_model3d_gen.go @@ -23,12 +23,13 @@ type FsProductModel3d struct { Status *int64 `gorm:"default:0;" json:"status"` // 状态位 显示 删除 Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` // OptionTemplate *int64 `gorm:"default:0;" json:"option_template"` // 配件绑定的公共模板 - FittingPrice *int64 `gorm:"default:0;" json:"fitting_price"` // 仅配件用,配件的价格, 单位:美分 + 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"` // 是否设置为云渲染模型 Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` // StepPrice *[]byte `gorm:"default:'';" json:"step_price"` // + PackedUnit *int64 `gorm:"default:0;" json:"packed_unit"` // } type FsProductModel3dModel struct { db *gorm.DB diff --git a/server/product/internal/logic/getfittingbypidlogic.go b/server/product/internal/logic/getfittingbypidlogic.go index 30d1c9d8..53db5460 100644 --- a/server/product/internal/logic/getfittingbypidlogic.go +++ b/server/product/internal/logic/getfittingbypidlogic.go @@ -111,7 +111,7 @@ func (l *GetFittingByPidLogic) GetFittingByPid(req *types.GetFittingByPidReq, us Id: fitting.Id, MaterialImg: materialImg, Title: *fitting.Title, - Price: *fitting.FittingPrice, + Price: *fitting.Price, ModelInfo: modelInfo, IsPopular: *fitting.IsHot > 0, }) diff --git a/server/shopping-cart/internal/logic/calculatecartpricelogic.go b/server/shopping-cart/internal/logic/calculatecartpricelogic.go index 4747760e..fc461746 100644 --- a/server/shopping-cart/internal/logic/calculatecartpricelogic.go +++ b/server/shopping-cart/internal/logic/calculatecartpricelogic.go @@ -93,7 +93,7 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri } mapFitting := make(map[int64]int64) for _, v := range fittingList { - mapFitting[v.Id] = *v.FittingPrice + mapFitting[v.Id] = *v.Price } //开始计算价格 calculateResultList := make([]types.CalculateResultItem, 0, len(req.CalculateList)) diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index bd87a7ac..1f798027 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -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.FittingPrice + fittingPrice = *curFittingInfo.Price } else { return resp.SetStatusWithMessage(basic.CodeServiceErr, fmt.Sprintf("cart contain some one witch lose fitting:%d", *cart.FittingId)) } diff --git a/service/repositories/order.go b/service/repositories/order.go index 974be1ca..57364a00 100644 --- a/service/repositories/order.go +++ b/service/repositories/order.go @@ -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.FittingPrice) + productPrice, productTotalPrice, stepNum, stepPrice, err := NewShoppingCart(tx, nil, nil).CaculateCartPrice(*shoppingCart.PurchaseQuantity, shoppingCartProductPrice, *shoppingCart.ShoppingCartProductModel3dFitting.Price) if err != nil { errorCode = *basic.CodeErrOrderCreatProductPriceAbsent errorCode.Message = "create order failed, step price of product '" + shoppingCartSnapshot.ProductInfo.ProductName + "'is failed"