Compare commits
2 Commits
33e1ff4698
...
51d888c960
| Author | SHA1 | Date | |
|---|---|---|---|
| 51d888c960 | |||
| 4c9d45a08b |
@@ -134,11 +134,15 @@ type (
|
|||||||
LevelName string `json:"level_name"` // 等级名称
|
LevelName string `json:"level_name"` // 等级名称
|
||||||
LevelBonus float64 `json:"level_bonus"` // 等级加成(元)
|
LevelBonus float64 `json:"level_bonus"` // 等级加成(元)
|
||||||
PriceReduction float64 `json:"price_reduction"` // 底价降低(元,相对于当前等级)
|
PriceReduction float64 `json:"price_reduction"` // 底价降低(元,相对于当前等级)
|
||||||
PromoteRebate string `json:"promote_rebate"` // 推广返佣说明
|
PromoteRebate string `json:"promote_rebate"` // 推广返佣说明(旧字段,兼容保留)
|
||||||
MaxPromoteRebate float64 `json:"max_promote_rebate"` // 最高推广返佣金额(元)
|
MaxPromoteRebate float64 `json:"max_promote_rebate"` // 最高推广返佣金额(元,旧字段,兼容保留)
|
||||||
UpgradeRebate string `json:"upgrade_rebate"` // 下级升级返佣说明
|
UpgradeRebate string `json:"upgrade_rebate"` // 下级升级返佣说明(旧字段,兼容保留)
|
||||||
Privileges []string `json:"privileges"` // 特权列表
|
Privileges []string `json:"privileges"` // 特权列表(旧字段,兼容保留)
|
||||||
CanUpgradeSubordinate bool `json:"can_upgrade_subordinate"` // 是否可以升级下级
|
CanUpgradeSubordinate bool `json:"can_upgrade_subordinate"` // 是否可以升级下级(旧字段,兼容保留)
|
||||||
|
MaxSetPrice float64 `json:"max_set_price"` // 该等级可设置查询价最高金额(按所有产品最高价格取上限)
|
||||||
|
SubordinateRewardMax float64 `json:"subordinate_reward_max"` // 下级代理查询奖励最高金额(元/单)
|
||||||
|
InviteGoldReward float64 `json:"invite_gold_reward"` // 邀请黄金代理奖励金额(元)
|
||||||
|
InviteDiamondReward float64 `json:"invite_diamond_reward"` // 邀请钻石代理奖励金额(元)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -404,18 +408,18 @@ type (
|
|||||||
MonthEarnings float64 `json:"month_earnings"` // 月收益
|
MonthEarnings float64 `json:"month_earnings"` // 月收益
|
||||||
}
|
}
|
||||||
TeamMemberItem {
|
TeamMemberItem {
|
||||||
AgentId string `json:"agent_id"` // 代理ID
|
AgentId string `json:"agent_id"` // 代理ID
|
||||||
Level int64 `json:"level"` // 等级
|
Level int64 `json:"level"` // 等级
|
||||||
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"` // 当日查询量
|
TodayInvites int64 `json:"today_invites"` // 邀请加入团队的今日人数
|
||||||
TotalQueries int64 `json:"total_queries"` // 总查询量
|
MonthInvites int64 `json:"month_invites"` // 邀请加入团队的本月人数
|
||||||
TotalRebateAmount float64 `json:"total_rebate_amount"` // 返佣给我的总金额
|
TotalInvites int64 `json:"total_invites"` // 邀请加入团队的总人数
|
||||||
TodayRebateAmount float64 `json:"today_rebate_amount"` // 返佣给我的今日金额
|
TodayQueries int64 `json:"today_queries"` // 当日查询量
|
||||||
TotalInvites int64 `json:"total_invites"` // 邀请加入团队的总人数
|
MonthQueries int64 `json:"month_queries"` // 本月查询量
|
||||||
TodayInvites int64 `json:"today_invites"` // 邀请加入团队的今日人数
|
TotalQueries int64 `json:"total_queries"` // 总查询量
|
||||||
IsDirect bool `json:"is_direct"` // 是否直接下级
|
IsDirect bool `json:"is_direct"` // 是否直接下级
|
||||||
}
|
}
|
||||||
// 收益信息
|
// 收益信息
|
||||||
GetRevenueInfoResp {
|
GetRevenueInfoResp {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package agent
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"qnc-server/app/main/model"
|
"qnc-server/app/main/model"
|
||||||
"qnc-server/common/ctxdata"
|
"qnc-server/common/ctxdata"
|
||||||
"qnc-server/common/xerr"
|
"qnc-server/common/xerr"
|
||||||
@@ -76,7 +77,7 @@ func (l *GetLevelPrivilegeLogic) GetLevelPrivilege() (resp *types.GetLevelPrivil
|
|||||||
currentBonus = level1Bonus
|
currentBonus = level1Bonus
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取升级返佣与费用配置
|
// 获取升级返佣与费用配置(同时作为邀请奖励金额)
|
||||||
upgradeToGoldRebate := getConfigFloat("upgrade_to_gold_rebate", 139.0)
|
upgradeToGoldRebate := getConfigFloat("upgrade_to_gold_rebate", 139.0)
|
||||||
upgradeToDiamondRebate := getConfigFloat("upgrade_to_diamond_rebate", 680.0)
|
upgradeToDiamondRebate := getConfigFloat("upgrade_to_diamond_rebate", 680.0)
|
||||||
upgradeToGoldFee := getConfigFloat("upgrade_to_gold_fee", 199.0)
|
upgradeToGoldFee := getConfigFloat("upgrade_to_gold_fee", 199.0)
|
||||||
@@ -87,6 +88,34 @@ func (l *GetLevelPrivilegeLogic) GetLevelPrivilege() (resp *types.GetLevelPrivil
|
|||||||
directParentAmountGold := getConfigFloat("direct_parent_amount_gold", 3.0)
|
directParentAmountGold := getConfigFloat("direct_parent_amount_gold", 3.0)
|
||||||
directParentAmountNormal := getConfigFloat("direct_parent_amount_normal", 2.0)
|
directParentAmountNormal := getConfigFloat("direct_parent_amount_normal", 2.0)
|
||||||
|
|
||||||
|
// 获取不同等级的提价上限(用于计算各等级可设置的最高查询价)
|
||||||
|
goldMaxUpliftAmount := getConfigFloat("gold_max_uplift_amount", 0.0)
|
||||||
|
diamondMaxUpliftAmount := getConfigFloat("diamond_max_uplift_amount", 0.0)
|
||||||
|
|
||||||
|
// 计算所有产品在各等级下的可设最高查询价(取所有产品中的最大值)
|
||||||
|
var maxSetPriceLevel1, maxSetPriceLevel2, maxSetPriceLevel3 float64
|
||||||
|
builder := l.svcCtx.AgentProductConfigModel.SelectBuilder()
|
||||||
|
productConfigs, err := l.svcCtx.AgentProductConfigModel.FindAll(l.ctx, builder, "")
|
||||||
|
if err == nil {
|
||||||
|
for _, cfg := range productConfigs {
|
||||||
|
// 普通等级:直接使用系统价格上限
|
||||||
|
if cfg.SystemMaxPrice > maxSetPriceLevel1 {
|
||||||
|
maxSetPriceLevel1 = cfg.SystemMaxPrice
|
||||||
|
}
|
||||||
|
// 黄金等级:系统价格上限 + gold_max_uplift_amount
|
||||||
|
if cfg.SystemMaxPrice+goldMaxUpliftAmount > maxSetPriceLevel2 {
|
||||||
|
maxSetPriceLevel2 = cfg.SystemMaxPrice + goldMaxUpliftAmount
|
||||||
|
}
|
||||||
|
// 钻石等级:系统价格上限 + diamond_max_uplift_amount
|
||||||
|
if cfg.SystemMaxPrice+diamondMaxUpliftAmount > maxSetPriceLevel3 {
|
||||||
|
maxSetPriceLevel3 = cfg.SystemMaxPrice + diamondMaxUpliftAmount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if !errors.Is(err, model.ErrNotFound) {
|
||||||
|
// 查询失败不影响主流程,仅记录日志,前端会看到 0
|
||||||
|
l.Errorf("查询产品配置失败用于计算最高可设查询价, err: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// 构建各等级特权信息
|
// 构建各等级特权信息
|
||||||
levels := []types.LevelPrivilegeItem{
|
levels := []types.LevelPrivilegeItem{
|
||||||
{
|
{
|
||||||
@@ -104,6 +133,10 @@ func (l *GetLevelPrivilegeLogic) GetLevelPrivilege() (resp *types.GetLevelPrivil
|
|||||||
"可邀请下级代理",
|
"可邀请下级代理",
|
||||||
},
|
},
|
||||||
CanUpgradeSubordinate: false,
|
CanUpgradeSubordinate: false,
|
||||||
|
MaxSetPrice: maxSetPriceLevel1,
|
||||||
|
SubordinateRewardMax: directParentAmountNormal,
|
||||||
|
InviteGoldReward: upgradeToGoldRebate,
|
||||||
|
InviteDiamondReward: upgradeToDiamondRebate,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Level: 2,
|
Level: 2,
|
||||||
@@ -121,6 +154,10 @@ func (l *GetLevelPrivilegeLogic) GetLevelPrivilege() (resp *types.GetLevelPrivil
|
|||||||
"更多推广权益",
|
"更多推广权益",
|
||||||
},
|
},
|
||||||
CanUpgradeSubordinate: false,
|
CanUpgradeSubordinate: false,
|
||||||
|
MaxSetPrice: maxSetPriceLevel2,
|
||||||
|
SubordinateRewardMax: directParentAmountGold,
|
||||||
|
InviteGoldReward: upgradeToGoldRebate,
|
||||||
|
InviteDiamondReward: upgradeToDiamondRebate,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Level: 3,
|
Level: 3,
|
||||||
@@ -138,6 +175,10 @@ func (l *GetLevelPrivilegeLogic) GetLevelPrivilege() (resp *types.GetLevelPrivil
|
|||||||
"可免费升级下级为黄金代理",
|
"可免费升级下级为黄金代理",
|
||||||
},
|
},
|
||||||
CanUpgradeSubordinate: true,
|
CanUpgradeSubordinate: true,
|
||||||
|
MaxSetPrice: maxSetPriceLevel3,
|
||||||
|
SubordinateRewardMax: directParentAmountDiamond,
|
||||||
|
InviteGoldReward: upgradeToGoldRebate,
|
||||||
|
InviteDiamondReward: upgradeToDiamondRebate,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,32 +310,34 @@ 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]
|
||||||
|
|
||||||
return types.TeamMemberItem{
|
return types.TeamMemberItem{
|
||||||
AgentId: member.Id,
|
AgentId: member.Id,
|
||||||
Level: member.Level,
|
Level: member.Level,
|
||||||
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,
|
TodayInvites: todayInvites,
|
||||||
TotalQueries: totalQueries,
|
MonthInvites: monthInvites,
|
||||||
TotalRebateAmount: totalRebateAmount,
|
TotalInvites: totalInvites,
|
||||||
TodayRebateAmount: todayRebateAmount,
|
TodayQueries: todayQueries,
|
||||||
TotalInvites: totalInvites,
|
MonthQueries: monthQueries,
|
||||||
TodayInvites: todayInvites,
|
TotalQueries: totalQueries,
|
||||||
IsDirect: isDirect,
|
IsDirect: isDirect,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,11 +268,15 @@ type LevelPrivilegeItem struct {
|
|||||||
LevelName string `json:"level_name"` // 等级名称
|
LevelName string `json:"level_name"` // 等级名称
|
||||||
LevelBonus float64 `json:"level_bonus"` // 等级加成(元)
|
LevelBonus float64 `json:"level_bonus"` // 等级加成(元)
|
||||||
PriceReduction float64 `json:"price_reduction"` // 底价降低(元,相对于当前等级)
|
PriceReduction float64 `json:"price_reduction"` // 底价降低(元,相对于当前等级)
|
||||||
PromoteRebate string `json:"promote_rebate"` // 推广返佣说明
|
PromoteRebate string `json:"promote_rebate"` // 推广返佣说明(旧字段,兼容保留)
|
||||||
MaxPromoteRebate float64 `json:"max_promote_rebate"` // 最高推广返佣金额(元)
|
MaxPromoteRebate float64 `json:"max_promote_rebate"` // 最高推广返佣金额(元,旧字段,兼容保留)
|
||||||
UpgradeRebate string `json:"upgrade_rebate"` // 下级升级返佣说明
|
UpgradeRebate string `json:"upgrade_rebate"` // 下级升级返佣说明(旧字段,兼容保留)
|
||||||
Privileges []string `json:"privileges"` // 特权列表
|
Privileges []string `json:"privileges"` // 特权列表(旧字段,兼容保留)
|
||||||
CanUpgradeSubordinate bool `json:"can_upgrade_subordinate"` // 是否可以升级下级
|
CanUpgradeSubordinate bool `json:"can_upgrade_subordinate"` // 是否可以升级下级(旧字段,兼容保留)
|
||||||
|
MaxSetPrice float64 `json:"max_set_price"` // 该等级可设置查询价最高金额(按所有产品最高价格取上限)
|
||||||
|
SubordinateRewardMax float64 `json:"subordinate_reward_max"` // 下级代理查询奖励最高金额(元/单)
|
||||||
|
InviteGoldReward float64 `json:"invite_gold_reward"` // 邀请黄金代理奖励金额(元)
|
||||||
|
InviteDiamondReward float64 `json:"invite_diamond_reward"` // 邀请钻石代理奖励金额(元)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Notification struct {
|
type Notification struct {
|
||||||
@@ -496,18 +500,18 @@ type SubordinateItem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TeamMemberItem struct {
|
type TeamMemberItem struct {
|
||||||
AgentId string `json:"agent_id"` // 代理ID
|
AgentId string `json:"agent_id"` // 代理ID
|
||||||
Level int64 `json:"level"` // 等级
|
Level int64 `json:"level"` // 等级
|
||||||
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"` // 当日查询量
|
TodayInvites int64 `json:"today_invites"` // 邀请加入团队的今日人数
|
||||||
TotalQueries int64 `json:"total_queries"` // 总查询量
|
MonthInvites int64 `json:"month_invites"` // 邀请加入团队的本月人数
|
||||||
TotalRebateAmount float64 `json:"total_rebate_amount"` // 返佣给我的总金额
|
TotalInvites int64 `json:"total_invites"` // 邀请加入团队的总人数
|
||||||
TodayRebateAmount float64 `json:"today_rebate_amount"` // 返佣给我的今日金额
|
TodayQueries int64 `json:"today_queries"` // 当日查询量
|
||||||
TotalInvites int64 `json:"total_invites"` // 邀请加入团队的总人数
|
MonthQueries int64 `json:"month_queries"` // 本月查询量
|
||||||
TodayInvites int64 `json:"today_invites"` // 邀请加入团队的今日人数
|
TotalQueries int64 `json:"total_queries"` // 总查询量
|
||||||
IsDirect bool `json:"is_direct"` // 是否直接下级
|
IsDirect bool `json:"is_direct"` // 是否直接下级
|
||||||
}
|
}
|
||||||
|
|
||||||
type TeamStatistics struct {
|
type TeamStatistics struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user