Bläddra i källkod

update

master
shenjiachi 1 vecka sedan
förälder
incheckning
6df15acfbd
8 ändrade filer med 710 tillägg och 53 borttagningar
  1. +16
    -24
      app/hdl/member_center/hdl_level__management.go
  2. +2
    -23
      app/hdl/member_center/hdl_tag__management.go
  3. +214
    -0
      app/hdl/notice/hdl_aliyun_sms.go
  4. +214
    -0
      app/hdl/notice/hdl_notice.go
  5. +189
    -0
      app/md/md_notice.go
  6. +6
    -6
      app/router/router.go
  7. +31
    -0
      app/svc/member_center/svc_level_management.go
  8. +38
    -0
      app/svc/member_center/svc_tag__management.go

+ 16
- 24
app/hdl/member_center/hdl_level__management.go Visa fil

@@ -30,35 +30,12 @@ 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))
list, total, err := svc.LevelManagementGetLevelList(page, 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([]md2.LevelListNode, len(levels))
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 := md2.GetLevelListResp{
List: list,
Paginate: md2.Paginate{
@@ -165,6 +142,21 @@ func UpdateLevel(c *gin.Context) {
forceColumns = append(forceColumns, "level_weight")
}
if req.IsUse == "0" || req.IsUse == "1" {
// 判断当前该等级有没有被使用
userDb := implement.NewUserDb(db.Db)
has, err := userDb.UserExistByParams(map[string]interface{}{
"key": "level",
"value": req.IsUse,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if has {
e.OutErr(c, e.ERR, errors.New("该等级下存在会员,无法关闭该会员等级,请移除对应等级下会员或将会员移动到其他等级").Error())
return
}

level.LevelWeight = utils.StrToInt(req.IsUse)
forceColumns = append(forceColumns, "is_use")
}


+ 2
- 23
app/hdl/member_center/hdl_tag__management.go Visa fil

@@ -4,6 +4,7 @@ import (
"applet/app/db"
"applet/app/e"
md2 "applet/app/md/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"
@@ -28,33 +29,11 @@ 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)
list, total, err := svc.TagManagementGetList(page, limit)
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([]md2.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
list[i].TagID = utils.IntToStr(tag.Id)
list[i].IsPunish = tag.IsPunish
}

resp := md2.GetTagListResp{
List: list,


+ 214
- 0
app/hdl/notice/hdl_aliyun_sms.go Visa fil

@@ -1,7 +1,14 @@
package notice

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

@@ -124,3 +131,210 @@ func AliyunSmsPushList(c *gin.Context) {
func AliyunSmsPushSave(c *gin.Context) {
notice.AliyunSmsPushSave(c)
}

// AliyunSmsGetUserList
// @Summary 消息中心-短信推送记录-获取用户信息
// @Tags 消息中心
// @Description 获取用户信息
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.JPushGetUserListReq true "(分页信息必填)"
// @Success 200 {Object} md.JPushGetUserListResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/notice/aliyunSms/getUserList [post]
func AliyunSmsGetUserList(c *gin.Context) {
var req *md.AliyunSmsUserListReq
if err := c.ShouldBindJSON(&req); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, 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
}

stateList := []map[string]interface{}{
{
"name": "正常",
"value": "1",
},
{
"name": "冻结",
"value": "2",
},
}
userMemberRequest := req.ToUserMemberRequest()
users, total, err3 := svc.UserManagementGetUsers(userMemberRequest)
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.GetUserListNode, len(users))
for i, user := range users {
list[i] = md.GetUserListNode{
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.Phone,
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.AliyunSmsGetUserListResp{
LevelsList: levelsList,
TagsList: tagsList,
StateList: stateList,
List: list,
Paginate: md.Paginate{
Limit: req.Limit,
Page: req.Page,
Total: total,
},
}
e.OutSuc(c, resp, nil)
}

// AliyunSmsTagList
// @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.AliyunSmsGetTagListResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/notice/aliyunSms/getTagList [get]
func AliyunSmsTagList(c *gin.Context) {
page := c.DefaultQuery("page", "1")
limit := c.DefaultQuery("limit", "10")

list, total, err := svc.TagManagementGetList(page, limit)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

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

// AliyunSmsGetLevelList
// @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.AliyunSmsGetLevelListResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/notice/aliyunSms/getLevelList [get]
func AliyunSmsGetLevelList(c *gin.Context) {
page := c.DefaultQuery("page", "1")
limit := c.DefaultQuery("limit", "10")

list, total, err := svc.LevelManagementGetLevelList(page, limit)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

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

e.OutSuc(c, resp, nil)
}

+ 214
- 0
app/hdl/notice/hdl_notice.go Visa fil

@@ -1,7 +1,14 @@
package notice

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

@@ -79,3 +86,210 @@ func PushList(c *gin.Context) {
func PushSave(c *gin.Context) {
notice.PushSave(c)
}

// JPushGetUserList
// @Summary 消息中心-基本配置-获取用户信息
// @Tags 消息中心
// @Description 获取用户信息
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.JPushGetUserListReq true "(分页信息必填)"
// @Success 200 {Object} md.JPushGetUserListResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/notice/jPush/getUserList [post]
func JPushGetUserList(c *gin.Context) {
var req *md.JPushGetUserListReq
if err := c.ShouldBindJSON(&req); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, 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
}

stateList := []map[string]interface{}{
{
"name": "正常",
"value": "1",
},
{
"name": "冻结",
"value": "2",
},
}
userMemberRequest := req.ToUserMemberRequest()
users, total, err3 := svc.UserManagementGetUsers(userMemberRequest)
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.GetUserListNode, len(users))
for i, user := range users {
list[i] = md.GetUserListNode{
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.Phone,
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.JPushGetUserListResp{
LevelsList: levelsList,
TagsList: tagsList,
StateList: stateList,
List: list,
Paginate: md.Paginate{
Limit: req.Limit,
Page: req.Page,
Total: total,
},
}
e.OutSuc(c, resp, nil)
}

// JPushGetTagList
// @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.JPushGetTagListResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/notice/jPush/getTagList [get]
func JPushGetTagList(c *gin.Context) {
page := c.DefaultQuery("page", "1")
limit := c.DefaultQuery("limit", "10")

list, total, err := svc.TagManagementGetList(page, limit)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

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

// JPushGetLevelList
// @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.JPushGetLevelListResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/notice/jPush/getLevelList [get]
func JPushGetLevelList(c *gin.Context) {
page := c.DefaultQuery("page", "1")
limit := c.DefaultQuery("limit", "10")

list, total, err := svc.LevelManagementGetLevelList(page, limit)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

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

e.OutSuc(c, resp, nil)
}

+ 189
- 0
app/md/md_notice.go Visa fil

@@ -1,5 +1,10 @@
package md

import (
md "applet/app/md/member_center"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
)

type NoticeListReq struct {
Page string `json:"page,required"` // 页数
Limit string `json:"limit,required"` // 每页大小
@@ -118,3 +123,187 @@ type NoticeAliyunSmsPushSaveReq struct {
TagList []string `json:"tag_list"`
Level []string `json:"level"`
}

type Paginate struct {
Limit int `json:"limit"` // 每页大小
Page int `json:"page"` // 页数
Total int64 `json:"total"` // 总数据量
}

type JPushGetUserListResp struct {
LevelsList []map[string]interface{} `json:"levels_list"` // 等级列表
TagsList []map[string]interface{} `json:"tags_list"` // 标签列表
StateList []map[string]interface{} `json:"state_list"` // 状态列表
List []GetUserListNode `json:"list"`
Paginate Paginate `json:"paginate"` // 分页信息
}

type TagNode struct {
TagID int `json:"tag_id"` // 标签 ID
TagName string `json:"tag_name"` // 标签名称
}
type LevelCount struct {
Level int `xorm:"level"`
Count int `xorm:"count"`
}

type GetUserListNode struct {
ID int64 `json:"id"` // 会员 ID
Tag []TagNode `json:"tag"` // 会员标签
Sex int `json:"sex"` // 性别(0:未知 1:男 2:女)
Avatar string `json:"avatar"` // 头像
Nickname string `json:"nickname"` // 昵称
Phone string `json:"phone"` // 手机号
IsRealName int `json:"is_real_name"` // 是否实名 0.未实名,1.已实名
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"` // 备注
Wechat string `json:"wechat"` // 微信号
RegisterType int `json:"register_type"` // 注册类型
State int `json:"state"` // 状态
LastLoginAt string `json:"last_login_at"` // 最后登录时间
}

type JPushGetUserListReq struct {
ID int64 `json:"id"` // 会员 ID
Nickname string `json:"nickname" example:"会员昵称"`
RecommendID int64 `json:"recommend_id"` // 推荐人 ID
Tag int `json:"tag"` // 标签 id
Phone string `json:"phone" example:"会员手机号"`
InviteCode string `json:"invite_code" example:"会员邀请码"`
ParentInviteCode string `json:"parent_invite_code" example:"上级邀请码"`
ParentPhone string `json:"parent_phone" example:"上级手机号"`
Sex int `json:"sex"` // 性别(0:未知 1:男 2:女)
UnionId string `json:"union_id" example:"微信号"`
Level int `json:"level"` // 会员等级
RegisterType int `json:"register_type"` // 注册类型(1:APP注册、2:H5注册)
State int `json:"state"` // 状态
Effective int `json:"effective"` // 有效会员
IsRealName int `json:"is_real_name"` // 是否实名 0.未实名,1.已实名
Memo string `json:"memo"` // 备注
RegisterBefore string `json:"register_before"` // 注册时间起点
RegisterAfter string `json:"register_after"` // 注册时间终点
LoginBefore string `json:"login_before"` // 最近登录开始时间
LoginAfter string `json:"login_after"` // 最近登录结束时间
Page int `json:"page,required"`
Limit int `json:"limit,required"`
}

type UserInfo struct {
model.User `xorm:"extends"`
TagID int `xorm:"tag_id"`
ParentPhone string `xorm:"parent_phone"`
ParentSystemInviteCode string `xorm:"parent_system_invite_code"`
ParentCustomInviteCode string `xorm:"parent_custom_invite_code"`
}

type JPushGetTagListResp struct {
List []md.TagListNode `json:"list"`
Paginate Paginate `json:"paginate"`
}

type JPushGetLevelListResp struct {
List []md.LevelListNode `json:"list"`
Paginate Paginate `json:"paginate"`
}

type AliyunSmsGetUserListResp struct {
LevelsList []map[string]interface{} `json:"levels_list"` // 等级列表
TagsList []map[string]interface{} `json:"tags_list"` // 标签列表
StateList []map[string]interface{} `json:"state_list"` // 状态列表
List []GetUserListNode `json:"list"`
Paginate Paginate `json:"paginate"` // 分页信息
}

type AliyunSmsUserListReq struct {
ID int64 `json:"id"` // 会员 ID
Nickname string `json:"nickname" example:"会员昵称"`
RecommendID int64 `json:"recommend_id"` // 推荐人 ID
Tag int `json:"tag"` // 标签 id
Phone string `json:"phone" example:"会员手机号"`
InviteCode string `json:"invite_code" example:"会员邀请码"`
ParentInviteCode string `json:"parent_invite_code" example:"上级邀请码"`
ParentPhone string `json:"parent_phone" example:"上级手机号"`
Sex int `json:"sex"` // 性别(0:未知 1:男 2:女)
UnionId string `json:"union_id" example:"微信号"`
Level int `json:"level"` // 会员等级
RegisterType int `json:"register_type"` // 注册类型(1:APP注册、2:H5注册)
State int `json:"state"` // 状态
Effective int `json:"effective"` // 有效会员
IsRealName int `json:"is_real_name"` // 是否实名 0.未实名,1.已实名
Memo string `json:"memo"` // 备注
RegisterBefore string `json:"register_before"` // 注册时间起点
RegisterAfter string `json:"register_after"` // 注册时间终点
LoginBefore string `json:"login_before"` // 最近登录开始时间
LoginAfter string `json:"login_after"` // 最近登录结束时间
Page int `json:"page,required"`
Limit int `json:"limit,required"`
}

type AliyunSmsGetTagListResp struct {
List []md.TagListNode `json:"list"`
Paginate Paginate `json:"paginate"`
}

type AliyunSmsGetLevelListResp struct {
List []md.LevelListNode `json:"list"`
Paginate Paginate `json:"paginate"`
}

func (req JPushGetUserListReq) ToUserMemberRequest() *md.UserManagementGetUserListReq {
return &md.UserManagementGetUserListReq{
ID: req.ID,
Nickname: req.Nickname,
RecommendID: req.RecommendID,
Tag: req.Tag,
Phone: req.Phone,
InviteCode: req.InviteCode,
ParentInviteCode: req.ParentInviteCode,
ParentPhone: req.ParentPhone,
Sex: req.Sex,
UnionId: req.UnionId,
Level: req.Level,
RegisterType: req.RegisterType,
State: req.State,
Effective: req.Effective,
IsRealName: req.IsRealName,
Memo: req.Memo,
RegisterBefore: req.RegisterBefore,
RegisterAfter: req.RegisterAfter,
LoginBefore: req.LoginBefore,
LoginAfter: req.LoginAfter,
Page: req.Page,
Limit: req.Limit,
}
}

func (req AliyunSmsUserListReq) ToUserMemberRequest() *md.UserManagementGetUserListReq {
return &md.UserManagementGetUserListReq{
ID: req.ID,
Nickname: req.Nickname,
RecommendID: req.RecommendID,
Tag: req.Tag,
Phone: req.Phone,
InviteCode: req.InviteCode,
ParentInviteCode: req.ParentInviteCode,
ParentPhone: req.ParentPhone,
Sex: req.Sex,
UnionId: req.UnionId,
Level: req.Level,
RegisterType: req.RegisterType,
State: req.State,
Effective: req.Effective,
IsRealName: req.IsRealName,
Memo: req.Memo,
RegisterBefore: req.RegisterBefore,
RegisterAfter: req.RegisterAfter,
LoginBefore: req.LoginBefore,
LoginAfter: req.LoginAfter,
Page: req.Page,
Limit: req.Limit,
}
}

+ 6
- 6
app/router/router.go Visa fil

@@ -147,17 +147,17 @@ func rNotice(r *gin.RouterGroup) {
rJpush := r.Group("/jPush") //极光
{
rJpush.POST("/push/list", notice.PushList)
rJpush.POST("/getUserList", member_center.UserManagementGetUserList)
rJpush.GET("/getTagList", member_center.GetTagList)
rJpush.GET("/getLevelList", member_center.GetLevelList)
rJpush.POST("/getUserList", notice.JPushGetUserList)
rJpush.GET("/getTagList", notice.JPushGetTagList)
rJpush.GET("/getLevelList", notice.JPushGetLevelList)
rJpush.POST("/push/save", notice.PushSave)
}
rAliyunSms := r.Group("/aliyunSms") //阿里云短信
{
rAliyunSms.POST("/file/phone", notice.AliyunSmsFilePhone)
rAliyunSms.POST("/getUserList", member_center.UserManagementGetUserList)
rAliyunSms.GET("/getTagList", member_center.GetTagList)
rAliyunSms.GET("/getLevelList", member_center.GetLevelList)
rAliyunSms.POST("/getUserList", notice.AliyunSmsGetUserList)
rAliyunSms.GET("/getTagList", notice.AliyunSmsTagList)
rAliyunSms.GET("/getLevelList", notice.AliyunSmsGetLevelList)
rAliyunSms.GET("/sale/base", notice.AliyunSmsSaleBase)
rAliyunSms.POST("/sale/save", notice.AliyunSmsSaleSave)
rAliyunSms.POST("/push/list", notice.AliyunSmsPushList)


+ 31
- 0
app/svc/member_center/svc_level_management.go Visa fil

@@ -45,3 +45,34 @@ func BatchAddLevelTask(session *xorm.Session, tasks []md.LevelTaskNode, levelId
return nil

}

func LevelManagementGetLevelList(page, limit string) ([]md.LevelListNode, int64, error) {
levelDb := implement.NewUserLevelDb(db.Db)
levels, total, err := levelDb.UserLevelAllByAscByPage(utils.StrToInt(page), utils.StrToInt(limit))
if err != nil {
return nil, 0, err
}

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

list := make([]md.LevelListNode, len(levels))
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
}

return list, total, nil
}

+ 38
- 0
app/svc/member_center/svc_tag__management.go Visa fil

@@ -0,0 +1,38 @@
package svc

import (
"applet/app/db"
md "applet/app/md/member_center"
"applet/app/utils"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
)

func TagManagementGetList(page, limit string) ([]md.TagListNode, int64, error) {
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 {
return nil, 0, err
}
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 {
return nil, 0, err
}

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
list[i].TagID = utils.IntToStr(tag.Id)
list[i].IsPunish = tag.IsPunish
}

return list, total, nil
}

Laddar…
Avbryt
Spara