feat: 授权管理改为设置卡类价格,代理管理增加消费列
This commit is contained in:
@@ -27,9 +27,10 @@ type User struct {
|
||||
ApiCallsResetAt *time.Time `json:"api_calls_reset_at"`
|
||||
ApiToken string `gorm:"size:64" json:"api_token"`
|
||||
|
||||
ParentAgentID *uint `gorm:"index" json:"parent_agent_id"`
|
||||
CanCreateAgent bool `gorm:"default:false" json:"can_create_agent"`
|
||||
Balance float64 `gorm:"default:0" json:"balance"`
|
||||
ParentAgentID *uint `gorm:"index" json:"parent_agent_id"`
|
||||
CanCreateAgent bool `gorm:"default:false" json:"can_create_agent"`
|
||||
Balance float64 `gorm:"default:0" json:"balance"`
|
||||
TotalConsumption float64 `gorm:"default:0" json:"total_consumption"`
|
||||
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
@@ -626,6 +627,7 @@ type AgentApplicationCardType struct {
|
||||
AgentApplicationID uint `json:"agent_application_id"`
|
||||
CardTypeID uint `json:"card_type_id"`
|
||||
CanGenerate bool `gorm:"default:false" json:"can_generate"`
|
||||
Price float64 `gorm:"type:decimal(10,2);default:0" json:"price"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
|
||||
@@ -98,10 +98,13 @@ func handleGetAgentApps(c *gin.Context) {
|
||||
}
|
||||
|
||||
type CardTypeResponse struct {
|
||||
ID uint `json:"id"`
|
||||
CardTypeID uint `json:"card_type_id"`
|
||||
Name string `json:"name"`
|
||||
CanGenerate bool `json:"can_generate"`
|
||||
ID uint `json:"id"`
|
||||
CardTypeID uint `json:"card_type_id"`
|
||||
Name string `json:"name"`
|
||||
BillingType string `json:"billing_type"`
|
||||
CanGenerate bool `json:"can_generate"`
|
||||
Price float64 `json:"price"`
|
||||
OriginPrice float64 `json:"origin_price"`
|
||||
}
|
||||
|
||||
type AgentAppResponse struct {
|
||||
@@ -142,7 +145,10 @@ func handleGetAgentApps(c *gin.Context) {
|
||||
ID: ct.ID,
|
||||
CardTypeID: ct.CardTypeID,
|
||||
Name: ct.CardType.Name,
|
||||
BillingType: ct.CardType.RechargeType,
|
||||
CanGenerate: ct.CanGenerate,
|
||||
Price: ct.Price,
|
||||
OriginPrice: ct.CardType.Price,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -746,8 +752,9 @@ func handleDirectAuthorize(c *gin.Context) {
|
||||
ApplicationID uint `json:"application_id" binding:"required"`
|
||||
Discount float64 `json:"discount"`
|
||||
CardTypes []struct {
|
||||
CardTypeID uint `json:"card_type_id" binding:"required"`
|
||||
CanGenerate bool `json:"can_generate"`
|
||||
CardTypeID uint `json:"card_type_id" binding:"required"`
|
||||
CanGenerate bool `json:"can_generate"`
|
||||
Price float64 `json:"price"`
|
||||
} `json:"card_types"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&reqBody); err != nil {
|
||||
@@ -823,6 +830,7 @@ func handleDirectAuthorize(c *gin.Context) {
|
||||
AgentApplicationID: agentApp.ID,
|
||||
CardTypeID: ct.CardTypeID,
|
||||
CanGenerate: ct.CanGenerate,
|
||||
Price: ct.Price,
|
||||
}
|
||||
if err := tx.Create(&agentCardType).Error; err != nil {
|
||||
tx.Rollback()
|
||||
@@ -838,6 +846,7 @@ func handleDirectAuthorize(c *gin.Context) {
|
||||
AgentApplicationID: agentApp.ID,
|
||||
CardTypeID: ct.ID,
|
||||
CanGenerate: false,
|
||||
Price: ct.Price,
|
||||
}
|
||||
if err := tx.Create(&agentCardType).Error; err != nil {
|
||||
tx.Rollback()
|
||||
|
||||
Reference in New Issue
Block a user