Files
zt-closet-backend/internal/service/constants.go
T
2026-09-15 23:04:13 +08:00

223 lines
7.4 KiB
Go
Raw 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 service
// 本文件集中定义各业务域的状态/类型枚举常量,消除魔法数字。
// 取值与 internal/mysqlmodel 各表字段注释保持一致。
// ===== 用户 User =====
const (
UserStatusNormal int8 = 1 // 正常
UserStatusTempBan int8 = 2 // 临时禁用
UserStatusPermBan int8 = 3 // 永久禁用
UserStatusDeactivated int8 = 4 // 已注销
SexMale int8 = 1 // 男
SexFemale int8 = 2 // 女
VIPTypeNone int8 = 1 // 非会员
VIPTypeMonthly int8 = 2 // 月度会员
VIPTypeYearly int8 = 3 // 年度会员
VIPTypeTrial int8 = 4 // 体验会员(新用户注册赠送,天数由 UserDefaultQuota.GiftVIPDay 配置)
)
// ===== 配额 Quota =====
const (
QuotaTypeCos int8 = 1 // COS 上传
QuotaTypeAI int8 = 2 // AI 推荐
QuotaTypeOutfitShare int8 = 3 // 社区分享
QuotaTypeClosetShare int8 = 4 // 衣柜分享
// 额度凭证来源(quota_grants.source)
QuotaGrantSourceMember int8 = 1 // 会员包(跟随 VIP 有效期)
QuotaGrantSourceAddon int8 = 2 // 加量包(独立有效期)
QuotaGrantSourceAdReward int8 = 3 // 广告激励(当天有效)
// ChangeTarget 调整额度类型
QuotaChangeTargetAdjust int8 = 1 // 配额调整
QuotaChangeTargetUse int8 = 2 // 使用
// ChangeType 变更类型
QuotaChangeTypePurchase int8 = 1 // 购买获赠
QuotaChangeTypeActivity int8 = 2 // 活动赠送
QuotaChangeTypeConsume int8 = 3 // 上传消耗
QuotaChangeTypeRefund int8 = 4 // 删除回退
QuotaChangeTypeManual int8 = 5 // 人工调整
QuotaChangeTypeRefundRevoke int8 = 6 // 退款回收
)
// 新用户默认免费额度(内置兜底值)。
// 优先使用 global.UserDefaultQuotaSetting 的配置值(配置为 0 时生效,表示不赠送该类免费额度);
// 仅在该项未配置(指针为 nil)或配置为负数时回落这些常量。
const (
DefaultQuotaCos int64 = 20 // 免费上传额度
DefaultQuotaAI int64 = 3 // 免费 AI 推荐额度
DefaultQuotaOutfitShare int64 = 10 // 免费社区分享额度
DefaultQuotaClosetShare int64 = 5 // 免费衣柜分享额度
)
// 新用户注册赠送体验会员的内置兜底天数。
// 优先使用 UserDefaultQuota.GiftVIPDay 的配置值(配置为 0 时生效,表示不赠送);
// 仅在该项未配置(指针为 nil)或配置为负数时回落此常量。
const DefaultVipDays int64 = 3
// ===== 衣物 Clothes 图片处理状态 =====
const (
ImageProcessMatting int8 = 1 // 抠图中
ImageProcessClassifying int8 = 2 // 分类中
ImageProcessQueuing int8 = 3 // 排队中
ImageProcessSuccess int8 = 4 // 成功
ImageProcessFailed int8 = 5 // 失败
)
// ===== 穿搭 Outfit =====
const (
OutfitSourceUser int8 = 1 // 用户创建
OutfitSourceAI int8 = 2 // AI 推荐
OutfitPrivate int8 = 1 // 不公开
OutfitPublic int8 = 2 // 公开
OutfitAuditPending int8 = 1 // 待审核
OutfitAuditPass int8 = 2 // 审核通过
OutfitAuditReject int8 = 3 // 审核不通过
OutfitStatusNormal int8 = 1 // 正常
OutfitStatusBanned int8 = 2 // 封禁
OutfitStatusUnsaved int8 = 3 // 待用户保存(AI 推荐生成后未保存)
)
// ===== 衣柜分享 ClosetShare =====
const (
ShareTypePartial int8 = 1 // 部分衣物分享
ShareTypeSnapshot int8 = 2 // 全量快照分享
ShareStatusNormal int8 = 1 // 正常
ShareStatusCancelled int8 = 2 // 用户取消
ShareStatusExpired int8 = 3 // 已过期
ShareStatusBanned int8 = 4 // 管理员封禁
)
// ===== 审核日志 AuditLog =====
const (
AuditResultPass int8 = 1 // 通过
AuditResultReject int8 = 2 // 驳回
)
// ===== 收藏 / 点赞 =====
const (
CollectTypeOutfit int8 = 1 // 社区穿搭
LikeTypeOutfit int8 = 1 // 社区穿搭
InteractStatusOn int8 = 1 // 已收藏 / 已点赞
InteractStatusOff int8 = 0 // 已取消
ActionDo int8 = 1 // 收藏 / 点赞
ActionCancel int8 = 2 // 取消
)
// ===== 通知 Notification =====
const (
NotificationTypeLike int8 = 1 // 点赞通知
NotificationTypeOrder int8 = 2 // 订单通知
NotificationTypeSystem int8 = 3 // 系统通知
NotificationUnread int8 = 1 // 未读
NotificationRead int8 = 2 // 已读
)
// ===== 商品 Goods =====
const (
GoodsTypeMember int8 = 1 // 会员包
GoodsTypeUpload int8 = 2 // 上传包
GoodsTypeAIRecommend int8 = 3 // AI 推荐包
GoodsTypeClosetShare int8 = 4 // 衣柜分享包
GoodsTypeOutfitShare int8 = 5 // 搭配分享包
GoodsStatusOnShelf int8 = 1 // 上架
GoodsStatusOffShelf int8 = 2 // 下架
// 虚拟支付道具发布状态
GoodsProductUnpublished int8 = 0 // 未发布
GoodsProductPublishing int8 = 1 // 发布中(上传/发布任务处理中)
GoodsProductPublished int8 = 2 // 已发布
GoodsProductPublishFail int8 = 3 // 发布失败
)
// ===== 订单 Order =====
const (
OrderStatusPending int8 = 1 // 待支付
OrderStatusPaid int8 = 2 // 已支付
OrderStatusCancelled int8 = 3 // 已取消
OrderStatusExpired int8 = 4 // 已过期
OrderStatusRefunded int8 = 5 // 已退款
PayChannelWechat int8 = 1 // 微信支付(普通 JSAPI)
PayChannelVirtual int8 = 2 // 微信虚拟支付(XPay)
// 虚拟支付平台(由前端按 systemInfo.platform 上报)
XPayPlatformAndroid = "android"
XPayPlatformIOS = "ios"
XPayPlatformHarmony = "harmony"
XPayPlatformWindows = "windows"
)
// ===== 退款 Refund =====
const (
RefundStatusPending int8 = 0 // 待处理
RefundStatusProcessing int8 = 1 // 退款中
RefundStatusSuccess int8 = 2 // 退款成功
RefundStatusFailed int8 = 3 // 退款失败
)
// ===== VIP 流水 =====
const (
VIPChangeTypeOpen int8 = 1 // 开通
VIPChangeTypeRenew int8 = 2 // 续费
VIPChangeTypeActivity int8 = 3 // 活动赠送
VIPChangeTypeExpire int8 = 4 // 到期失效
VIPChangeTypeManual int8 = 5 // 人工调整
VIPChangeTypeRefundRevoke int8 = 6 // 退款回收
VIPSourcePersonalPay int8 = 1 // 个人支付
VIPSourceActivity int8 = 2 // 活动赠送
VIPSourceSystem int8 = 3 // 系统
VIPSourceManual int8 = 4 // 人工调整
)
// ===== AI 流水状态 =====
const (
AIFlowStatusSuccess int8 = 1 // 成功
AIFlowStatusFailed int8 = 2 // 失败
)
// ===== AI 推荐异步任务状态(Redis 快照) =====
const (
AIRecommendTaskPending int8 = 1 // 生成中
AIRecommendTaskSuccess int8 = 2 // 生成成功
AIRecommendTaskFailed int8 = 3 // 生成失败
)
// 订单支付有效期(秒)。
const orderPayTTLSeconds int64 = 15 * 60
// ===== 权益发放补偿 BenefitGrantTask =====
const (
BenefitTypeVIP int8 = 1 // 会员
BenefitTypeCos int8 = 2 // 上传额度
BenefitTypeAI int8 = 3 // AI 推荐额度
BenefitTypeClosetShare int8 = 4 // 衣柜分享额度
BenefitTypeOutfitShare int8 = 5 // 搭配分享额度
BenefitTaskPending int8 = 0 // 待发放
BenefitTaskSuccess int8 = 1 // 已发放
BenefitTaskFailed int8 = 2 // 发放失败(重试超限)
BenefitTaskProcessing int8 = 3 // 发放中(认领后,防并发重复发放)
BenefitTaskCancelled int8 = 4 // 订单已退款,禁止继续发放
benefitMaxRetry int = 3 // 默认最大重试次数
// benefitRetryCooldownSeconds 失败任务被回调重新触发的冷却期(秒):
// 冷却期内不重置,防止微信回调重试风暴无限重置任务绕过重试上限。
benefitRetryCooldownSeconds int64 = 300
benefitRevokeMaxRetry = 10
)