|
@@ -5,9 +5,12 @@ import ( |
|
|
"applet/app/e" |
|
|
"applet/app/e" |
|
|
md "applet/app/md/institutional_management/member_center" |
|
|
md "applet/app/md/institutional_management/member_center" |
|
|
svc "applet/app/svc/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/implement" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
|
|
"fmt" |
|
|
"github.com/gin-gonic/gin" |
|
|
"github.com/gin-gonic/gin" |
|
|
|
|
|
"strings" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
// UserManagementGetUserList |
|
|
// UserManagementGetUserList |
|
@@ -175,7 +178,7 @@ func UserManagementUpdateUserInfo(c *gin.Context) { |
|
|
// UserManagementGetOneBasic |
|
|
// UserManagementGetOneBasic |
|
|
// @Summary 制度中心-会员中心-会员明细概况(获取) |
|
|
// @Summary 制度中心-会员中心-会员明细概况(获取) |
|
|
// @Tags 会员中心 |
|
|
// @Tags 会员中心 |
|
|
// @Description 会员明细概况(更新) |
|
|
|
|
|
|
|
|
// @Description 会员明细概况(获取) |
|
|
// @Accept json |
|
|
// @Accept json |
|
|
// @Produce json |
|
|
// @Produce json |
|
|
// @param Authorization header string true "验证参数Bearer和token空格拼接" |
|
|
// @param Authorization header string true "验证参数Bearer和token空格拼接" |
|
@@ -183,84 +186,405 @@ func UserManagementUpdateUserInfo(c *gin.Context) { |
|
|
// @Success 200 {object} md.UserManagementGetOneBasicResp "会员明细概况具体数据" |
|
|
// @Success 200 {object} md.UserManagementGetOneBasicResp "会员明细概况具体数据" |
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
// @Router /api/memberCenter/userManagement/getOneBasicInfo [get] |
|
|
// @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() |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
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. 查询货币列表 |
|
|
|
|
|
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 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//4. 查询父用户信息 |
|
|
|
|
|
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 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//5. 查询用户标签 |
|
|
|
|
|
recordsDb := implement.NewUserTagRecordsDb(db.Db) |
|
|
|
|
|
userTagRecord, err := recordsDb.UserTagRecordsGetOneByParams(map[string]interface{}{ |
|
|
|
|
|
"key": "uid", |
|
|
|
|
|
"value": uid, |
|
|
|
|
|
}) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//6. 查询用户虚拟钱包 |
|
|
|
|
|
amountDb := implement.NewUserVirtualAmountDb(db.Db) |
|
|
|
|
|
virtualWallets, err := amountDb.GetUserVirtualAllWallets(utils.AnyToInt64(uid)) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
virtualAmountList := make([]md.VirtualAmountInfoNode, 0) |
|
|
|
|
|
for _, virtualWallet := range *virtualWallets { |
|
|
|
|
|
virtualAmountList = append(virtualAmountList, md.VirtualAmountInfoNode{ |
|
|
|
|
|
CoinName: coinsMap[virtualWallet.CoinId], |
|
|
|
|
|
Amount: virtualWallet.Amount, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//7. 查询用户钱包余额 |
|
|
|
|
|
userWalletDb := implement.NewUserWalletDb(db.Db) |
|
|
|
|
|
wallet, err := userWalletDb.GetUserVirtualWallet(utils.StrToInt64(uid)) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
resp := md.UserManagementGetOneBasicResp{ |
|
|
|
|
|
TagsList: tagsList, |
|
|
|
|
|
LevelsList: levelsList, |
|
|
|
|
|
CoinsList: coinsList, |
|
|
|
|
|
VirtualAmountInfo: virtualAmountList, |
|
|
|
|
|
BasicInfo: md.BasicInfoNode{ |
|
|
|
|
|
Avatar: user.Avatar, |
|
|
|
|
|
Sex: user.Sex, |
|
|
|
|
|
Nickname: user.Nickname, |
|
|
|
|
|
TagID: userTagRecord.TagId, |
|
|
|
|
|
Phone: user.Phone, |
|
|
|
|
|
UnionId: user.UnionId, |
|
|
|
|
|
Password: user.Password, |
|
|
|
|
|
Passcode: user.Passcode, |
|
|
|
|
|
State: user.State, |
|
|
|
|
|
Memo: user.Memo, |
|
|
|
|
|
ParentUid: parent.Id, |
|
|
|
|
|
ParentName: parent.Nickname, |
|
|
|
|
|
ParentPhone: parent.Phone, |
|
|
|
|
|
SystemInviteCode: user.SystemInviteCode, |
|
|
|
|
|
CustomInviteCode: user.CustomInviteCode, |
|
|
|
|
|
Level: levelsMap[user.Level], |
|
|
|
|
|
}, |
|
|
|
|
|
WalletInfo: md.WalletNode{ |
|
|
|
|
|
Amount: wallet.Amount, |
|
|
|
|
|
}, |
|
|
|
|
|
OtherInfo: md.OtherNode{ |
|
|
|
|
|
LastLoginIp: user.LastLoginIp, |
|
|
|
|
|
LastLoginAt: user.UpdateAt, |
|
|
|
|
|
CreateAt: user.CreateAt, |
|
|
|
|
|
RegisterType: user.RegisterType, |
|
|
|
|
|
}, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
e.OutSuc(c, resp, nil) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// UserManagementGetFans |
|
|
|
|
|
// @Summary 制度中心-会员中心-会员明细粉丝情况(获取) |
|
|
|
|
|
// @Tags 会员中心 |
|
|
|
|
|
// @Description 会员明细粉丝情况(获取) |
|
|
|
|
|
// @Accept json |
|
|
|
|
|
// @Produce json |
|
|
|
|
|
// @param Authorization header string true "验证参数Bearer和token空格拼接" |
|
|
|
|
|
// @Param uid query int true "用户 ID" |
|
|
|
|
|
// @Param type query int true "粉丝类型(1.全部 2.直推 3.二代 4.二代以后)" |
|
|
|
|
|
// @Param limit query int true "每页大小" |
|
|
|
|
|
// @Param page query int 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. 查询累计收益 |
|
|
|
|
|
userIDStrs := make([]string, len(*relates)) |
|
|
|
|
|
for i, id := range userIDs { |
|
|
|
|
|
userIDStrs[i] = utils.Int64ToStr(id) |
|
|
|
|
|
} |
|
|
|
|
|
sql := "SELECT SUM(amount) as total, uid FORM `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 |
|
|
|
|
|
} |
|
|
|
|
|
var incomeMap = map[int64]string{} |
|
|
|
|
|
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], |
|
|
|
|
|
TotalIncome: incomeMap[user.Id], |
|
|
|
|
|
RegisterAt: user.CreateAt, |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 int true "用户 ID" |
|
|
|
|
|
// @Param limit query int true "每页大小" |
|
|
|
|
|
// @Param page query int 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.Query("page") |
|
|
|
|
|
limit := c.Query("limit") |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
userDb := implement.NewUserDb(db.Db) |
|
|
|
|
|
user, err := userDb.UserGetOneByParams(map[string]interface{}{ |
|
|
|
|
|
"key": "uid", |
|
|
|
|
|
"value": uid, |
|
|
|
|
|
}) |
|
|
|
|
|
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, |
|
|
|
|
|
Uid: user.Id, |
|
|
|
|
|
Nickname: user.Nickname, |
|
|
|
|
|
Phone: user.Phone, |
|
|
|
|
|
Amount: flow.Amount, |
|
|
|
|
|
AfterAmount: flow.AfterAmount, |
|
|
|
|
|
Kind: kindMap[flow.Kind], |
|
|
|
|
|
OrdID: flow.OrdId, |
|
|
|
|
|
CreateAt: flow.CreateAt, |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// todo增加总数、支出总数 |
|
|
|
|
|
|
|
|
|
|
|
resp := md.UserManagementGetBalanceDetailResp{ |
|
|
|
|
|
List: list, |
|
|
|
|
|
Paginate: md.Paginate{ |
|
|
|
|
|
Limit: utils.StrToInt(limit), |
|
|
|
|
|
Page: utils.StrToInt(page), |
|
|
|
|
|
Total: total, |
|
|
|
|
|
}, |
|
|
|
|
|
} |
|
|
|
|
|
e.OutSuc(c, resp, nil) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// UserManagementGetVirtualCoinDetail todo 补充s wag 注释 |
|
|
|
|
|
func UserManagementGetVirtualCoinDetail(c *gin.Context) { |
|
|
|
|
|
page := c.Query("page") |
|
|
|
|
|
limit := c.Query("limit") |
|
|
|
|
|
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 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
} |