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%
180 lines
5.8 KiB
Go
180 lines
5.8 KiB
Go
package xerr
|
||
|
||
/** (The first 3 digits represent the business, and the last three digits represent the specific function) **/
|
||
|
||
// General error code
|
||
const (
|
||
SUCCESS uint32 = 200
|
||
ERROR uint32 = 500
|
||
)
|
||
|
||
// Database error
|
||
const (
|
||
DatabaseQueryError uint32 = 10001
|
||
DatabaseUpdateError uint32 = 10002
|
||
DatabaseInsertError uint32 = 10003
|
||
DatabaseDeletedError uint32 = 10004
|
||
)
|
||
|
||
// User error
|
||
const (
|
||
UserExist uint32 = 20001
|
||
UserNotExist uint32 = 20002
|
||
UserPasswordError uint32 = 20003
|
||
UserDisabled uint32 = 20004
|
||
InsufficientBalance uint32 = 20005
|
||
StopRegister uint32 = 20006
|
||
TelegramNotBound uint32 = 20007
|
||
UserNotBindOauth uint32 = 20008
|
||
InviteCodeError uint32 = 20009
|
||
UserCommissionNotEnough uint32 = 20010
|
||
RegisterIPLimit uint32 = 20011
|
||
EmailBindError uint32 = 20012
|
||
UserBindInviteCodeExist uint32 = 20013
|
||
FamilyMemberLimitExceeded uint32 = 20014
|
||
FamilyAlreadyBound uint32 = 20015
|
||
FamilyCrossBindForbidden uint32 = 20016
|
||
FamilyNotExist uint32 = 20017
|
||
FamilyStatusInvalid uint32 = 20018
|
||
FamilyOwnerOperationForbidden uint32 = 20019
|
||
WithdrawalStatusInvalid uint32 = 20020
|
||
)
|
||
|
||
// Node error
|
||
const (
|
||
NodeExist uint32 = 30001
|
||
NodeNotExist uint32 = 30002
|
||
NodeGroupExist uint32 = 30003
|
||
NodeGroupNotExist uint32 = 30004
|
||
NodeGroupNotEmpty uint32 = 30005
|
||
)
|
||
|
||
// Request error
|
||
const (
|
||
InvalidParams uint32 = 400
|
||
TooManyRequests uint32 = 401
|
||
ErrorTokenEmpty uint32 = 40002
|
||
ErrorTokenInvalid uint32 = 40003
|
||
ErrorTokenExpire uint32 = 40004
|
||
InvalidAccess uint32 = 40005
|
||
InvalidCiphertext uint32 = 40006
|
||
SecretIsEmpty uint32 = 40007
|
||
SignatureMissing uint32 = 40008
|
||
SignatureExpired uint32 = 40009
|
||
SignatureInvalid uint32 = 40010
|
||
SignatureReplay uint32 = 40011
|
||
)
|
||
|
||
//coupon error
|
||
|
||
const (
|
||
CouponNotExist uint32 = 50001 // Coupon does not exist
|
||
CouponAlreadyUsed uint32 = 50002 // Coupon has already been used
|
||
CouponNotApplicable uint32 = 50003 // Coupon does not match the order or conditions
|
||
CouponInsufficientUsage uint32 = 50004 // Coupon has insufficient remaining uses
|
||
CouponExpired uint32 = 50005 // Coupon is expired
|
||
)
|
||
|
||
// Subscribe
|
||
|
||
const (
|
||
SubscribeExpired uint32 = 60001
|
||
SubscribeNotAvailable uint32 = 60002
|
||
UserSubscribeExist uint32 = 60003
|
||
SubscribeIsUsedError uint32 = 60004
|
||
SingleSubscribeModeExceedsLimit uint32 = 60005
|
||
SubscribeQuotaLimit uint32 = 60006
|
||
SubscribeOutOfStock uint32 = 60007
|
||
SingleSubscribePlanMismatch uint32 = 60008
|
||
SubscribeNewUserOnly uint32 = 60009
|
||
)
|
||
|
||
// Auth error
|
||
|
||
const (
|
||
VerifyCodeError uint32 = 70001
|
||
)
|
||
|
||
// equipment error
|
||
|
||
const (
|
||
QueueEnqueueError uint32 = 80001
|
||
)
|
||
|
||
// System error
|
||
|
||
const (
|
||
DebugModeError uint32 = 90001
|
||
)
|
||
|
||
const (
|
||
SendSmsError uint32 = 90002
|
||
SmsNotEnabled uint32 = 90003
|
||
EmailNotEnabled uint32 = 90004
|
||
)
|
||
|
||
const (
|
||
GetAuthenticatorError uint32 = 90005
|
||
AuthenticatorNotSupportedError uint32 = 90006
|
||
TelephoneAreaCodeIsEmpty uint32 = 90007
|
||
TodaySendCountExceedsLimit uint32 = 90015
|
||
)
|
||
|
||
const (
|
||
PasswordIsEmpty uint32 = 90008
|
||
AreaCodeIsEmpty uint32 = 90009
|
||
PasswordOrVerificationCodeRequired uint32 = 90010
|
||
EmailExist uint32 = 90011
|
||
TelephoneExist uint32 = 90012
|
||
DeviceExist uint32 = 90013
|
||
TelephoneError uint32 = 90014
|
||
)
|
||
const (
|
||
DeviceNotExist uint32 = 90017
|
||
UseridNotMatch uint32 = 90018
|
||
DeviceBindLimitExceeded uint32 = 90019
|
||
)
|
||
|
||
// Permission error
|
||
const (
|
||
PermissionDenied uint32 = 40300
|
||
)
|
||
|
||
const (
|
||
OrderNotExist uint32 = 61001
|
||
PaymentMethodNotFound uint32 = 61002
|
||
OrderStatusError uint32 = 61003
|
||
InsufficientOfPeriod uint32 = 61004
|
||
ExistAvailableTraffic uint32 = 61005
|
||
OrderAlreadyRefunded uint32 = 61006
|
||
OrderRefundNoSubscription uint32 = 61007
|
||
OrderRefundCommissionMismatch uint32 = 61008
|
||
)
|
||
|
||
// Lottery error (100xxx range; 3-digit business = 100)
|
||
// codes align with HIF-3 spec (Stage 1 issue description) + HIF-4 (Stage 2):
|
||
//
|
||
// 4001 not_eligible / 4002 no_chances / 4003 activity_ended
|
||
// 4004 rate_limited / 4005 already_submitted / 4006 invalid_claim_data
|
||
// 4007 draw_not_found / 4008 not_your_draw / 4009 claim_expired
|
||
// 4010 not_claimable / 5001 internal_error
|
||
//
|
||
// wire-level ints stay unique across the whole codebase.
|
||
const (
|
||
LotteryNotEligible uint32 = 100001 // 用户未通过门槛
|
||
LotteryNoChances uint32 = 100002 // 用户已无剩余次数
|
||
LotteryActivityEnded uint32 = 100003 // 活动未开始 / 已结束 / 或 feature flag 关闭
|
||
LotteryRateLimited uint32 = 100004 // 触发每秒 1 次限流
|
||
LotteryAlreadySubmitted uint32 = 100005 // Stage 2: 该 draw 已经处于不可再提交的状态
|
||
LotteryInvalidClaimData uint32 = 100006 // Stage 2: 领奖表单校验失败
|
||
LotteryDrawNotFound uint32 = 100007 // Stage 2: draw_id 不存在
|
||
LotteryNotYourDraw uint32 = 100008 // Stage 2: draw 不属于当前登录用户
|
||
LotteryClaimExpired uint32 = 100009 // Stage 2: 领奖窗口已过期
|
||
LotteryNotClaimable uint32 = 100010 // Stage 2: 该 draw 不需要 / 不允许领奖(自动奖 / 未中奖)
|
||
LotteryInternalError uint32 = 100500 // 内部错误
|
||
LotteryRuleTooDeep uint32 = 100020 // rules JSON 深度超限
|
||
LotteryRuleTooMany uint32 = 100021 // rules JSON 节点数超限
|
||
LotteryRuleTooLarge uint32 = 100022 // rules JSON 体积超限
|
||
LotteryClaimStateInvalid uint32 = 100011 // Stage 2: 运营操作时状态机不允许(如非 reviewing 却 approve)
|
||
)
|