From f2a0c7608e4341cb8d54c06f4d079151e23e40f9 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Mon, 25 Sep 2023 15:58:33 +0800 Subject: [PATCH 1/5] info --- model/gmodel/fs_user_logic.go | 3 +- .../internal/handler/addressaddhandler.go | 35 +++++++++++++++ .../internal/handler/addressdefaulthandler.go | 35 +++++++++++++++ .../internal/handler/addressdeletehandler.go | 35 +++++++++++++++ .../internal/handler/addressupdatehandler.go | 35 +++++++++++++++ server/info/internal/handler/routes.go | 20 +++++++++ server/info/internal/logic/addressaddlogic.go | 43 +++++++++++++++++++ .../internal/logic/addressdefaultlogic.go | 43 +++++++++++++++++++ .../info/internal/logic/addressdeletelogic.go | 43 +++++++++++++++++++ .../info/internal/logic/addressupdatelogic.go | 43 +++++++++++++++++++ server/info/internal/logic/infologic.go | 1 + server/info/internal/types/types.go | 21 +++++++-- server_api/info.api | 25 +++++++++++ 13 files changed, 376 insertions(+), 6 deletions(-) create mode 100644 server/info/internal/handler/addressaddhandler.go create mode 100644 server/info/internal/handler/addressdefaulthandler.go create mode 100644 server/info/internal/handler/addressdeletehandler.go create mode 100644 server/info/internal/handler/addressupdatehandler.go create mode 100644 server/info/internal/logic/addressaddlogic.go create mode 100644 server/info/internal/logic/addressdefaultlogic.go create mode 100644 server/info/internal/logic/addressdeletelogic.go create mode 100644 server/info/internal/logic/addressupdatelogic.go diff --git a/model/gmodel/fs_user_logic.go b/model/gmodel/fs_user_logic.go index 24d0a1a4..439178d4 100644 --- a/model/gmodel/fs_user_logic.go +++ b/model/gmodel/fs_user_logic.go @@ -9,7 +9,6 @@ import ( "fusenapi/utils/fssql" "time" - "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" ) @@ -222,7 +221,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT Utime: &now, } - logx.Error(metadata) + // logx.Error(metadata) err = txUserInfo.Where("module = 'profile' and user_id = ?", *uinfo.UserId).Take(nil).Error if err != nil { diff --git a/server/info/internal/handler/addressaddhandler.go b/server/info/internal/handler/addressaddhandler.go new file mode 100644 index 00000000..0e02dc4b --- /dev/null +++ b/server/info/internal/handler/addressaddhandler.go @@ -0,0 +1,35 @@ +package handler + +import ( + "net/http" + "reflect" + + "fusenapi/utils/basic" + + "fusenapi/server/info/internal/logic" + "fusenapi/server/info/internal/svc" + "fusenapi/server/info/internal/types" +) + +func AddressAddHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + + var req types.AddressNameRequest + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) + if err != nil { + return + } + + // 创建一个业务逻辑层实例 + l := logic.NewAddressAddLogic(r.Context(), svcCtx) + + rl := reflect.ValueOf(l) + basic.BeforeLogic(w, r, rl) + + resp := l.AddressAdd(&req, userinfo) + + if !basic.AfterLogic(w, r, rl, resp) { + basic.NormalAfterLogic(w, r, resp) + } + } +} diff --git a/server/info/internal/handler/addressdefaulthandler.go b/server/info/internal/handler/addressdefaulthandler.go new file mode 100644 index 00000000..38920ca7 --- /dev/null +++ b/server/info/internal/handler/addressdefaulthandler.go @@ -0,0 +1,35 @@ +package handler + +import ( + "net/http" + "reflect" + + "fusenapi/utils/basic" + + "fusenapi/server/info/internal/logic" + "fusenapi/server/info/internal/svc" + "fusenapi/server/info/internal/types" +) + +func AddressDefaultHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + + var req types.AddressIdRequest + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) + if err != nil { + return + } + + // 创建一个业务逻辑层实例 + l := logic.NewAddressDefaultLogic(r.Context(), svcCtx) + + rl := reflect.ValueOf(l) + basic.BeforeLogic(w, r, rl) + + resp := l.AddressDefault(&req, userinfo) + + if !basic.AfterLogic(w, r, rl, resp) { + basic.NormalAfterLogic(w, r, resp) + } + } +} diff --git a/server/info/internal/handler/addressdeletehandler.go b/server/info/internal/handler/addressdeletehandler.go new file mode 100644 index 00000000..1a3c64df --- /dev/null +++ b/server/info/internal/handler/addressdeletehandler.go @@ -0,0 +1,35 @@ +package handler + +import ( + "net/http" + "reflect" + + "fusenapi/utils/basic" + + "fusenapi/server/info/internal/logic" + "fusenapi/server/info/internal/svc" + "fusenapi/server/info/internal/types" +) + +func AddressDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + + var req types.AddressIdRequest + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) + if err != nil { + return + } + + // 创建一个业务逻辑层实例 + l := logic.NewAddressDeleteLogic(r.Context(), svcCtx) + + rl := reflect.ValueOf(l) + basic.BeforeLogic(w, r, rl) + + resp := l.AddressDelete(&req, userinfo) + + if !basic.AfterLogic(w, r, rl, resp) { + basic.NormalAfterLogic(w, r, resp) + } + } +} diff --git a/server/info/internal/handler/addressupdatehandler.go b/server/info/internal/handler/addressupdatehandler.go new file mode 100644 index 00000000..9f12456c --- /dev/null +++ b/server/info/internal/handler/addressupdatehandler.go @@ -0,0 +1,35 @@ +package handler + +import ( + "net/http" + "reflect" + + "fusenapi/utils/basic" + + "fusenapi/server/info/internal/logic" + "fusenapi/server/info/internal/svc" + "fusenapi/server/info/internal/types" +) + +func AddressUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + + var req types.AddressObjectRequest + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) + if err != nil { + return + } + + // 创建一个业务逻辑层实例 + l := logic.NewAddressUpdateLogic(r.Context(), svcCtx) + + rl := reflect.ValueOf(l) + basic.BeforeLogic(w, r, rl) + + resp := l.AddressUpdate(&req, userinfo) + + if !basic.AfterLogic(w, r, rl, resp) { + basic.NormalAfterLogic(w, r, resp) + } + } +} diff --git a/server/info/internal/handler/routes.go b/server/info/internal/handler/routes.go index 7fd32e51..c259faea 100644 --- a/server/info/internal/handler/routes.go +++ b/server/info/internal/handler/routes.go @@ -17,6 +17,26 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/api/info/user", Handler: InfoHandler(serverCtx), }, + { + Method: http.MethodPost, + Path: "/api/info/address/default", + Handler: AddressDefaultHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/api/info/address/add", + Handler: AddressAddHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/api/info/address/update", + Handler: AddressUpdateHandler(serverCtx), + }, + { + Method: http.MethodPost, + Path: "/api/info/address/delete", + Handler: AddressDeleteHandler(serverCtx), + }, }, ) } diff --git a/server/info/internal/logic/addressaddlogic.go b/server/info/internal/logic/addressaddlogic.go new file mode 100644 index 00000000..9527b89c --- /dev/null +++ b/server/info/internal/logic/addressaddlogic.go @@ -0,0 +1,43 @@ +package logic + +import ( + "fusenapi/utils/auth" + "fusenapi/utils/basic" + + "context" + + "fusenapi/server/info/internal/svc" + "fusenapi/server/info/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AddressAddLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAddressAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressAddLogic { + return &AddressAddLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +// 处理进入前逻辑w,r +// func (l *AddressAddLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { +// } + +func (l *AddressAddLogic) AddressAdd(req *types.AddressNameRequest, userinfo *auth.UserInfo) (resp *basic.Response) { + // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) + // userinfo 传入值时, 一定不为null + + return resp.SetStatus(basic.CodeOK) +} + +// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 +// func (l *AddressAddLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { +// // httpx.OkJsonCtx(r.Context(), w, resp) +// } diff --git a/server/info/internal/logic/addressdefaultlogic.go b/server/info/internal/logic/addressdefaultlogic.go new file mode 100644 index 00000000..c7ad7067 --- /dev/null +++ b/server/info/internal/logic/addressdefaultlogic.go @@ -0,0 +1,43 @@ +package logic + +import ( + "fusenapi/utils/auth" + "fusenapi/utils/basic" + + "context" + + "fusenapi/server/info/internal/svc" + "fusenapi/server/info/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AddressDefaultLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAddressDefaultLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressDefaultLogic { + return &AddressDefaultLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +// 处理进入前逻辑w,r +// func (l *AddressDefaultLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { +// } + +func (l *AddressDefaultLogic) AddressDefault(req *types.AddressIdRequest, userinfo *auth.UserInfo) (resp *basic.Response) { + // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) + // userinfo 传入值时, 一定不为null + + return resp.SetStatus(basic.CodeOK) +} + +// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 +// func (l *AddressDefaultLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { +// // httpx.OkJsonCtx(r.Context(), w, resp) +// } diff --git a/server/info/internal/logic/addressdeletelogic.go b/server/info/internal/logic/addressdeletelogic.go new file mode 100644 index 00000000..59f37f85 --- /dev/null +++ b/server/info/internal/logic/addressdeletelogic.go @@ -0,0 +1,43 @@ +package logic + +import ( + "fusenapi/utils/auth" + "fusenapi/utils/basic" + + "context" + + "fusenapi/server/info/internal/svc" + "fusenapi/server/info/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AddressDeleteLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAddressDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressDeleteLogic { + return &AddressDeleteLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +// 处理进入前逻辑w,r +// func (l *AddressDeleteLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { +// } + +func (l *AddressDeleteLogic) AddressDelete(req *types.AddressIdRequest, userinfo *auth.UserInfo) (resp *basic.Response) { + // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) + // userinfo 传入值时, 一定不为null + + return resp.SetStatus(basic.CodeOK) +} + +// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 +// func (l *AddressDeleteLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { +// // httpx.OkJsonCtx(r.Context(), w, resp) +// } diff --git a/server/info/internal/logic/addressupdatelogic.go b/server/info/internal/logic/addressupdatelogic.go new file mode 100644 index 00000000..8cdac113 --- /dev/null +++ b/server/info/internal/logic/addressupdatelogic.go @@ -0,0 +1,43 @@ +package logic + +import ( + "fusenapi/utils/auth" + "fusenapi/utils/basic" + + "context" + + "fusenapi/server/info/internal/svc" + "fusenapi/server/info/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type AddressUpdateLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAddressUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressUpdateLogic { + return &AddressUpdateLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +// 处理进入前逻辑w,r +// func (l *AddressUpdateLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { +// } + +func (l *AddressUpdateLogic) AddressUpdate(req *types.AddressObjectRequest, userinfo *auth.UserInfo) (resp *basic.Response) { + // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) + // userinfo 传入值时, 一定不为null + + return resp.SetStatus(basic.CodeOK) +} + +// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 +// func (l *AddressUpdateLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { +// // httpx.OkJsonCtx(r.Context(), w, resp) +// } diff --git a/server/info/internal/logic/infologic.go b/server/info/internal/logic/infologic.go index b166c650..0d08d46b 100644 --- a/server/info/internal/logic/infologic.go +++ b/server/info/internal/logic/infologic.go @@ -39,6 +39,7 @@ func NewInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoLogic { var ModuleTable map[string]string = map[string]string{ "userinfo": "fs_user_info", "material": "fs_user_material", + "address": "fs_address", // TODO: 地址列表 } type ModuleQuery struct { diff --git a/server/info/internal/types/types.go b/server/info/internal/types/types.go index 6edce7d4..3b42e0a9 100644 --- a/server/info/internal/types/types.go +++ b/server/info/internal/types/types.go @@ -9,6 +9,19 @@ type UserInfoRequest struct { Module []string `json:"module"` } +type AddressObjectRequest struct { + AddressId int64 `json:"address_id"` // 地址id + Address string `json:"address"` // 地址 +} + +type AddressIdRequest struct { + AddressId int64 `json:"address_id"` // 地址id +} + +type AddressNameRequest struct { + Address string `json:"address"` // 地址 +} + type Request struct { } @@ -32,10 +45,10 @@ type File struct { } type Meta struct { - TotalCount int64 `json:"totalCount"` - PageCount int64 `json:"pageCount"` - CurrentPage int `json:"currentPage"` - PerPage int `json:"perPage"` + TotalCount int64 `json:"total_count"` + PageCount int64 `json:"page_count"` + CurrentPage int `json:"current_page"` + PerPage int `json:"per_page"` } // Set 设置Response的Code和Message值 diff --git a/server_api/info.api b/server_api/info.api index 966ab832..3e96c43d 100644 --- a/server_api/info.api +++ b/server_api/info.api @@ -12,10 +12,35 @@ import "basic.api" service info { @handler InfoHandler post /api/info/user(UserInfoRequest) returns (response); + + @handler AddressDefaultHandler + post /api/info/address/default(AddressIdRequest) returns (response); + + @handler AddressAddHandler + post /api/info/address/add(AddressNameRequest) returns (response); + + @handler AddressUpdateHandler + post /api/info/address/update(AddressObjectRequest) returns (response); + + @handler AddressDeleteHandler + post /api/info/address/delete(AddressIdRequest) returns (response); } type ( UserInfoRequest { Module []string `json:"module"` } + + AddressObjectRequest { + AddressId int64 `json:"address_id"` // 地址id + Address string `json:"address"` // 地址 + } + + AddressIdRequest { + AddressId int64 `json:"address_id"` // 地址id + } + + AddressNameRequest { + Address string `json:"address"` // 地址 + } ) \ No newline at end of file From 6005f20c5e191e7216ad1bf24623b58e7eee932f Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 25 Sep 2023 16:00:50 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/gmodel/fs_address_gen.go | 32 ++++++++------ model/gmodel/fs_change_code_gen.go | 15 ++++--- model/gmodel/fs_product_gen.go | 1 + model/gmodel/fs_product_model3d_gen.go | 44 ++++++++++--------- .../pay/internal/logic/stripewebhooklogic.go | 1 + 5 files changed, 52 insertions(+), 41 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_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..884d73e4 100644 --- a/model/gmodel/fs_product_model3d_gen.go +++ b/model/gmodel/fs_product_model3d_gen.go @@ -2,30 +2,34 @@ 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 *time.Time `gorm:"default:'0000-00-00 00:00:00';" 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"` // 是否设置为云渲染模型 + 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/pay/internal/logic/stripewebhooklogic.go b/server/pay/internal/logic/stripewebhooklogic.go index f08a0df1..70fe699c 100644 --- a/server/pay/internal/logic/stripewebhooklogic.go +++ b/server/pay/internal/logic/stripewebhooklogic.go @@ -233,6 +233,7 @@ func (l *StripeWebhookLogic) handlePaymentSessionCompleted(sessionId string, tra // 付款成功 func (l *StripeWebhookLogic) HandlePaymentIntentSucceeded(paymentIntent *stripe.PaymentIntent, eventId string) error { + fmt.Println(paymentIntent) // 支付成功 if paymentIntent.Status == "succeeded" { model, ok := paymentIntent.Metadata["model"] From c1203e8989b0b66058177b1c80fcd2a1a7344262 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Mon, 25 Sep 2023 16:01:28 +0800 Subject: [PATCH 3/5] info --- .../internal/logic/useraddaddresslogic.go | 56 +++++++++---------- server_api/info.api | 4 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/server/home-user-auth/internal/logic/useraddaddresslogic.go b/server/home-user-auth/internal/logic/useraddaddresslogic.go index 9b876274..7e3217aa 100644 --- a/server/home-user-auth/internal/logic/useraddaddresslogic.go +++ b/server/home-user-auth/internal/logic/useraddaddresslogic.go @@ -49,42 +49,42 @@ func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, useri isDefautl int64 = 1 // 默认地址为1 ) createOne := &gmodel.FsAddress{ // 构建FsAddress结构体 - Name: &req.Name, - FirstName: &req.FirstName, - LastName: &req.LastName, - Mobile: &req.Mobile, - Street: &req.Street, - Suite: &req.Suite, - City: &req.City, - State: &req.State, - Country: &country, - Status: &status, - UserId: &userinfo.UserId, - ZipCode: &req.ZipCode, - IsDefault: &isDefautl, + AddressName: &req.Name, + FirstName: &req.FirstName, + LastName: &req.LastName, + Mobile: &req.Mobile, + Street: &req.Street, + Suite: &req.Suite, + City: &req.City, + State: &req.State, + Country: &country, + Status: &status, + UserId: &userinfo.UserId, + ZipCode: &req.ZipCode, + IsDefault: &isDefautl, } created, err := m.CreateOne(l.ctx, createOne) // 新增地址 if err != nil { logx.Error(err) // 日志记录错误 return resp.SetStatus(basic.CodeDbCreateErr) // 返回数据库创建错误 } - return resp.SetStatus(basic.CodeOK, map[string]int64{"id": created.Id}) // 返回成功并返回地址ID + return resp.SetStatus(basic.CodeOK, map[string]int64{"id": created.AddressId}) // 返回成功并返回地址ID } address := &gmodel.FsAddress{ - Id: req.Id, - Name: &req.Name, - FirstName: &req.FirstName, - LastName: &req.LastName, - Mobile: &req.Mobile, - Street: &req.Street, - Suite: &req.Suite, - City: &req.City, - State: &req.State, - Status: &status, - UserId: &userinfo.UserId, - ZipCode: &req.ZipCode, - IsDefault: &req.IsDefault, + AddressId: req.Id, + AddressName: &req.Name, + FirstName: &req.FirstName, + LastName: &req.LastName, + Mobile: &req.Mobile, + Street: &req.Street, + Suite: &req.Suite, + City: &req.City, + State: &req.State, + Status: &status, + UserId: &userinfo.UserId, + ZipCode: &req.ZipCode, + IsDefault: &req.IsDefault, } // 插入数据库 更新地址 @@ -94,5 +94,5 @@ func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, useri return resp.SetStatus(basic.CodeDbUpdateErr) } - return resp.SetStatus(basic.CodeOK, map[string]int64{"id": address.Id}) + return resp.SetStatus(basic.CodeOK, map[string]int64{"id": address.AddressId}) } diff --git a/server_api/info.api b/server_api/info.api index 3e96c43d..ce28f486 100644 --- a/server_api/info.api +++ b/server_api/info.api @@ -33,7 +33,7 @@ type ( AddressObjectRequest { AddressId int64 `json:"address_id"` // 地址id - Address string `json:"address"` // 地址 + AddressName string `json:"address_name"` // 地址 } AddressIdRequest { @@ -41,6 +41,6 @@ type ( } AddressNameRequest { - Address string `json:"address"` // 地址 + AddressName string `json:"address_name"` // 地址 } ) \ No newline at end of file From 3c094cf201bee68ce81702ceaead2f52312baadd Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 25 Sep 2023 17:06:12 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/pay/internal/logic/stripewebhooklogic.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/pay/internal/logic/stripewebhooklogic.go b/server/pay/internal/logic/stripewebhooklogic.go index 70fe699c..cc8a954f 100644 --- a/server/pay/internal/logic/stripewebhooklogic.go +++ b/server/pay/internal/logic/stripewebhooklogic.go @@ -57,12 +57,15 @@ func (l *StripeWebhookLogic) StripeWebhook(req *types.StripeWebhookReq, userinfo logc.Errorf(l.ctx, "StripeWebhookLogic StripeWebhook Unmarshal err:%v", err) return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "pay notify Unmarshal fail") } + // fmt.Println(req) + // fmt.Println(event) endpointSecret := l.svcCtx.Config.PayConfig.Stripe.EndpointSecret signatureHeader := req.StripeSignature + fmt.Println(endpointSecret) event, err := webhook.ConstructEvent(req.Payload, signatureHeader, endpointSecret) if err != nil { - logx.Error(err) + logc.Errorf(l.ctx, "webhook.ConstructEvent err:%v", err) return resp.SetStatusWithMessage(basic.CodeAesCbcDecryptionErr, "Webhook signature verification failed") } From 07185fdb469b32fd299655ae1eea27702d4efc04 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 25 Sep 2023 17:17:09 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 1 + go.sum | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index c2696e38..945b4a60 100644 --- a/go.mod +++ b/go.mod @@ -68,6 +68,7 @@ require ( github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/schollz/progressbar v1.0.0 // indirect github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect + github.com/stripe/stripe-go/v75 v75.7.0 // indirect github.com/valyala/fastrand v1.1.0 // indirect github.com/valyala/histogram v1.2.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0 // indirect diff --git a/go.sum b/go.sum index 5e518b03..dd4229c7 100644 --- a/go.sum +++ b/go.sum @@ -553,10 +553,10 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stripe/stripe-go/v74 v74.26.0 h1:enbhLtjKGWvJKcGM0f2CazqFSXzpHXcQ42nG2PNsWK0= -github.com/stripe/stripe-go/v74 v74.26.0/go.mod h1:f9L6LvaXa35ja7eyvP6GQswoaIPaBRvGAimAO+udbBw= github.com/stripe/stripe-go/v74 v74.30.0 h1:0Kf0KkeFnY7iRhOwvTerX0Ia1BRw+eV1CVJ51mGYAUY= github.com/stripe/stripe-go/v74 v74.30.0/go.mod h1:f9L6LvaXa35ja7eyvP6GQswoaIPaBRvGAimAO+udbBw= +github.com/stripe/stripe-go/v75 v75.7.0 h1:Zk7trlj0kClZOwnpjGz7FgVQRBI0Koi28/eaNATgAs0= +github.com/stripe/stripe-go/v75 v75.7.0/go.mod h1:wT44gah+eCY8Z0aSpY/vQlYYbicU9uUAbAqdaUxxDqE= github.com/tidwall/gjson v1.12.0 h1:61wEp/qfvFnqKH/WCI3M8HuRut+mHT6Mr82QrFmM2SY= github.com/tidwall/gjson v1.12.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=