Pārlūkot izejas kodu

merge member_center

master
shenjiachi pirms 1 mēnesi
vecāks
revīzija
db235efc53
8 mainītis faili ar 840 papildinājumiem un 170 dzēšanām
  1. +1
    -0
      app/hdl/institutional_management/egg_energy/hdl_basic.go
  2. +103
    -0
      app/hdl/member_center/hdl_level__management.go
  3. +138
    -0
      app/hdl/member_center/hdl_tag__management.go
  4. +449
    -135
      app/hdl/member_center/hdl_user_management.go
  5. +24
    -0
      app/md/institutional_management/member_center/md_level_management.go
  6. +26
    -0
      app/md/institutional_management/member_center/md_tag_management.go
  7. +82
    -32
      app/md/institutional_management/member_center/md_user_management.go
  8. +17
    -3
      app/router/router.go

+ 1
- 0
app/hdl/institutional_management/egg_energy/hdl_basic.go Parādīt failu

@@ -190,6 +190,7 @@ func UpdateEggEnergyBasic(c *gin.Context) {
forceColums := []string{"is_open", "video_reward_is_open"}
energyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
session := db.Db.NewSession()
defer session.Close()
affected, err := energyBasicSettingDb.EggEnergyBasicSettingUpdate(session, req.SystemID, &m, forceColums...)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())


+ 103
- 0
app/hdl/member_center/hdl_level__management.go Parādīt failu

@@ -0,0 +1,103 @@
package member_center

import (
"applet/app/db"
"applet/app/e"
md "applet/app/md/institutional_management/member_center"
"applet/app/utils"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"github.com/gin-gonic/gin"
)

// GetLevelList
// @Summary 制度中心-会员中心-等级管理(获取)
// @Tags 会员中心
// @Description 标签管理(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param limit query int true "每页大小"
// @Param page query int true "页数"
// @Success 200 {object} md.GetLevelListResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/levelManagement/getLevelList [get]
func GetLevelList(c *gin.Context) {
page := c.DefaultQuery("page", "1")
limit := c.DefaultQuery("limit", "10")

levelDb := implement.NewUserLevelDb(db.Db)
levels, total, err := levelDb.UserLevelAllByAscByPage(utils.StrToInt(page), utils.StrToInt(limit))
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

sql := "SElECT count(distinct id) as total, level FROM `user` GROUP BY level"
results, err := db.QueryNativeString(db.Db, sql)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
var countMap = map[int]string{}
for _, res := range results {
countMap[utils.StrToInt(res["level"])] = res["total"]
}

list := make([]md.LevelListNode, 0)
for i, level := range levels {
list[i].LevelWeight = level.LevelWeight
list[i].LevelID = level.Id
list[i].LevelName = level.LevelName
list[i].Count = countMap[level.Id]
list[i].CreateAt = level.CreateAt
list[i].IsUse = level.IsUse
list[i].Memo = level.Memo
}

resp := md.GetLevelListResp{
List: list,
Paginate: md.Paginate{
Limit: utils.StrToInt(limit),
Page: utils.StrToInt(page),
Total: total,
},
}

e.OutSuc(c, resp, nil)
}

// UpdateLevel
// @Summary 制度中心-会员中心-等级管理(更新)
// @Tags 会员中心
// @Description 等级管理(更新)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.UpdateLevelReq true "需要修改的等级信息"
// @Success 200 {int} "成功修改数据条数"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/levelManagement/updateLevel [post]
func UpdateLevel(c *gin.Context) {
var req *md.UpdateLevelReq
if err := c.ShouldBindJSON(&req); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
return
}

level := &model.UserLevel{
Id: utils.StrToInt(req.LevelID),
LevelName: req.LevelName,
LevelWeight: req.LevelWeight,
IsUse: req.IsUse,
Memo: req.Memo,
}
forceColumns := []string{"level_weight", "is_use"}
levelDb := implement.NewUserLevelDb(db.Db)
affected, err := levelDb.UserLevelUpdate(req.LevelID, level, forceColumns...)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
e.OutSuc(c, affected, nil)
}

+ 138
- 0
app/hdl/member_center/hdl_tag__management.go Parādīt failu

@@ -0,0 +1,138 @@
package member_center

import (
"applet/app/db"
"applet/app/e"
md "applet/app/md/institutional_management/member_center"
"applet/app/utils"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"github.com/gin-gonic/gin"
)

// GetTagList
// @Summary 制度中心-会员中心-标签管理(获取)
// @Tags 会员中心
// @Description 标签管理(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param limit query int true "每页大小"
// @Param page query int true "页数"
// @Success 200 {object} md.GetTagListResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/tagManagement/getTagList [get]
func GetTagList(c *gin.Context) {
page := c.DefaultQuery("page", "1")
limit := c.DefaultQuery("limit", "10")

sql := "SElECT count(distinct uid) as total, tag_id FROM `user_tag_records` GROUP BY tag_id"
results, err := db.QueryNativeString(db.Db, sql)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
var countMap = map[int64]string{}
for _, res := range results {
countMap[utils.StrToInt64(res["tag_id"])] = res["total"]
}

tagDb := implement.NewUserTagDb(db.Db)
tags, total, err := tagDb.UserTagAllByAscByPage(utils.StrToInt(page), utils.StrToInt(limit))
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

list := make([]md.TagListNode, len(*tags))
for i, tag := range *tags {
list[i].Name = tag.TagName
list[i].Count = countMap[int64(tag.Id)]
list[i].CreateAt = tag.CreateAt
list[i].Memo = tag.Memo
}

resp := md.GetTagListResp{
List: list,
Paginate: md.Paginate{
Limit: utils.StrToInt(limit),
Page: utils.StrToInt(page),
Total: total,
},
}
e.OutSuc(c, resp, nil)
}

// UpdateTag
// @Summary 制度中心-会员中心-标签管理(更新)
// @Tags 会员中心
// @Description 标签管理(更新)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.UpdateTagReq true "需要修改的标签信息"
// @Success 200 {int} "成功修改数据条数"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/tagManagement/updateTag [post]
func UpdateTag(c *gin.Context) {
var req *md.UpdateTagReq
if err := c.ShouldBindJSON(&req); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
return
}
tagID := utils.StrToInt(req.TagID)

tag := &model.UserTag{
Id: tagID,
TagName: req.Name,
Memo: req.Memo,
}

forceColumns := []string{"tag_name", "memo"}

tagDb := implement.NewUserTagDb(db.Db)
affected, err := tagDb.UserTagUpdate(tagID, tag, forceColumns...)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
e.OutSuc(c, affected, nil)
}

// DeleteTag
// @Summary 制度中心-会员中心-标签管理(删除)
// @Tags 会员中心
// @Description 标签管理(删除)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.DeleteTagReq true "需要删除的标签 ID"
// @Success 200 {int} "成功删除标签用户数"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/tagManagement/deleteTag [post]
func DeleteTag(c *gin.Context) {
var req *md.DeleteTagReq
if err := c.ShouldBindJSON(&req); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
return
}

tagDb := implement.NewUserTagDb(db.Db)
recordsDb := implement.NewUserTagRecordsDb(db.Db)
session := db.Db.NewSession()
defer session.Close()

_, err := tagDb.UserTagDeleteBySession(session, req.TagID)
if err != nil {
session.Rollback()
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
affected, err := recordsDb.UserTagRecordDeleteBySession(session, utils.StrToInt64(req.TagID))
if err != nil {
session.Rollback()
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
e.OutSuc(c, affected, nil)
}

+ 449
- 135
app/hdl/member_center/hdl_user_management.go Parādīt failu

@@ -5,12 +5,17 @@ import (
"applet/app/e"
md "applet/app/md/institutional_management/member_center"
svc "applet/app/svc/member_center"
"applet/app/utils"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"strings"
)

// UserManagementGetUserList
// @Summary 制度中心-会员中心-用户信息管理(获取)
// @Summary 制度中心-会员中心-用户管理-用户信息管理(获取)
// @Tags 会员中心
// @Description 用户信息管理(获取)
// @Accept json
@@ -81,7 +86,7 @@ func UserManagementGetUserList(c *gin.Context) {
Nickname: user.Nickname,
Phone: user.Phone,
IsRealName: user.IsRealName,
Level: levelsMap[user.Level],
LevelName: levelsMap[user.Level],
InviteCode: user.SystemInviteCode,
ParentID: user.ParentUid,
ParentInviteCode: user.ParentSystemInviteCode,
@@ -105,7 +110,7 @@ func UserManagementGetUserList(c *gin.Context) {
}

// UserManagementUpdateUserInfo
// @Summary 制度中心-会员中心-用户信息管理(更新)
// @Summary 制度中心-会员中心-用户管理-用户信息管理(更新)
// @Tags 会员中心
// @Description 用户信息管理(更新)
// @Accept json
@@ -121,145 +126,454 @@ func UserManagementUpdateUserInfo(c *gin.Context) {
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
return
}
session := db.Db.NewSession()
defer session.Close()
session.Begin()
userDb := implement.NewUserDb(db.Db)
var affected int64
var err1 error
forceColumns := make([]string, 0)
user := model.User{
Id: req.UID,
Phone: req.Phone,
UnionId: req.UnionId,
Nickname: req.Nickname,
Avatar: req.Avatar,
LastLoginIp: req.LastLoginIp,
Memo: req.Memo,
}
if req.Level != "" {
user.Level = utils.StrToInt(req.Level)
}
if req.State != "" {
user.State = utils.StrToInt(req.State)
}
if req.Sex != "" {
user.Sex = utils.StrToInt(req.Sex)
}
if req.ParentUid != "" {
user.ParentUid = utils.StrToInt64(req.ParentUid)
} else {
user.ParentUid = 0
}

forceColumns = []string{"sex", "parent_uid"}
affected, err1 = userDb.UserUpdateBySession(session, req.UID, &user, forceColumns...)
if err1 != nil {
session.Rollback()
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}

relateDb := implement.NewUserRelateDb(db.Db)
relateForceColumns := []string{"sex", "parent_uid"}
relate := &model.UserRelate{
ParentUid: user.ParentUid,
}
affected, err1 = relateDb.UpdateUserRelateBySession(session, req.UID, relate, relateForceColumns...)
if err1 != nil {
session.Rollback()
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}

var err2 error
if req.Tag != "" {
record := model.UserTagRecords{
TagId: utils.StrToInt(req.Tag),
}
recordsDb := implement.NewUserTagRecordsDb(db.Db)
affected, err2 = recordsDb.UserTagRecordsUpdateBySession(session, req.UID, &record, "tag_id")
if err2 != nil {
session.Rollback()
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
}

}
err3 := session.Commit()
if err3 != nil {
session.Rollback()
e.OutErr(c, e.ERR_DB_ORM, err3.Error())
return
}

_ = implement.NewUserDb(db.Db)

//var affected int64
//var err1 error
//forceColumns := make([]string, 0)
//user := model.User{
// Id: req.UID,
//}
//if req.Memo != "" {
// user.Memo = req.Memo
// forceColumns = append(forceColumns, "memo")
//}
//if req.Disable != false {
// user.State = 2
// forceColumns = append(forceColumns, "state")
//}
//if req.LastLoginIp != "" {
// user.LastLoginIp = req.LastLoginIp
// forceColumns = append(forceColumns, "last_login_ip")
//}
//if req.Avatar != "" {
// user.Avatar = req.Avatar
// forceColumns = append(forceColumns, "avatar")
//}
//if len(forceColumns) > 0 {
// affected, err1 = userDb.UserUpdate(req.UID, &user)
// if err1 != nil {
// e.OutErr(c, e.ERR_DB_ORM, err1.Error())
// return
// }
//}
//
//var err2 error
//if req.Tag != 0 {
// record := model.UserTagRecords{
// TagId: req.Tag,
// }
// recordsDb := implement.NewUserTagRecordsDb(db.Db)
// affected, err2 = recordsDb.UserTagRecordsUpdate(req.UID, &record, "tag_id")
// if err2 != nil {
// e.OutErr(c, e.ERR_DB_ORM, err2.Error())
// return
// }
//
//}

e.OutSuc(c, 0, nil)
e.OutSuc(c, affected, nil)
}

// UserManagementGetOneBasic
// @Summary 制度中心-会员中心-会员明细概况(获取)
// @Summary 制度中心-会员中心-用户管理-会员明细概况(获取)
// @Tags 会员中心
// @Description 会员明细概况(更新)
// @Description 会员明细概况(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param uid query int true "用户 ID"
// @Param uid query string true "用户 ID"
// @Success 200 {object} md.UserManagementGetOneBasicResp "会员明细概况具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/userManagement/getOneBasicInfo [get]
//func UserManagementGetOneBasic(c *gin.Context) {
// uid := c.Query("uid")
// userDb := implement.NewUserDb(db.Db)
// user, err := userDb.UserGetOneByParams(map[string]interface{}{
// "key": "id",
// "value": uid,
// })
// if err != nil {
// e.OutErr(c, e.ERR_DB_ORM, err.Error())
// return
// }
//
// 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
// }
//
// coinDb := implement.NewVirtualCoinDb(db.Db)
// coins, err3 := coinDb.VirtualCoinFindAll()
// if err3 != nil {
// e.OutErr(c, e.ERR_DB_ORM, err3.Error())
// return
// }
// coinsList := make([]map[string]interface{}, 0)
// coinsMap := make(map[int]string)
// for _, coin := range coins {
// coinsList = append(coinsList, map[string]interface{}{
// "id": coin.Id,
// "name": coin.Name,
// })
// coinsMap[coin.Id] = coin.Name
// }
//
// parent, err := userDb.UserGetOneByParams(map[string]interface{}{
// "key": "id",
// "value": user.ParentUid,
// })
// if err != nil {
// e.OutErr(c, e.ERR_DB_ORM, err.Error())
// return
// }
//
// recordsDb := implement.NewUserTagRecordsDb(db.Db)
// userTagRecord, err := recordsDb.UserTagRecordsGetOneByParams(map[string]interface{}{
// "key": "uid",
// "value": uid,
// })
// if err != nil {
// return
// }
//
// amountDb := implement.NewUserVirtualAmountDb(db.Db)
// amountDb.GetUserVirtualWalletBySession()
//}
// @Router /api/memberCenter/userManagement/userData [get]
func UserManagementGetOneBasic(c *gin.Context) {
uid := c.Query("uid")
userDb := implement.NewUserDb(db.Db)
user, err := userDb.UserGetOneByParams(map[string]interface{}{
"key": "id",
"value": uid,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

// 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
}

//2. 查询标签列表
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
}

//3. 查询父用户信息
parent, err := userDb.UserGetOneByParams(map[string]interface{}{
"key": "id",
"value": user.ParentUid,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

//4. 查询用户标签
recordsDb := implement.NewUserTagRecordsDb(db.Db)
userTagRecord, err := recordsDb.UserTagRecordsGetOneByParams(map[string]interface{}{
"key": "uid",
"value": uid,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

resp := md.UserManagementGetOneBasicResp{
TagsList: tagsList,
LevelsList: levelsList,
BasicInfo: md.BasicInfoNode{
Avatar: user.Avatar,
Sex: user.Sex,
Nickname: user.Nickname,
LevelName: levelsMap[user.Level],
Phone: user.Phone,
UnionId: user.UnionId,
Password: user.Password,
State: user.State,
Memo: user.Memo,
},
OtherInfo: md.OtherNode{
LastLoginIp: user.LastLoginIp,
LastLoginAt: user.UpdateAt,
CreateAt: user.CreateAt,
},
}
if userTagRecord != nil {
resp.BasicInfo.TagName = tagsMap[userTagRecord.TagId]
}
if parent != nil {
resp.BasicInfo.ParentUid = parent.Id
resp.BasicInfo.ParentName = parent.Nickname
resp.BasicInfo.ParentPhone = parent.Phone
}

e.OutSuc(c, resp, nil)
}

// UserManagementGetFans
// @Summary 制度中心-会员中心-用户管理-会员明细粉丝情况(获取)
// @Tags 会员中心
// @Description 会员明细粉丝情况(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param uid query string true "用户 ID"
// @Param type query string true "粉丝类型(1.全部 2.直推 3.二代 4.二代以后)"
// @Param limit query string true "每页大小"
// @Param page query string true "页数"
// @Success 200 {object} md.UserManagementGetFansResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/userManagement/getFans [get]
func UserManagementGetFans(c *gin.Context) {
uid := c.Query("uid")
fansType := c.Query("type")
limit := c.Query("limit")
page := c.Query("page")

//1. 查询符合情况用户 ID
relateDb := implement.NewUserRelateDb(db.Db)
var level int
switch fansType {
case "0":
level = 0
case "1":
level = 1
case "2":
level = 2
default:
level = 3
}
relates, total, err := relateDb.PageFindUserRelateByParentUidAndLevel(utils.StrToInt64(uid), utils.StrToInt(page), utils.StrToInt(limit), level)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
userIDs := make([]int64, len(*relates))
for i, relate := range *relates {
userIDs[i] = relate.Uid
}

//2. 查询所属代数
platoonUserRelationDb := implement.NewPublicPlatoonUserRelationDb(db.Db)
levelTotals, err := platoonUserRelationDb.PublicPlatoonUserRelationFindByParamsByPage(map[string]interface{}{
"key": "uid",
"value": userIDs,
}, utils.StrToInt(page), utils.StrToInt(limit))
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
levelTotalMap := make(map[int64]int)
for _, levelTotal := range *levelTotals {
levelTotalMap[levelTotal.Uid] = levelTotal.LevelTotal
}

//3. 查询可提现余额
walletDb := implement.NewUserWalletDb(db.Db)
wallets, err := walletDb.FindUserWalletByParams(map[string]interface{}{
"key": uid,
"value": userIDs,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
walletMap := make(map[int64]string)
for _, wallet := range *wallets {
walletMap[wallet.Uid] = wallet.Amount
}

//4. 查询累计收益
var incomeMap = map[int64]string{}
if len(*relates) > 0 {
userIDStrs := make([]string, len(*relates))
for i, id := range userIDs {
userIDStrs[i] = utils.Int64ToStr(id)
}
sql := "SELECT SUM(amount) as total, uid FROM `user_wallet_flow` WHERE uid in (%s) AND direction = 1 Group BY uid"
results, err := db.QueryNativeString(db.Db, fmt.Sprintf(sql, strings.Join(userIDStrs, ",")))
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
for _, res := range results {
incomeMap[utils.StrToInt64(res["uid"])] = res["total"]
}
}

//5. 查询用户信息
userDb := implement.NewUserDb(db.Db)
users, err := userDb.UserFindByParams(map[string]interface{}{
"key": "uid",
"value": userIDs,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

list := make([]md.FansNode, len(users))
for i, user := range users {
list[i] = md.FansNode{
ID: user.Id,
Nickname: user.Nickname,
Phone: user.Phone,
LevelTotal: levelTotalMap[user.Id],
Amount: walletMap[user.Id],
RegisterAt: user.CreateAt,
}
val, ok := incomeMap[user.Id]
if ok {
list[i].TotalIncome = val
}
}

resp := md.UserManagementGetFansResp{
List: list,
Paginate: md.Paginate{
Limit: utils.StrToInt(limit),
Page: utils.StrToInt(page),
Total: total,
},
}

e.OutSuc(c, resp, nil)
}

// UserManagementGetBalanceDetail
// @Summary 制度中心-会员中心-用户管理-会员明细(余额获取)
// @Tags 会员中心
// @Description 会员明细(余额获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param uid query string true "用户 ID"
// @Param limit query string true "每页大小"
// @Param page query string true "页数"
// @Success 200 {object} md.UserManagementGetBalanceDetailResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/userManagement/balanceDetail [get]
func UserManagementGetBalanceDetail(c *gin.Context) {
uid := c.Query("uid")
page := c.DefaultQuery("page", "1")
limit := c.DefaultQuery("limit", "10")

walletFlowDb := implement.NewUserWalletFlowDb(db.Db)
walletFlows, total, err := walletFlowDb.UserWalletFlowFindByParams(map[string]interface{}{
"key": "uid",
"value": uid,
}, utils.StrToInt(page), utils.StrToInt(limit))
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

kindMap := map[int]string{
1: "管理员操作增加余额",
2: "管理员操作扣除余额",
3: "蛋蛋能量兑换余额",
4: "余额兑换蛋蛋能量",
}

list := make([]md.BalanceDetailNode, len(*walletFlows))
for i, flow := range *walletFlows {
list[i] = md.BalanceDetailNode{
ID: flow.Id,
Amount: flow.Amount,
AfterAmount: flow.AfterAmount,
Kind: kindMap[flow.Kind],
CreateAt: flow.CreateAt,
}
}

resp := md.UserManagementGetBalanceDetailResp{
List: list,
Paginate: md.Paginate{
Limit: utils.StrToInt(limit),
Page: utils.StrToInt(page),
Total: total,
},
}
e.OutSuc(c, resp, nil)
}

// UserManagementGetVirtualCoinDetail
// @Summary 制度中心-会员中心-用户管理-会员明细(积分明细获取)
// @Tags 会员中心
// @Description 会员明细(积分明细获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param uid query string true "用户 ID"
// @Param coinId query string true "货币 ID"
// @Param limit query string true "每页大小"
// @Param page query string true "页数"
// @Success 200 {object} md.UserManagementGetVirtualCoinDetailResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/memberCenter/userManagement/getVirtualCoinDetail [get]
func UserManagementGetVirtualCoinDetail(c *gin.Context) {
page := c.DefaultQuery("page", "1")
limit := c.DefaultQuery("limit", "10")
uid := c.Query("uid")
coinID := c.Query("coinId")
coinDb := implement.NewVirtualCoinDb(db.Db)
coins, err := coinDb.VirtualCoinFindAll()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if coins == nil {
e.OutErr(c, e.ERR_NO_DATA, errors.New("未初始化货币"))
return
}

coinsList := make([]map[string]interface{}, len(coins))
coinsMap := map[int]string{}
for i, coin := range coins {
coinsList[i] = map[string]interface{}{
"coinID": coin.Id,
"name": coin.Name,
}
coinsMap[coin.Id] = coin.Name
}

// 传入不存在的货币类型时 默认为第一种货币类型
var reqCoinID int
_, ok := coinsMap[utils.StrToInt(coinID)]
if !ok {
reqCoinID = coinsList[0]["coinID"].(int)
} else {
reqCoinID = utils.StrToInt(coinID)
}

flowDb := implement.NewUserVirtualCoinFlowDb(db.Db)
flows, total, err := flowDb.UserVirtualCoinFlowFindByCoinAndUser(utils.StrToInt(page), utils.StrToInt(limit), reqCoinID, utils.StrToInt64(uid), "", "", 0)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

list := make([]md.VirtualCoinDetailNode, len(flows))
for i, flow := range flows {
list[i] = md.VirtualCoinDetailNode{
Uid: flow.Uid,
Amount: flow.Amount,
AfterAmount: flow.AfterAmount,
Direction: flow.Direction,
CreateAt: flow.CreateAt,
}
}

resp := md.UserManagementGetVirtualCoinDetailResp{
CoinList: coinsList,
List: list,
Paginate: md.Paginate{
Limit: utils.StrToInt(limit),
Page: utils.StrToInt(page),
Total: total,
},
}

e.OutSuc(c, resp, nil)
}

+ 24
- 0
app/md/institutional_management/member_center/md_level_management.go Parādīt failu

@@ -0,0 +1,24 @@
package md

type LevelListNode struct {
LevelID int `json:"level_id"` // 等级 ID
LevelName string `json:"level_name"` // 等级名称
LevelWeight int `json:"level_weight"` // 等级权重
Count string `json:"count"` // 等级人数
IsUse int `json:"is_use"` // 是否开启(0.否, 1.是)
Memo string `json:"memo"` // 备注
CreateAt string `json:"create_at"` // 创建时间
}

type GetLevelListResp struct {
List []LevelListNode `json:"list"`
Paginate Paginate `json:"paginate"`
}

type UpdateLevelReq struct {
LevelID string `json:"level_id"`
IsUse int `json:"is_use"` // 是否开启(0.否, 1.是)
LevelName string `json:"level_name"` // 等级名称
Memo string `json:"memo"` // 备注
LevelWeight int `json:"level_weight"` // 等级权重
}

+ 26
- 0
app/md/institutional_management/member_center/md_tag_management.go Parādīt failu

@@ -0,0 +1,26 @@
package md

import "time"

type TagListNode struct {
TagID string `json:"tag_id"` // 标签 ID
Name string `json:"name"` // 名称
Count string `json:"count"` // 标签人数
CreateAt time.Time `json:"create_at"` // 创建时间
Memo string `json:"memo"` // 备注
}

type GetTagListResp struct {
List []TagListNode `json:"list"`
Paginate Paginate `json:"paginate"`
}

type UpdateTagReq struct {
TagID string `json:"tag_id,required"` // 标签 ID
Name string `json:"name,required"` // 标签名称
Memo string `json:"memo,required"` // 备注
}

type DeleteTagReq struct {
TagID string `json:"tag_id,required"` // 标签 ID
}

+ 82
- 32
app/md/institutional_management/member_center/md_user_management.go Parādīt failu

@@ -16,7 +16,7 @@ type UserManagementGetUserListReq struct {
Sex int `json:"sex"` // 性别
UnionId string `json:"union_id" example:"微信号"`
Level int `json:"level"` // 会员等级
RegisterType int `json:"register_type"` // 注册类型(1:APP注册、2:H5注册)
RegisterType int `json:"register_type"` // 注册类型(0.未知, 1.免验证码手机号注册,2.微信授权)
State int `json:"state"` // 状态
Effective int `json:"effective"` // 有效会员
IsRealName int `json:"is_real_name"` // 是否实名 0.未实名,1.已实名
@@ -25,8 +25,8 @@ type UserManagementGetUserListReq struct {
RegisterAfter string `json:"register_after"` // 注册时间终点
LoginBefore string `json:"login_before"` // 最近登录开始时间
LoginAfter string `json:"login_after"` // 最近登录结束时间
Page int `json:"page"`
Limit int `json:"limit"`
Page int `json:"page,required"`
Limit int `json:"limit,required"`
}

type Paginate struct {
@@ -42,14 +42,13 @@ type UserManagementGetUserListNode struct {
Nickname string `json:"nickname"` // 昵称
Phone string `json:"phone"` // 手机号
IsRealName int `json:"is_real_name"` // 是否实名 0.未实名,1.已实名
Level string `json:"level_name"` // 会员等级
LevelName string `json:"level_name"` // 会员等级
InviteCode string `json:"invite_code" example:"会员邀请码"`
ParentID int64 `json:"parent_id"` // 推荐人 ID
ParentInviteCode string `json:"parent_invite_code" example:"推荐人邀请码"`
ParentPhone string `json:"parent_phone" example:"推荐人手机号"`
RegisterTime string `json:"register_time"` // 注册时间
Memo string `json:"memo"` // 备注
model.User
}

type UserManagementGetUserListResp struct {
@@ -74,45 +73,96 @@ type LevelCount struct {

type UserManagementUpdateUserInfoReq struct {
UID int64 `json:"uid,required"`
Avatar string `json:"avatar"` // 头像
Sex string `json:"sex"` // 性别(0:未知 1:男 2:女)
Level string `json:"level"` // 会员等级 ID
Tag string `json:"tag"` // 用户标签 ID
Phone string `json:"phone"` // 手机号
Nickname string `json:"nickname"` // 用户名
UnionId string `json:"union_id"` // 微信号
Memo string `json:"memo" example:"备注"`
Disable bool `json:"disable"` // 是否禁用用户
Tag int `json:"tag"` // 用户标签 ID
State string `json:"state"` // 账号状态 1正常,2冻结
LastLoginIp string `json:"last_login_ip"` // 用户最后登录 IP
Avatar string `json:"avatar"` // 头像
}

type UserManagementGetOneBasicNode struct {
Avatar string `json:"avatar"` // 头像
Sex int `json:"sex"` // 性别
Nickname string `json:"nickname"` // 会员名称
TagID int `json:"tag_id"` // 标签 ID
Phone string `json:"phone"` // 手机号
UnionId string `json:"union_id"` // 微信号
Password string `json:"password"` // 登录密码
Passcode string `json:"passcode"` // 支付密码
State int `json:"state"` // 账号状态 1正常,2冻结
Memo string `json:"memo"` // 备注
ParentUid int64 `json:"parent_uid"` // 推荐人
ParentName string `json:"parent_name"` // 推荐人名称
ParentPhone string `json:"parent_phone"` // 推荐人手机号
SystemInviteCode string `json:"system_invite_code"` // 系统邀请码
CustomInviteCode string `json:"custom_invite_code"` // 自定义邀请码
Level int `json:"level"` // 等级 ID
ParentUid string `json:"parent_uid"` // 邀请人 ID
}

type BasicInfoNode struct {
Avatar string `json:"avatar"` // 头像
Sex int `json:"sex"` // 性别
Nickname string `json:"nickname"` // 用户名称
LevelName string `json:"level_name"` // 会员等级名称
TagName string `json:"tag_name"` // 标签名称
Phone string `json:"phone"` // 手机号
UnionId string `json:"union_id"` // 微信号
Password string `json:"password"` // 登录密码
State int `json:"state"` // 账号状态 1正常,2冻结
Memo string `json:"memo"` // 备注
ParentUid int64 `json:"parent_uid"` // 推荐人
ParentName string `json:"parent_name"` // 推荐人名称
ParentPhone string `json:"parent_phone"` // 推荐人手机号
}

type OtherNode struct {
LastLoginIp string `json:"last_login_ip" ` // 最后登录 IP
LastLoginAt string `json:"last_login_at" ` // 最近登录时间
CreateAt string `json:"create_at" ` // 注册时间
RegisterType int `json:"register_at" ` // 注册类型(0.未知, 1.免验证码手机号注册,2.微信授权)
LastLoginIp string `json:"last_login_ip" ` // 最后登录 IP
LastLoginAt string `json:"last_login_at" ` // 最近登录时间
CreateAt string `json:"create_at" ` // 注册时间
}

type WalletNode struct {
Amount string `json:"amount"` // 用户余额
}

type VirtualAmountInfoNode struct {
CoinName string `json:"coin_name"` // 货币类型
Amount string `json:"amount"` // 余额
}

type UserManagementGetOneBasicResp struct {
TagsList []map[string]interface{} `json:"tags_list"` // 标签列表
LevelsList []map[string]interface{} `json:"levels_list"` // 等级列表
CoinsList []map[string]interface{} `json:"coins_list"` // 货币列表
BasicInfo BasicInfoNode `json:"basic_info"` // 基本信息
OtherInfo OtherNode `json:"other_info"` // 其他信息
}

type FansNode struct {
ID int64 `json:"id"` // 用户ID
Nickname string `json:"nickname" example:"用户昵称"`
Phone string `json:"phone" example:"手机号"`
LevelTotal int `json:"level_total"` // 所属代数
Amount string `json:"amount"` // 可提现余额
TotalIncome string `json:"total_income"` // 累计收益
RegisterAt string `json:"register_at"` // 注册时间
}

type UserManagementGetFansResp struct {
List []FansNode `json:"list"` // 用户数据
Paginate Paginate `json:"paginate"` // 分页信息
}

type BalanceDetailNode struct {
ID int64 `json:"id"` // 记录ID
Amount string `json:"amount"` // 变更数量
BeforeAmount string `json:"before_amount"` // 变更前余额
AfterAmount string `json:"after_amount"` // 变更后余额
Kind string `json:"kind"` //类型 1:管理员操作增加余额 2:管理员操作扣除余额 3:蛋蛋能量兑换余额 4:余额兑换蛋蛋能量
CreateAt string `json:"create_at"` // 创建时间
}

type UserManagementGetBalanceDetailResp struct {
List []BalanceDetailNode `json:"list"`
Paginate Paginate `json:"paginate"`
}

type VirtualCoinDetailNode struct {
Uid int64 `json:"uid"` // 用户 ID
Amount string `json:"amount"` // 变更数量
AfterAmount string `json:"after_amount"` // 变更后积分余额
Direction int `json:"direction"` // 类型 1.收入 2.支出
CreateAt string `json:"create_at"` // 创建时间
}

type UserManagementGetVirtualCoinDetailResp struct {
CoinList []map[string]interface{} `json:"coin_list"`
List []VirtualCoinDetailNode `json:"list"`
Paginate Paginate `json:"paginate"`
}

+ 17
- 3
app/router/router.go Parādīt failu

@@ -54,9 +54,9 @@ func Init() *gin.Engine {
func route(r *gin.RouterGroup) {
r.GET("/test", hdl.Demo)
r.POST("/login", hdl.Login)
r.Use(mw.Auth) // 以下接口需要JWT验证
//r.Use(mw.Auth) // 以下接口需要JWT验证
rComm(r.Group("/comm"))
r.Use(mw.CheckPermission) // 检测权限
//r.Use(mw.CheckPermission) // 检测权限
rInstitutionalManagement(r.Group("/institutionalManagement"))
rMarketingApplications(r.Group("/marketingApplications"))
rMemberCenter(r.Group("/memberCenter"))
@@ -159,8 +159,22 @@ func rMemberCenter(r *gin.RouterGroup) { // 会员中心
rUserManagement := r.Group("/userManagement")
{
rUserManagement.POST("/getUserList", member_center.UserManagementGetUserList)
//rUserManagement.GET("/userData", member_center.UserManagementGetOneBasic)
rUserManagement.GET("/userData", member_center.UserManagementGetOneBasic)
rUserManagement.POST("/updateUserInfo", member_center.UserManagementUpdateUserInfo)
rUserManagement.GET("/getFans", member_center.UserManagementGetFans)
rUserManagement.GET("/balanceDetail", member_center.UserManagementGetBalanceDetail)
rUserManagement.GET("/getVirtualCoinDetail", member_center.UserManagementGetVirtualCoinDetail)
}
rTagManagement := r.Group("/tagManagement")
{
rTagManagement.GET("/getTagList", member_center.GetTagList)
rTagManagement.POST("/updateTag", member_center.UpdateTag)
rTagManagement.DELETE("/deleteTag", member_center.DeleteTag)
}
rLevelManagement := r.Group("/levelManagement")
{
rLevelManagement.GET("/getLevelList", member_center.GetLevelList)
rLevelManagement.POST("/updateLevel", member_center.UpdateLevel)
}
}



Notiek ielāde…
Atcelt
Saglabāt