feat(adtracking): 新增推广链接追踪与数据大盘,支持自定义短码、注册与下单归因及二维码物料生成
1. 数据库新增 000064_ad_tracking.sql 迁移,创建 ad_tracking_links 和 ad_tracking_clicks 表,并在 users、rental_orders 增加归因字段 2. 后端新增 adtracking 模块,挂载 GET /r/:code 302 智能重定向、点击流水异步记录、转化率/GMV聚合统计及管理接口 3. 用户认证 (auth) 与订单创建 (order) 链路贯通,实现注册用户与订单成交推广短码全链路归因 4. 前端管理后台左侧新增【推广追踪】目录,支持大盘指标总览、推广链接 CRUD、状态启停、一键复制短链及二维码下载 (PNG)
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package adtracking
|
||||
|
||||
import "time"
|
||||
|
||||
type TrackingLinkItem struct {
|
||||
ID uint64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
ChannelType string `json:"channel_type"`
|
||||
TargetURL string `json:"target_url"`
|
||||
ShortURL string `json:"short_url"`
|
||||
Status string `json:"status"`
|
||||
CostCent int64 `json:"cost_cent"`
|
||||
Notes string `json:"notes"`
|
||||
CreatedBy uint64 `json:"created_by"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
// 统计指标
|
||||
ClickPV int64 `json:"click_pv"`
|
||||
ClickUV int64 `json:"click_uv"`
|
||||
ClickIP int64 `json:"click_ip"`
|
||||
RegisterCount int64 `json:"register_count"`
|
||||
OrderCount int64 `json:"order_count"`
|
||||
PaidOrderCount int64 `json:"paid_order_count"`
|
||||
PaidGMVCent int64 `json:"paid_gmv_cent"`
|
||||
ConversionRate float64 `json:"conversion_rate"` // 下单转化率 (OrderCount / max(ClickUV, 1))
|
||||
}
|
||||
|
||||
type CreateTrackingLinkRequest struct {
|
||||
Name string `json:"name" binding:"required,min=1,max=128"`
|
||||
Code string `json:"code" binding:"required,min=2,max=64"`
|
||||
ChannelType string `json:"channel_type"`
|
||||
TargetURL string `json:"target_url"`
|
||||
CostCent int64 `json:"cost_cent"`
|
||||
Notes string `json:"notes" binding:"max=500"`
|
||||
}
|
||||
|
||||
type UpdateTrackingLinkRequest struct {
|
||||
Name string `json:"name" binding:"required,min=1,max=128"`
|
||||
ChannelType string `json:"channel_type"`
|
||||
TargetURL string `json:"target_url"`
|
||||
CostCent int64 `json:"cost_cent"`
|
||||
Notes string `json:"notes" binding:"max=500"`
|
||||
}
|
||||
|
||||
type UpdateLinkStatusRequest struct {
|
||||
Status string `json:"status" binding:"required,oneof=active disabled"`
|
||||
}
|
||||
|
||||
type ListTrackingLinksQuery struct {
|
||||
Keyword string `form:"keyword"`
|
||||
ChannelType string `form:"channel_type"`
|
||||
Status string `form:"status"`
|
||||
Page int `form:"page,default=1"`
|
||||
PageSize int `form:"page_size,default=20"`
|
||||
}
|
||||
|
||||
type TrackingOverviewStats struct {
|
||||
TotalLinks int64 `json:"total_links"`
|
||||
ActiveLinks int64 `json:"active_links"`
|
||||
TotalPV int64 `json:"total_pv"`
|
||||
TotalUV int64 `json:"total_uv"`
|
||||
TotalIP int64 `json:"total_ip"`
|
||||
TotalRegisters int64 `json:"total_registers"`
|
||||
TotalOrders int64 `json:"total_orders"`
|
||||
TotalPaidOrders int64 `json:"total_paid_orders"`
|
||||
TotalPaidGMVCent int64 `json:"total_paid_gmv_cent"`
|
||||
|
||||
TodayPV int64 `json:"today_pv"`
|
||||
TodayUV int64 `json:"today_uv"`
|
||||
TodayRegisters int64 `json:"today_registers"`
|
||||
TodayOrders int64 `json:"today_orders"`
|
||||
TodayPaidGMVCent int64 `json:"today_paid_gmv_cent"`
|
||||
}
|
||||
Reference in New Issue
Block a user