Pārlūkot izejas kodu

会员加入回收站

会员删除
master
huangjiajun pirms 1 nedēļas
vecāks
revīzija
0b805d33f8
6 mainītis faili ar 282 papildinājumiem un 5 dzēšanām
  1. +260
    -0
      app/hdl/member_center/hdl_user_management.go
  2. +5
    -0
      app/md/md_mq.go
  3. +4
    -4
      app/md/md_website.go
  4. +4
    -1
      app/md/member_center/md_user_management.go
  5. +4
    -0
      app/router/router.go
  6. +5
    -0
      app/svc/member_center/svc_user_management.go

+ 260
- 0
app/hdl/member_center/hdl_user_management.go Parādīt failu

@@ -3,15 +3,20 @@ package member_center
import (
"applet/app/db"
"applet/app/e"
md2 "applet/app/md"
"applet/app/md/member_center"
svc2 "applet/app/svc"
svc "applet/app/svc/member_center"
"applet/app/utils"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"strings"
"time"
)

// UserManagementGetUserList
@@ -180,6 +185,261 @@ func UserManagementUpdateUserInfo(c *gin.Context) {
e.OutSuc(c, affected, nil)
}

// UserManagementGetUserRecycleList
// @Summary 会员中心-用户管理-回收站列表
// @Tags 会员中心
// @Description 回收站列表
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.UserManagementGetUserListReq true "分页信息必填"
// @Success 200 {object} md.UserManagementGetUserListResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/userManagement/userRecycleList [post]
func UserManagementGetUserRecycleList(c *gin.Context) {
var req *md.UserManagementGetUserListReq
if err := c.ShouldBindJSON(&req); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
return
}
req.IsRecycle = "1"
levelDb := implement.NewUserLevelDb(db.Db)
levels, err1 := levelDb.UserLevelAllByAsc()
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
levelsList := make([]map[string]interface{}, 0)
levelsMap := make(map[int]string)
for _, level := range levels {
levelsList = append(levelsList, map[string]interface{}{
"id": level.Id,
"name": level.LevelName,
})
levelsMap[level.Id] = level.LevelName
}

tagDb := implement.NewUserTagDb(db.Db)
tags, err2 := tagDb.UserTagAllByAsc()
if err2 != nil {
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
}
tagsList := make([]map[string]interface{}, 0)
tagsMap := make(map[int]string)
for _, tag := range tags {
tagsList = append(tagsList, map[string]interface{}{
"id": tag.Id,
"name": tag.TagName,
})
tagsMap[tag.Id] = tag.TagName
}

stateList := []map[string]interface{}{
{
"name": "正常",
"value": "1",
},
{
"name": "冻结",
"value": "2",
},
}

users, total, err3 := svc.UserManagementGetUsers(req)
if err3 != nil {
e.OutErr(c, e.ERR_DB_ORM, err3.Error())
return
}
userIDs := make([]int64, len(users))
for i, user := range users {
userIDs[i] = user.Id
}

recordsDb := implement.NewUserTagRecordsDb(db.Db)
records, err := recordsDb.UserTagRecordsFindByParams(map[string]interface{}{
"key": "uid",
"value": userIDs,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

var levelCounts []md.LevelCount
err4 := db.Db.Table("user").Select("level, Count(*) AS count").GroupBy("level").Find(&levelCounts)
if err4 != nil {
e.OutErr(c, e.ERR_DB_ORM, err4.Error())
return
}

userMap := make(map[int64]int, len(users))
list := make([]md.UserManagementGetUserListNode, len(users))
for i, user := range users {
list[i] = md.UserManagementGetUserListNode{
ID: user.Id,
Sex: user.Sex,
Avatar: svc2.GetOssUrl(user.Avatar),
Nickname: user.Nickname,
Phone: user.Phone,
IsRealName: user.IsRealName,
InviteCode: user.SystemInviteCode,
ParentID: user.ParentUid,
ParentInviteCode: user.ParentSystemInviteCode,
ParentPhone: user.ParentPhone,
RegisterTime: user.CreateAt,
Memo: user.Memo,
Wechat: user.UnionId,
RegisterType: user.RegisterType,
State: user.State,
LastLoginAt: user.UpdateAt,
}
var tempTagList []md.TagNode
list[i].Tag = tempTagList
userMap[user.Id] = i
level, ok := levelsMap[user.Level]
if ok {
list[i].LevelName = level
}
}

for _, record := range *records {
tempTagNode := md.TagNode{
TagID: record.TagId,
TagName: tagsMap[record.TagId],
}
list[userMap[record.Uid]].Tag = append(list[userMap[record.Uid]].Tag, tempTagNode)
}

resp := md.UserManagementGetUserListResp{
LevelsList: levelsList,
TagsList: tagsList,
StateList: stateList,
List: list,
Paginate: md.Paginate{
Limit: req.Limit,
Page: req.Page,
Total: total,
},
}
e.OutSuc(c, resp, nil)
}

// UserManagementUserRecycle
// @Summary 会员中心-用户管理-删除到回收站
// @Tags 会员中心
// @Description 删除到回收站
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.UserManagementUserInfoReq true "用户ID 必传"
// @Success 200 {int} "修改数据行数"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/userManagement/userRecycle [post]
func UserManagementUserRecycle(c *gin.Context) {
var req *md.UserManagementUserInfoReq
if err := c.ShouldBindJSON(&req); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
return
}
NewUserDb := implement.NewUserDb(db.Db)
user, _ := NewUserDb.GetUser(utils.StrToInt64(req.UID))
if user == nil {
e.OutErr(c, 400, e.NewErr(400, "用户不存在"))
return
}
user.State = 4
db.Db.Where("id=?", user.Id).Cols("state").Update(user)
admin := svc2.GetUser(c)
svc2.AddAdminLog(c, admin.AdmId, "用户回收", "用户id:"+utils.Int64ToStr(user.Id)+",用户手机号:"+user.Phone+" 删除到回收站", utils.SerializeStr(user))
e.OutSuc(c, "success", nil)
}

// UserManagementUserRecycleCancel
// @Summary 会员中心-用户管理-恢复到会员列表
// @Tags 会员中心
// @Description 恢复到会员列表
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.UserManagementUserInfoReq true "用户ID 必传"
// @Success 200 {int} "修改数据行数"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/userManagement/userRecycleCancel [post]
func UserManagementUserRecycleCancel(c *gin.Context) {
var req *md.UserManagementUserInfoReq
if err := c.ShouldBindJSON(&req); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
return
}
NewUserDb := implement.NewUserDb(db.Db)
user, _ := NewUserDb.GetUser(utils.StrToInt64(req.UID))
if user == nil {
e.OutErr(c, 400, e.NewErr(400, "用户不存在"))
return
}
user.State = 1
db.Db.Where("id=?", user.Id).Cols("state").Update(user)
admin := svc2.GetUser(c)
svc2.AddAdminLog(c, admin.AdmId, "用户恢复", "用户id:"+utils.Int64ToStr(user.Id)+",用户手机号:"+user.Phone+" 恢复到会员列表", utils.SerializeStr(user))
e.OutSuc(c, "success", nil)
}

// UserManagementUserDelete
// @Summary 会员中心-用户管理-永久删除
// @Tags 会员中心
// @Description 删除到回收站
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.UserManagementUserInfoReq true "用户ID 必传"
// @Success 200 {int} "修改数据行数"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/userManagement/userDelete [post]
func UserManagementUserDelete(c *gin.Context) {
var req *md.UserManagementUserInfoReq
if err := c.ShouldBindJSON(&req); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
return
}
NewUserDb := implement.NewUserDb(db.Db)
user, _ := NewUserDb.GetUser(utils.StrToInt64(req.UID))
if user == nil {
e.OutErr(c, 400, e.NewErr(400, "用户不存在"))
return
}
if user.State != 4 {
e.OutErr(c, 400, e.NewErr(400, "不能删除"))
return
}
user.State = 3
db.Db.Where("id=?", user.Id).Cols("state").Update(user)
tmp := model.UserDeleteInfo{
Uid: int(user.Id),
Phone: user.Phone,
CreateAt: time.Now(),
}
db.Db.Insert(&tmp)
ch, err := rabbit.Cfg.Pool.GetChannel()
if err == nil {
defer ch.Release()
err = ch.PublishV2(md2.EggUserExchange, md2.CommUserId{
Uid: utils.Int64ToStr(user.Id),
}, md2.EggUserDelete)
if err != nil {
ch.PublishV2(md2.EggUserExchange, md2.CommUserId{
Uid: utils.Int64ToStr(user.Id),
}, md2.EggUserDelete)
}
}
// 清掉token
cacheKey := fmt.Sprintf("egg_app_jwt_token:%d", user.Id)
_, err = cache.SetEx(cacheKey, "", 1)
admin := svc2.GetUser(c)
svc2.AddAdminLog(c, admin.AdmId, "用户永久删除", "用户id:"+utils.Int64ToStr(user.Id)+",用户手机号:"+user.Phone+" 永久删除", utils.SerializeStr(user))
e.OutSuc(c, "success", nil)
}

// UserManagementGetOneBasic
// @Summary 制度中心-会员中心-用户管理-会员明细概况(获取)
// @Tags 会员中心


+ 5
- 0
app/md/md_mq.go Parādīt failu

@@ -3,8 +3,13 @@ package md
const (
EggJpushRecordQueueExchange = "egg.jpush"
EggJpushRecordQueue = "jpush_record"
EggUserExchange = "egg.user"
EggUserDelete = "user_delete"
)

type JpushRecordFundData struct {
Id string `json:"id"`
}
type CommUserId struct {
Uid string `json:"uid"`
}

+ 4
- 4
app/md/md_website.go Parādīt failu

@@ -31,9 +31,9 @@ type CertificateResp struct {
}

var Certificate = CertificateResp{
Logo: "default_icon/certificate_logo.jpg",
Logo: "default_icon/certificate_logo.png",
BgImg: "default_icon/certificate_bg_img.jpg",
NameIcon: "default_icon/certificate_name_icon.jpg",
Medal: "default_icon/certificate_medal.jpg",
Seal: "default_icon/certificate_seal.jpg",
NameIcon: "default_icon/certificate_name_icon.png",
Medal: "default_icon/certificate_medal.png",
Seal: "default_icon/certificate_seal.png",
}

+ 4
- 1
app/md/member_center/md_user_management.go Parādīt failu

@@ -27,6 +27,7 @@ type UserManagementGetUserListReq struct {
LoginAfter string `json:"login_after"` // 最近登录结束时间
Page int `json:"page,required"`
Limit int `json:"limit,required"`
IsRecycle string `json:"is_recycle"`
}

type Paginate struct {
@@ -92,7 +93,9 @@ type UserManagementUpdateUserInfoReq struct {
ParentUid string `json:"parent_uid"` // 邀请人 ID
Password string `json:"password"` // 登录密码
}

type UserManagementUserInfoReq struct {
UID string `json:"uid"`
}
type TagNode struct {
TagID int `json:"tag_id"` // 标签 ID
TagName string `json:"tag_name"` // 标签名称


+ 4
- 0
app/router/router.go Parādīt failu

@@ -335,6 +335,10 @@ func rMemberCenter(r *gin.RouterGroup) { // 会员中心
rUserManagement.POST("/getUserList", member_center.UserManagementGetUserList)
rUserManagement.GET("/userData", member_center.UserManagementGetOneBasic)
rUserManagement.POST("/updateUserInfo", member_center.UserManagementUpdateUserInfo)
rUserManagement.POST("/userRecycle", member_center.UserManagementUserRecycle)
rUserManagement.POST("/userRecycleCancel", member_center.UserManagementUserRecycleCancel)
rUserManagement.POST("/userRecycleList", member_center.UserManagementGetUserRecycleList)
rUserManagement.POST("/userDelete", member_center.UserManagementUserDelete)
rUserManagement.GET("/getFans", member_center.UserManagementGetFans)
rUserManagement.GET("/balanceDetail", member_center.UserManagementGetBalanceDetail)
rUserManagement.GET("/getVirtualCoinDetail", member_center.UserManagementGetVirtualCoinDetail)


+ 5
- 0
app/svc/member_center/svc_user_management.go Parādīt failu

@@ -33,6 +33,11 @@ func userManagementGetUsersBindQuery(engine *xorm.Engine, req *md.UserManagement
session := engine.Table("user").Alias("a").
Join("LEFT OUTER", []string{"user", "b"}, "a.parent_uid = b.id").
Join("LEFT OUTER", "user_tag_records", "user_tag_records.uid = a.id")
if req.IsRecycle == "1" {
session = session.In("a.state", []string{"4"})
} else {
session = session.In("a.state", []string{"1", "2"})
}
if req.ID != 0 {
session = session.Where("a.id = ?", req.ID)
}


Notiek ielāde…
Atcelt
Saglabāt