修改:付费升级代理等级页面
This commit is contained in:
@@ -3,6 +3,7 @@ package agent
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"qnc-server/app/main/model"
|
||||
"qnc-server/common/ctxdata"
|
||||
"qnc-server/common/xerr"
|
||||
@@ -76,7 +77,7 @@ func (l *GetLevelPrivilegeLogic) GetLevelPrivilege() (resp *types.GetLevelPrivil
|
||||
currentBonus = level1Bonus
|
||||
}
|
||||
|
||||
// 获取升级返佣与费用配置
|
||||
// 获取升级返佣与费用配置(同时作为邀请奖励金额)
|
||||
upgradeToGoldRebate := getConfigFloat("upgrade_to_gold_rebate", 139.0)
|
||||
upgradeToDiamondRebate := getConfigFloat("upgrade_to_diamond_rebate", 680.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)
|
||||
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{
|
||||
{
|
||||
@@ -104,6 +133,10 @@ func (l *GetLevelPrivilegeLogic) GetLevelPrivilege() (resp *types.GetLevelPrivil
|
||||
"可邀请下级代理",
|
||||
},
|
||||
CanUpgradeSubordinate: false,
|
||||
MaxSetPrice: maxSetPriceLevel1,
|
||||
SubordinateRewardMax: directParentAmountNormal,
|
||||
InviteGoldReward: upgradeToGoldRebate,
|
||||
InviteDiamondReward: upgradeToDiamondRebate,
|
||||
},
|
||||
{
|
||||
Level: 2,
|
||||
@@ -121,6 +154,10 @@ func (l *GetLevelPrivilegeLogic) GetLevelPrivilege() (resp *types.GetLevelPrivil
|
||||
"更多推广权益",
|
||||
},
|
||||
CanUpgradeSubordinate: false,
|
||||
MaxSetPrice: maxSetPriceLevel2,
|
||||
SubordinateRewardMax: directParentAmountGold,
|
||||
InviteGoldReward: upgradeToGoldRebate,
|
||||
InviteDiamondReward: upgradeToDiamondRebate,
|
||||
},
|
||||
{
|
||||
Level: 3,
|
||||
@@ -138,6 +175,10 @@ func (l *GetLevelPrivilegeLogic) GetLevelPrivilege() (resp *types.GetLevelPrivil
|
||||
"可免费升级下级为黄金代理",
|
||||
},
|
||||
CanUpgradeSubordinate: true,
|
||||
MaxSetPrice: maxSetPriceLevel3,
|
||||
SubordinateRewardMax: directParentAmountDiamond,
|
||||
InviteGoldReward: upgradeToGoldRebate,
|
||||
InviteDiamondReward: upgradeToDiamondRebate,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user