- 数据库与数据模型:新增 migration 000081,支持用户专属邀请码、被邀请人绑定与实名时间戳;新增邀请返利配置表与结算明细表 - 业务与结算逻辑:实现首月 60%、次月 30%、往后 15% 阶梯返利算法;买卖双向独立寻源并根据订单平台利润 50% 单边基准核算;与终态订单结算和钱包可用余额强幂等联动 - 分销站点支持:支持主站与加盟分站独立配置返利比例;跨站交易按照收号端与售卖端独立出资,资金互不侵蚀 - 前端交互与入口: - 新增专属短链注册落地页 /i/:code,自动带入并锁定邀请码,引导实名认证 - 个人中心与移动端新增邀请返利看板(专属码、推广链接、统计面板、好友记录与返利流水明细) - 管理后台新增邀请返利管理(比例配置、邀请关系与返利流水审计) - 验证方式: - 通过 repository_test.go 单元测试(阶梯区间、实名激活、跨站多方分流验证) - 通过 npm run format、npm run check 与 scripts/check.sh 全量门禁校验
96 lines
4.0 KiB
Go
96 lines
4.0 KiB
Go
package invitation
|
|
|
|
import "time"
|
|
|
|
// InviteCodeInfoDTO 用于邀请注册落地页公开展示邀请人信息
|
|
type InviteCodeInfoDTO struct {
|
|
Valid bool `json:"valid"`
|
|
InviteCode string `json:"invite_code"`
|
|
InviterNickname string `json:"inviter_nickname"`
|
|
InviterAvatar string `json:"inviter_avatar"`
|
|
}
|
|
|
|
// UserInvitationSummaryDTO 个人中心邀请返利概览
|
|
type UserInvitationSummaryDTO struct {
|
|
HasInviteCode bool `json:"has_invite_code"`
|
|
InviteCode string `json:"invite_code"`
|
|
InviteLink string `json:"invite_link"`
|
|
IsRealnameVerified bool `json:"is_realname_verified"`
|
|
TotalInvitedCount int64 `json:"total_invited_count"`
|
|
ActiveInvitedCount int64 `json:"active_invited_count"`
|
|
PendingInvitedCount int64 `json:"pending_invited_count"`
|
|
TotalRebateCent int64 `json:"total_rebate_cent"`
|
|
CurrentMonthEstCent int64 `json:"current_month_est_cent"`
|
|
FirstMonthRate float64 `json:"first_month_rate"`
|
|
SecondMonthRate float64 `json:"second_month_rate"`
|
|
SubsequentRate float64 `json:"subsequent_rate"`
|
|
}
|
|
|
|
// InvitedUserRecordDTO 邀请好友记录
|
|
type InvitedUserRecordDTO struct {
|
|
ID uint64 `json:"id"`
|
|
InviteeID uint64 `json:"invitee_id"`
|
|
MaskedPhone string `json:"masked_phone"`
|
|
Nickname string `json:"nickname"`
|
|
AvatarURL string `json:"avatar_url"`
|
|
Status string `json:"status"` // pending=待实名, active=已实名生效
|
|
CycleStage string `json:"cycle_stage"` // first_month, second_month, subsequent, unverified
|
|
DaysSinceVerified int `json:"days_since_verified"`
|
|
VerifiedAt *time.Time `json:"verified_at,omitempty"`
|
|
RegisteredAt time.Time `json:"registered_at"`
|
|
TotalEarnedFromCent int64 `json:"total_earned_from_cent"`
|
|
}
|
|
|
|
// RebateLedgerDTO 返利明细记录
|
|
type RebateLedgerDTO struct {
|
|
ID uint64 `json:"id"`
|
|
OrderID uint64 `json:"order_id"`
|
|
OrderNo string `json:"order_no"`
|
|
InviteeMaskedPhone string `json:"invitee_masked_phone"`
|
|
InviteeNickname string `json:"invitee_nickname"`
|
|
TradeRole string `json:"trade_role"` // buyer / seller
|
|
SingleSideBasisCent int64 `json:"single_side_basis_cent"`
|
|
RateApplied float64 `json:"rate_applied"`
|
|
CycleStage string `json:"cycle_stage"`
|
|
RebateAmountCent int64 `json:"rebate_amount_cent"`
|
|
SettledAt time.Time `json:"settled_at"`
|
|
}
|
|
|
|
// ConfigDTO 返利比例配置 DTO
|
|
type ConfigDTO struct {
|
|
DistributionSiteID uint64 `json:"distribution_site_id"`
|
|
FirstMonthRate float64 `json:"first_month_rate"`
|
|
SecondMonthRate float64 `json:"second_month_rate"`
|
|
SubsequentRate float64 `json:"subsequent_rate"`
|
|
Enabled bool `json:"enabled"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// UpdateConfigRequest 更新返利比例请求
|
|
type UpdateConfigRequest struct {
|
|
FirstMonthRate float64 `json:"first_month_rate" binding:"min=0,max=1"`
|
|
SecondMonthRate float64 `json:"second_month_rate" binding:"min=0,max=1"`
|
|
SubsequentRate float64 `json:"subsequent_rate" binding:"min=0,max=1"`
|
|
Enabled *bool `json:"enabled"`
|
|
}
|
|
|
|
// AdminInvitationQuery 后台查询邀请关系
|
|
type AdminInvitationQuery struct {
|
|
Page int `form:"page,default=1"`
|
|
PageSize int `form:"page_size,default=20"`
|
|
InviterPhone string `form:"inviter_phone"`
|
|
InviteePhone string `form:"invitee_phone"`
|
|
Status string `form:"status"`
|
|
DistributionSiteID *uint64 `form:"distribution_site_id"`
|
|
}
|
|
|
|
// AdminRebateLedgerQuery 后台查询返利明细
|
|
type AdminRebateLedgerQuery struct {
|
|
Page int `form:"page,default=1"`
|
|
PageSize int `form:"page_size,default=20"`
|
|
OrderNo string `form:"order_no"`
|
|
InviterPhone string `form:"inviter_phone"`
|
|
TradeRole string `form:"trade_role"`
|
|
DistributionSiteID *uint64 `form:"distribution_site_id"`
|
|
}
|