07409eb602
Closes HIF-4 Stage 2 交付:人工奖领奖工单完整闭环。crypto / physical / manual_other 三类奖品从抽中到 mark-paid 的全流程可用。 - 迁移 02159_lottery_claim:UNIQUE(draw_id) + 3 支持索引,状态机 pending_claim→reviewing→paying→paid,rejected 可复活,超时 expired - 3 个 PrizeHandler:Dispatch→ErrDispatchNotSupported 兜底、ClaimSchema 各自形态、ValidateClaim 表驱动 - BuildCryptoClaimSchema:抽中时按奖品 config.networks 注入 enum,前端下拉直接可用 - Draw service dispatchOrEnqueueClaim:人工奖同 tx 插 pending_claim(回滚双清),nonce 重放回读 ExpiresAt + ClaimFormSchema - POST /claim 实装:ownership 校验 → prize 类型校验 → handler.ValidateClaim → crypto network 白名单二次校验 → tx CAS status IN (pending_claim, rejected) AND expires_at > now - Admin CRUD 5 接口:list(IN 批拉 snap + user,无 N+1)、summary(GROUP BY 一次拿计数 + overdue 单查)、approve/reject/mark-paid 全走 CAS + audit - Scheduler @every 1h 扫过期,级联 lottery_draw.dispatch_state → expired - 新增错误码 100005-100011(already_submitted / invalid_claim_data / draw_not_found / not_your_draw / claim_expired / claim_state_invalid) - Rebase 后 Stage 2 测试主动 reuse PR E 的 unmetReasonsNotEmpty + evaluatedAtNotZero matcher,人工奖分支若绕过守卫会立即挂 - Stage 1 全部 4 处 guardrail 后端 rebase 时自检过:UnmetReasons、EvaluatedAt、GrantLedger.Payload、AdminMetaMiddleware 全保留 CI 全绿;28 files, +2442/-126;覆盖率 handler 78.9% / model.lottery 74.3% / draw 68.7% / queue/lottery 76.9%
154 lines
6.3 KiB
Go
154 lines
6.3 KiB
Go
package xerr
|
|
|
|
var message map[uint32]string
|
|
|
|
func init() {
|
|
message = make(map[uint32]string)
|
|
message = map[uint32]string{
|
|
// General error
|
|
SUCCESS: "Success",
|
|
ERROR: "Internal Server Error",
|
|
// parameter error
|
|
TooManyRequests: "Too Many Requests",
|
|
InvalidParams: "Param Error",
|
|
ErrorTokenEmpty: "User token is empty",
|
|
ErrorTokenInvalid: "User token is invalid",
|
|
ErrorTokenExpire: "User token is expired",
|
|
SecretIsEmpty: "Secret is empty",
|
|
InvalidAccess: "Invalid access",
|
|
InvalidCiphertext: "Invalid ciphertext",
|
|
SignatureMissing: "Signature headers are missing",
|
|
SignatureExpired: "Signature is expired",
|
|
SignatureInvalid: "Signature is invalid",
|
|
SignatureReplay: "Signature nonce replay detected",
|
|
// Database error
|
|
DatabaseQueryError: "Database query error",
|
|
DatabaseUpdateError: "Database update error",
|
|
DatabaseInsertError: "Database insert error",
|
|
DatabaseDeletedError: "Database deleted error",
|
|
|
|
// User error
|
|
UserExist: "User already exists",
|
|
UserNotExist: "User does not exist",
|
|
UserPasswordError: "User password error",
|
|
UserDisabled: "User disabled",
|
|
InsufficientBalance: "Insufficient balance",
|
|
StopRegister: "Stop register",
|
|
TelegramNotBound: "Telegram not bound ",
|
|
UserNotBindOauth: "User not bind oauth method",
|
|
InviteCodeError: "Invite code error",
|
|
UserCommissionNotEnough: "佣金余额不足",
|
|
RegisterIPLimit: "Too many registrations",
|
|
EmailBindError: "Email already bound",
|
|
UserBindInviteCodeExist: "Invite code already bound",
|
|
FamilyMemberLimitExceeded: "家庭成员数量已达上限",
|
|
FamilyAlreadyBound: "已绑定家庭组",
|
|
FamilyCrossBindForbidden: "禁止跨家庭组绑定",
|
|
FamilyNotExist: "家庭组不存在",
|
|
FamilyStatusInvalid: "家庭组状态无效",
|
|
FamilyOwnerOperationForbidden: "家庭组所有者不允许此操作",
|
|
WithdrawalStatusInvalid: "提现状态无效",
|
|
|
|
// Node error
|
|
NodeExist: "Node already exists",
|
|
NodeNotExist: "Node does not exist",
|
|
NodeGroupExist: "Node group already exists",
|
|
NodeGroupNotExist: "Node group does not exist",
|
|
NodeGroupNotEmpty: "Node group is not empty",
|
|
|
|
//coupon error
|
|
CouponNotExist: "Coupon does not exist",
|
|
CouponAlreadyUsed: "Coupon has already been used",
|
|
CouponNotApplicable: "Coupon does not match the order or conditions",
|
|
CouponInsufficientUsage: "Coupon has insufficient remaining uses",
|
|
CouponExpired: "Coupon is expired",
|
|
|
|
// Subscribe
|
|
SubscribeExpired: "Subscribe is expired",
|
|
SubscribeNotAvailable: "Subscribe is not available",
|
|
UserSubscribeExist: "User has subscription",
|
|
SubscribeIsUsedError: "Subscribe is used",
|
|
SingleSubscribeModeExceedsLimit: "Single subscribe mode exceeds limit",
|
|
SubscribeQuotaLimit: "Subscribe quota limit",
|
|
SubscribeOutOfStock: "Subscribe out of stock",
|
|
SingleSubscribePlanMismatch: "Single subscribe mode does not support switching subscription by purchase",
|
|
SubscribeNewUserOnly: "This plan is only available for new users within 24 hours of registration",
|
|
|
|
// auth error
|
|
VerifyCodeError: "Verify code error",
|
|
|
|
// EnqueueError
|
|
QueueEnqueueError: " Queue enqueue error",
|
|
|
|
// System error
|
|
DebugModeError: "Debug mode is enabled",
|
|
|
|
SendSmsError: "短信发送失败",
|
|
|
|
GetAuthenticatorError: "Unsupported login method",
|
|
AuthenticatorNotSupportedError: "The authenticator does not support this method",
|
|
|
|
TelephoneAreaCodeIsEmpty: "Telephone area code is empty",
|
|
TodaySendCountExceedsLimit: "This account has reached the limit of sending times today",
|
|
SmsNotEnabled: "Telephone login is not enabled",
|
|
EmailNotEnabled: "Email function is not enabled yet",
|
|
PasswordOrVerificationCodeRequired: "Password or verification code required",
|
|
EmailExist: "Email already exists",
|
|
TelephoneExist: "Telephone already exists",
|
|
DeviceExist: "device exists",
|
|
PasswordIsEmpty: "password is empty",
|
|
AreaCodeIsEmpty: "国家区号不能为空",
|
|
TelephoneError: "telephone number error",
|
|
DeviceNotExist: "Device does not exist",
|
|
UseridNotMatch: "Userid not match",
|
|
DeviceBindLimitExceeded: "设备绑定数量已达上限",
|
|
|
|
// Order error
|
|
OrderNotExist: "Order does not exist",
|
|
PaymentMethodNotFound: "Payment method not found",
|
|
OrderStatusError: "Order status error",
|
|
InsufficientOfPeriod: "Insufficient number of period",
|
|
ExistAvailableTraffic: "存在可用流量",
|
|
OrderAlreadyRefunded: "Order already refunded",
|
|
OrderRefundNoSubscription: "Refund target subscription not found",
|
|
OrderRefundCommissionMismatch: "Refund commission source not found",
|
|
|
|
// Lottery error
|
|
LotteryNotEligible: "抽奖门槛未达成",
|
|
LotteryNoChances: "抽奖次数不足",
|
|
LotteryActivityEnded: "抽奖活动未开放",
|
|
LotteryRateLimited: "抽奖操作过于频繁,请稍后再试",
|
|
LotteryAlreadySubmitted: "该奖品的领奖信息已提交,无需重复提交",
|
|
LotteryInvalidClaimData: "领奖信息格式不正确",
|
|
LotteryDrawNotFound: "抽奖记录不存在",
|
|
LotteryNotYourDraw: "无权操作此抽奖记录",
|
|
LotteryClaimExpired: "领奖窗口已过期",
|
|
LotteryNotClaimable: "该奖品当前不支持领取",
|
|
LotteryClaimStateInvalid: "当前工单状态不允许此操作",
|
|
LotteryInternalError: "抽奖服务暂时不可用",
|
|
LotteryRuleTooDeep: "规则树嵌套层数超限",
|
|
LotteryRuleTooMany: "规则树节点数超限",
|
|
LotteryRuleTooLarge: "规则树 JSON 体积超限",
|
|
|
|
// Permission error
|
|
PermissionDenied: "Permission denied",
|
|
}
|
|
|
|
}
|
|
|
|
func MapErrMsg(errCode uint32) string {
|
|
if msg, ok := message[errCode]; ok {
|
|
return msg
|
|
} else {
|
|
return "Internal Server Error"
|
|
}
|
|
}
|
|
|
|
func IsCodeErr(errCode uint32) bool {
|
|
if _, ok := message[errCode]; ok {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|