修改:我的团队页面item统计项修改
This commit is contained in:
@@ -413,12 +413,12 @@ type (
|
|||||||
LevelName string `json:"level_name"` // 等级名称
|
LevelName string `json:"level_name"` // 等级名称
|
||||||
Mobile string `json:"mobile"` // 手机号
|
Mobile string `json:"mobile"` // 手机号
|
||||||
CreateTime string `json:"create_time"` // 加入团队时间
|
CreateTime string `json:"create_time"` // 加入团队时间
|
||||||
TodayQueries int64 `json:"today_queries"` // 当日查询量
|
|
||||||
TotalQueries int64 `json:"total_queries"` // 总查询量
|
|
||||||
TotalRebateAmount float64 `json:"total_rebate_amount"` // 返佣给我的总金额
|
|
||||||
TodayRebateAmount float64 `json:"today_rebate_amount"` // 返佣给我的今日金额
|
|
||||||
TotalInvites int64 `json:"total_invites"` // 邀请加入团队的总人数
|
|
||||||
TodayInvites int64 `json:"today_invites"` // 邀请加入团队的今日人数
|
TodayInvites int64 `json:"today_invites"` // 邀请加入团队的今日人数
|
||||||
|
MonthInvites int64 `json:"month_invites"` // 邀请加入团队的本月人数
|
||||||
|
TotalInvites int64 `json:"total_invites"` // 邀请加入团队的总人数
|
||||||
|
TodayQueries int64 `json:"today_queries"` // 当日查询量
|
||||||
|
MonthQueries int64 `json:"month_queries"` // 本月查询量
|
||||||
|
TotalQueries int64 `json:"total_queries"` // 总查询量
|
||||||
IsDirect bool `json:"is_direct"` // 是否直接下级
|
IsDirect bool `json:"is_direct"` // 是否直接下级
|
||||||
}
|
}
|
||||||
// 收益信息
|
// 收益信息
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ package agent
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
"qnc-server/app/main/model"
|
"qnc-server/app/main/model"
|
||||||
"qnc-server/common/ctxdata"
|
"qnc-server/common/ctxdata"
|
||||||
"qnc-server/common/globalkey"
|
"qnc-server/common/globalkey"
|
||||||
"qnc-server/common/xerr"
|
"qnc-server/common/xerr"
|
||||||
"qnc-server/pkg/lzkit/crypto"
|
"qnc-server/pkg/lzkit/crypto"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/Masterminds/squirrel"
|
"github.com/Masterminds/squirrel"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -170,7 +170,7 @@ func (l *GetTeamListLogic) GetTeamList(req *types.GetTeamListReq) (resp *types.G
|
|||||||
// 11. 组装响应列表
|
// 11. 组装响应列表
|
||||||
var list []types.TeamMemberItem
|
var list []types.TeamMemberItem
|
||||||
for _, member := range teamMembers {
|
for _, member := range teamMembers {
|
||||||
memberItem := l.buildTeamMemberItem(agent.Id, member, directSubordinateIds, todayStart)
|
memberItem := l.buildTeamMemberItem(agent.Id, member, directSubordinateIds, todayStart, monthStart)
|
||||||
list = append(list, memberItem)
|
list = append(list, memberItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ func (l *GetTeamListLogic) countDistinctOrdersForMember(ctx context.Context, bui
|
|||||||
}
|
}
|
||||||
|
|
||||||
// buildTeamMemberItem 构建团队成员项
|
// buildTeamMemberItem 构建团队成员项
|
||||||
func (l *GetTeamListLogic) buildTeamMemberItem(agentId string, member *model.Agent, directSubordinateIds map[string]bool, todayStart time.Time) types.TeamMemberItem {
|
func (l *GetTeamListLogic) buildTeamMemberItem(agentId string, member *model.Agent, directSubordinateIds map[string]bool, todayStart, monthStart time.Time) types.TeamMemberItem {
|
||||||
levelName := ""
|
levelName := ""
|
||||||
switch member.Level {
|
switch member.Level {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -310,16 +310,18 @@ func (l *GetTeamListLogic) buildTeamMemberItem(agentId string, member *model.Age
|
|||||||
totalQueries := l.countDistinctOrdersForMember(l.ctx, rebateBuilder)
|
totalQueries := l.countDistinctOrdersForMember(l.ctx, rebateBuilder)
|
||||||
todayRebateBuilder := rebateBuilder.Where("create_time >= ?", todayStart)
|
todayRebateBuilder := rebateBuilder.Where("create_time >= ?", todayStart)
|
||||||
todayQueries := l.countDistinctOrdersForMember(l.ctx, todayRebateBuilder)
|
todayQueries := l.countDistinctOrdersForMember(l.ctx, todayRebateBuilder)
|
||||||
|
monthRebateBuilder := rebateBuilder.Where("create_time >= ?", monthStart)
|
||||||
|
monthQueries := l.countDistinctOrdersForMember(l.ctx, monthRebateBuilder)
|
||||||
|
|
||||||
// 统计返佣给我的金额(从agent_rebate表,source_agent_id = member.Id, agent_id = agentId)
|
// 统计返佣给我的金额(从agent_rebate表,source_agent_id = member.Id, agent_id = agentId)
|
||||||
totalRebateAmount, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, rebateBuilder, "rebate_amount")
|
// 原返佣统计字段已在新需求中不再下发给前端,这里暂不计算金额,后续如有需要可在 .api 中重新定义并补充实现
|
||||||
todayRebateAmount, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, rebateBuilder.Where("create_time >= ?", todayStart), "rebate_amount")
|
|
||||||
|
|
||||||
// 统计邀请人数(从agent_relation表,parent_id = member.Id)
|
// 统计邀请人数(从agent_relation表,parent_id = member.Id)
|
||||||
inviteBuilder := l.svcCtx.AgentRelationModel.SelectBuilder().
|
inviteBuilder := l.svcCtx.AgentRelationModel.SelectBuilder().
|
||||||
Where("parent_id = ? AND relation_type = ? AND del_state = ?", member.Id, 1, globalkey.DelStateNo)
|
Where("parent_id = ? AND relation_type = ? AND del_state = ?", member.Id, 1, globalkey.DelStateNo)
|
||||||
totalInvites, _ := l.svcCtx.AgentRelationModel.FindCount(l.ctx, inviteBuilder, "id")
|
totalInvites, _ := l.svcCtx.AgentRelationModel.FindCount(l.ctx, inviteBuilder, "id")
|
||||||
todayInvites, _ := l.svcCtx.AgentRelationModel.FindCount(l.ctx, inviteBuilder.Where("create_time >= ?", todayStart), "id")
|
todayInvites, _ := l.svcCtx.AgentRelationModel.FindCount(l.ctx, inviteBuilder.Where("create_time >= ?", todayStart), "id")
|
||||||
|
monthInvites, _ := l.svcCtx.AgentRelationModel.FindCount(l.ctx, inviteBuilder.Where("create_time >= ?", monthStart), "id")
|
||||||
|
|
||||||
// 判断是否直接下级
|
// 判断是否直接下级
|
||||||
isDirect := directSubordinateIds[member.Id]
|
isDirect := directSubordinateIds[member.Id]
|
||||||
@@ -330,12 +332,12 @@ func (l *GetTeamListLogic) buildTeamMemberItem(agentId string, member *model.Age
|
|||||||
LevelName: levelName,
|
LevelName: levelName,
|
||||||
Mobile: mobile,
|
Mobile: mobile,
|
||||||
CreateTime: member.CreateTime.Format("2006-01-02 15:04:05"),
|
CreateTime: member.CreateTime.Format("2006-01-02 15:04:05"),
|
||||||
TodayQueries: todayQueries,
|
|
||||||
TotalQueries: totalQueries,
|
|
||||||
TotalRebateAmount: totalRebateAmount,
|
|
||||||
TodayRebateAmount: todayRebateAmount,
|
|
||||||
TotalInvites: totalInvites,
|
|
||||||
TodayInvites: todayInvites,
|
TodayInvites: todayInvites,
|
||||||
|
MonthInvites: monthInvites,
|
||||||
|
TotalInvites: totalInvites,
|
||||||
|
TodayQueries: todayQueries,
|
||||||
|
MonthQueries: monthQueries,
|
||||||
|
TotalQueries: totalQueries,
|
||||||
IsDirect: isDirect,
|
IsDirect: isDirect,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -505,12 +505,12 @@ type TeamMemberItem struct {
|
|||||||
LevelName string `json:"level_name"` // 等级名称
|
LevelName string `json:"level_name"` // 等级名称
|
||||||
Mobile string `json:"mobile"` // 手机号
|
Mobile string `json:"mobile"` // 手机号
|
||||||
CreateTime string `json:"create_time"` // 加入团队时间
|
CreateTime string `json:"create_time"` // 加入团队时间
|
||||||
TodayQueries int64 `json:"today_queries"` // 当日查询量
|
|
||||||
TotalQueries int64 `json:"total_queries"` // 总查询量
|
|
||||||
TotalRebateAmount float64 `json:"total_rebate_amount"` // 返佣给我的总金额
|
|
||||||
TodayRebateAmount float64 `json:"today_rebate_amount"` // 返佣给我的今日金额
|
|
||||||
TotalInvites int64 `json:"total_invites"` // 邀请加入团队的总人数
|
|
||||||
TodayInvites int64 `json:"today_invites"` // 邀请加入团队的今日人数
|
TodayInvites int64 `json:"today_invites"` // 邀请加入团队的今日人数
|
||||||
|
MonthInvites int64 `json:"month_invites"` // 邀请加入团队的本月人数
|
||||||
|
TotalInvites int64 `json:"total_invites"` // 邀请加入团队的总人数
|
||||||
|
TodayQueries int64 `json:"today_queries"` // 当日查询量
|
||||||
|
MonthQueries int64 `json:"month_queries"` // 本月查询量
|
||||||
|
TotalQueries int64 `json:"total_queries"` // 总查询量
|
||||||
IsDirect bool `json:"is_direct"` // 是否直接下级
|
IsDirect bool `json:"is_direct"` // 是否直接下级
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user