Files
2026-09-17 17:38:45 +08:00

84 lines
2.6 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package consts
// JWT audience
const (
AudUser = "user"
AudAdmin = "admin"
)
// 请求上下文变量(中间件 SetCtxVar)
const (
CtxUserId = "userId"
CtxLevelKey = "levelKey"
CtxAdminId = "adminId"
)
// 业务错误码(响应 code 字段)
const (
CodeLocked = 4001 // 模块未授权(等级锁定)
CodeQuotaExhausted = 4002 // 额度用尽(免费/会员/付费额度都已耗尽)
CodePayFail = 4101 // 下单/支付参数异常
)
// 默认等级:会员到期后回落的目标等级
const DefaultLevelKey = "v1"
// 表名
const (
TableUsers = "users"
TableModules = "modules"
TableLevels = "levels"
TableTools = "tools"
TableUsageLogs = "tool_usage_logs"
TableWorkbench = "user_workbench"
TableAdminUsers = "admin_users"
TableFeedbacks = "feedbacks"
TableMemberPlans = "member_plans"
TableMemberOrders = "member_orders"
TableQuotaPacks = "quota_packs"
TableUserToolQuota = "user_tool_quota"
TableQuotaUsage = "user_quota_usage"
TableSettings = "settings"
)
// 订单类型:同一个下单/发货链路承载「会员」与「次数包」两种商品
const (
OrderTypeMember = 1 // 会员套餐(延长等级有效期)
OrderTypeQuota = 2 // 次数包(增加某工具的付费额度余额)
)
// 额度来源(扣减时实际命中的池)
const (
QuotaSourceFree = "free" // 免费额度
QuotaSourceMember = "member" // 会员额度
QuotaSourcePaid = "paid" // 付费额度(次数包)
QuotaSourceNone = "none" // 已耗尽
)
// 额度设置键(settings 表)
const (
SettingQuotaPeriodDays = "quota_period_days" // 全局默认额度重置周期(天)
)
// DefaultQuotaPeriodDays 额度周期兜底值:settings 与 config 都未配置时使用。
// 后台「额度设置」可改,用户维度与会员套餐维度可各自覆盖。
const DefaultQuotaPeriodDays = 7
// 会员订单状态
const (
OrderStatusPending = 0 // 待支付
OrderStatusDelivered = 1 // 已支付并发货(会员权益已生效)
OrderStatusRefunded = 2 // 已退款
OrderStatusClosed = 3 // 已关闭(超时未支付)
)
// 虚拟支付环境与支付渠道
const (
XPayEnvProd = 0 // env 固定填 0(现网)
XPayCurrency = "CNY" // 币种固定 CNY
XPayMode = "short_series_goods" // 道具直购
PayChannelWx = "wxpay" // 微信虚拟支付(Android 等)
PayChannelIOS = "apple" // Apple IAP
XPayNotifyEvent = "xpay_goods_deliver_notify" // 发货推送事件名
)