@@ -5,6 +5,7 @@ import ( | |||
"applet/app/e" | |||
md "applet/app/md/institutional_management/public_platoon" | |||
svc "applet/app/svc/public_platoon" | |||
"applet/app/utils" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||
"errors" | |||
@@ -216,74 +217,73 @@ func FindUserRelationshipMap(c *gin.Context) { | |||
// @Produce json | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Param uid query string true "用户ID" | |||
// @Success 200 {object} md.TreeNode "具体数据" | |||
// @Success 200 {object} md.FindSubUserRelationshipMapResp "具体数据" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/institutionalManagement/publicPlatoon/findSubUserRelationshipMap [get] | |||
func FindSubUserRelationshipMap(c *gin.Context) { | |||
uid := c.Query("uid") | |||
RelationDb := implement.NewPublicPlatoonUserRelationDb(db.Db) | |||
sonRelation, err1 := RelationDb.PublicPlatoonUserRelationGetOneByParams(map[string]interface{}{ | |||
"key": "uid", | |||
"value": uid, | |||
}) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||
return | |||
} | |||
parentRelation, err2 := RelationDb.PublicPlatoonUserRelationGetOneByParams(map[string]interface{}{ | |||
"key": "uid", | |||
"value": sonRelation.FatherUid1, | |||
}) | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||
uidInt := utils.AnyToInt64(uid) | |||
relateDb := implement.NewUserRelateDb(db.Db) | |||
userRelate, err := relateDb.GetUserParentUserRelate(uidInt) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
userDb := implement.NewUserDb(db.Db) | |||
son, err3 := userDb.UserGetOneByParams(map[string]interface{}{ | |||
parentUser, err4 := userDb.UserGetOneByParams(map[string]interface{}{ | |||
"key": "id", | |||
"value": sonRelation.Uid, | |||
"value": userRelate.ParentUid, | |||
}) | |||
if err3 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err3.Error()) | |||
if err4 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err4.Error()) | |||
return | |||
} | |||
parent, err4 := userDb.UserGetOneByParams(map[string]interface{}{ | |||
"key": "id", | |||
"value": parentRelation.Uid, | |||
platoonUserRelationDb := implement.NewPublicPlatoonUserRelationDb(db.Db) | |||
parentRelation, err := platoonUserRelationDb.PublicPlatoonUserRelationGetOneByParams(map[string]interface{}{ | |||
"key": "uid", | |||
"value": parentUser.Id, | |||
}) | |||
if err4 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err4.Error()) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
var sonNode []*md.TreeNode | |||
sonNode = append(sonNode, &md.TreeNode{ | |||
AvatarURL: son.Avatar, | |||
Phone: son.Phone, | |||
Nickname: son.Nickname, | |||
Uid: son.Id, | |||
PID: sonRelation.RecommendUid, | |||
Level: sonRelation.Level1, | |||
Position: sonRelation.Position1, | |||
SystemID: sonRelation.Id, | |||
Son: nil, | |||
}) | |||
res := md.TreeNode{ | |||
AvatarURL: parent.Avatar, | |||
Phone: parent.Phone, | |||
Nickname: parent.Nickname, | |||
Uid: parent.Id, | |||
subUser := md.SubUser{ | |||
AvatarURL: parentUser.Avatar, | |||
Phone: parentUser.Phone, | |||
Nickname: parentUser.Nickname, | |||
Uid: parentUser.Id, | |||
PID: parentRelation.RecommendUid, | |||
Level: parentRelation.Level1, | |||
Level: parentRelation.LevelTotal, | |||
Position: parentRelation.Position1, | |||
SystemID: parentRelation.Id, | |||
Son: sonNode, | |||
} | |||
e.OutSuc(c, res, nil) | |||
basicSettingDb := implement.NewPublicPlatoonBasicSettingDb(db.Db) | |||
basicSetting, err := basicSettingDb.PublicPlatoonBasicSettingGetOne() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
basicSettingResp := md.BasicSetting{ | |||
Id: basicSetting.Id, | |||
IsOpen: basicSetting.IsOpen, | |||
SeveralTimes: basicSetting.SeveralTimes, | |||
SeveralRows: basicSetting.SeveralRows, | |||
OriginatorUid: basicSetting.OriginatorUid, | |||
SystemPunishReplace: basicSetting.SystemPunishReplace, | |||
SystemPunishReplaceValue: basicSetting.SystemPunishReplaceValue, | |||
IsSelfActiveGetTeamRevenue: basicSetting.IsSelfActiveGetTeamRevenue, | |||
} | |||
resp := md.FindSubUserRelationshipMapResp{ | |||
SubUser: subUser, | |||
BasicSetting: basicSettingResp, | |||
SearchUid: uid, | |||
} | |||
e.OutSuc(c, resp, nil) | |||
} | |||
// ExchangeUserPosition | |||
@@ -305,7 +305,10 @@ func ExchangeUserPosition(c *gin.Context) { | |||
} | |||
userRelationDb := implement.NewPublicPlatoonUserRelationDb(db.Db) | |||
relation1, err2 := userRelationDb.PublicPlatoonUserRelationGetOneByPosition(req.Position1) | |||
relation1, err2 := userRelationDb.PublicPlatoonUserRelationGetOneByParams(map[string]interface{}{ | |||
"key": "uid", | |||
"value": req.Position1, | |||
}) | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||
return | |||
@@ -315,7 +318,10 @@ func ExchangeUserPosition(c *gin.Context) { | |||
return | |||
} | |||
relation2, err3 := userRelationDb.PublicPlatoonUserRelationGetOneByPosition(req.Position1) | |||
relation2, err3 := userRelationDb.PublicPlatoonUserRelationGetOneByParams(map[string]interface{}{ | |||
"key": "uid", | |||
"value": req.Position2, | |||
}) | |||
if err3 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err3.Error()) | |||
return | |||
@@ -325,7 +331,7 @@ func ExchangeUserPosition(c *gin.Context) { | |||
return | |||
} | |||
if relation1.Uid == 1 || relation2.Uid == 1 { | |||
if relation1.LevelTotal == 1 || relation2.LevelTotal == 1 { | |||
e.OutErr(c, e.ERR_BAD_REQUEST, errors.New("创始人位置不能被修改")) | |||
} | |||
@@ -470,8 +476,6 @@ func AddCommunityDividends(c *gin.Context) { | |||
return | |||
} | |||
// todo 判断分红数量是否大于社区分红钱包余额 | |||
now := time.Now() | |||
var m model.EggEnergyCommunityDividends | |||
m = model.EggEnergyCommunityDividends{ | |||
@@ -1,23 +1,50 @@ | |||
package md | |||
type GetPublicPlatoonBasicResp struct { | |||
IsOpen int `json:"is_open"` | |||
OriginatorUid int `json:"originator_uid"` | |||
SeveralTimes int `json:"several_times"` | |||
SeveralRows int `json:"several_rows"` | |||
SystemPunishReplace int `json:"system_punish_replace"` | |||
SystemPunishReplaceValue int `json:"system_punish_replace_value"` | |||
IsSelfActiveGetTeamRevenue int `json:"is_self_active_get_team_revenue"` | |||
IsOpen int `json:"is_open"` // 是否开启(1:开启 0:关闭) | |||
OriginatorUid int `json:"originator_uid"` // 创始人uid | |||
SeveralTimes int `json:"several_times"` // 几乘 | |||
SeveralRows int `json:"several_rows"` // 几排 | |||
SystemPunishReplace int `json:"system_punish_replace"` // 是否位置滑落 被新用户替换 0否 1是 | |||
SystemPunishReplaceValue int `json:"system_punish_replace_value"` // xx天未活跃,处罚滑落 | |||
IsSelfActiveGetTeamRevenue int `json:"is_self_active_get_team_revenue"` // 会员本人没有日活,没有圈层奖励(1:开启 0:关闭) | |||
} | |||
type UpdatePublicPlatoonBasicReq struct { | |||
IsOpen int `json:"is_open"` | |||
OriginatorUid int `json:"originator_uid"` | |||
SeveralTimes int `json:"several_times"` | |||
SeveralRows int `json:"several_rows"` | |||
SystemPunishReplace int `json:"system_punish_replace"` | |||
SystemPunishReplaceValue int `json:"system_punish_replace_value"` | |||
IsSelfActiveGetTeamRevenue int `json:"is_self_active_get_team_revenue"` | |||
IsOpen int `json:"is_open"` // 是否开启(1:开启 0:关闭) | |||
OriginatorUid int `json:"originator_uid"` // 创始人uid | |||
SeveralTimes int `json:"several_times"` // 几乘 | |||
SeveralRows int `json:"several_rows"` // 几排 | |||
SystemPunishReplace int `json:"system_punish_replace"` // 是否位置滑落 被新用户替换 0否 1是 | |||
SystemPunishReplaceValue int `json:"system_punish_replace_value"` // xx天未活跃,处罚滑落 | |||
IsSelfActiveGetTeamRevenue int `json:"is_self_active_get_team_revenue"` // 会员本人没有日活,没有圈层奖励(1:开启 0:关闭) | |||
} | |||
type SubUser struct { | |||
AvatarURL string `json:"avatar_url" example:"头像"` | |||
Phone string `json:"phone" example:"手机号"` | |||
Nickname string `json:"nickname" example:"昵称"` | |||
Uid int64 `json:"uid"` | |||
PID int64 `json:"pid"` | |||
Level int `json:"level"` // 整个系统中的等级 | |||
Position int64 `json:"position"` // 以pid1为创始人中网的位置 | |||
} | |||
type BasicSetting struct { | |||
Id int `json:"id"` | |||
IsOpen int `json:"is_open"` // 是否开启(1:开启 0:关闭) | |||
SeveralTimes int `json:"several_times"` // 几乘 | |||
SeveralRows int `json:"several_rows"` // 几排 | |||
OriginatorUid int `json:"originator_uid"` // 创始人uid | |||
SystemPunishReplace int `json:"system_punish_replace"` // 是否位置滑落 被新用户替换 0否 1是 | |||
SystemPunishReplaceValue int `json:"system_punish_replace_value"` // xx天未活跃,处罚滑落 | |||
IsSelfActiveGetTeamRevenue int `json:"is_self_active_get_team_revenue"` // 会员本人没有日活,没有圈层奖励(1:开启 0:关闭) | |||
} | |||
type FindSubUserRelationshipMapResp struct { | |||
SubUser SubUser `json:"sub_user"` // 上级用户信息 | |||
BasicSetting BasicSetting `json:"basic_setting"` // 公排设置 | |||
SearchUid string `json:"search_uid"` // 查找的用户 ID | |||
} | |||
type ExchangeUserPositionReq struct { | |||
@@ -38,26 +65,26 @@ type TreeNode struct { | |||
} | |||
type GetFreePublishUserReq struct { | |||
Limit int `json:"limit,required"` | |||
Uid int64 `json:"uid"` | |||
Page int `json:"page,required"` | |||
Limit int `json:"limit,required"` // 每页大小 | |||
Uid int64 `json:"uid"` // 筛选的用户 ID | |||
Page int `json:"page,required"` // 当前页数 | |||
} | |||
type FreePublishUserNode struct { | |||
UID int64 `json:"uid"` | |||
Phone string `json:"phone"` | |||
Nickname string `json:"nickname"` | |||
Phone string `json:"phone" example:"手机号"` | |||
Nickname string `json:"nickname" example:"昵称"` | |||
} | |||
type GetFreePublishUserResp struct { | |||
Paginate Paginate `json:"paginate"` | |||
List []FreePublishUserNode `json:"list"` | |||
Paginate Paginate `json:"paginate"` // 分页信息 | |||
List []FreePublishUserNode `json:"list"` // 免罚用户列表 | |||
} | |||
type Paginate struct { | |||
Limit int `json:"limit"` | |||
Page int `json:"page"` | |||
Total int64 `json:"total"` | |||
Limit int `json:"limit"` // 每页大小 | |||
Page int `json:"page"` // 页数 | |||
Total int64 `json:"total"` // 总数据量 | |||
} | |||
type AddFreePublishUserReq struct { | |||
@@ -65,11 +92,11 @@ type AddFreePublishUserReq struct { | |||
} | |||
type AddCommunityDividendsReq struct { | |||
Name string `json:"name,required"` | |||
Nums int `json:"nums,required"` | |||
Name string `json:"name,required" example:"社区分红名称"` | |||
Nums int `json:"nums,required"` // 社区分红数量 | |||
} | |||
type AddCommunityDividendsWithUserReq struct { | |||
Uid int64 `json:"uid,required"` | |||
Memo string `json:"memo"` | |||
Uid int64 `json:"uid,required"` // 新增社区长用户 ID | |||
Memo string `json:"memo" example:"备注"` | |||
} |
@@ -101,11 +101,19 @@ func ExchangeUserPosition(engine *xorm.Engine, relation1, relation2 *model.Publi | |||
return zhios_order_relate_logx.Error(err) | |||
} | |||
_, err = session.Where("id = ?", relation1.Id).Cols(forceColums...).Update(session, &relation1) | |||
_, err = session.Table(new(model.PublicPlatoonUserRelation)).ID(relation1.Id).Update(map[string]interface{}{"uid": -99}) | |||
if err != nil { | |||
return zhios_order_relate_logx.Error(err) | |||
} | |||
_, err = session.Table(new(model.PublicPlatoonUserRelation)).ID(relation2.Id).Update(map[string]interface{}{"uid": -999}) | |||
if err != nil { | |||
return zhios_order_relate_logx.Error(err) | |||
} | |||
_, err = session.Where("id = ?", relation1.Id).Cols(forceColums...).Update(session, &relation1) | |||
if err != nil { | |||
return zhios_order_relate_logx.Error(err) | |||
} | |||
_, err = session.Where("id = ?", relation2.Id).Cols(forceColums...).Update(session, &relation2) | |||
if err != nil { | |||
return zhios_order_relate_logx.Error(err) | |||