ce3babcc33
Closes HIF-3 Stage 1 完整闭环 PR C:用户 API + 后台 CRUD + 抽奖事务服务 + 审计 + QA curl。合并后 Stage 1 可交测试。 架构师 review R1(rulecaps depth≤8/nodes≤64/bytes≤8KB)+ R2(InviteHook source_ref 加 order: 前缀)已全部落地。 - 迁移 02158_admin_action_log:后台写操作审计 - xerr 100xxx 段:抽奖错误码(NotEligible/NoChances/ActivityEnded/RateLimited/NotClaimable/InternalError/RuleTooDeep/RuleTooMany/RuleTooLarge) - feature flag config.Lottery.Enable 默认 false,合并后线上零副作用 - draw service:feature flag → rate limit → pre-tx reads → nonce dedupe → Consume → Pick → 乐观扣库存 → 双快照 → Dispatch → finalize - 用户 API 4 个:GET /config、POST /draw、GET /records、POST /claim(Stage 1 返回 100010) - 后台 CRUD:活动 / 奖品 / rules PUT(rulecaps gate)/ chances/grant - audit.WriteAdminAction:与调用方 tx 同生共死,SHA1 body 摘要 - QA 脚本:qa/lottery/stage1_curl.sh 全链路 curl 测试覆盖:model 76.5% / draw 69% / handler 68.3% / hook 91.9% / rulecaps 87.8% / audit 100% 100 并发抢库存 + 10000 次概率分布 e2e 推 QA 环境(sqlmock 无法忠实模拟 InnoDB 行锁) CI 全绿:构建/Vet/测试 + golangci-lint
170 lines
5.0 KiB
Go
170 lines
5.0 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):
|
|
// 4001 not_eligible / 4002 no_chances / 4003 activity_ended
|
|
// 4004 rate_limited / 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 次限流
|
|
LotteryNotClaimable uint32 = 100010 // Stage 2 领奖入口占位
|
|
LotteryInternalError uint32 = 100500 // 内部错误
|
|
LotteryRuleTooDeep uint32 = 100020 // rules JSON 深度超限
|
|
LotteryRuleTooMany uint32 = 100021 // rules JSON 节点数超限
|
|
LotteryRuleTooLarge uint32 = 100022 // rules JSON 体积超限
|
|
)
|