f
This commit is contained in:
@@ -83,6 +83,9 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type
|
||||
if user.Disable == 1 {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.USER_DISABLED), "账号已被封禁")
|
||||
}
|
||||
if user.CancelledAt.Valid {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.USER_CANCELLED), "账号已注销")
|
||||
}
|
||||
if claims != nil && claims.UserType == model.UserTypeTemp {
|
||||
// 临时用户,转为正式用户
|
||||
err = l.svcCtx.UserService.TempUserBindUser(l.ctx, session, user.Id)
|
||||
|
||||
@@ -161,11 +161,21 @@ func (l *GetAgentSubordinateContributionDetailLogic) GetAgentSubordinateContribu
|
||||
}
|
||||
}
|
||||
|
||||
// 解密手机号
|
||||
// 解密手机号(账号已注销时展示占位文案)
|
||||
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
||||
mobile, err := crypto.DecryptMobile(subordinateAgent.Mobile, secretKey)
|
||||
subUser, err := l.svcCtx.UserModel.FindOne(l.ctx, subordinateAgent.UserId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理下级贡献详情, 解密手机号失败: %v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "获取代理下级贡献详情, 查询用户失败: %v", err)
|
||||
}
|
||||
var mobileMasked string
|
||||
if subUser.CancelledAt.Valid {
|
||||
mobileMasked = "已注销用户"
|
||||
} else {
|
||||
mobile, err := crypto.DecryptMobile(subordinateAgent.Mobile, secretKey)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理下级贡献详情, 解密手机号失败: %v", err)
|
||||
}
|
||||
mobileMasked = maskPhone(mobile)
|
||||
}
|
||||
|
||||
// 获取合并后的分页列表
|
||||
@@ -187,7 +197,7 @@ func (l *GetAgentSubordinateContributionDetailLogic) GetAgentSubordinateContribu
|
||||
}
|
||||
|
||||
return &types.GetAgentSubordinateContributionDetailResp{
|
||||
Mobile: maskPhone(mobile),
|
||||
Mobile: mobileMasked,
|
||||
Total: total,
|
||||
CreateTime: closure.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
TotalEarnings: totalEarnings,
|
||||
|
||||
@@ -124,6 +124,20 @@ func (l *GetAgentSubordinateListLogic) GetAgentSubordinateList(req *types.GetAge
|
||||
orderCountMap[v.AgentId]++
|
||||
}
|
||||
|
||||
// 下级对应用户是否已注销
|
||||
accountCancelled := make(map[int64]bool)
|
||||
for _, id := range descendantIDs {
|
||||
ag := agentMap[id]
|
||||
if ag == nil {
|
||||
continue
|
||||
}
|
||||
u, err := l.svcCtx.UserModel.FindOne(l.ctx, ag.UserId)
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "获取下级用户信息失败: %v", err)
|
||||
}
|
||||
accountCancelled[id] = u.CancelledAt.Valid
|
||||
}
|
||||
|
||||
// 构建返回结果
|
||||
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
||||
descendantList = make([]types.AgentSubordinateList, 0, len(descendantIDs))
|
||||
@@ -133,19 +147,26 @@ func (l *GetAgentSubordinateListLogic) GetAgentSubordinateList(req *types.GetAge
|
||||
continue
|
||||
}
|
||||
|
||||
mobile, err := crypto.DecryptMobile(agent.Mobile, secretKey)
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理信息, 解密手机号失败: %v", err)
|
||||
var mobileDisplay string
|
||||
if accountCancelled[id] {
|
||||
mobileDisplay = "已注销用户"
|
||||
} else {
|
||||
mobile, err := crypto.DecryptMobile(agent.Mobile, secretKey)
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理信息, 解密手机号失败: %v", err)
|
||||
}
|
||||
mobileDisplay = maskPhone(mobile)
|
||||
}
|
||||
|
||||
subordinate := types.AgentSubordinateList{
|
||||
ID: id,
|
||||
Mobile: maskPhone(mobile),
|
||||
LevelName: agent.LevelName,
|
||||
CreateTime: createTimeMap[id].Format("2006-01-02 15:04:05"),
|
||||
TotalContribution: deductionMap[id] + rewardsMap[id],
|
||||
TotalEarnings: commissionMap[id],
|
||||
TotalOrders: orderCountMap[id],
|
||||
ID: id,
|
||||
Mobile: mobileDisplay,
|
||||
LevelName: agent.LevelName,
|
||||
CreateTime: createTimeMap[id].Format("2006-01-02 15:04:05"),
|
||||
TotalContribution: deductionMap[id] + rewardsMap[id],
|
||||
TotalEarnings: commissionMap[id],
|
||||
TotalOrders: orderCountMap[id],
|
||||
AccountCancelled: accountCancelled[id],
|
||||
}
|
||||
descendantList = append(descendantList, subordinate)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user