fix: 订阅模式登录验证、永久会员类型区分、动态代码HTTP返回值修复、侧边栏滚动位置保持
- 修复订阅模式登录时错误检查余额的问题 - 区分无限余额和永久订阅两种永久会员类型 - 修复动态代码HTTP请求返回值在JS中无法正确访问的问题 - 添加侧边栏滚动位置保持功能 - 移除developer角色相关代码,统一使用admin - 添加缺失的i18n翻译key
This commit is contained in:
+36
-36
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -66,10 +66,10 @@ func checkAgentPermission(userID uint) bool {
|
||||
|
||||
func handleGetAgentApps(c *gin.Context) {
|
||||
userID := c.GetUint("user_id")
|
||||
log.Printf("[DEBUG] handleGetAgentApps called for developer %d\n", userID)
|
||||
log.Printf("[DEBUG] handleGetAgentApps called for Admin %d\n", userID)
|
||||
|
||||
var myAuthorizations []model.AgentApplication
|
||||
if err := database.DB.Where("developer_id = ?", userID).
|
||||
if err := database.DB.Where("admin_id = ?", userID).
|
||||
Preload("CardTypes.CardType").
|
||||
Find(&myAuthorizations).Error; err != nil {
|
||||
response.Error(c, 500, "获取授权列表失败")
|
||||
@@ -84,7 +84,7 @@ func handleGetAgentApps(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Found %d my authorizations and %d received authorizations for developer %d\n",
|
||||
log.Printf("[DEBUG] Found %d my authorizations and %d received authorizations for Admin %d\n",
|
||||
len(myAuthorizations), len(receivedAuthorizations), userID)
|
||||
|
||||
var allAgentApps []model.AgentApplication
|
||||
@@ -92,17 +92,17 @@ func handleGetAgentApps(c *gin.Context) {
|
||||
allAgentApps = append(allAgentApps, receivedAuthorizations...)
|
||||
|
||||
var agentIDs []uint
|
||||
var developerIDs []uint
|
||||
var AdminIDs []uint
|
||||
var applicationIDs []uint
|
||||
|
||||
for _, aa := range allAgentApps {
|
||||
agentIDs = append(agentIDs, aa.AgentID)
|
||||
developerIDs = append(developerIDs, aa.DeveloperID)
|
||||
AdminIDs = append(AdminIDs, aa.AdminID)
|
||||
applicationIDs = append(applicationIDs, aa.ApplicationID)
|
||||
}
|
||||
|
||||
var users []model.User
|
||||
if err := database.DB.Where("id IN ?", append(agentIDs, developerIDs...)).Find(&users).Error; err != nil {
|
||||
if err := database.DB.Where("id IN ?", append(agentIDs, AdminIDs...)).Find(&users).Error; err != nil {
|
||||
log.Printf("[ERROR] Failed to query users: %v\n", err)
|
||||
} else {
|
||||
log.Printf("[DEBUG] Found %d users\n", len(users))
|
||||
@@ -199,7 +199,7 @@ func handleGetAgentRequests(c *gin.Context) {
|
||||
userID := c.GetUint("user_id")
|
||||
requestType := c.Query("type")
|
||||
|
||||
query := database.DB.Where("developer_id = ?", userID)
|
||||
query := database.DB.Where("admin_id = ?", userID)
|
||||
if requestType == "invite" {
|
||||
query = query.Where("type = ?", "invite")
|
||||
} else if requestType == "request" {
|
||||
@@ -221,7 +221,7 @@ func handleGetAgentRequests(c *gin.Context) {
|
||||
AgentID uint `json:"agent_id"`
|
||||
AgentName string `json:"agent_name"`
|
||||
AgentEmail string `json:"agent_email"`
|
||||
DeveloperID uint `json:"developer_id"`
|
||||
AdminID uint `json:"admin_id"`
|
||||
ApplicationID uint `json:"application_id"`
|
||||
AppName string `json:"app_name"`
|
||||
Type string `json:"type"`
|
||||
@@ -252,7 +252,7 @@ func handleGetAgentRequests(c *gin.Context) {
|
||||
AgentID: req.AgentID,
|
||||
AgentName: agentName,
|
||||
AgentEmail: agentEmail,
|
||||
DeveloperID: req.DeveloperID,
|
||||
AdminID: req.AdminID,
|
||||
ApplicationID: req.ApplicationID,
|
||||
AppName: appName,
|
||||
Type: req.Type,
|
||||
@@ -282,7 +282,7 @@ func handleGetMyRequests(c *gin.Context) {
|
||||
|
||||
var requests []model.AgentApplicationRequest
|
||||
if err := query.
|
||||
Preload("Developer").
|
||||
Preload("Admin").
|
||||
Preload("Application").
|
||||
Order("created_at DESC").
|
||||
Find(&requests).Error; err != nil {
|
||||
@@ -293,8 +293,8 @@ func handleGetMyRequests(c *gin.Context) {
|
||||
type RequestResponse struct {
|
||||
ID uint `json:"id"`
|
||||
AgentID uint `json:"agent_id"`
|
||||
DeveloperID uint `json:"developer_id"`
|
||||
DeveloperName string `json:"developer_name"`
|
||||
AdminID uint `json:"admin_id"`
|
||||
AdminName string `json:"admin_name"`
|
||||
ApplicationID uint `json:"application_id"`
|
||||
AppName string `json:"app_name"`
|
||||
Type string `json:"type"`
|
||||
@@ -306,9 +306,9 @@ func handleGetMyRequests(c *gin.Context) {
|
||||
|
||||
var result []RequestResponse
|
||||
for _, req := range requests {
|
||||
developerName := ""
|
||||
if req.Developer.ID != 0 {
|
||||
developerName = req.Developer.Username
|
||||
AdminName := ""
|
||||
if req.Admin.ID != 0 {
|
||||
AdminName = req.Admin.Username
|
||||
}
|
||||
|
||||
appName := ""
|
||||
@@ -319,8 +319,8 @@ func handleGetMyRequests(c *gin.Context) {
|
||||
result = append(result, RequestResponse{
|
||||
ID: req.ID,
|
||||
AgentID: req.AgentID,
|
||||
DeveloperID: req.DeveloperID,
|
||||
DeveloperName: developerName,
|
||||
AdminID: req.AdminID,
|
||||
AdminName: AdminName,
|
||||
ApplicationID: req.ApplicationID,
|
||||
AppName: appName,
|
||||
Type: req.Type,
|
||||
@@ -379,7 +379,7 @@ func handleInviteAgent(c *gin.Context) {
|
||||
|
||||
request := model.AgentApplicationRequest{
|
||||
AgentID: req.AgentID,
|
||||
DeveloperID: userID,
|
||||
AdminID: userID,
|
||||
ApplicationID: req.ApplicationID,
|
||||
Type: "invite",
|
||||
Status: "pending",
|
||||
@@ -405,7 +405,7 @@ func handleInviteAgent(c *gin.Context) {
|
||||
func handleRequestAuthorization(c *gin.Context) {
|
||||
userID := c.GetUint("user_id")
|
||||
var req struct {
|
||||
DeveloperID uint `json:"developer_id"`
|
||||
AdminID uint `json:"admin_id"`
|
||||
ApplicationID uint `json:"application_id"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
@@ -414,18 +414,18 @@ func handleRequestAuthorization(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
var developer model.User
|
||||
if err := database.DB.First(&developer, req.DeveloperID).Error; err != nil {
|
||||
var Admin model.User
|
||||
if err := database.DB.First(&Admin, req.AdminID).Error; err != nil {
|
||||
response.Error(c, 404, "开发者不存在")
|
||||
return
|
||||
}
|
||||
if developer.Role != "admin" {
|
||||
if Admin.Role != "admin" {
|
||||
response.Error(c, 400, "该用户不是管理员")
|
||||
return
|
||||
}
|
||||
|
||||
var app model.Application
|
||||
if err := database.DB.Where("id = ? AND user_id = ?", req.ApplicationID, req.DeveloperID).First(&app).Error; err != nil {
|
||||
if err := database.DB.Where("id = ? AND user_id = ?", req.ApplicationID, req.AdminID).First(&app).Error; err != nil {
|
||||
response.Error(c, 404, "应用不存在")
|
||||
return
|
||||
}
|
||||
@@ -437,15 +437,15 @@ func handleRequestAuthorization(c *gin.Context) {
|
||||
}
|
||||
|
||||
var existingRequest model.AgentApplicationRequest
|
||||
if err := database.DB.Where("agent_id = ? AND developer_id = ? AND application_id = ? AND status = ?",
|
||||
userID, req.DeveloperID, req.ApplicationID, "pending").First(&existingRequest).Error; err == nil {
|
||||
if err := database.DB.Where("agent_id = ? AND admin_id = ? AND application_id = ? AND status = ?",
|
||||
userID, req.AdminID, req.ApplicationID, "pending").First(&existingRequest).Error; err == nil {
|
||||
response.Error(c, 400, "您已有待处理的申请")
|
||||
return
|
||||
}
|
||||
|
||||
request := model.AgentApplicationRequest{
|
||||
AgentID: userID,
|
||||
DeveloperID: req.DeveloperID,
|
||||
AdminID: req.AdminID,
|
||||
ApplicationID: req.ApplicationID,
|
||||
Type: "request",
|
||||
Status: "pending",
|
||||
@@ -459,8 +459,8 @@ func handleRequestAuthorization(c *gin.Context) {
|
||||
|
||||
response.Success(c, gin.H{
|
||||
"id": request.ID,
|
||||
"developer_id": request.DeveloperID,
|
||||
"developer_name": developer.Username,
|
||||
"admin_id": request.AdminID,
|
||||
"admin_name": Admin.Username,
|
||||
"app_id": request.ApplicationID,
|
||||
"app_name": app.Name,
|
||||
"type": request.Type,
|
||||
@@ -478,7 +478,7 @@ func handleApproveRequest(c *gin.Context) {
|
||||
}
|
||||
|
||||
var req model.AgentApplicationRequest
|
||||
if err := database.DB.Where("id = ? AND developer_id = ?", requestID, userID).First(&req).Error; err != nil {
|
||||
if err := database.DB.Where("id = ? AND admin_id = ?", requestID, userID).First(&req).Error; err != nil {
|
||||
response.Error(c, 404, "申请不存在")
|
||||
return
|
||||
}
|
||||
@@ -493,7 +493,7 @@ func handleApproveRequest(c *gin.Context) {
|
||||
agentApp := model.AgentApplication{
|
||||
AgentID: req.AgentID,
|
||||
ApplicationID: req.ApplicationID,
|
||||
DeveloperID: userID,
|
||||
AdminID: userID,
|
||||
Discount: 1.0,
|
||||
Status: "active",
|
||||
IsReceived: true,
|
||||
@@ -544,7 +544,7 @@ func handleRejectRequest(c *gin.Context) {
|
||||
}
|
||||
|
||||
var req model.AgentApplicationRequest
|
||||
if err := database.DB.Where("id = ? AND developer_id = ?", requestID, userID).First(&req).Error; err != nil {
|
||||
if err := database.DB.Where("id = ? AND admin_id = ?", requestID, userID).First(&req).Error; err != nil {
|
||||
response.Error(c, 404, "申请不存在")
|
||||
return
|
||||
}
|
||||
@@ -572,7 +572,7 @@ func handleGetAgentAppDetail(c *gin.Context) {
|
||||
agentAppID := c.Param("id")
|
||||
|
||||
var agentApp model.AgentApplication
|
||||
if err := database.DB.Where("id = ? AND developer_id = ?", agentAppID, userID).
|
||||
if err := database.DB.Where("id = ? AND admin_id = ?", agentAppID, userID).
|
||||
Preload("CardTypes.CardType").
|
||||
First(&agentApp).Error; err != nil {
|
||||
response.Error(c, 404, "授权记录不存在")
|
||||
@@ -652,7 +652,7 @@ func handleUpdateAgentApp(c *gin.Context) {
|
||||
}
|
||||
|
||||
var agentApp model.AgentApplication
|
||||
if err := database.DB.Where("id = ? AND developer_id = ?", agentAppID, userID).First(&agentApp).Error; err != nil {
|
||||
if err := database.DB.Where("id = ? AND admin_id = ?", agentAppID, userID).First(&agentApp).Error; err != nil {
|
||||
response.Error(c, 404, "授权记录不存在")
|
||||
return
|
||||
}
|
||||
@@ -693,7 +693,7 @@ func handleUpdateAgentCardTypes(c *gin.Context) {
|
||||
}
|
||||
|
||||
var agentApp model.AgentApplication
|
||||
if err := database.DB.Where("id = ? AND developer_id = ?", agentAppID, userID).First(&agentApp).Error; err != nil {
|
||||
if err := database.DB.Where("id = ? AND admin_id = ?", agentAppID, userID).First(&agentApp).Error; err != nil {
|
||||
response.Error(c, 404, "授权记录不存在")
|
||||
return
|
||||
}
|
||||
@@ -731,7 +731,7 @@ func handleRemoveAgentApp(c *gin.Context) {
|
||||
agentAppID := c.Param("id")
|
||||
|
||||
var agentApp model.AgentApplication
|
||||
if err := database.DB.Where("id = ? AND developer_id = ?", agentAppID, userID).First(&agentApp).Error; err != nil {
|
||||
if err := database.DB.Where("id = ? AND admin_id = ?", agentAppID, userID).First(&agentApp).Error; err != nil {
|
||||
response.Error(c, 404, "授权记录不存在")
|
||||
return
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -48,9 +48,9 @@ func SetupCardRoutesWithoutPackage(r *gin.RouterGroup) {
|
||||
}
|
||||
}
|
||||
|
||||
func checkDeveloperPackageValid(developerID uint) bool {
|
||||
func checkAdminPackageValid(AdminID uint) bool {
|
||||
var user model.User
|
||||
if err := database.DB.First(&user, developerID).Error; err != nil {
|
||||
if err := database.DB.First(&user, AdminID).Error; err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func checkDeveloperPackageValid(developerID uint) bool {
|
||||
|
||||
var userPackage model.UserPackage
|
||||
if err := database.DB.Where("user_id = ? AND package_id = ? AND status = ?",
|
||||
developerID, user.CurrentPackageID, "active").First(&userPackage).Error; err != nil {
|
||||
AdminID, user.CurrentPackageID, "active").First(&userPackage).Error; err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -678,7 +678,7 @@ func handleBatchGenerateCards(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("[DEBUG] AgentApp found - ID: %d, DeveloperID: %d\n", agentApp.ID, agentApp.DeveloperID)
|
||||
fmt.Printf("[DEBUG] AgentApp found - ID: %d, AdminID: %d\n", agentApp.ID, agentApp.AdminID)
|
||||
|
||||
var cardTypePerm *model.AgentApplicationCardType
|
||||
for _, ct := range agentApp.CardTypes {
|
||||
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"time"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"log"
|
||||
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package developer
|
||||
package admin
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
@@ -116,13 +116,24 @@ func handleAppHeartbeat(c *gin.Context) {
|
||||
}
|
||||
|
||||
if shouldDeduct {
|
||||
if user.Balance >= app.DeductionAmount {
|
||||
user.Balance -= app.DeductionAmount
|
||||
log.Printf("[DEBUG] Deducted %.2f from user %d, new balance: %.2f", app.DeductionAmount, user.ID, user.Balance)
|
||||
if user.Balance == -1 {
|
||||
log.Printf("[DEBUG] User %d is permanent member, skip deduction", user.ID)
|
||||
} else if app.BillingType == "subscription" {
|
||||
if user.ExpiryAt == nil || user.ExpiryAt.Before(now) {
|
||||
log.Printf("[DEBUG] User %d subscription expired, ExpiryAt=%v", user.ID, user.ExpiryAt)
|
||||
response.Error(c, 403, "订阅已过期")
|
||||
return
|
||||
}
|
||||
log.Printf("[DEBUG] User %d subscription valid, skip balance deduction", user.ID)
|
||||
} else {
|
||||
log.Printf("[DEBUG] User %d has insufficient balance: %.2f < %.2f", user.ID, user.Balance, app.DeductionAmount)
|
||||
response.Error(c, 403, "余额不足")
|
||||
return
|
||||
if user.Balance >= app.DeductionAmount {
|
||||
user.Balance -= app.DeductionAmount
|
||||
log.Printf("[DEBUG] Deducted %.2f from user %d, new balance: %.2f", app.DeductionAmount, user.ID, user.Balance)
|
||||
} else {
|
||||
log.Printf("[DEBUG] User %d has insufficient balance: %.2f < %.2f", user.ID, user.Balance, app.DeductionAmount)
|
||||
response.Error(c, 403, "余额不足")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,11 +456,24 @@ func handleAppLogin(c *gin.Context) {
|
||||
log.Printf("[DEBUG] isTrialValid=%v, IsTrialUser=%v, TrialEndAt=%v, Balance=%f", isTrialValid, user.IsTrialUser, user.TrialEndAt, user.Balance)
|
||||
|
||||
if !isTrialValid {
|
||||
if appModel.BillingType != "free" && user.Balance <= 0 {
|
||||
log.Printf("[DEBUG] User %d has no balance remaining", user.ID)
|
||||
service.LogVerification(c, &appModel.ID, &user.ID, "login_failed", "登录失败: 余额不足 - "+req.Username, req.DeviceID, fmt.Errorf("余额不足,请充值后继续使用"))
|
||||
response.Error(c, 403, "余额不足,请充值后继续使用")
|
||||
return
|
||||
if appModel.BillingType != "free" {
|
||||
if user.Balance == -1 {
|
||||
log.Printf("[DEBUG] User %d is permanent member, allowing login", user.ID)
|
||||
} else if appModel.BillingType == "subscription" {
|
||||
if user.ExpiryAt == nil || user.ExpiryAt.Before(time.Now()) {
|
||||
log.Printf("[DEBUG] User %d subscription expired, ExpiryAt=%v", user.ID, user.ExpiryAt)
|
||||
service.LogVerification(c, &appModel.ID, &user.ID, "login_failed", "登录失败: 订阅已过期 - "+req.Username, req.DeviceID, fmt.Errorf("订阅已过期,请充值后继续使用"))
|
||||
response.Error(c, 403, "订阅已过期,请充值后继续使用")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if user.Balance <= 0 {
|
||||
log.Printf("[DEBUG] User %d has no balance remaining", user.ID)
|
||||
service.LogVerification(c, &appModel.ID, &user.ID, "login_failed", "登录失败: 余额不足 - "+req.Username, req.DeviceID, fmt.Errorf("余额不足,请充值后继续使用"))
|
||||
response.Error(c, 403, "余额不足,请充值后继续使用")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -549,18 +549,18 @@ func handleAppUploadVariableBinary(c *gin.Context) {
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
var developer model.User
|
||||
if err := database.DB.First(&developer, app.UserID).Error; err != nil {
|
||||
response.Error(c, 500, "获取开发者信息失败")
|
||||
var adminUser model.User
|
||||
if err := database.DB.First(&adminUser, app.UserID).Error; err != nil {
|
||||
response.Error(c, 500, "获取管理员信息失败")
|
||||
return
|
||||
}
|
||||
|
||||
if developer.CurrentPackageID != nil {
|
||||
if adminUser.CurrentPackageID != nil {
|
||||
var permission model.PackagePermission
|
||||
if err := database.DB.Where("package_id = ?", developer.CurrentPackageID).First(&permission).Error; err == nil {
|
||||
if err := database.DB.Where("package_id = ?", adminUser.CurrentPackageID).First(&permission).Error; err == nil {
|
||||
maxStorageBytes := int64(permission.MaxStorage) * 1024 * 1024
|
||||
if developer.StorageUsed+header.Size > maxStorageBytes {
|
||||
usedMB := float64(developer.StorageUsed) / 1024 / 1024
|
||||
if adminUser.StorageUsed+header.Size > maxStorageBytes {
|
||||
usedMB := float64(adminUser.StorageUsed) / 1024 / 1024
|
||||
maxMB := float64(permission.MaxStorage)
|
||||
response.Error(c, 403, fmt.Sprintf("存储空间不足,已使用 %.2f MB / %.2f MB", usedMB, maxMB))
|
||||
return
|
||||
|
||||
@@ -250,19 +250,35 @@ func handleExecuteDynamicCode(c *gin.Context) {
|
||||
|
||||
httpClient := httputil.NewHTTPClient(10 * time.Second)
|
||||
httpObj := map[string]interface{}{
|
||||
"get": func(url string, headers map[string]interface{}) *httputil.HTTPResponse {
|
||||
"get": func(url string, headers map[string]interface{}) map[string]interface{} {
|
||||
convertedHeaders := make(map[string]string)
|
||||
for k, v := range headers {
|
||||
convertedHeaders[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
return httpClient.Get(url, convertedHeaders)
|
||||
resp := httpClient.Get(url, convertedHeaders)
|
||||
return map[string]interface{}{
|
||||
"statusCode": resp.StatusCode,
|
||||
"status": resp.Status,
|
||||
"headers": resp.Headers,
|
||||
"body": resp.Body,
|
||||
"json": resp.JSON,
|
||||
"error": resp.Error,
|
||||
}
|
||||
},
|
||||
"post": func(url string, headers map[string]interface{}, body interface{}) *httputil.HTTPResponse {
|
||||
"post": func(url string, headers map[string]interface{}, body interface{}) map[string]interface{} {
|
||||
convertedHeaders := make(map[string]string)
|
||||
for k, v := range headers {
|
||||
convertedHeaders[k] = fmt.Sprintf("%v", v)
|
||||
}
|
||||
return httpClient.Post(url, convertedHeaders, body)
|
||||
resp := httpClient.Post(url, convertedHeaders, body)
|
||||
return map[string]interface{}{
|
||||
"statusCode": resp.StatusCode,
|
||||
"status": resp.Status,
|
||||
"headers": resp.Headers,
|
||||
"body": resp.Body,
|
||||
"json": resp.JSON,
|
||||
"error": resp.Error,
|
||||
}
|
||||
},
|
||||
}
|
||||
if err := vm.Set("http", httpObj); err != nil {
|
||||
|
||||
@@ -91,8 +91,14 @@ func handleAppRecharge(c *gin.Context) {
|
||||
user.IsTrialUser = false
|
||||
|
||||
if card.CardType.Value == -1 {
|
||||
user.Balance = -1
|
||||
user.ExpiryAt = nil
|
||||
if card.CardType.RechargeType == "subscription" {
|
||||
permanentExpiry := time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC)
|
||||
user.ExpiryAt = &permanentExpiry
|
||||
user.Balance = -1
|
||||
} else {
|
||||
user.Balance = -1
|
||||
user.ExpiryAt = nil
|
||||
}
|
||||
} else {
|
||||
switch card.CardType.RechargeType {
|
||||
case "subscription":
|
||||
|
||||
@@ -673,7 +673,7 @@ func HandleCreateOrder(c *gin.Context) {
|
||||
}
|
||||
|
||||
notifyURL := fmt.Sprintf("%s/api/v1/payment/callback/bepusdt", callbackBaseURL)
|
||||
redirectURL := fmt.Sprintf("%s/developer/finance?order=%s", callbackBaseURL, orderNo)
|
||||
redirectURL := fmt.Sprintf("%s/admin/finance?order=%s", callbackBaseURL, orderNo)
|
||||
|
||||
result, err := paymentService.CreateOrder(orderNo, pkg.Price, notifyURL, redirectURL, order.Title)
|
||||
if err != nil {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"verification-platform-backend/internal/middleware"
|
||||
"verification-platform-backend/internal/router/agent"
|
||||
"verification-platform-backend/internal/router/app"
|
||||
"verification-platform-backend/internal/router/developer"
|
||||
"verification-platform-backend/internal/router/admin"
|
||||
"verification-platform-backend/internal/router/extension"
|
||||
"verification-platform-backend/internal/router/frontend"
|
||||
"verification-platform-backend/pkg/response"
|
||||
@@ -32,9 +32,9 @@ func SetupRoutes(r *gin.Engine) {
|
||||
devGroup := api.Group("/dev")
|
||||
{
|
||||
devGroup.Use(middleware.JWT())
|
||||
devGroup.Use(middleware.DeveloperAuth())
|
||||
developer.SetupRoutes(devGroup)
|
||||
developer.SetupRoutesWithoutPackage(devGroup)
|
||||
devGroup.Use(middleware.AdminAuth())
|
||||
admin.SetupRoutes(devGroup)
|
||||
admin.SetupRoutesWithoutPackage(devGroup)
|
||||
}
|
||||
|
||||
agentGroup := api.Group("/agent")
|
||||
|
||||
Reference in New Issue
Block a user