refactor: 移除佣金比例字段,将developer统一为admin
This commit is contained in:
@@ -28,7 +28,6 @@ type User struct {
|
||||
ApiToken string `gorm:"size:64" json:"api_token"`
|
||||
|
||||
ParentAgentID *uint `gorm:"index" json:"parent_agent_id"`
|
||||
Commission float64 `gorm:"default:0" json:"commission"`
|
||||
CanCreateAgent bool `gorm:"default:false" json:"can_create_agent"`
|
||||
Balance float64 `gorm:"default:0" json:"balance"`
|
||||
|
||||
@@ -557,7 +556,6 @@ type AgentApplication struct {
|
||||
AgentID uint `json:"agent_id"`
|
||||
ApplicationID uint `json:"application_id"`
|
||||
DeveloperID uint `json:"developer_id"`
|
||||
Commission float64 `gorm:"default:0.1" json:"commission"`
|
||||
Discount float64 `gorm:"default:1.0" json:"discount"`
|
||||
Status string `gorm:"size:20;default:active" json:"status"`
|
||||
IsReceived bool `gorm:"default:false" json:"is_received"`
|
||||
|
||||
@@ -80,7 +80,6 @@ func handleGetApps(c *gin.Context) {
|
||||
"description": aa.Application.Description,
|
||||
"status": aa.Application.Status,
|
||||
"authorized_at": aa.CreatedAt,
|
||||
"commission": aa.Commission,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -224,7 +223,6 @@ func handleGetFinance(c *gin.Context) {
|
||||
|
||||
response.Success(c, gin.H{
|
||||
"balance": user.Balance,
|
||||
"commission": user.Commission,
|
||||
"records": records,
|
||||
})
|
||||
}
|
||||
@@ -244,7 +242,6 @@ func handleGetProfile(c *gin.Context) {
|
||||
"email": user.Email,
|
||||
"avatar": user.Avatar,
|
||||
"balance": user.Balance,
|
||||
"commission": user.Commission,
|
||||
"can_create_agent": user.CanCreateAgent,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -137,7 +137,6 @@ func handleGetAgentApps(c *gin.Context) {
|
||||
AgentEmail string `json:"agent_email"`
|
||||
ApplicationID uint `json:"application_id"`
|
||||
AppName string `json:"app_name"`
|
||||
Commission float64 `json:"commission"`
|
||||
Discount float64 `json:"discount"`
|
||||
Status string `json:"status"`
|
||||
CardTypes []CardTypeResponse `json:"card_types"`
|
||||
@@ -181,7 +180,6 @@ func handleGetAgentApps(c *gin.Context) {
|
||||
AgentEmail: agentEmail,
|
||||
ApplicationID: aa.ApplicationID,
|
||||
AppName: appName,
|
||||
Commission: aa.Commission,
|
||||
Discount: aa.Discount,
|
||||
Status: aa.Status,
|
||||
CardTypes: cardTypes,
|
||||
@@ -496,7 +494,6 @@ func handleApproveRequest(c *gin.Context) {
|
||||
AgentID: req.AgentID,
|
||||
ApplicationID: req.ApplicationID,
|
||||
DeveloperID: userID,
|
||||
Commission: 0.1,
|
||||
Discount: 1.0,
|
||||
Status: "active",
|
||||
IsReceived: true,
|
||||
@@ -606,7 +603,6 @@ func handleGetAgentAppDetail(c *gin.Context) {
|
||||
AgentEmail string `json:"agent_email"`
|
||||
ApplicationID uint `json:"application_id"`
|
||||
AppName string `json:"app_name"`
|
||||
Commission float64 `json:"commission"`
|
||||
Discount float64 `json:"discount"`
|
||||
Status string `json:"status"`
|
||||
CardTypes []CardTypeResponse `json:"card_types"`
|
||||
@@ -629,7 +625,6 @@ func handleGetAgentAppDetail(c *gin.Context) {
|
||||
AgentName: agent.Username,
|
||||
ApplicationID: agentApp.ApplicationID,
|
||||
AppName: application.Name,
|
||||
Commission: agentApp.Commission,
|
||||
Discount: agentApp.Discount,
|
||||
Status: agentApp.Status,
|
||||
CardTypes: cardTypes,
|
||||
@@ -648,7 +643,6 @@ func handleUpdateAgentApp(c *gin.Context) {
|
||||
agentAppID := c.Param("id")
|
||||
|
||||
var reqBody struct {
|
||||
Commission *float64 `json:"commission"`
|
||||
Discount *float64 `json:"discount"`
|
||||
Status *string `json:"status"`
|
||||
}
|
||||
@@ -664,9 +658,6 @@ func handleUpdateAgentApp(c *gin.Context) {
|
||||
}
|
||||
|
||||
updates := make(map[string]interface{})
|
||||
if reqBody.Commission != nil {
|
||||
updates["commission"] = *reqBody.Commission
|
||||
}
|
||||
if reqBody.Discount != nil {
|
||||
updates["discount"] = *reqBody.Discount
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ type AgentTreeNode struct {
|
||||
CreatedAt string `json:"created_at"`
|
||||
LastLoginAt string `json:"last_login_at"`
|
||||
Balance float64 `json:"balance"`
|
||||
Commission float64 `json:"commission"`
|
||||
CanCreateAgent bool `json:"can_create_agent"`
|
||||
CardsCount int `json:"cards_count"`
|
||||
ChildAgentsCount int `json:"child_agents_count"`
|
||||
@@ -69,7 +68,6 @@ func handleGetAgents(c *gin.Context) {
|
||||
CreatedAt string `json:"created_at"`
|
||||
LastLoginAt string `json:"last_login_at"`
|
||||
Balance float64 `json:"balance"`
|
||||
Commission float64 `json:"commission"`
|
||||
CanCreateAgent bool `json:"can_create_agent"`
|
||||
CardsCount int `json:"cards_count"`
|
||||
ChildAgentsCount int `json:"child_agents_count"`
|
||||
@@ -110,7 +108,6 @@ func handleGetAgents(c *gin.Context) {
|
||||
CreatedAt: user.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
LastLoginAt: lastLoginAt,
|
||||
Balance: user.Balance,
|
||||
Commission: user.Commission,
|
||||
CanCreateAgent: user.CanCreateAgent,
|
||||
CardsCount: int(cardsCount),
|
||||
ChildAgentsCount: int(childAgentsCount),
|
||||
@@ -185,7 +182,6 @@ func handleGetAgentsTree(c *gin.Context) {
|
||||
CreatedAt: user.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
LastLoginAt: lastLoginAt,
|
||||
Balance: user.Balance,
|
||||
Commission: user.Commission,
|
||||
CanCreateAgent: user.CanCreateAgent,
|
||||
CardsCount: int(cardsCount),
|
||||
ChildAgentsCount: int(childAgentsCount),
|
||||
@@ -217,7 +213,6 @@ func handleCreateAgent(c *gin.Context) {
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
ParentAgentID *uint `json:"parent_agent_id"`
|
||||
Commission float64 `json:"commission"`
|
||||
CanCreateAgent bool `json:"can_create_agent"`
|
||||
Balance float64 `json:"balance"`
|
||||
}
|
||||
@@ -259,7 +254,6 @@ func handleCreateAgent(c *gin.Context) {
|
||||
Role: "agent",
|
||||
Status: "active",
|
||||
ParentAgentID: req.ParentAgentID,
|
||||
Commission: req.Commission,
|
||||
CanCreateAgent: req.CanCreateAgent,
|
||||
Balance: req.Balance,
|
||||
}
|
||||
@@ -365,7 +359,6 @@ func handleGetAgentDetail(c *gin.Context) {
|
||||
"role": user.Role,
|
||||
"parent_agent_id": user.ParentAgentID,
|
||||
"parent_agent_name": parentAgentName,
|
||||
"commission": user.Commission,
|
||||
"can_create_agent": user.CanCreateAgent,
|
||||
"balance": user.Balance,
|
||||
"created_at": user.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||
@@ -387,7 +380,6 @@ func handleUpdateAgent(c *gin.Context) {
|
||||
|
||||
var req struct {
|
||||
ParentAgentID *uint `json:"parent_agent_id"`
|
||||
Commission *float64 `json:"commission"`
|
||||
Email *string `json:"email"`
|
||||
Password *string `json:"password"`
|
||||
CanCreateAgent *bool `json:"can_create_agent"`
|
||||
@@ -414,9 +406,6 @@ func handleUpdateAgent(c *gin.Context) {
|
||||
if req.Email != nil {
|
||||
user.Email = req.Email
|
||||
}
|
||||
if req.Commission != nil {
|
||||
user.Commission = *req.Commission
|
||||
}
|
||||
if req.Password != nil && *req.Password != "" {
|
||||
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(*req.Password), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
|
||||
@@ -153,7 +153,7 @@ func main() {
|
||||
},
|
||||
"如何实现代理授权?": {
|
||||
TitleEn: "How to Implement Agent Authorization?",
|
||||
ContentEn: "# How to Implement Agent Authorization?\n\n## Overview\nAgent authorization allows you to delegate application management to agents.\n\n## Setup Steps\n\n### 1. Create Agent Application\n1. Go to Console > Agent Applications\n2. Click \"Create Agent Application\"\n3. Select the application to authorize\n4. Set commission rate\n\n### 2. Generate Agent Link\nAfter creation, you'll get an agent link:\n```\nhttps://platform.com/agent/AGENT_CODE\n```\n\n### 3. Agent Dashboard\nAgents can access their dashboard to:\n- View sales statistics\n- Generate card keys\n- Manage users",
|
||||
ContentEn: "# How to Implement Agent Authorization?\n\n## Overview\nAgent authorization allows you to delegate application management to agents.\n\n## Setup Steps\n\n### 1. Create Agent Application\n1. Go to Console > Agent Applications\n2. Click \"Create Agent Application\"\n3. Select the application to authorize\n4. Set discount rate\n\n### 2. Generate Agent Link\nAfter creation, you'll get an agent link:\n```\nhttps://platform.com/agent/AGENT_CODE\n```\n\n### 3. Agent Dashboard\nAgents can access their dashboard to:\n- View sales statistics\n- Generate card keys\n- Manage users",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ func main() {
|
||||
},
|
||||
"faq-agent": {
|
||||
TitleEn: "How to Implement Agent Authorization?",
|
||||
ContentEn: "# How to Implement Agent Authorization?\n\n## What is Agent Authorization?\n\nAgent authorization allows developers to authorize their applications to other developers, who can then generate card keys and sell them.\n\n## Authorization Process\n\n1. **Apply for Authorization**\n - Authorized party submits application to authorizer\n - Enter application ID\n - Wait for authorizer approval\n\n2. **Approve Authorization**\n - Authorizer views application\n - Set card key type permissions after approval\n - Set agent commission and discount\n\n3. **Generate Card Keys**\n - Authorized party selects authorized application\n - Select card key types with permission\n - Generate and sell card keys\n\n4. **Settle Commission**\n - Sales revenue is settled proportionally\n - Authorized party receives commission income\n\n## Permission Management\n\n- Authorizer can modify card key type permissions at any time\n- Can pause or terminate authorization\n- Can view agent's sales data",
|
||||
ContentEn: "# How to Implement Agent Authorization?\n\n## What is Agent Authorization?\n\nAgent authorization allows developers to authorize their applications to other developers, who can then generate card keys and sell them.\n\n## Authorization Process\n\n1. **Apply for Authorization**\n - Authorized party submits application to authorizer\n - Enter application ID\n - Wait for authorizer approval\n\n2. **Approve Authorization**\n - Authorizer views application\n - Set card key type permissions after approval\n - Set agent discount\n\n3. **Generate Card Keys**\n - Authorized party selects authorized application\n - Select card key types with permission\n - Generate and sell card keys\n\n4. **Settle Revenue**\n - Sales revenue is settled proportionally\n - Authorized party receives income\n\n## Permission Management\n\n- Authorizer can modify card key type permissions at any time\n- Can pause or terminate authorization\n- Can view agent's sales data",
|
||||
SummaryEn: "Implementation process and permission management for agent authorization",
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user