1、新增接口:历史汇总(按小时)、用户留存记录表(按天);

2、修改用户留存记录,增加最近2个月1号的留存数据;
3、订单表增加退订状态,3-1小时内退订;
This commit is contained in:
chenlin 2024-12-13 20:35:36 +08:00
parent 60f318961c
commit 16ad7a9b6c
7 changed files with 2137 additions and 51 deletions

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,7 @@ import (
const ( const (
QueryTimeFormat = "2006-01-02T15:04:05+08:00" QueryTimeFormat = "2006-01-02T15:04:05+08:00"
TimeFormat = "2006-01-02 15-04-05" TimeFormat = "2006-01-02 15-04-05"
MiGuTimeFormat = "2006-01-02 15:04:05"
ExportUrl = "https://admin.go2switch.cn/load/export/" ExportUrl = "https://admin.go2switch.cn/load/export/"
ExportExcelFlag = 1 ExportExcelFlag = 1
ExportPath = "/www/server/images/export/" ExportPath = "/www/server/images/export/"

View File

@ -98,9 +98,31 @@ type MgChannel struct {
Remarks string `json:"remarks"` // 备注 Remarks string `json:"remarks"` // 备注
} }
// MgHistoricalSummary 历史汇总查询表对应的结构体 // HourSummaryListResp 历史汇总(按小时)-出参
type MgHistoricalSummary struct { type HourSummaryListResp struct {
Date string `gorm:"type:date" json:"date"` // 日期 List []MgHourSummary `json:"list"` // 列表数据
Count int `json:"count"` // 数据总数
PageSize int `json:"page_size"` // 每页条数
PageNum int `json:"page_num"` // 当前页数
SummaryData *TotalHourSummary `json:"summary_data"` // 汇总数据,单条数据时返回
}
// TotalHourSummary 历史汇总查询表汇总数据对应的结构体(按小时)
type TotalHourSummary struct {
SubmissionCount int `json:"submission_count"` // 提交数
NewUserCount int `json:"new_user_count"` // 新用户数
SubmissionSuccessRate string `json:"submission_success_rate"` // 提交成功率
NewUserUnsubWithinHour int `json:"new_user_unsub_within_hour"` // 当日新用户退订数1小时以内
NewUserUnsubWithinHourRate string `json:"new_user_unsub_within_hour_rate"` // 当日新用户退订率1小时以内
NewUserUnsubOnDay int `json:"new_user_unsub_on_day"` // 当日新用户退订数
NewUserUnsubOnDayRate string `json:"new_user_unsub_on_day_rate"` // 当日新用户退订率
TotalNewUserUnsub int `json:"total_new_user_unsub"` // 累计新用户退订数
TotalNewUserUnsubRate string `json:"total_new_user_unsub_rate"` // 累计新用户退订率
}
// MgHourSummary 历史汇总查询表对应的结构体(按小时)
type MgHourSummary struct {
Hour string `json:"hour"` // 日期
ProductID int64 `json:"product_id"` // 产品ID ProductID int64 `json:"product_id"` // 产品ID
ChannelCode string `gorm:"size:255" json:"channel_code"` // 渠道编码 ChannelCode string `gorm:"size:255" json:"channel_code"` // 渠道编码
SubmissionCount int `json:"submission_count"` // 提交数 SubmissionCount int `json:"submission_count"` // 提交数
@ -110,6 +132,24 @@ type MgHistoricalSummary struct {
NewUserUnsubWithinHourRate string `json:"new_user_unsub_within_hour_rate"` // 当日新用户退订率1小时以内 NewUserUnsubWithinHourRate string `json:"new_user_unsub_within_hour_rate"` // 当日新用户退订率1小时以内
NewUserUnsubOnDay int `json:"new_user_unsub_on_day"` // 当日新用户退订数 NewUserUnsubOnDay int `json:"new_user_unsub_on_day"` // 当日新用户退订数
NewUserUnsubOnDayRate string `json:"new_user_unsub_on_day_rate"` // 当日新用户退订率 NewUserUnsubOnDayRate string `json:"new_user_unsub_on_day_rate"` // 当日新用户退订率
TotalNewUserUnsub int `json:"total_new_user_unsub"` // 累计新用户退订数
TotalNewUserUnsubRate string `json:"total_new_user_unsub_rate"` // 累计新用户退订率
}
// MgHistoricalSummary 历史汇总查询表对应的结构体
type MgHistoricalSummary struct {
Date string `json:"date"` // 日期
ProductID int64 `json:"product_id"` // 产品ID
ChannelCode string `gorm:"size:255" json:"channel_code"` // 渠道编码
SubmissionCount int `json:"submission_count"` // 提交数
NewUserCount int `json:"new_user_count"` // 新用户数
SubmissionSuccessRate string `json:"submission_success_rate"` // 提交成功率
NewUserUnsubWithinHour int `json:"new_user_unsub_within_hour"` // 当日新用户退订数1小时以内
NewUserUnsubWithinHourRate string `json:"new_user_unsub_within_hour_rate"` // 当日新用户退订率1小时以内
NewUserUnsubOnDay int `json:"new_user_unsub_on_day"` // 当日新用户退订数
NewUserUnsubOnDayRate string `json:"new_user_unsub_on_day_rate"` // 当日新用户退订率
TotalNewUserUnsub int `json:"total_new_user_unsub"` // 累计新用户退订数
TotalNewUserUnsubRate string `json:"total_new_user_unsub_rate"` // 累计新用户退订率
//Province string `gorm:"size:255" json:"province"` // 省份 //Province string `gorm:"size:255" json:"province"` // 省份
} }
@ -145,13 +185,26 @@ type MgTransactionLog struct {
// MgUserRetention 用户留存记录表对应的结构体 // MgUserRetention 用户留存记录表对应的结构体
type MgUserRetention struct { type MgUserRetention struct {
RetentionMonth string `gorm:"size:7" json:"retention_month"` // 留存月份格式YYYY-MM RetentionMonth string `gorm:"size:7" json:"retention_month"` // 留存月份格式YYYY-MM
NewUserCount int `json:"new_user_count"` // 新增用户数 ChannelCode string `gorm:"size:255" json:"channel_code"` // 渠道编码
RetainedUserCount int `json:"retained_user_count"` // 留存用户数 ProductID int64 `json:"product_id"` // 产品ID
ChannelCode string `gorm:"size:255" json:"channel_code"` // 渠道编码 NewUserCount int `json:"new_user_count"` // 新增用户数
ProductID int64 `json:"product_id"` // 产品ID RetainedUserCount int `json:"retained_user_count"` // 留存用户数(实时)
RetentionRate string `json:"retention_rate"` // 留存率(以百分比形式存储) RetentionRate string `json:"retention_rate"` // 留存率(实时,以百分比形式存储)
//Province string `gorm:"size:255" json:"province"` // 省份 LastTwoMonthDate string `json:"last_two_month_date"` // 最近2个月留存日期格式YYYY-MM-DD
LastTwoMonthRetentionCount int `json:"last_two_month_retention_count"` // 最近2个月留存用户数如12/1, 11/1
LastTwoMonthRetentionRate string `json:"last_two_month_retention_rate"` // 最近2个月留存率如12/1, 11/1
LastMonthDate string `json:"last_month_date"` // 最近1个月留存日期格式YYYY-MM-DD
LastMonthRetentionCount int `json:"last_month_retention_count"` // 最近1个月留存用户数如12/1
LastMonthRetentionRate string `json:"last_month_retention_rate"` // 最近1个月留存率如12/1
}
// MgUserDayRetention 用户留存记录表(按天)对应的结构体
type MgUserDayRetention struct {
Date string `json:"date"` // 留存日期格式YYYY-MM-DD
RetainedUserCount int `json:"retained_user_count"` // 留存用户数
RetentionRate string `json:"retention_rate"` // 留存率
UserUnsubOnDay int `json:"user_unsub_on_day"` // 当日退订数
} }
// 以下是接口出入参结构体 // 以下是接口出入参结构体
@ -343,7 +396,7 @@ type OrderListReq struct {
ChannelTradeNo string `json:"channelTradeNo"` // 渠道订单号 ChannelTradeNo string `json:"channelTradeNo"` // 渠道订单号
Phone string `json:"phone"` // 手机号码 Phone string `json:"phone"` // 手机号码
SM4PhoneNumber string `json:"sm4_phone_number"` // SM4加密手机号 SM4PhoneNumber string `json:"sm4_phone_number"` // SM4加密手机号
State int `json:"state"` // 退订状态 0-查所有 1-未退订 2-已退订 State int `json:"state"` // 退订状态 0-查所有 1-未退订 2-已退订 3-1小时内退订
PageNum int `json:"page_num"` // 页码 PageNum int `json:"page_num"` // 页码
PageSize int `json:"page_size"` // 每页条数 PageSize int `json:"page_size"` // 每页条数
IsExport uint32 `json:"is_export"` // 1-导出 IsExport uint32 `json:"is_export"` // 1-导出
@ -401,11 +454,12 @@ type RealtimeSummaryListResp struct {
type UserRetentionListReq struct { type UserRetentionListReq struct {
//Date string `json:"date"` // 月用户格式YYYY-MM //Date string `json:"date"` // 月用户格式YYYY-MM
RetentionMonth string `json:"retention_month"` // 留存月份格式YYYY-MM RetentionMonth string `json:"retention_month"` // 留存月份格式YYYY-MM
SkuCode string `json:"skuCode"` // 产品编号 SkuCode int `json:"skuCode"` // 产品编号
Channel string `json:"channel"` // 渠道号 Channel string `json:"channel"` // 渠道号
Province string `json:"province"` // 省份 Province string `json:"province"` // 省份
PageNum int `json:"page_num"` // 页码 PageNum int `json:"page_num"` // 页码
PageSize int `json:"page_size"` // 每页条数 PageSize int `json:"page_size"` // 每页条数
IsExport uint32 `json:"is_export"` // 1-导出
} }
// UserRetentionListResp 用户留存记录查询-出参 // UserRetentionListResp 用户留存记录查询-出参
@ -416,6 +470,25 @@ type UserRetentionListResp struct {
PageNum int `json:"page_num"` PageNum int `json:"page_num"`
} }
// UserDayRetentionListReq 用户留存记录(按天)查询-入参
type UserDayRetentionListReq struct {
RetentionMonth string `json:"retention_month" binding:"required"` // 留存月份格式YYYY-MM
SkuCode int `json:"skuCode" binding:"required"` // 产品编号
Channel string `json:"channel" binding:"required"` // 渠道号
PageNum int `json:"page_num"` // 页码
PageSize int `json:"page_size"` // 每页条数
OnlyFirstDay bool `json:"only_first_day"` // 是否只查询每个月1号的数据
IsExport uint32 `json:"is_export"` // 1-导出
}
// UserDayRetentionListResp 用户留存记录(按天)查询-出参
type UserDayRetentionListResp struct {
List []MgUserDayRetention `json:"list"`
Count int `json:"count"`
PageSize int `json:"page_size"`
PageNum int `json:"page_num"`
}
// SysChannelListReq 查询渠道列表入参 // SysChannelListReq 查询渠道列表入参
type SysChannelListReq struct { type SysChannelListReq struct {
PageNum int `json:"page_num"` // 页码 PageNum int `json:"page_num"` // 页码
@ -1315,7 +1388,8 @@ func ExportHistoricalSummaryToExcel(data []MgHistoricalSummary, db *gorm.DB) (st
sheet := "Sheet1" sheet := "Sheet1"
// 设置标题栏 // 设置标题栏
titles := []string{"日期", "产品ID", "渠道编码", "提交数", "新用户数", "提交成功率", "1小时内退订数", "1小时内退订率", "当日退订数", "当日退订率"} titles := []string{"日期", "产品ID", "渠道编码", "提交数", "新用户数", "提交成功率", "1小时退订数", "1小时退订率",
"当日退订数", "当日退订率", "累计退订数", "累计退订率"}
for i, title := range titles { for i, title := range titles {
cell, _ := excelize.CoordinatesToCellName(i+1, 1) cell, _ := excelize.CoordinatesToCellName(i+1, 1)
file.SetCellValue(sheet, cell, title) file.SetCellValue(sheet, cell, title)
@ -1340,6 +1414,8 @@ func ExportHistoricalSummaryToExcel(data []MgHistoricalSummary, db *gorm.DB) (st
file.SetColWidth(sheet, "H", "H", 15) file.SetColWidth(sheet, "H", "H", 15)
file.SetColWidth(sheet, "I", "I", 15) file.SetColWidth(sheet, "I", "I", 15)
file.SetColWidth(sheet, "J", "J", 15) file.SetColWidth(sheet, "J", "J", 15)
file.SetColWidth(sheet, "K", "K", 15)
file.SetColWidth(sheet, "L", "L", 15)
// 创建一个产品ID到名称的映射 // 创建一个产品ID到名称的映射
productMap := make(map[int64]string) productMap := make(map[int64]string)
@ -1369,9 +1445,11 @@ func ExportHistoricalSummaryToExcel(data []MgHistoricalSummary, db *gorm.DB) (st
file.SetCellValue(sheet, "H"+strconv.Itoa(row), record.NewUserUnsubWithinHourRate) file.SetCellValue(sheet, "H"+strconv.Itoa(row), record.NewUserUnsubWithinHourRate)
file.SetCellValue(sheet, "I"+strconv.Itoa(row), record.NewUserUnsubOnDay) file.SetCellValue(sheet, "I"+strconv.Itoa(row), record.NewUserUnsubOnDay)
file.SetCellValue(sheet, "J"+strconv.Itoa(row), record.NewUserUnsubOnDayRate) file.SetCellValue(sheet, "J"+strconv.Itoa(row), record.NewUserUnsubOnDayRate)
file.SetCellValue(sheet, "K"+strconv.Itoa(row), record.TotalNewUserUnsub)
file.SetCellValue(sheet, "L"+strconv.Itoa(row), record.TotalNewUserUnsubRate)
} }
endRow := fmt.Sprintf("J%d", len(data)+1) endRow := fmt.Sprintf("L%d", len(data)+1)
// 应用样式到整个表格 // 应用样式到整个表格
_ = file.SetCellStyle(sheet, "A1", endRow, style) _ = file.SetCellStyle(sheet, "A1", endRow, style)
@ -1449,7 +1527,7 @@ func ExportRealtimeSummaryToExcel(data []MgRealtimeSummary, db *gorm.DB) (string
file.SetCellValue(sheet, "I"+strconv.Itoa(row), record.NewUserUnsubOnDayRate) file.SetCellValue(sheet, "I"+strconv.Itoa(row), record.NewUserUnsubOnDayRate)
} }
endRow := fmt.Sprintf("J%d", len(data)+1) endRow := fmt.Sprintf("I%d", len(data)+1)
// 应用样式到整个表格 // 应用样式到整个表格
_ = file.SetCellStyle(sheet, "A1", endRow, style) _ = file.SetCellStyle(sheet, "A1", endRow, style)
@ -1594,3 +1672,111 @@ func ConvertStringToTime(dateStr string) (string, error) {
formattedTime := t.Format("2006-01-02 15:04:05") formattedTime := t.Format("2006-01-02 15:04:05")
return formattedTime, nil return formattedTime, nil
} }
// ExportHourSummaryToExcel 历史汇总查询(按小时导出excel
func ExportHourSummaryToExcel(data []MgHourSummary, sumData TotalHourSummary, db *gorm.DB) (string, error) {
// 创建一个新的Excel文件
file := excelize.NewFile()
sheet := "Sheet1"
nExcelStartRow := 0
// 设置标题栏
titles := []string{"小时", "产品", "渠道", "提交数", "新用户数", "提交成功率", "1小时退订数", "1小时退订率",
"当日退订数", "当日退订率", "累计退订数", "累计退订率"}
for i, title := range titles {
cell, _ := excelize.CoordinatesToCellName(i+1, 1)
file.SetCellValue(sheet, cell, title)
}
nExcelStartRow += 1
// 设置所有单元格的样式: 居中、加边框
style, _ := file.NewStyle(`{"alignment":{"horizontal":"center","vertical":"center"},
"border":[{"type":"left","color":"000000","style":1},
{"type":"top","color":"000000","style":1},
{"type":"right","color":"000000","style":1},
{"type":"bottom","color":"000000","style":1}]}`)
// 设置单元格高度
file.SetRowHeight(sheet, 1, 20)
// 设置列宽
file.SetColWidth(sheet, "A", "A", 15)
file.SetColWidth(sheet, "B", "B", 18)
file.SetColWidth(sheet, "C", "C", 18)
file.SetColWidth(sheet, "F", "F", 15)
file.SetColWidth(sheet, "G", "G", 15)
file.SetColWidth(sheet, "H", "H", 15)
file.SetColWidth(sheet, "I", "I", 15)
file.SetColWidth(sheet, "J", "J", 15)
file.SetColWidth(sheet, "K", "K", 15)
file.SetColWidth(sheet, "L", "L", 15)
// 创建一个产品ID到名称的映射
productMap := make(map[int64]string)
for _, order := range data {
if _, exists := productMap[order.ProductID]; !exists {
var product MgProduct
// 查询产品信息
if err := db.First(&product, order.ProductID).Error; err == nil {
productMap[order.ProductID] = product.Name
} else {
productMap[order.ProductID] = "未知产品"
}
}
}
// 填充数据
for i, record := range data {
nExcelStartRow += 1
row := i + 2
productName := productMap[record.ProductID] // 获取产品名称
file.SetCellValue(sheet, "A"+strconv.Itoa(row), record.Hour)
file.SetCellValue(sheet, "B"+strconv.Itoa(row), productName)
file.SetCellValue(sheet, "C"+strconv.Itoa(row), record.ChannelCode)
file.SetCellValue(sheet, "D"+strconv.Itoa(row), record.SubmissionCount)
file.SetCellValue(sheet, "E"+strconv.Itoa(row), record.NewUserCount)
file.SetCellValue(sheet, "F"+strconv.Itoa(row), record.SubmissionSuccessRate)
file.SetCellValue(sheet, "G"+strconv.Itoa(row), record.NewUserUnsubWithinHour)
file.SetCellValue(sheet, "H"+strconv.Itoa(row), record.NewUserUnsubWithinHourRate)
file.SetCellValue(sheet, "I"+strconv.Itoa(row), record.NewUserUnsubOnDay)
file.SetCellValue(sheet, "J"+strconv.Itoa(row), record.NewUserUnsubOnDayRate)
file.SetCellValue(sheet, "K"+strconv.Itoa(row), record.TotalNewUserUnsub)
file.SetCellValue(sheet, "L"+strconv.Itoa(row), record.TotalNewUserUnsubRate)
}
endRow := fmt.Sprintf("L%d", len(data)+1)
// 应用样式到整个表格
_ = file.SetCellStyle(sheet, "A1", endRow, style)
totalData := "订单数:" + strconv.FormatInt(int64(len(data)), 10)
end := []interface{}{totalData, "", "",
sumData.SubmissionCount,
sumData.NewUserCount,
sumData.SubmissionSuccessRate,
sumData.NewUserUnsubWithinHour,
sumData.NewUserUnsubWithinHourRate,
sumData.NewUserUnsubOnDay,
sumData.NewUserUnsubOnDayRate,
sumData.TotalNewUserUnsub,
sumData.TotalNewUserUnsubRate,
}
for i, _ := range end {
cell, _ := excelize.CoordinatesToCellName(1+i, nExcelStartRow+2)
err := file.SetCellValue(sheet, cell, end[i])
if err != nil {
logger.Errorf("file set value err:", err)
}
}
// 从配置文件读取保存路径和URL前缀
fileName := time.Now().Format("20060102150405") + "_历史汇总按小时.xlsx"
url := MiGuExportUrl + fileName
// 保存Excel文件
if err := file.SaveAs(ExportFile + fileName); err != nil {
logger.Errorf("Failed to save Excel file: %v", err)
return "", err
}
return url, nil
}

View File

@ -21,15 +21,18 @@ func registerMiGuControlManageRouter(v1 *gin.RouterGroup, authMiddleware *jwt.Gi
//api.POST("channel/update", apiMiGu.UpdateChannel) // 编辑渠道 //api.POST("channel/update", apiMiGu.UpdateChannel) // 编辑渠道
//api.POST("channel/delete", apiMiGu.DeleteChannel) // 删除渠道 //api.POST("channel/delete", apiMiGu.DeleteChannel) // 删除渠道
api.POST("transaction/list", apiMiGu.TransactionList) // 查询交易流水记录 api.POST("transaction/list", apiMiGu.TransactionList) // 查询交易流水记录
api.POST("order/list", apiMiGu.OrderList) // 查询订单列表 api.POST("order/list", apiMiGu.OrderList) // 查询订单列表
api.POST("historical_summary/list", apiMiGu.HistoricalSummaryList) // 历史汇总查询 api.POST("historical_summary/list", apiMiGu.HistoricalSummaryListNew) // 历史汇总查询
api.POST("realtime_summary/list", apiMiGu.RealtimeSummaryList) // 当日实时汇总 api.POST("hour_summary/list", apiMiGu.HourSummaryList) // 历史汇总查询(按小时)
api.POST("user_retention/list", apiMiGu.UserRetentionList) // 用户留存记录 api.POST("realtime_summary/list", apiMiGu.RealtimeSummaryList) // 当日实时汇总
api.POST("sys_channel/list", apiMiGu.SysChannelList) // 查询系统所有渠道编码 api.POST("user_retention/list", apiMiGu.UserRetentionList) // 用户留存记录
api.POST("home/data", apiMiGu.HomepageDataSummary) // 查询首页汇总数据 api.POST("user_day_retention/list", apiMiGu.UserDayRetentionList) // 用户留存记录(按天)
api.POST("home/revenue_analysis", apiMiGu.CalculateRevenueAnalysis) // 查询不同日期的留存月份 api.POST("sys_channel/list", apiMiGu.SysChannelList) // 查询系统所有渠道编码
api.POST("home/data", apiMiGu.HomepageDataSummary) // 查询首页汇总数据
api.POST("home/revenue_analysis", apiMiGu.CalculateRevenueAnalysis) // 查询不同日期的留存月份
//api.POST("historical_summary/list_old", apiMiGu.HistoricalSummaryListOld) // 历史汇总查询
//api.POST("order/import", apiMiGu.ImportExcelToMgOrderHandler) // 通过excel导入订单数据 //api.POST("order/import", apiMiGu.ImportExcelToMgOrderHandler) // 通过excel导入订单数据
//api.POST("order/import_update", apiMiGu.ImportExcelToMgOrderHandlerUpdate) // 通过excel导入订单退订数据 //api.POST("order/import_update", apiMiGu.ImportExcelToMgOrderHandlerUpdate) // 通过excel导入订单退订数据
} }

View File

@ -184,6 +184,39 @@ const docTemplateadmin = `{
} }
} }
}, },
"/api/v1/admin/hour_summary/list": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"2024-咪咕-管理后台"
],
"summary": "历史汇总(按小时)",
"parameters": [
{
"description": "历史汇总(按小时)",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.HistoricalSummaryListReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.HourSummaryListResp"
}
}
}
}
},
"/api/v1/admin/order/list": { "/api/v1/admin/order/list": {
"post": { "post": {
"consumes": [ "consumes": [
@ -382,6 +415,39 @@ const docTemplateadmin = `{
} }
} }
}, },
"/api/v1/admin/user_day_retention/list": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"2024-咪咕-管理后台"
],
"summary": "用户留存记录(按天)",
"parameters": [
{
"description": "用户留存记录(按天)",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.UserDayRetentionListReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.UserDayRetentionListResp"
}
}
}
}
},
"/api/v1/admin/user_retention/list": { "/api/v1/admin/user_retention/list": {
"post": { "post": {
"consumes": [ "consumes": [
@ -4886,6 +4952,38 @@ const docTemplateadmin = `{
} }
} }
}, },
"models.HourSummaryListResp": {
"type": "object",
"properties": {
"count": {
"description": "数据总数",
"type": "integer"
},
"list": {
"description": "列表数据",
"type": "array",
"items": {
"$ref": "#/definitions/models.MgHourSummary"
}
},
"page_num": {
"description": "当前页数",
"type": "integer"
},
"page_size": {
"description": "每页条数",
"type": "integer"
},
"summary_data": {
"description": "汇总数据,单条数据时返回",
"allOf": [
{
"$ref": "#/definitions/models.TotalHourSummary"
}
]
}
}
},
"models.MgChannel": { "models.MgChannel": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -4967,6 +5065,67 @@ const docTemplateadmin = `{
"submission_success_rate": { "submission_success_rate": {
"description": "提交成功率", "description": "提交成功率",
"type": "string" "type": "string"
},
"total_new_user_unsub": {
"description": "累计新用户退订数",
"type": "integer"
},
"total_new_user_unsub_rate": {
"description": "累计新用户退订率",
"type": "string"
}
}
},
"models.MgHourSummary": {
"type": "object",
"properties": {
"channel_code": {
"description": "渠道编码",
"type": "string"
},
"hour": {
"description": "日期",
"type": "string"
},
"new_user_count": {
"description": "新用户数",
"type": "integer"
},
"new_user_unsub_on_day": {
"description": "当日新用户退订数",
"type": "integer"
},
"new_user_unsub_on_day_rate": {
"description": "当日新用户退订率",
"type": "string"
},
"new_user_unsub_within_hour": {
"description": "当日新用户退订数1小时以内",
"type": "integer"
},
"new_user_unsub_within_hour_rate": {
"description": "当日新用户退订率1小时以内",
"type": "string"
},
"product_id": {
"description": "产品ID",
"type": "integer"
},
"submission_count": {
"description": "提交数",
"type": "integer"
},
"submission_success_rate": {
"description": "提交成功率",
"type": "string"
},
"total_new_user_unsub": {
"description": "累计新用户退订数",
"type": "integer"
},
"total_new_user_unsub_rate": {
"description": "累计新用户退订率",
"type": "string"
} }
} }
}, },
@ -5164,6 +5323,27 @@ const docTemplateadmin = `{
} }
} }
}, },
"models.MgUserDayRetention": {
"type": "object",
"properties": {
"date": {
"description": "留存日期格式YYYY-MM-DD",
"type": "string"
},
"retained_user_count": {
"description": "留存用户数",
"type": "integer"
},
"retention_rate": {
"description": "留存率",
"type": "string"
},
"user_unsub_on_day": {
"description": "当日退订数",
"type": "integer"
}
}
},
"models.MgUserRetention": { "models.MgUserRetention": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -5171,6 +5351,30 @@ const docTemplateadmin = `{
"description": "渠道编码", "description": "渠道编码",
"type": "string" "type": "string"
}, },
"last_month_date": {
"description": "最近1个月留存日期格式YYYY-MM-DD",
"type": "string"
},
"last_month_retention_count": {
"description": "最近1个月留存用户数如12/1",
"type": "integer"
},
"last_month_retention_rate": {
"description": "最近1个月留存率如12/1",
"type": "string"
},
"last_two_month_date": {
"description": "最近2个月留存日期格式YYYY-MM-DD",
"type": "string"
},
"last_two_month_retention_count": {
"description": "最近2个月留存用户数如12/1, 11/1",
"type": "integer"
},
"last_two_month_retention_rate": {
"description": "最近2个月留存率如12/1, 11/1",
"type": "string"
},
"new_user_count": { "new_user_count": {
"description": "新增用户数", "description": "新增用户数",
"type": "integer" "type": "integer"
@ -5180,7 +5384,7 @@ const docTemplateadmin = `{
"type": "integer" "type": "integer"
}, },
"retained_user_count": { "retained_user_count": {
"description": "留存用户数", "description": "留存用户数(实时)",
"type": "integer" "type": "integer"
}, },
"retention_month": { "retention_month": {
@ -5188,7 +5392,7 @@ const docTemplateadmin = `{
"type": "string" "type": "string"
}, },
"retention_rate": { "retention_rate": {
"description": "留存率(以百分比形式存储)", "description": "留存率(实时,以百分比形式存储)",
"type": "string" "type": "string"
} }
} }
@ -5270,7 +5474,7 @@ const docTemplateadmin = `{
"type": "string" "type": "string"
}, },
"state": { "state": {
"description": "退订状态 0-查所有 1-未退订 2-已退订", "description": "退订状态 0-查所有 1-未退订 2-已退订 3-1小时内退订",
"type": "integer" "type": "integer"
} }
} }
@ -5655,6 +5859,47 @@ const docTemplateadmin = `{
} }
} }
}, },
"models.TotalHourSummary": {
"type": "object",
"properties": {
"new_user_count": {
"description": "新用户数",
"type": "integer"
},
"new_user_unsub_on_day": {
"description": "当日新用户退订数",
"type": "integer"
},
"new_user_unsub_on_day_rate": {
"description": "当日新用户退订率",
"type": "string"
},
"new_user_unsub_within_hour": {
"description": "当日新用户退订数1小时以内",
"type": "integer"
},
"new_user_unsub_within_hour_rate": {
"description": "当日新用户退订率1小时以内",
"type": "string"
},
"submission_count": {
"description": "提交数",
"type": "integer"
},
"submission_success_rate": {
"description": "提交成功率",
"type": "string"
},
"total_new_user_unsub": {
"description": "累计新用户退订数",
"type": "integer"
},
"total_new_user_unsub_rate": {
"description": "累计新用户退订率",
"type": "string"
}
}
},
"models.TransactionListReq": { "models.TransactionListReq": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -5712,6 +5957,60 @@ const docTemplateadmin = `{
} }
} }
}, },
"models.UserDayRetentionListReq": {
"type": "object",
"required": [
"channel",
"retention_month",
"skuCode"
],
"properties": {
"channel": {
"description": "渠道号",
"type": "string"
},
"only_first_day": {
"description": "是否只查询每个月1号的数据",
"type": "boolean"
},
"page_num": {
"description": "页码",
"type": "integer"
},
"page_size": {
"description": "每页条数",
"type": "integer"
},
"retention_month": {
"description": "留存月份格式YYYY-MM",
"type": "string"
},
"skuCode": {
"description": "产品编号",
"type": "integer"
}
}
},
"models.UserDayRetentionListResp": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/models.MgUserDayRetention"
}
},
"page_num": {
"type": "integer"
},
"page_size": {
"type": "integer"
}
}
},
"models.UserRetentionListReq": { "models.UserRetentionListReq": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -5737,7 +6036,7 @@ const docTemplateadmin = `{
}, },
"skuCode": { "skuCode": {
"description": "产品编号", "description": "产品编号",
"type": "string" "type": "integer"
} }
} }
}, },

View File

@ -176,6 +176,39 @@
} }
} }
}, },
"/api/v1/admin/hour_summary/list": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"2024-咪咕-管理后台"
],
"summary": "历史汇总(按小时)",
"parameters": [
{
"description": "历史汇总(按小时)",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.HistoricalSummaryListReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.HourSummaryListResp"
}
}
}
}
},
"/api/v1/admin/order/list": { "/api/v1/admin/order/list": {
"post": { "post": {
"consumes": [ "consumes": [
@ -374,6 +407,39 @@
} }
} }
}, },
"/api/v1/admin/user_day_retention/list": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"2024-咪咕-管理后台"
],
"summary": "用户留存记录(按天)",
"parameters": [
{
"description": "用户留存记录(按天)",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.UserDayRetentionListReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.UserDayRetentionListResp"
}
}
}
}
},
"/api/v1/admin/user_retention/list": { "/api/v1/admin/user_retention/list": {
"post": { "post": {
"consumes": [ "consumes": [
@ -4878,6 +4944,38 @@
} }
} }
}, },
"models.HourSummaryListResp": {
"type": "object",
"properties": {
"count": {
"description": "数据总数",
"type": "integer"
},
"list": {
"description": "列表数据",
"type": "array",
"items": {
"$ref": "#/definitions/models.MgHourSummary"
}
},
"page_num": {
"description": "当前页数",
"type": "integer"
},
"page_size": {
"description": "每页条数",
"type": "integer"
},
"summary_data": {
"description": "汇总数据,单条数据时返回",
"allOf": [
{
"$ref": "#/definitions/models.TotalHourSummary"
}
]
}
}
},
"models.MgChannel": { "models.MgChannel": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -4959,6 +5057,67 @@
"submission_success_rate": { "submission_success_rate": {
"description": "提交成功率", "description": "提交成功率",
"type": "string" "type": "string"
},
"total_new_user_unsub": {
"description": "累计新用户退订数",
"type": "integer"
},
"total_new_user_unsub_rate": {
"description": "累计新用户退订率",
"type": "string"
}
}
},
"models.MgHourSummary": {
"type": "object",
"properties": {
"channel_code": {
"description": "渠道编码",
"type": "string"
},
"hour": {
"description": "日期",
"type": "string"
},
"new_user_count": {
"description": "新用户数",
"type": "integer"
},
"new_user_unsub_on_day": {
"description": "当日新用户退订数",
"type": "integer"
},
"new_user_unsub_on_day_rate": {
"description": "当日新用户退订率",
"type": "string"
},
"new_user_unsub_within_hour": {
"description": "当日新用户退订数1小时以内",
"type": "integer"
},
"new_user_unsub_within_hour_rate": {
"description": "当日新用户退订率1小时以内",
"type": "string"
},
"product_id": {
"description": "产品ID",
"type": "integer"
},
"submission_count": {
"description": "提交数",
"type": "integer"
},
"submission_success_rate": {
"description": "提交成功率",
"type": "string"
},
"total_new_user_unsub": {
"description": "累计新用户退订数",
"type": "integer"
},
"total_new_user_unsub_rate": {
"description": "累计新用户退订率",
"type": "string"
} }
} }
}, },
@ -5156,6 +5315,27 @@
} }
} }
}, },
"models.MgUserDayRetention": {
"type": "object",
"properties": {
"date": {
"description": "留存日期格式YYYY-MM-DD",
"type": "string"
},
"retained_user_count": {
"description": "留存用户数",
"type": "integer"
},
"retention_rate": {
"description": "留存率",
"type": "string"
},
"user_unsub_on_day": {
"description": "当日退订数",
"type": "integer"
}
}
},
"models.MgUserRetention": { "models.MgUserRetention": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -5163,6 +5343,30 @@
"description": "渠道编码", "description": "渠道编码",
"type": "string" "type": "string"
}, },
"last_month_date": {
"description": "最近1个月留存日期格式YYYY-MM-DD",
"type": "string"
},
"last_month_retention_count": {
"description": "最近1个月留存用户数如12/1",
"type": "integer"
},
"last_month_retention_rate": {
"description": "最近1个月留存率如12/1",
"type": "string"
},
"last_two_month_date": {
"description": "最近2个月留存日期格式YYYY-MM-DD",
"type": "string"
},
"last_two_month_retention_count": {
"description": "最近2个月留存用户数如12/1, 11/1",
"type": "integer"
},
"last_two_month_retention_rate": {
"description": "最近2个月留存率如12/1, 11/1",
"type": "string"
},
"new_user_count": { "new_user_count": {
"description": "新增用户数", "description": "新增用户数",
"type": "integer" "type": "integer"
@ -5172,7 +5376,7 @@
"type": "integer" "type": "integer"
}, },
"retained_user_count": { "retained_user_count": {
"description": "留存用户数", "description": "留存用户数(实时)",
"type": "integer" "type": "integer"
}, },
"retention_month": { "retention_month": {
@ -5180,7 +5384,7 @@
"type": "string" "type": "string"
}, },
"retention_rate": { "retention_rate": {
"description": "留存率(以百分比形式存储)", "description": "留存率(实时,以百分比形式存储)",
"type": "string" "type": "string"
} }
} }
@ -5262,7 +5466,7 @@
"type": "string" "type": "string"
}, },
"state": { "state": {
"description": "退订状态 0-查所有 1-未退订 2-已退订", "description": "退订状态 0-查所有 1-未退订 2-已退订 3-1小时内退订",
"type": "integer" "type": "integer"
} }
} }
@ -5647,6 +5851,47 @@
} }
} }
}, },
"models.TotalHourSummary": {
"type": "object",
"properties": {
"new_user_count": {
"description": "新用户数",
"type": "integer"
},
"new_user_unsub_on_day": {
"description": "当日新用户退订数",
"type": "integer"
},
"new_user_unsub_on_day_rate": {
"description": "当日新用户退订率",
"type": "string"
},
"new_user_unsub_within_hour": {
"description": "当日新用户退订数1小时以内",
"type": "integer"
},
"new_user_unsub_within_hour_rate": {
"description": "当日新用户退订率1小时以内",
"type": "string"
},
"submission_count": {
"description": "提交数",
"type": "integer"
},
"submission_success_rate": {
"description": "提交成功率",
"type": "string"
},
"total_new_user_unsub": {
"description": "累计新用户退订数",
"type": "integer"
},
"total_new_user_unsub_rate": {
"description": "累计新用户退订率",
"type": "string"
}
}
},
"models.TransactionListReq": { "models.TransactionListReq": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -5704,6 +5949,60 @@
} }
} }
}, },
"models.UserDayRetentionListReq": {
"type": "object",
"required": [
"channel",
"retention_month",
"skuCode"
],
"properties": {
"channel": {
"description": "渠道号",
"type": "string"
},
"only_first_day": {
"description": "是否只查询每个月1号的数据",
"type": "boolean"
},
"page_num": {
"description": "页码",
"type": "integer"
},
"page_size": {
"description": "每页条数",
"type": "integer"
},
"retention_month": {
"description": "留存月份格式YYYY-MM",
"type": "string"
},
"skuCode": {
"description": "产品编号",
"type": "integer"
}
}
},
"models.UserDayRetentionListResp": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/models.MgUserDayRetention"
}
},
"page_num": {
"type": "integer"
},
"page_size": {
"type": "integer"
}
}
},
"models.UserRetentionListReq": { "models.UserRetentionListReq": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -5729,7 +6028,7 @@
}, },
"skuCode": { "skuCode": {
"description": "产品编号", "description": "产品编号",
"type": "string" "type": "integer"
} }
} }
}, },

View File

@ -1072,6 +1072,27 @@ definitions:
- $ref: '#/definitions/models.SummaryData' - $ref: '#/definitions/models.SummaryData'
description: 汇总数据 description: 汇总数据
type: object type: object
models.HourSummaryListResp:
properties:
count:
description: 数据总数
type: integer
list:
description: 列表数据
items:
$ref: '#/definitions/models.MgHourSummary'
type: array
page_num:
description: 当前页数
type: integer
page_size:
description: 每页条数
type: integer
summary_data:
allOf:
- $ref: '#/definitions/models.TotalHourSummary'
description: 汇总数据,单条数据时返回
type: object
models.MgChannel: models.MgChannel:
properties: properties:
createdAt: createdAt:
@ -1132,6 +1153,51 @@ definitions:
submission_success_rate: submission_success_rate:
description: 提交成功率 description: 提交成功率
type: string type: string
total_new_user_unsub:
description: 累计新用户退订数
type: integer
total_new_user_unsub_rate:
description: 累计新用户退订率
type: string
type: object
models.MgHourSummary:
properties:
channel_code:
description: 渠道编码
type: string
hour:
description: 日期
type: string
new_user_count:
description: 新用户数
type: integer
new_user_unsub_on_day:
description: 当日新用户退订数
type: integer
new_user_unsub_on_day_rate:
description: 当日新用户退订率
type: string
new_user_unsub_within_hour:
description: 当日新用户退订数1小时以内
type: integer
new_user_unsub_within_hour_rate:
description: 当日新用户退订率1小时以内
type: string
product_id:
description: 产品ID
type: integer
submission_count:
description: 提交数
type: integer
submission_success_rate:
description: 提交成功率
type: string
total_new_user_unsub:
description: 累计新用户退订数
type: integer
total_new_user_unsub_rate:
description: 累计新用户退订率
type: string
type: object type: object
models.MgOrder: models.MgOrder:
properties: properties:
@ -1274,11 +1340,44 @@ definitions:
description: 验证码 description: 验证码
type: string type: string
type: object type: object
models.MgUserDayRetention:
properties:
date:
description: 留存日期格式YYYY-MM-DD
type: string
retained_user_count:
description: 留存用户数
type: integer
retention_rate:
description: 留存率
type: string
user_unsub_on_day:
description: 当日退订数
type: integer
type: object
models.MgUserRetention: models.MgUserRetention:
properties: properties:
channel_code: channel_code:
description: 渠道编码 description: 渠道编码
type: string type: string
last_month_date:
description: 最近1个月留存日期格式YYYY-MM-DD
type: string
last_month_retention_count:
description: 最近1个月留存用户数如12/1
type: integer
last_month_retention_rate:
description: 最近1个月留存率如12/1
type: string
last_two_month_date:
description: 最近2个月留存日期格式YYYY-MM-DD
type: string
last_two_month_retention_count:
description: 最近2个月留存用户数如12/1, 11/1
type: integer
last_two_month_retention_rate:
description: 最近2个月留存率如12/1, 11/1
type: string
new_user_count: new_user_count:
description: 新增用户数 description: 新增用户数
type: integer type: integer
@ -1286,13 +1385,13 @@ definitions:
description: 产品ID description: 产品ID
type: integer type: integer
retained_user_count: retained_user_count:
description: 留存用户数 description: 留存用户数(实时)
type: integer type: integer
retention_month: retention_month:
description: 留存月份格式YYYY-MM description: 留存月份格式YYYY-MM
type: string type: string
retention_rate: retention_rate:
description: 留存率(以百分比形式存储) description: 留存率(实时,以百分比形式存储)
type: string type: string
type: object type: object
models.MonthlyRetention: models.MonthlyRetention:
@ -1352,7 +1451,7 @@ definitions:
description: 开始时间 description: 开始时间
type: string type: string
state: state:
description: 退订状态 0-查所有 1-未退订 2-已退订 description: 退订状态 0-查所有 1-未退订 2-已退订 3-1小时内退订
type: integer type: integer
type: object type: object
models.OrderListResp: models.OrderListResp:
@ -1615,6 +1714,36 @@ definitions:
page_size: page_size:
type: integer type: integer
type: object type: object
models.TotalHourSummary:
properties:
new_user_count:
description: 新用户数
type: integer
new_user_unsub_on_day:
description: 当日新用户退订数
type: integer
new_user_unsub_on_day_rate:
description: 当日新用户退订率
type: string
new_user_unsub_within_hour:
description: 当日新用户退订数1小时以内
type: integer
new_user_unsub_within_hour_rate:
description: 当日新用户退订率1小时以内
type: string
submission_count:
description: 提交数
type: integer
submission_success_rate:
description: 提交成功率
type: string
total_new_user_unsub:
description: 累计新用户退订数
type: integer
total_new_user_unsub_rate:
description: 累计新用户退订率
type: string
type: object
models.TransactionListReq: models.TransactionListReq:
properties: properties:
channel: channel:
@ -1655,6 +1784,44 @@ definitions:
page_size: page_size:
type: integer type: integer
type: object type: object
models.UserDayRetentionListReq:
properties:
channel:
description: 渠道号
type: string
only_first_day:
description: 是否只查询每个月1号的数据
type: boolean
page_num:
description: 页码
type: integer
page_size:
description: 每页条数
type: integer
retention_month:
description: 留存月份格式YYYY-MM
type: string
skuCode:
description: 产品编号
type: integer
required:
- channel
- retention_month
- skuCode
type: object
models.UserDayRetentionListResp:
properties:
count:
type: integer
list:
items:
$ref: '#/definitions/models.MgUserDayRetention'
type: array
page_num:
type: integer
page_size:
type: integer
type: object
models.UserRetentionListReq: models.UserRetentionListReq:
properties: properties:
channel: channel:
@ -1674,7 +1841,7 @@ definitions:
type: string type: string
skuCode: skuCode:
description: 产品编号 description: 产品编号
type: string type: integer
type: object type: object
models.UserRetentionListResp: models.UserRetentionListResp:
properties: properties:
@ -2004,6 +2171,27 @@ paths:
summary: 营收分析 summary: 营收分析
tags: tags:
- 2024-咪咕-管理后台 - 2024-咪咕-管理后台
/api/v1/admin/hour_summary/list:
post:
consumes:
- application/json
parameters:
- description: 历史汇总(按小时)
in: body
name: request
required: true
schema:
$ref: '#/definitions/models.HistoricalSummaryListReq'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.HourSummaryListResp'
summary: 历史汇总(按小时)
tags:
- 2024-咪咕-管理后台
/api/v1/admin/order/list: /api/v1/admin/order/list:
post: post:
consumes: consumes:
@ -2130,6 +2318,27 @@ paths:
summary: 查询交易流水记录 summary: 查询交易流水记录
tags: tags:
- 2024-咪咕-管理后台 - 2024-咪咕-管理后台
/api/v1/admin/user_day_retention/list:
post:
consumes:
- application/json
parameters:
- description: 用户留存记录(按天)
in: body
name: request
required: true
schema:
$ref: '#/definitions/models.UserDayRetentionListReq'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.UserDayRetentionListResp'
summary: 用户留存记录(按天)
tags:
- 2024-咪咕-管理后台
/api/v1/admin/user_retention/list: /api/v1/admin/user_retention/list:
post: post:
consumes: consumes: