This commit is contained in:
2026-01-19 21:10:35 +08:00
parent c868422a1d
commit a8ec1a5aa1
29 changed files with 247 additions and 282 deletions

View File

@@ -104,7 +104,7 @@ desc/
- 参数定义注意事项:
1. 创建类请求Create
- 所有字段都是必填的,使用普通类型(非指针)
- 所有字段都是必填的,使用白银类型(非指针)
- 使用 `json` 标签,不需要 `optional` 标记
- 必须添加字段说明注释
@@ -115,7 +115,7 @@ desc/
- 必须添加字段说明注释
3. 查询列表请求GetList
- 分页参数page、pageSize使用普通类型
- 分页参数page、pageSize使用白银类型
- 查询条件字段都是可选的,使用指针类型
- 使用 `form` 标签,并添加 `optional` 标记
- 必须添加字段说明注释

View File

@@ -97,7 +97,7 @@ type (
AgentListItem {
Id string `json:"id"` // 主键
UserId string `json:"user_id"` // 用户ID
Level int64 `json:"level"` // 等级1=普通2=黄金3=钻石
Level int64 `json:"level"` // 等级1=白银2=黄金3=钻石
LevelName string `json:"level_name"` // 等级名称
Region string `json:"region"` // 区域
Mobile string `json:"mobile"` // 手机号
@@ -317,20 +317,20 @@ type (
LevelBonusConfig {
Diamond int64 `json:"diamond"` // 钻石加成0
Gold int64 `json:"gold"` // 黄金加成3
Normal int64 `json:"normal"` // 普通加成6
Normal int64 `json:"normal"` // 白银加成6
}
UpgradeFeeConfig {
NormalToGold float64 `json:"normal_to_gold"` // 普通→黄金199
NormalToDiamond float64 `json:"normal_to_diamond"` // 普通→钻石980
NormalToGold float64 `json:"normal_to_gold"` // 白银→黄金199
NormalToDiamond float64 `json:"normal_to_diamond"` // 白银→钻石980
}
UpgradeRebateConfig {
NormalToGoldRebate float64 `json:"normal_to_gold_rebate"` // 普通→黄金返佣139
NormalToGoldRebate float64 `json:"normal_to_gold_rebate"` // 白银→黄金返佣139
ToDiamondRebate float64 `json:"to_diamond_rebate"` // 升级为钻石返佣680
}
DirectParentRebateConfig {
Diamond float64 `json:"diamond"` // 直接上级是钻石的返佣金额6元
Gold float64 `json:"gold"` // 直接上级是黄金的返佣金额3元
Normal float64 `json:"normal"` // 直接上级是普通的返佣金额2元
Normal float64 `json:"normal"` // 直接上级是白银的返佣金额2元
}
CommissionFreezeConfig {
Ratio float64 `json:"ratio"` // 佣金冻结比例例如0.1表示10%

View File

@@ -130,7 +130,7 @@ type (
UpgradeToDiamondRebate float64 `json:"upgrade_to_diamond_rebate"`
}
LevelPrivilegeItem {
Level int64 `json:"level"` // 等级1=普通2=黄金3=钻石
Level int64 `json:"level"` // 等级1=白银2=黄金3=钻石
LevelName string `json:"level_name"` // 等级名称
LevelBonus float64 `json:"level_bonus"` // 等级加成(元)
PriceReduction float64 `json:"price_reduction"` // 底价降低(元,相对于当前等级)
@@ -468,7 +468,7 @@ type (
Id string `json:"id"` // 记录ID
SourceAgentId string `json:"source_agent_id"` // 来源代理ID
SourceAgentMobile string `json:"source_agent_mobile"` // 来源代理手机号
SourceAgentLevel int64 `json:"source_agent_level"` // 来源代理等级1=普通2=黄金3=钻石
SourceAgentLevel int64 `json:"source_agent_level"` // 来源代理等级1=白银2=黄金3=钻石
OrderId string `json:"order_id"` // 订单ID
OrderNo string `json:"order_no"` // 订单号
RebateType int64 `json:"rebate_type"` // 返佣类型1=直接上级2=钻石上级3=黄金上级

View File

@@ -83,5 +83,5 @@ TencentCloud:
SecretId: "AKIDIZgZFi172kFZgZFj2A4nT4bAPzQtKtT0"
SecretKey: "nRvCINGwPr68xa0CBxVqyta2QrESVZhi"
SmsSdkAppId: "1401075256"
SignName: "北京正信环宇科技"
SignName: "正信环宇"
TemplateId: "2583728"

View File

@@ -80,5 +80,5 @@ TencentCloud:
SecretId: "AKIDIZgZFi172kFZgZFj2A4nT4bAPzQtKtT0"
SecretKey: "nRvCINGwPr68xa0CBxVqyta2QrESVZhi"
SmsSdkAppId: "1401075256"
SignName: "北京正信环宇科技"
SignName: "正信环宇"
TemplateId: "2583728"

View File

@@ -64,7 +64,7 @@ func (l *AdminGetAgentListLogic) AdminGetAgentList(req *types.AdminGetAgentListR
levelName := ""
switch agent.Level {
case 1:
levelName = "普通"
levelName = "白银"
case 2:
levelName = "黄金"
case 3:

View File

@@ -1,10 +1,10 @@
package admin_agent
import (
"bdqr-server/common/xerr"
"context"
"database/sql"
"strconv"
"bdqr-server/common/xerr"
"github.com/pkg/errors"
@@ -119,10 +119,10 @@ func (l *AdminUpdateAgentConfigLogic) AdminUpdateAgentConfig(req *types.AdminUpd
// 更新升级费用配置
if req.UpgradeFee != nil {
if err := updateConfig("upgrade_to_gold_fee", &req.UpgradeFee.NormalToGold); err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新普通→黄金升级费用失败, %v", err)
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新白银→黄金升级费用失败, %v", err)
}
if err := updateConfig("upgrade_to_diamond_fee", &req.UpgradeFee.NormalToDiamond); err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新普通→钻石升级费用失败, %v", err)
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新白银→钻石升级费用失败, %v", err)
}
// gold_to_diamond 是计算得出的,不需要更新
}
@@ -130,7 +130,7 @@ func (l *AdminUpdateAgentConfigLogic) AdminUpdateAgentConfig(req *types.AdminUpd
// 更新升级返佣配置
if req.UpgradeRebate != nil {
if err := updateConfig("upgrade_to_gold_rebate", &req.UpgradeRebate.NormalToGoldRebate); err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新普通→黄金返佣失败, %v", err)
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新白银→黄金返佣失败, %v", err)
}
if err := updateConfig("upgrade_to_diamond_rebate", &req.UpgradeRebate.ToDiamondRebate); err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新升级为钻石返佣失败, %v", err)
@@ -146,7 +146,7 @@ func (l *AdminUpdateAgentConfigLogic) AdminUpdateAgentConfig(req *types.AdminUpd
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新直接上级是黄金的返佣金额失败, %v", err)
}
if err := updateConfig("direct_parent_amount_normal", &req.DirectParentRebate.Normal); err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新直接上级是普通的返佣金额失败, %v", err)
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新直接上级是白银的返佣金额失败, %v", err)
}
}

View File

@@ -1,17 +1,17 @@
package agent
import (
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/globalkey"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/crypto"
"context"
"database/sql"
"fmt"
"os"
"strconv"
"time"
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/globalkey"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/crypto"
"github.com/google/uuid"
"github.com/pkg/errors"
@@ -241,12 +241,12 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type
// 4.8 更新邀请码状态
// 钻石级别的邀请码只能使用一次,使用后立即失效
// 普通级别的邀请码可以无限使用,不更新状态
// 白银级别的邀请码可以无限使用,不更新状态
if targetLevel == 3 {
// 钻石邀请码:使用后失效
inviteCodeModel.Status = 1 // 已使用(使用后立即失效)
}
// 记录使用信息(用于统计,普通邀请码可以多次使用)
// 记录使用信息(用于统计,白银邀请码可以多次使用)
inviteCodeModel.UsedUserId = sql.NullString{String: userID, Valid: true}
if inviteCodeModel != nil {
inviteCodeModel.UsedAgentId = sql.NullString{String: newAgent.Id, Valid: true}

View File

@@ -1,11 +1,11 @@
package agent
import (
"context"
"database/sql"
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/xerr"
"context"
"database/sql"
"github.com/google/uuid"
"github.com/pkg/errors"
@@ -115,7 +115,7 @@ func (l *ApplyUpgradeLogic) ApplyUpgrade(req *types.ApplyUpgradeReq) (resp *type
// canUpgrade 检查是否可以升级
func (l *ApplyUpgradeLogic) canUpgrade(fromLevel, toLevel int64, upgradeType int64) bool {
if upgradeType == 1 { // 自主付费
if fromLevel == 1 { // 普通
if fromLevel == 1 { // 白银
return toLevel == 2 || toLevel == 3 // 可以升级为黄金或钻石
} else if fromLevel == 2 { // 黄金
return toLevel == 3 // 可以升级为钻石

View File

@@ -1,6 +1,12 @@
package agent
import (
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/globalkey"
"bdqr-server/common/tool"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/crypto"
"context"
"database/sql"
"encoding/hex"
@@ -9,12 +15,6 @@ import (
"net/url"
"strconv"
"strings"
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/globalkey"
"bdqr-server/common/tool"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/crypto"
"github.com/Masterminds/squirrel"
"github.com/pkg/errors"
@@ -173,7 +173,7 @@ func (l *GeneratingLinkLogic) GeneratingLink(req *types.AgentGeneratingLinkReq)
func (l *GeneratingLinkLogic) getLevelBonus(level int64) (int64, error) {
var configKey string
switch level {
case 1: // 普通
case 1: // 白银
configKey = "level_1_bonus"
case 2: // 黄金
configKey = "level_2_bonus"

View File

@@ -1,10 +1,10 @@
package agent
import (
"context"
"bdqr-server/common/ctxdata"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/crypto"
"context"
"github.com/pkg/errors"
@@ -104,7 +104,7 @@ func (l *GetAgentInfoLogic) GetAgentInfo() (resp *types.AgentInfoResp, err error
func (l *GetAgentInfoLogic) getLevelName(level int64) string {
switch level {
case 1:
return "普通"
return "白银"
case 2:
return "黄金"
case 3:

View File

@@ -1,11 +1,11 @@
package agent
import (
"context"
"strconv"
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/xerr"
"context"
"strconv"
"github.com/pkg/errors"
@@ -113,7 +113,7 @@ func (l *GetAgentProductConfigLogic) GetAgentProductConfig() (resp *types.AgentP
func (l *GetAgentProductConfigLogic) getLevelBonus(level int64) (int64, error) {
var configKey string
switch level {
case 1: // 普通
case 1: // 白银
configKey = "level_1_bonus"
case 2: // 黄金
configKey = "level_2_bonus"

View File

@@ -98,7 +98,7 @@ func (l *GetLevelPrivilegeLogic) GetLevelPrivilege() (resp *types.GetLevelPrivil
productConfigs, err := l.svcCtx.AgentProductConfigModel.FindAll(l.ctx, builder, "")
if err == nil {
for _, cfg := range productConfigs {
// 普通等级:直接使用系统价格上限
// 白银等级:直接使用系统价格上限
if cfg.SystemMaxPrice > maxSetPriceLevel1 {
maxSetPriceLevel1 = cfg.SystemMaxPrice
}

View File

@@ -1,14 +1,14 @@
package agent
import (
"context"
"sort"
"time"
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/globalkey"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/crypto"
"context"
"sort"
"time"
"github.com/Masterminds/squirrel"
"github.com/pkg/errors"
@@ -76,7 +76,7 @@ func (l *GetSubordinateContributionDetailLogic) GetSubordinateContributionDetail
levelName := ""
switch subordinate.Level {
case 1:
levelName = "普通"
levelName = "白银"
case 2:
levelName = "黄金"
case 3:
@@ -375,7 +375,7 @@ func (l *GetSubordinateContributionDetailLogic) getInviteList(ctx context.Contex
levelName := ""
switch invitedAgent.Level {
case 1:
levelName = "普通"
levelName = "白银"
case 2:
levelName = "黄金"
case 3:

View File

@@ -1,12 +1,12 @@
package agent
import (
"context"
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/globalkey"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/crypto"
"context"
"github.com/pkg/errors"
@@ -85,7 +85,7 @@ func (l *GetSubordinateListLogic) GetSubordinateList(req *types.GetSubordinateLi
levelName := ""
switch subordinate.Level {
case 1:
levelName = "普通"
levelName = "白银"
case 2:
levelName = "黄金"
case 3:

View File

@@ -1,12 +1,12 @@
package agent
import (
"context"
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/globalkey"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/crypto"
"context"
"sort"
"strings"
"time"
@@ -288,7 +288,7 @@ func (l *GetTeamListLogic) buildTeamMemberItem(agentId string, member *model.Age
levelName := ""
switch member.Level {
case 1:
levelName = "普通"
levelName = "白银"
case 2:
levelName = "黄金"
case 3:

View File

@@ -1,12 +1,12 @@
package agent
import (
"context"
"time"
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/globalkey"
"bdqr-server/common/xerr"
"context"
"time"
"github.com/Masterminds/squirrel"
"github.com/pkg/errors"
@@ -120,7 +120,7 @@ func (l *GetTeamStatisticsLogic) GetTeamStatistics() (resp *types.TeamStatistics
directCount := int64(len(directSubordinateIds))
indirectCount := totalCount - directCount
level1Count := int64(0) // 普通
level1Count := int64(0) // 白银
level2Count := int64(0) // 黄金
// 不再统计钻石,因为下级不可能是钻石
@@ -128,7 +128,7 @@ func (l *GetTeamStatisticsLogic) GetTeamStatistics() (resp *types.TeamStatistics
monthNewCount := int64(0)
for _, member := range teamMembers {
// 统计等级(只统计普通和黄金)
// 统计等级(只统计白银和黄金)
switch member.Level {
case 1:
level1Count++

View File

@@ -1,17 +1,17 @@
package agent
import (
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/globalkey"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/crypto"
"context"
"database/sql"
"fmt"
"os"
"strconv"
"time"
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/globalkey"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/crypto"
"github.com/google/uuid"
"github.com/pkg/errors"
@@ -289,8 +289,8 @@ func (l *RegisterByInviteCodeLogic) RegisterByInviteCode(req *types.RegisterByIn
}
l.Infof("[RegisterByInviteCode] 钻石代理创建成功, agentId: %s, 设置为团队首领", agentID)
} else {
// 普通/黄金代理,但没有上级(异常情况)
l.Infof("[RegisterByInviteCode] 普通/黄金代理,无上级(异常情况), level: %d", targetLevel)
// 白银/黄金代理,但没有上级(异常情况)
l.Infof("[RegisterByInviteCode] 白银/黄金代理,无上级(异常情况), level: %d", targetLevel)
newAgent.AgentCode = 0
_, err = l.svcCtx.AgentModel.Insert(transCtx, session, newAgent)
if err != nil {
@@ -311,7 +311,7 @@ func (l *RegisterByInviteCodeLogic) RegisterByInviteCode(req *types.RegisterByIn
// 8. 更新邀请码状态
// 钻石级别的邀请码只能使用一次,使用后立即失效
// 普通级别的邀请码可以无限使用,不更新状态
// 白银级别的邀请码可以无限使用,不更新状态
if inviteCodeModel != nil {
if targetLevel == 3 {
// 钻石邀请码:使用后失效
@@ -361,7 +361,7 @@ func (l *RegisterByInviteCodeLogic) RegisterByInviteCode(req *types.RegisterByIn
levelName := ""
switch agentLevel {
case 1:
levelName = "普通"
levelName = "白银"
case 2:
levelName = "黄金"
case 3:

View File

@@ -1,13 +1,13 @@
package agent
import (
"context"
"database/sql"
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/globalkey"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/lzUtils"
"context"
"database/sql"
"github.com/google/uuid"
"github.com/pkg/errors"
@@ -82,7 +82,7 @@ func (l *UpgradeSubordinateLogic) UpgradeSubordinate(req *types.UpgradeSubordina
upgradeRecord := &model.AgentUpgrade{
Id: uuid.New().String(),
AgentId: subordinateAgent.Id,
FromLevel: 1, // 普通
FromLevel: 1, // 白银
ToLevel: toLevel,
UpgradeType: 2, // 钻石升级下级
UpgradeFee: 0, // 免费

View File

@@ -13,10 +13,6 @@ import (
"bdqr-server/app/main/api/internal/svc"
"bdqr-server/app/main/api/internal/types"
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
dysmsapi "github.com/alibabacloud-go/dysmsapi-20170525/v3/client"
"github.com/alibabacloud-go/tea-utils/v2/service"
"github.com/alibabacloud-go/tea/tea"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -55,12 +51,9 @@ func (l *SendSmsLogic) SendSms(req *types.SendSmsReq) error {
code := fmt.Sprintf("%06d", rand.New(rand.NewSource(time.Now().UnixNano())).Intn(1000000))
// 发送短信
smsResp, err := l.sendSmsRequest(req.Mobile, code)
err = l.svcCtx.TencentCloudService.SendVerificationCode(req.Mobile, code)
if err != nil {
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "短信发送, 调用阿里客户端失败: %v", err)
}
if *smsResp.Body.Code != "OK" {
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "短信发送, 阿里客户端响应失败: %s", *smsResp.Body.Message)
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "短信发送, 调用腾讯云短信服务失败: %v", err)
}
codeKey := fmt.Sprintf("%s:%s", req.ActionType, encryptedMobile)
// 将验证码保存到 Redis设置过期时间
@@ -75,31 +68,3 @@ func (l *SendSmsLogic) SendSms(req *types.SendSmsReq) error {
}
return nil
}
// CreateClient 创建阿里云短信客户端
func (l *SendSmsLogic) CreateClient() (*dysmsapi.Client, error) {
config := &openapi.Config{
AccessKeyId: &l.svcCtx.Config.VerifyCode.AccessKeyID,
AccessKeySecret: &l.svcCtx.Config.VerifyCode.AccessKeySecret,
}
config.Endpoint = tea.String(l.svcCtx.Config.VerifyCode.EndpointURL)
return dysmsapi.NewClient(config)
}
// sendSmsRequest 发送短信请求
func (l *SendSmsLogic) sendSmsRequest(mobile, code string) (*dysmsapi.SendSmsResponse, error) {
// 初始化阿里云短信客户端
cli, err := l.CreateClient()
if err != nil {
return nil, err
}
request := &dysmsapi.SendSmsRequest{
SignName: tea.String(l.svcCtx.Config.VerifyCode.SignName),
TemplateCode: tea.String(l.svcCtx.Config.VerifyCode.TemplateCode),
PhoneNumbers: tea.String(mobile),
TemplateParam: tea.String(fmt.Sprintf("{\"code\":\"%s\"}", code)),
}
runtime := &service.RuntimeOptions{}
return cli.SendSmsWithOptions(request, runtime)
}

View File

@@ -1,6 +1,12 @@
package pay
import (
"bdqr-server/app/main/api/internal/svc"
"bdqr-server/app/main/api/internal/types"
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/lzUtils"
"context"
"database/sql"
"encoding/json"
@@ -9,12 +15,6 @@ import (
"strconv"
"strings"
"time"
"bdqr-server/app/main/api/internal/svc"
"bdqr-server/app/main/api/internal/types"
"bdqr-server/app/main/model"
"bdqr-server/common/ctxdata"
"bdqr-server/common/xerr"
"bdqr-server/pkg/lzkit/lzUtils"
"github.com/google/uuid"
"github.com/pkg/errors"
@@ -434,7 +434,7 @@ func (l *PaymentLogic) AgentUpgradeOrderPayment(req *types.PaymentReq, session s
func (l *PaymentLogic) getLevelBonus(level int64) (int64, error) {
var configKey string
switch level {
case 1: // 普通
case 1: // 白银
configKey = "level_1_bonus"
case 2: // 黄金
configKey = "level_2_bonus"

View File

@@ -1,15 +1,15 @@
package service
import (
"bdqr-server/app/main/api/internal/config"
"bdqr-server/app/main/model"
"bdqr-server/common/globalkey"
"bdqr-server/pkg/lzkit/lzUtils"
"context"
"database/sql"
"fmt"
"strconv"
"time"
"bdqr-server/app/main/api/internal/config"
"bdqr-server/app/main/model"
"bdqr-server/common/globalkey"
"bdqr-server/pkg/lzkit/lzUtils"
"github.com/google/uuid"
"github.com/pkg/errors"
@@ -168,7 +168,7 @@ func (s *AgentService) AgentProcess(ctx context.Context, order *model.Order) err
func (s *AgentService) getLevelBonus(ctx context.Context, level int64) (int64, error) {
var configKey string
switch level {
case 1: // 普通
case 1: // 白银
configKey = "level_1_bonus"
case 2: // 黄金
configKey = "level_2_bonus"
@@ -346,36 +346,36 @@ func (s *AgentService) distributeLevelBonus(ctx context.Context, session sqlx.Se
// 分配规则总览:
// 1. 直接上级是钻石:等级加成全部给钻石
// 2. 直接上级是黄金一部分给黄金配置direct_parent_amount_gold默认3元剩余给钻石上级
// 3. 直接上级是普通一部分给直接上级配置direct_parent_amount_normal默认2元剩余给钻石/黄金上级
// 3. 直接上级是白银一部分给直接上级配置direct_parent_amount_normal默认2元剩余给钻石/黄金上级
//
// 覆盖的所有情况:
//
// 情况1普通(推广人) -> 钻石(直接上级)
// 情况1白银(推广人) -> 钻石(直接上级)
// => 全部给钻石
//
// 情况2普通(推广人) -> 黄金(直接上级) -> 钻石
// 情况2白银(推广人) -> 黄金(直接上级) -> 钻石
// => 一部分给黄金,剩余给钻石
//
// 情况3普通(推广人) -> 黄金(直接上级) -> 无钻石上级
// 情况3白银(推广人) -> 黄金(直接上级) -> 无钻石上级
// => 一部分给黄金,剩余归平台
//
// 情况4普通(推广人) -> 普通(直接上级) -> 钻石
// => 一部分给直接上级普通,剩余全部给钻石
// 情况4白银(推广人) -> 白银(直接上级) -> 钻石
// => 一部分给直接上级白银,剩余全部给钻石
//
// 情况5普通(推广人) -> 普通(直接上级) -> 黄金 -> 钻石
// => 一部分给直接上级普通例如2元一部分给黄金等级加成差减去给普通例如3-2=1元剩余给钻石例如3元
// 情况5白银(推广人) -> 白银(直接上级) -> 黄金 -> 钻石
// => 一部分给直接上级白银例如2元一部分给黄金等级加成差减去给白银例如3-2=1元剩余给钻石例如3元
//
// 情况6普通(推广人) -> 普通(直接上级) -> 黄金(无钻石)
// => 一部分给直接上级普通剩余一部分给黄金最多3元超出归平台
// 情况6白银(推广人) -> 白银(直接上级) -> 黄金(无钻石)
// => 一部分给直接上级白银剩余一部分给黄金最多3元超出归平台
//
// 情况7普通(推广人) -> 普通(直接上级) -> 普通 -> 钻石
// => 一部分给直接上级普通,剩余全部给钻石(跳过中间白银代理)
// 情况7白银(推广人) -> 白银(直接上级) -> 白银 -> 钻石
// => 一部分给直接上级白银,剩余全部给钻石(跳过中间白银代理)
//
// 情况8普通(推广人) -> 普通(直接上级) -> 普通 -> 黄金(无钻石)
// => 一部分给直接上级普通剩余一部分给黄金最多3元超出归平台跳过中间白银代理
// 情况8白银(推广人) -> 白银(直接上级) -> 白银 -> 黄金(无钻石)
// => 一部分给直接上级白银剩余一部分给黄金最多3元超出归平台跳过中间白银代理
//
// 情况9普通(推广人) -> 普通(直接上级) -> 普通 -> 普通...(全部是普通
// => 一部分给直接上级普通,剩余归平台
// 情况9白银(推广人) -> 白银(直接上级) -> 白银 -> 白银...(全部是白银
// => 一部分给直接上级白银,剩余归平台
//
// 注意findDiamondParent 和 findGoldParent 会自动跳过中间的所有白银代理,
//
@@ -397,7 +397,7 @@ func (s *AgentService) distributeNormalAgentBonus(ctx context.Context, session s
case 3: // 直接上级是钻石代理的情况
// ========== 直接上级是钻石:等级加成全部给钻石上级 ==========
// 场景示例:
// - 普通(推广人) -> 钻石(直接上级)等级加成6元全部给钻石
// - 白银(推广人) -> 钻石(直接上级)等级加成6元全部给钻石
// 说明:如果直接上级就是钻石,不需要再向上查找,全部返佣给直接上级钻石
// rebateType = 2表示钻石上级返佣
return s.giveRebate(ctx, session, parent.Id, agent.Id, orderId, productId, amount, levelBonusInt, 2)
@@ -435,9 +435,9 @@ func (s *AgentService) distributeNormalAgentBonus(ctx context.Context, session s
if remaining > 0 {
// 从黄金上级开始向上查找钻石上级
// 场景示例:
// - 普通(推广人) -> 黄金(直接上级) -> 钻石剩余3元给钻石
// - 普通(推广人) -> 黄金(直接上级) -> 普通 -> 钻石剩余3元给钻石跳过中间白银代理
// - 普通(推广人) -> 黄金(直接上级) -> 无上级剩余3元归平台没有钻石上级
// - 白银(推广人) -> 黄金(直接上级) -> 钻石剩余3元给钻石
// - 白银(推广人) -> 黄金(直接上级) -> 白银 -> 钻石剩余3元给钻石跳过中间白银代理
// - 白银(推广人) -> 黄金(直接上级) -> 无上级剩余3元归平台没有钻石上级
diamondParent, err := s.findDiamondParent(ctx, parent.Id)
if err != nil && !errors.Is(err, model.ErrNotFound) {
return errors.Wrapf(err, "查找钻石上级失败")
@@ -459,7 +459,7 @@ func (s *AgentService) distributeNormalAgentBonus(ctx context.Context, session s
// 说明:无论后续层级有多少白银代理,这部分金额只给推广人的直接上级
normalRebateAmount, err := s.getRebateConfigFloat(ctx, "direct_parent_amount_normal", 2.0)
if err != nil {
logx.Errorf("获取普通返佣配置失败使用默认值2元: %v", err)
logx.Errorf("获取白银返佣配置失败使用默认值2元: %v", err)
normalRebateAmount = 2.0 // 配置读取失败时使用默认值2元
}
@@ -490,11 +490,11 @@ func (s *AgentService) distributeNormalAgentBonus(ctx context.Context, session s
// ========== 步骤3从直接上级开始向上查找钻石和黄金代理 ==========
// 注意findDiamondParent 和 findGoldParent 会自动跳过中间的所有白银代理
// 例如:
// - 普通 -> 普通 -> 普通 -> 钻石:会跳过中间的白银代理,直接找到钻石
// - 普通 -> 普通 -> 黄金 -> 钻石:会找到钻石(优先级更高)
// - 普通 -> 黄金:会找到黄金
diamondParent, _ := s.findDiamondParent(ctx, parent.Id) // 向上查找钻石上级(跳过所有普通和黄金)
goldParent, _ := s.findGoldParent(ctx, parent.Id) // 向上查找黄金上级(跳过所有普通
// - 白银 -> 白银 -> 白银 -> 钻石:会跳过中间的白银代理,直接找到钻石
// - 白银 -> 白银 -> 黄金 -> 钻石:会找到钻石(优先级更高)
// - 白银 -> 黄金:会找到黄金
diamondParent, _ := s.findDiamondParent(ctx, parent.Id) // 向上查找钻石上级(跳过所有白银和黄金)
goldParent, _ := s.findGoldParent(ctx, parent.Id) // 向上查找黄金上级(跳过所有白银
// ========== 步骤4按优先级分配剩余金额 ==========
// 优先级规则:
@@ -505,14 +505,14 @@ func (s *AgentService) distributeNormalAgentBonus(ctx context.Context, session s
if diamondParent != nil {
// ========== 情况A找到钻石上级 ==========
// 场景示例:
// - 普通(推广人) -> 普通(直接上级) -> 钻石:给普通2元剩余4元给钻石
// - 普通(推广人) -> 普通(直接上级) -> 黄金 -> 钻石:给普通2元给黄金1元剩余3元给钻石
// - 普通(推广人) -> 普通(直接上级) -> 普通 -> 普通 -> 钻石:给普通2元剩余4元给钻石跳过中间白银代理
// - 白银(推广人) -> 白银(直接上级) -> 钻石:给白银2元剩余4元给钻石
// - 白银(推广人) -> 白银(直接上级) -> 黄金 -> 钻石:给白银2元给黄金1元剩余3元给钻石
// - 白银(推广人) -> 白银(直接上级) -> 白银 -> 白银 -> 钻石:给白银2元剩余4元给钻石跳过中间白银代理
//
// 分配规则:当有钻石上级时,需要给黄金上级一部分返佣
// 1. 等级加成的差 = 普通等级加成 - 黄金等级加成例如6元 - 3元 = 3元
// 1. 等级加成的差 = 白银等级加成 - 黄金等级加成例如6元 - 3元 = 3元
// 2. 从这个差中先给直接上级白银代理已给例如2元
// 3. 差减去给普通的部分剩余给黄金代理例如3元 - 2元 = 1元
// 3. 差减去给白银的部分剩余给黄金代理例如3元 - 2元 = 1元
// 4. 最后剩余部分给钻石例如6元 - 2元 - 1元 = 3元
// 步骤A1计算等级加成的差
@@ -532,14 +532,14 @@ func (s *AgentService) distributeNormalAgentBonus(ctx context.Context, session s
// - 等级加成的差bonusDiff代表白银代理和黄金代理的等级加成差异
// - 从这个差中先分配给直接上级白银代理directAmount已分配
// - 剩余的差分配给黄金代理goldRebateAmount = bonusDiff - directAmount
// - 如果差小于等于已给普通的部分,则不给黄金(这种情况理论上不应该发生,因为差应该>=给普通的部分)
// - 如果差小于等于已给白银的部分,则不给黄金(这种情况理论上不应该发生,因为差应该>=给白银的部分)
if goldParent != nil && bonusDiff > 0 {
// 计算给黄金上级的金额 = 等级加成差 - 已给普通上级的金额
// 例如等级加成差3元 - 已给普通2元 = 给黄金1元
// 计算给黄金上级的金额 = 等级加成差 - 已给白银上级的金额
// 例如等级加成差3元 - 已给白银2元 = 给黄金1元
goldRebateAmount := bonusDiff - directAmount
// 如果计算出的金额小于等于0说明差已经被白银代理全部占用了不给黄金
// 例如如果差是2元已给普通2元则 goldRebateAmount = 0不给黄金
// 例如如果差是2元已给白银2元则 goldRebateAmount = 0不给黄金
if goldRebateAmount > 0 {
// 边界检查:确保不超过剩余金额(理论上应该不会超过,但保险起见)
if goldRebateAmount > remaining {
@@ -567,8 +567,8 @@ func (s *AgentService) distributeNormalAgentBonus(ctx context.Context, session s
} else if goldParent != nil {
// ========== 情况B没有钻石上级但有黄金上级 ==========
// 场景示例:
// - 普通(推广人) -> 普通(直接上级) -> 黄金(没有钻石):给黄金一部分,剩余归平台
// - 普通(推广人) -> 普通(直接上级) -> 普通 -> 黄金(没有钻石):给黄金一部分,剩余归平台(跳过中间白银代理)
// - 白银(推广人) -> 白银(直接上级) -> 黄金(没有钻石):给黄金一部分,剩余归平台
// - 白银(推广人) -> 白银(直接上级) -> 白银 -> 黄金(没有钻石):给黄金一部分,剩余归平台(跳过中间白银代理)
// 配置键max_gold_rebate_amount白银代理给黄金上级的最大返佣金额
// 默认值3.0元
@@ -601,8 +601,8 @@ func (s *AgentService) distributeNormalAgentBonus(ctx context.Context, session s
// ========== 情况C既没有钻石上级也没有黄金上级 ==========
// 场景示例:
// - 普通(推广人) -> 普通(直接上级) -> 普通 -> 普通...(整个链路都是白银代理)
// - 普通(推广人) -> 普通(直接上级) -> 无上级(已经是最顶层)
// - 白银(推广人) -> 白银(直接上级) -> 白银 -> 白银...(整个链路都是白银代理)
// - 白银(推广人) -> 白银(直接上级) -> 无上级(已经是最顶层)
// 剩余金额全部归平台(不需要记录)
return nil
@@ -693,9 +693,9 @@ func (s *AgentService) findDirectParent(ctx context.Context, agentId string) (*m
// - 如果没有找到钻石代理,返回 ErrNotFound
//
// 示例场景:
// - 普通 -> 普通 -> 钻石:会找到钻石(跳过中间的白银代理)
// - 普通 -> 黄金 -> 钻石:会找到钻石(跳过黄金代理)
// - 普通 -> 普通 -> 黄金:返回 ErrNotFound没有钻石
// - 白银 -> 白银 -> 钻石:会找到钻石(跳过中间的白银代理)
// - 白银 -> 黄金 -> 钻石:会找到钻石(跳过黄金代理)
// - 白银 -> 白银 -> 黄金:返回 ErrNotFound没有钻石
func (s *AgentService) findDiamondParent(ctx context.Context, agentId string) (*model.Agent, error) {
currentId := agentId
maxDepth := 100 // 防止无限循环
@@ -733,9 +733,9 @@ func (s *AgentService) findDiamondParent(ctx context.Context, agentId string) (*
// - 如果没有找到黄金代理,返回 ErrNotFound
//
// 示例场景:
// - 普通 -> 普通 -> 黄金:会找到黄金(跳过中间的白银代理)
// - 普通 -> 黄金:会找到黄金
// - 普通 -> 普通 -> 钻石:返回 ErrNotFound跳过钻石继续查找黄金但找不到
// - 白银 -> 白银 -> 黄金:会找到黄金(跳过中间的白银代理)
// - 白银 -> 黄金:会找到黄金
// - 白银 -> 白银 -> 钻石:返回 ErrNotFound跳过钻石继续查找黄金但找不到
func (s *AgentService) findGoldParent(ctx context.Context, agentId string) (*model.Agent, error) {
currentId := agentId
maxDepth := 100 // 防止无限循环
@@ -1053,7 +1053,7 @@ func (s *AgentService) giveRebateForUpgrade(ctx context.Context, session sqlx.Se
// GetUpgradeFee 获取升级费用
func (s *AgentService) GetUpgradeFee(ctx context.Context, fromLevel, toLevel int64) (float64, error) {
if fromLevel == 1 && toLevel == 2 {
// 普通→黄金:从配置获取
// 白银→黄金:从配置获取
return s.getRebateConfigFloat(ctx, "upgrade_to_gold_fee", 199)
} else if toLevel == 3 {
// 升级为钻石:从配置获取
@@ -1065,7 +1065,7 @@ func (s *AgentService) GetUpgradeFee(ctx context.Context, fromLevel, toLevel int
// GetUpgradeRebate 获取升级返佣金额
func (s *AgentService) GetUpgradeRebate(ctx context.Context, fromLevel, toLevel int64) (float64, error) {
if fromLevel == 1 && toLevel == 2 {
// 普通→黄金返佣:从配置获取
// 白银→黄金返佣:从配置获取
return s.getRebateConfigFloat(ctx, "upgrade_to_gold_rebate", 139)
} else if toLevel == 3 {
// 升级为钻石返佣:从配置获取

View File

@@ -186,7 +186,7 @@ func (s *AuthorizationService) generatePDFContent(userInfo map[string]interface{
附加说明:
本人在授权的相关数据将依据法律法规及贵司内部数据管理规范妥善存储,存储期限为法律要求的最短必要时间。超过存储期限或在数据使用目的达成后,贵司将对相关数据进行销毁或匿名化处理。
本人有权随时撤回本授权书中的授权,但撤回前的授权行为及其法律后果仍具有法律效力。若需撤回授权,本人可通过贵司官方渠道提交书面申请,贵司将在收到申请后依法停止对本人数据的使用。
你通过"愉悦查",自愿支付相应费用,用于购买北京正信环宇科技有限公司的大数据报告产品。如若对产品内容存在异议,可通过邮箱这里可以换成kefu@yuyuecha.com或APP"联系客服"按钮进行反馈贵司将在收到异议之日起20日内进行核查和处理并将结果答复。
你通过"愉悦查"自愿支付相应费用用于购买北京正信环宇科技有限公司的大数据报告产品。如若对产品内容存在异议可通过邮箱kefu@yuyuecha.com或APP"联系客服"按钮进行反馈贵司将在收到异议之日起20日内进行核查和处理并将结果答复。
你向北京正信环宇科技有限公司的支付方式为:北京正信环宇科技有限公司及其经官方授权的相关企业的支付宝账户。
争议解决机制:

View File

@@ -73,7 +73,7 @@ type AgentLinkListItem struct {
type AgentListItem struct {
Id string `json:"id"` // 主键
UserId string `json:"user_id"` // 用户ID
Level int64 `json:"level"` // 等级1=普通2=黄金3=钻石
Level int64 `json:"level"` // 等级1=白银2=黄金3=钻石
LevelName string `json:"level_name"` // 等级名称
Region string `json:"region"` // 区域
Mobile string `json:"mobile"` // 手机号
@@ -200,7 +200,7 @@ type ConversionRateData struct {
type DirectParentRebateConfig struct {
Diamond float64 `json:"diamond"` // 直接上级是钻石的返佣金额6元
Gold float64 `json:"gold"` // 直接上级是黄金的返佣金额3元
Normal float64 `json:"normal"` // 直接上级是普通的返佣金额2元
Normal float64 `json:"normal"` // 直接上级是白银的返佣金额2元
}
type Feature struct {
@@ -260,11 +260,11 @@ type InviteStatistics struct {
type LevelBonusConfig struct {
Diamond int64 `json:"diamond"` // 钻石加成0
Gold int64 `json:"gold"` // 黄金加成3
Normal int64 `json:"normal"` // 普通加成6
Normal int64 `json:"normal"` // 白银加成6
}
type LevelPrivilegeItem struct {
Level int64 `json:"level"` // 等级1=普通2=黄金3=钻石
Level int64 `json:"level"` // 等级1=白银2=黄金3=钻石
LevelName string `json:"level_name"` // 等级名称
LevelBonus float64 `json:"level_bonus"` // 等级加成(元)
PriceReduction float64 `json:"price_reduction"` // 底价降低(元,相对于当前等级)
@@ -464,7 +464,7 @@ type RebateItem struct {
Id string `json:"id"` // 记录ID
SourceAgentId string `json:"source_agent_id"` // 来源代理ID
SourceAgentMobile string `json:"source_agent_mobile"` // 来源代理手机号
SourceAgentLevel int64 `json:"source_agent_level"` // 来源代理等级1=普通2=黄金3=钻石
SourceAgentLevel int64 `json:"source_agent_level"` // 来源代理等级1=白银2=黄金3=钻石
OrderId string `json:"order_id"` // 订单ID
OrderNo string `json:"order_no"` // 订单号
RebateType int64 `json:"rebate_type"` // 返佣类型1=直接上级2=钻石上级3=黄金上级
@@ -529,8 +529,8 @@ type TeamStatistics struct {
}
type UpgradeFeeConfig struct {
NormalToGold float64 `json:"normal_to_gold"` // 普通→黄金199
NormalToDiamond float64 `json:"normal_to_diamond"` // 普通→钻石980
NormalToGold float64 `json:"normal_to_gold"` // 白银→黄金199
NormalToDiamond float64 `json:"normal_to_diamond"` // 白银→钻石980
}
type UpgradeItem struct {
@@ -546,7 +546,7 @@ type UpgradeItem struct {
}
type UpgradeRebateConfig struct {
NormalToGoldRebate float64 `json:"normal_to_gold_rebate"` // 普通→黄金返佣139
NormalToGoldRebate float64 `json:"normal_to_gold_rebate"` // 白银→黄金返佣139
ToDiamondRebate float64 `json:"to_diamond_rebate"` // 升级为钻石返佣680
}

View File

@@ -62,7 +62,7 @@ type (
Id string `db:"id"`
Code string `db:"code"` // 邀请码(唯一)
AgentId sql.NullString `db:"agent_id"`
TargetLevel int64 `db:"target_level"` // 目标等级1=普通2=黄金3=钻石
TargetLevel int64 `db:"target_level"` // 目标等级1=白银2=黄金3=钻石
Status int64 `db:"status"` // 状态0=未使用1=已使用2=已失效(所有邀请码只能使用一次,使用后立即失效)
UsedUserId sql.NullString `db:"used_user_id"`
UsedAgentId sql.NullString `db:"used_agent_id"`

View File

@@ -62,7 +62,7 @@ type (
Code string `db:"code"` // 邀请码(冗余字段,便于查询)
UserId string `db:"user_id"`
AgentId string `db:"agent_id"`
AgentLevel int64 `db:"agent_level"` // 代理等级1=普通2=黄金3=钻石
AgentLevel int64 `db:"agent_level"` // 代理等级1=白银2=黄金3=钻石
UsedTime time.Time `db:"used_time"` // 使用时间
CreateTime time.Time `db:"create_time"` // 创建时间
UpdateTime time.Time `db:"update_time"` // 更新时间

View File

@@ -64,7 +64,7 @@ type (
Id string `db:"id"`
UserId string `db:"user_id"`
AgentCode int64 `db:"agent_code"` // 代理编码从16800开始递增
Level int64 `db:"level"` // 代理等级1=普通2=黄金3=钻石
Level int64 `db:"level"` // 代理等级1=白银2=黄金3=钻石
Region sql.NullString `db:"region"` // 区域(可选)
Mobile string `db:"mobile"` // 手机号(加密)
WechatId sql.NullString `db:"wechat_id"` // 微信号

View File

@@ -59,8 +59,8 @@ type (
AgentUpgrade struct {
Id string `db:"id"`
AgentId string `db:"agent_id"`
FromLevel int64 `db:"from_level"` // 原等级1=普通2=黄金3=钻石
ToLevel int64 `db:"to_level"` // 目标等级1=普通2=黄金3=钻石
FromLevel int64 `db:"from_level"` // 原等级1=白银2=黄金3=钻石
ToLevel int64 `db:"to_level"` // 目标等级1=白银2=黄金3=钻石
UpgradeType int64 `db:"upgrade_type"` // 升级类型1=自主付费2=钻石升级下级
UpgradeFee float64 `db:"upgrade_fee"` // 升级费用
RebateAmount float64 `db:"rebate_amount"` // 返佣金额(给原直接上级)

View File

@@ -3915,7 +3915,7 @@ CREATE TABLE `agent` (
`id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`user_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`agent_code` bigint NOT NULL COMMENT '代理编码从16800开始递增',
`level` tinyint NOT NULL DEFAULT '1' COMMENT '代理等级1=普通2=黄金3=钻石',
`level` tinyint NOT NULL DEFAULT '1' COMMENT '代理等级1=白银2=黄金3=钻石',
`region` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '区域(可选)',
`mobile` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '手机号(加密)',
`wechat_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '微信号',
@@ -4037,7 +4037,7 @@ VALUES (
'level_1_bonus',
'6',
'bonus',
'普通代理等级加成6元',
'白银代理等级加成6元',
'2025-11-26 13:45:27',
'2025-12-09 17:58:09',
NULL,
@@ -4157,7 +4157,7 @@ VALUES (
'upgrade_to_gold_rebate',
'139',
'upgrade',
'普通→黄金返佣金额',
'白银→黄金返佣金额',
'2025-11-26 13:45:27',
'2025-12-09 17:58:09',
NULL,
@@ -4181,7 +4181,7 @@ VALUES (
'upgrade_to_gold_fee',
'198',
'upgrade',
'普通→黄金升级费用',
'白银→黄金升级费用',
'2025-11-26 13:45:27',
'2025-12-09 17:58:09',
NULL,
@@ -4193,7 +4193,7 @@ VALUES (
'direct_parent_amount_normal',
'2',
'rebate',
'直接上级是普通的返佣金额2元',
'直接上级是白银的返佣金额2元',
'2025-11-26 13:45:27',
'2025-12-09 17:58:09',
NULL,
@@ -4237,7 +4237,7 @@ CREATE TABLE `agent_invite_code` (
`id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '邀请码(唯一)',
`agent_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`target_level` tinyint NOT NULL DEFAULT '1' COMMENT '目标等级1=普通2=黄金3=钻石',
`target_level` tinyint NOT NULL DEFAULT '1' COMMENT '目标等级1=白银2=黄金3=钻石',
`status` tinyint NOT NULL DEFAULT '0' COMMENT '状态0=未使用1=已使用2=已失效(所有邀请码只能使用一次,使用后立即失效)',
`used_user_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`used_agent_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
@@ -4263,7 +4263,7 @@ CREATE TABLE `agent_invite_code_usage` (
`code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '邀请码(冗余字段,便于查询)',
`user_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`agent_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`agent_level` tinyint NOT NULL COMMENT '代理等级1=普通2=黄金3=钻石',
`agent_level` tinyint NOT NULL COMMENT '代理等级1=白银2=黄金3=钻石',
`used_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '使用时间',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
@@ -4570,8 +4570,8 @@ CREATE TABLE `agent_short_link` (
CREATE TABLE `agent_upgrade` (
`id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`agent_id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`from_level` tinyint NOT NULL COMMENT '原等级1=普通2=黄金3=钻石',
`to_level` tinyint NOT NULL COMMENT '目标等级1=普通2=黄金3=钻石',
`from_level` tinyint NOT NULL COMMENT '原等级1=白银2=黄金3=钻石',
`to_level` tinyint NOT NULL COMMENT '目标等级1=白银2=黄金3=钻石',
`upgrade_type` tinyint NOT NULL COMMENT '升级类型1=自主付费2=钻石升级下级',
`upgrade_fee` decimal(10, 2) DEFAULT '0.00' COMMENT '升级费用',
`rebate_amount` decimal(10, 2) DEFAULT '0.00' COMMENT '返佣金额(给原直接上级)',