From 05d1faa0b06627143c43f27f284afc0d57662916 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 24 Dec 2024 14:56:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E9=99=A4=E6=94=AF=E4=BB=98=E5=AE=9D?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/hdl/member_center/hdl_user_management.go | 86 +++++++++++++++++++- app/md/member_center/md_user_management.go | 7 ++ app/router/router.go | 2 + app/svc/member_center/svc_user_management.go | 4 +- 4 files changed, 96 insertions(+), 3 deletions(-) diff --git a/app/hdl/member_center/hdl_user_management.go b/app/hdl/member_center/hdl_user_management.go index 900ffb9..fa7839c 100644 --- a/app/hdl/member_center/hdl_user_management.go +++ b/app/hdl/member_center/hdl_user_management.go @@ -279,6 +279,74 @@ func UserManagementAddUser(c *gin.Context) { defer ch.Release() ch.Publish(md3.EggAppExchange, md3.EggNewUserRegisterData{Uid: user.Id}, md3.EggNewUserRegister) svc.UserImeiAdd(c, user.Id) + admin := svc2.GetUser(c) + svc2.AddAdminLog(c, admin.AdmId, "用户新增", "用户id:"+utils.Int64ToStr(user.Id)+",用户手机号:"+user.Phone, "") + e.OutSuc(c, "success", nil) + return +} + +// UserManagementDelUserAlipay +// @Summary 制度中心-会员中心-用户管理-删除用户支付宝 +// @Tags 会员中心 +// @Description 用户添加 +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param req body md.UserReq true "分页信息必填" +// @Success 200 {string} "具体数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/memberCenter/userManagement/delUserAlipay [post] +func UserManagementDelUserAlipay(c *gin.Context) { + var req *md.UserReq + if err := c.ShouldBindJSON(&req); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err.Error()) + return + } + + NewAlipayUserInfoDb := implement.NewAlipayUserInfoDb(db.Db) + info, _ := NewAlipayUserInfoDb.GetAlipayUserInfo(utils.StrToInt64(req.Id)) + if info == nil { + e.OutErr(c, 400, e.NewErr(400, "支付宝信息不存在")) + return + } + oldUserName := info.UserName + oldOpenId := info.OpenId + db.Db.Where("id=?", info.Id).Delete(&model.AlipayUserInfo{}) + admin := svc2.GetUser(c) + svc2.AddAdminLog(c, admin.AdmId, "用户解除支付宝", "用户id:"+utils.Int64ToStr(info.Uid)+",原支付宝:"+oldUserName+" "+oldOpenId, utils.SerializeStr(info)) + e.OutSuc(c, "success", nil) + return +} + +// UserManagementDelUserWechat +// @Summary 制度中心-会员中心-用户管理-删除用户微信 +// @Tags 会员中心 +// @Description 用户微信 +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param req body md.UserReq true "分页信息必填" +// @Success 200 {string} "具体数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/memberCenter/userManagement/delUserAlipay [post] +func UserManagementDelUserWechat(c *gin.Context) { + var req *md.UserReq + if err := c.ShouldBindJSON(&req); err != nil { + e.OutErr(c, e.ERR_INVALID_ARGS, err.Error()) + return + } + + NewWxUserInfoDb := implement.NewWxUserInfoDb(db.Db) + info, _ := NewWxUserInfoDb.GetWxUserInfo(utils.StrToInt64(req.Id)) + if info == nil { + e.OutErr(c, 400, e.NewErr(400, "微信信息不存在")) + return + } + oldUserName := info.UserName + oldOpenId := info.OpenId + db.Db.Where("id=?", info.Id).Delete(&model.WxUserInfo{}) + admin := svc2.GetUser(c) + svc2.AddAdminLog(c, admin.AdmId, "用户解除微信", "用户id:"+utils.Int64ToStr(info.Uid)+",原微信:"+oldUserName+" "+oldOpenId, utils.SerializeStr(info)) e.OutSuc(c, "success", nil) return } @@ -333,12 +401,15 @@ func UserManagementSetCustomInviteCode(c *gin.Context) { } } } + oldCode := user.CustomInviteCode user.CustomInviteCode = req.CustomInviteCode _, err = db.Db.Where("id=?", user.Id).Cols("custom_invite_code").Update(user) if err != nil { e.OutErr(c, 400, e.NewErr(400, "修改失败")) return } + admin := svc2.GetUser(c) + svc2.AddAdminLog(c, admin.AdmId, "用户邀请码修改", "用户id:"+utils.Int64ToStr(user.Id)+",原邀请码:"+oldCode+",新邀请码"+user.CustomInviteCode, "") e.OutSuc(c, "success", nil) return } @@ -360,7 +431,7 @@ func UserManagementUpdateUserInfo(c *gin.Context) { e.OutErr(c, e.ERR_INVALID_ARGS, err.Error()) return } - affected, err := svc.UserManagementUpdateUserInfo(db.Db, req) + affected, err := svc.UserManagementUpdateUserInfo(c, db.Db, req) if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return @@ -745,6 +816,19 @@ func UserManagementGetOneBasic(c *gin.Context) { CreateAt: user.CreateAt, }, } + NewAlipayUserInfoDb := implement.NewAlipayUserInfoDb(db.Db) + info, _ := NewAlipayUserInfoDb.GetAlipayUserInfo(user.Id) + if info != nil { + resp.BasicInfo.AlipayUserName = info.UserName + resp.BasicInfo.AlipayOpenId = info.OpenId + } + NewWxUserInfoDb := implement.NewWxUserInfoDb(db.Db) + wxInfo, _ := NewWxUserInfoDb.GetWxUserInfo(user.Id) + if wxInfo != nil { + resp.BasicInfo.WechatUserName = wxInfo.UserName + resp.BasicInfo.WechatOpenId = wxInfo.OpenId + } + tagList := make([]md.TagNode, len(*userTagRecords)) if *userTagRecords != nil { for i, records := range *userTagRecords { diff --git a/app/md/member_center/md_user_management.go b/app/md/member_center/md_user_management.go index 74200bb..e5bc6ba 100644 --- a/app/md/member_center/md_user_management.go +++ b/app/md/member_center/md_user_management.go @@ -16,6 +16,9 @@ type InviteCodeReq struct { Id string `json:"id"` CustomInviteCode string `json:"custom_invite_code"` } +type UserReq struct { + Id string `json:"id"` +} type UserManagementGetUserListReq struct { ID int64 `json:"id"` // 会员 ID Nickname string `json:"nickname" example:"会员昵称"` @@ -137,6 +140,10 @@ type BasicInfoNode struct { WechatAccount string `json:"wechat_account"` SystemInviteCode string `json:"system_invite_code"` CustomInviteCode string `json:"custom_invite_code"` + AlipayUserName string `json:"alipay_user_name"` + AlipayOpenId string `json:"alipay_open_id"` + WechatUserName string `json:"wechat_user_name"` + WechatOpenId string `json:"wechat_open_id"` } type OtherNode struct { diff --git a/app/router/router.go b/app/router/router.go index 4fcb12a..86d0c1a 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -351,6 +351,8 @@ func rMemberCenter(r *gin.RouterGroup) { // 会员中心 { rUserManagement.POST("/getUserList", member_center.UserManagementGetUserList) rUserManagement.POST("/addUser", member_center.UserManagementAddUser) + rUserManagement.POST("/delUserAlipay", member_center.UserManagementDelUserAlipay) + rUserManagement.POST("/delUserWechat", member_center.UserManagementDelUserWechat) rUserManagement.POST("/setCustomInviteCode", member_center.UserManagementSetCustomInviteCode) rUserManagement.GET("/userData", member_center.UserManagementGetOneBasic) rUserManagement.POST("/updateUserInfo", member_center.UserManagementUpdateUserInfo) diff --git a/app/svc/member_center/svc_user_management.go b/app/svc/member_center/svc_user_management.go index a8ba477..7385792 100644 --- a/app/svc/member_center/svc_user_management.go +++ b/app/svc/member_center/svc_user_management.go @@ -8,6 +8,7 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/model" "errors" "fmt" + "github.com/gin-gonic/gin" "strings" "time" "xorm.io/xorm" @@ -92,7 +93,7 @@ func userManagementGetUsersBindQuery(engine *xorm.Engine, req *md.UserManagement } return session } -func UserManagementUpdateUserInfo(engine *xorm.Engine, req *md.UserManagementUpdateUserInfoReq) (int64, error) { +func UserManagementUpdateUserInfo(c *gin.Context, engine *xorm.Engine, req *md.UserManagementUpdateUserInfoReq) (int64, error) { session := engine.NewSession() defer session.Close() session.Begin() @@ -196,6 +197,5 @@ func UserManagementUpdateUserInfo(engine *xorm.Engine, req *md.UserManagementUpd session.Rollback() return 0, err3 } - return affected, nil }