新增几大中心功能

This commit is contained in:
Administrator
2026-04-23 15:29:07 +08:00
parent 5c2a146a44
commit c6354ee065
123 changed files with 13074 additions and 229 deletions

View File

@@ -0,0 +1,35 @@
package app
import "time"
type AppAssetType string
const (
AppAssetTypeAccount AppAssetType = "account"
AppAssetTypeGameCoin AppAssetType = "game_coin"
)
type AppRechargeType string
const (
AppRechargeTypeOffline AppRechargeType = "offline"
AppRechargeTypeOnlineNotArrived AppRechargeType = "online_not_arrived"
AppRechargeTypeActivitySubsidy AppRechargeType = "activity_subsidy"
AppRechargeTypeManualAdjustment AppRechargeType = "manual_adjustment"
)
// AppAssetTransaction 玩家资产流水(金额单位:厘)
type AppAssetTransaction struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"index;not null"`
AssetType AppAssetType `json:"assetType" gorm:"type:varchar(16);index;not null"`
RechargeType AppRechargeType `json:"rechargeType" gorm:"type:varchar(32);index;not null;default:'manual_adjustment'"`
DeltaLi int64 `json:"deltaLi" gorm:"not null;comment:变动(厘)"`
BeforeLi int64 `json:"beforeLi" gorm:"not null"`
AfterLi int64 `json:"afterLi" gorm:"not null"`
Reason string `json:"reason" gorm:"size:255;not null"`
OperatorUserID uint `json:"operatorUserId" gorm:"index;not null;comment:后台操作人ID"`
CreatedAt time.Time `json:"createdAt"`
}
func (AppAssetTransaction) TableName() string { return "app_asset_transactions" }

View File

@@ -0,0 +1,30 @@
package app
import "time"
type InviteCodeStatus string
const (
InviteCodeStatusUnused InviteCodeStatus = "unused"
InviteCodeStatusUsed InviteCodeStatus = "used"
InviteCodeStatusRevoked InviteCodeStatus = "revoked"
InviteCodeStatusExpired InviteCodeStatus = "expired"
)
// AppInviteCode 玩家邀请码(明文不落库,仅保存 hash
type AppInviteCode struct {
ID uint `json:"id" gorm:"primaryKey"`
CreatedByUserID uint `json:"createdByUserId" gorm:"index;not null"`
CodeHash string `json:"-" gorm:"uniqueIndex;size:64;not null"`
CodeLast4 string `json:"codeLast4" gorm:"size:8"`
Status InviteCodeStatus `json:"status" gorm:"type:varchar(16);index;not null"`
ExpiresAt *time.Time `json:"expiresAt" gorm:"index"`
UsedByUserID *uint `json:"usedByUserId" gorm:"index"`
UsedAt *time.Time `json:"usedAt"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppInviteCode) TableName() string {
return "app_invite_codes"
}

View File

@@ -0,0 +1,18 @@
package app
import "time"
// AppLoginLog 玩家登录日志(用于审计)
type AppLoginLog struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"index;comment:玩家ID(失败时可为0)"`
Username string `json:"username" gorm:"index;size:64;not null;comment:用户名"`
IP string `json:"ip" gorm:"size:64;not null;comment:请求IP"`
Referer string `json:"referer" gorm:"size:2048;comment:参考地址(Referer)"`
UserAgent string `json:"userAgent" gorm:"size:2048;comment:客户端信息(User-Agent)"`
Status bool `json:"status" gorm:"index;not null;comment:登录状态"`
ErrorMessage string `json:"errorMessage" gorm:"size:255;comment:失败原因"`
CreatedAt time.Time `json:"createdAt" gorm:"index"`
}
func (AppLoginLog) TableName() string { return "app_login_logs" }

View File

@@ -0,0 +1,19 @@
package app
import "time"
// AppRiskTag 风险标签(人工版)
type AppRiskTag struct {
ID uint `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"size:64;uniqueIndex;not null;comment:标签名"`
Level int `json:"level" gorm:"index;not null;default:1;comment:风险级别(1-5)"`
Color string `json:"color" gorm:"size:32;comment:颜色(前端展示)"`
Desc string `json:"desc" gorm:"size:255;comment:说明"`
CreatedAt time.Time `json:"createdAt" gorm:"index"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppRiskTag) TableName() string { return "app_risk_tags" }

View File

@@ -0,0 +1,23 @@
package app
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type AppUser struct {
ID uint `json:"id" gorm:"primaryKey"`
UUID uuid.UUID `json:"uuid" gorm:"index;not null;comment:用户UUID"`
Username string `json:"username" gorm:"uniqueIndex;size:64;not null"`
Password string `json:"-" gorm:"not null"`
Enable int `json:"enable" gorm:"default:1;comment:1正常 2禁用"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppUser) TableName() string {
return "app_users"
}

View File

@@ -0,0 +1,16 @@
package app
import "time"
// AppUserActivity 玩家登录与活跃信息
type AppUserActivity struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"uniqueIndex;not null"`
LastLoginAt *time.Time `json:"lastLoginAt" gorm:"index"`
LastActiveAt *time.Time `json:"lastActiveAt" gorm:"index"`
LastActiveIP string `json:"lastActiveIp" gorm:"size:64"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppUserActivity) TableName() string { return "app_user_activity" }

View File

@@ -0,0 +1,16 @@
package app
import "time"
// AppUserAsset 玩家资产(金额单位:厘)
type AppUserAsset struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"uniqueIndex;not null"`
AccountBalanceLi int64 `json:"accountBalanceLi" gorm:"not null;default:0;comment:账户余额(厘)"`
AccountFrozenLi int64 `json:"accountFrozenLi" gorm:"not null;default:0;comment:账户余额冻结(厘)"`
GameCoinBalanceLi int64 `json:"gameCoinBalanceLi" gorm:"not null;default:0;comment:游戏币余额(厘)"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppUserAsset) TableName() string { return "app_user_assets" }

View File

@@ -0,0 +1,15 @@
package app
import "time"
type AppUserInviteRelation struct {
ID uint `json:"id" gorm:"primaryKey"`
InviterUserID uint `json:"inviterUserId" gorm:"index;not null"`
InviteeUserID uint `json:"inviteeUserId" gorm:"uniqueIndex;not null"`
InviteCodeID uint `json:"inviteCodeId" gorm:"index;not null"`
CreatedAt time.Time `json:"createdAt"`
}
func (AppUserInviteRelation) TableName() string {
return "app_user_invite_relations"
}

View File

@@ -0,0 +1,18 @@
package app
import "time"
type AppUserProfile struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"uniqueIndex;not null"`
WelcomePhrase string `json:"welcomePhrase" gorm:"type:varchar(255);comment:安全欢迎词"`
NickName string `json:"nickName" gorm:"type:varchar(64)"`
Avatar string `json:"avatar" gorm:"type:varchar(255)"`
Channel string `json:"channel" gorm:"type:varchar(64)"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppUserProfile) TableName() string {
return "app_user_profiles"
}

View File

@@ -0,0 +1,19 @@
package app
import "time"
// AppUserRiskTag 玩家风险标签关系(人工版)
type AppUserRiskTag struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"index;not null"`
TagID uint `json:"tagId" gorm:"index;not null"`
OperatorUserID uint `json:"operatorUserId" gorm:"index;not null;comment:后台操作人ID"`
Remark string `json:"remark" gorm:"size:255;comment:备注"`
CreatedAt time.Time `json:"createdAt" gorm:"index"`
}
func (AppUserRiskTag) TableName() string { return "app_user_risk_tags" }

View File

@@ -0,0 +1,48 @@
package app
import "time"
type AppWithdrawOrderStatus string
const (
AppWithdrawOrderStatusPending AppWithdrawOrderStatus = "pending" // 已提交,待审核
AppWithdrawOrderStatusApproved AppWithdrawOrderStatus = "approved" // 已审核通过,待打款
AppWithdrawOrderStatusRejected AppWithdrawOrderStatus = "rejected" // 审核拒绝(已解冻)
AppWithdrawOrderStatusPaid AppWithdrawOrderStatus = "paid" // 已打款(余额已扣减)
AppWithdrawOrderStatusFailed AppWithdrawOrderStatus = "failed" // 打款失败(已解冻)
)
// AppWithdrawOrder 提现订单(金额单位:厘)
type AppWithdrawOrder struct {
ID uint `json:"id" gorm:"primaryKey"`
AppUserID uint `json:"appUserId" gorm:"index;not null;comment:玩家ID"`
Username string `json:"username" gorm:"size:64;index;not null;comment:用户名快照"`
AmountLi int64 `json:"amountLi" gorm:"not null;comment:提现金额(厘)"`
FeeLi int64 `json:"feeLi" gorm:"not null;default:0;comment:手续费(厘)"`
NetLi int64 `json:"netLi" gorm:"not null;comment:实际打款金额(厘)"`
Status AppWithdrawOrderStatus `json:"status" gorm:"type:varchar(16);index;not null;default:'pending'"`
Channel string `json:"channel" gorm:"size:32;comment:打款渠道(预留)"`
PayeeAccount string `json:"payeeAccount" gorm:"size:128;comment:收款账号(脱敏/快照)"`
PayeeRealName string `json:"payeeRealName" gorm:"size:64;comment:收款人(快照)"`
ApplyRemark string `json:"applyRemark" gorm:"size:255;comment:申请备注(预留)"`
AuditRemark string `json:"auditRemark" gorm:"size:255;comment:审核备注"`
RejectReason string `json:"rejectReason" gorm:"size:255;comment:拒绝原因"`
FailureReason string `json:"failureReason" gorm:"size:255;comment:打款失败原因"`
ExternalTxID string `json:"externalTxId" gorm:"size:128;index;comment:外部流水号(预留)"`
OperatorUserID uint `json:"operatorUserId" gorm:"index;not null;comment:创建/最近操作人ID"`
ApprovedBy uint `json:"approvedBy" gorm:"index;comment:审核人ID"`
ApprovedAt *time.Time `json:"approvedAt" gorm:"index"`
PaidBy uint `json:"paidBy" gorm:"index;comment:打款确认人ID"`
PaidAt *time.Time `json:"paidAt" gorm:"index"`
CreatedAt time.Time `json:"createdAt" gorm:"index"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppWithdrawOrder) TableName() string { return "app_withdraw_orders" }

View File

@@ -0,0 +1,8 @@
package request
type Login struct {
Username string `json:"username" binding:"required"`
Password string `json:"password" binding:"required"`
Captcha string `json:"captcha"`
CaptchaId string `json:"captchaId"`
}

View File

@@ -0,0 +1,12 @@
package request
type PublicRegister struct {
Username string `json:"username" binding:"required,min=3,max=64"`
Password string `json:"password" binding:"required,min=6,max=128"`
WelcomePhrase string `json:"welcomePhrase" binding:"required,min=1,max=255"`
Captcha string `json:"captcha"`
CaptchaId string `json:"captchaId"`
InviteCode string `json:"inviteCode"`
}

View File

@@ -0,0 +1,16 @@
package response
type RegisterMode string
const (
RegisterModeClosed RegisterMode = "closed"
RegisterModeOpen RegisterMode = "open"
RegisterModeInvite RegisterMode = "invite"
)
type RegisterStatusResponse struct {
Mode RegisterMode `json:"mode"`
RequireCaptcha bool `json:"requireCaptcha"`
InviteExpireHours int `json:"inviteExpireHours,omitempty"`
Message string `json:"message,omitempty"`
}