gomod引用
This commit is contained in:
@@ -98,7 +98,7 @@ type OrderDetail struct {
|
||||
ID string `json:"id"` // 订单ID
|
||||
TenantID string `json:"tenant_id"` // 租户ID
|
||||
OrderNo string `json:"order_no"` // 订单号
|
||||
UserID string `json:"user_id"` // 用户ID
|
||||
UserID int64 `json:"user_id"` // 用户ID
|
||||
TotalAmount int64 `json:"total_amount"` // 订单总金额
|
||||
PayAmount int64 `json:"pay_amount"` // 实付金额
|
||||
Status string `json:"status"` // 订单状态
|
||||
|
||||
141
model/dto/order_statistics.go
Normal file
141
model/dto/order_statistics.go
Normal file
@@ -0,0 +1,141 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// GetOrderStatisticsReq 获取订单统计数据请求
|
||||
type GetOrderStatisticsReq struct {
|
||||
g.Meta `path:"/statistics" method:"get" tags:"订单统计" summary:"获取订单统计数据" dc:"根据报表类型和日期获取订单统计数据"`
|
||||
TenantID int64 `v:"required" json:"tenant_id" dc:"租户ID"`
|
||||
ReportType string `v:"required|in:daily,monthly,quarterly,yearly" json:"report_type" dc:"报表类型"`
|
||||
StartDate string `json:"start_date,omitempty" dc:"开始日期"`
|
||||
EndDate string `json:"end_date,omitempty" dc:"结束日期"`
|
||||
}
|
||||
|
||||
// GetOrderStatisticsRes 获取订单统计数据响应
|
||||
type GetOrderStatisticsRes struct {
|
||||
Statistics *OrderStatisticsDetail `json:"statistics"`
|
||||
}
|
||||
|
||||
// OrderStatisticsDetail 订单统计详情
|
||||
type OrderStatisticsDetail struct {
|
||||
ReportType string `json:"report_type"`
|
||||
ReportDate time.Time `json:"report_date"`
|
||||
Period string `json:"period"`
|
||||
|
||||
// 订单基础统计
|
||||
TotalOrders int64 `json:"total_orders"`
|
||||
CompletedOrders int64 `json:"completed_orders"`
|
||||
CancelledOrders int64 `json:"cancelled_orders"`
|
||||
PaidOrders int64 `json:"paid_orders"`
|
||||
|
||||
// 金额统计(单位:分)
|
||||
TotalAmount int64 `json:"total_amount"`
|
||||
PaidAmount int64 `json:"paid_amount"`
|
||||
RefundAmount int64 `json:"refund_amount"`
|
||||
NetAmount int64 `json:"net_amount"`
|
||||
|
||||
// 业务指标
|
||||
AverageOrderValue int64 `json:"average_order_value"`
|
||||
PaymentRate float64 `json:"payment_rate"`
|
||||
CompletionRate float64 `json:"completion_rate"`
|
||||
|
||||
// 用户统计
|
||||
UniqueUsers int64 `json:"unique_users"`
|
||||
NewUsers int64 `json:"new_users"`
|
||||
ReturningUsers int64 `json:"returning_users"`
|
||||
|
||||
// 商品统计
|
||||
TotalItems int64 `json:"total_items"`
|
||||
UniqueAssets int64 `json:"unique_assets"`
|
||||
TopAssetID string `json:"top_asset_id,omitempty"`
|
||||
TopAssetName string `json:"top_asset_name,omitempty"`
|
||||
TopAssetCount int64 `json:"top_asset_count,omitempty"`
|
||||
|
||||
// 时间统计
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// GetOrderStatisticsListReq 获取订单统计列表请求
|
||||
type GetOrderStatisticsListReq struct {
|
||||
g.Meta `path:"/statistics/list" method:"get" tags:"订单统计" summary:"获取订单统计列表" dc:"分页获取订单统计列表"`
|
||||
TenantID int64 `v:"required" json:"tenant_id" dc:"租户ID"`
|
||||
ReportType string `v:"required|in:daily,monthly,quarterly,yearly" json:"report_type" dc:"报表类型"`
|
||||
StartDate string `json:"start_date,omitempty" dc:"开始日期"`
|
||||
EndDate string `json:"end_date,omitempty" dc:"结束日期"`
|
||||
PageNum int `json:"page_num,omitempty" dc:"页码"`
|
||||
PageSize int `json:"page_size,omitempty" dc:"每页数量"`
|
||||
}
|
||||
|
||||
// GetOrderStatisticsListRes 获取订单统计列表响应
|
||||
type GetOrderStatisticsListRes struct {
|
||||
List []*OrderStatisticsDetail `json:"list"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
PageNum int `json:"page_num"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// GenerateOrderStatisticsReq 生成订单统计数据请求
|
||||
type GenerateOrderStatisticsReq struct {
|
||||
g.Meta `path:"/statistics/generate" method:"post" tags:"订单统计" summary:"生成订单统计数据" dc:"手动触发生成指定日期的统计数据"`
|
||||
TenantID int64 `v:"required" json:"tenant_id" dc:"租户ID"`
|
||||
ReportType string `v:"required|in:daily,monthly,quarterly,yearly" json:"report_type" dc:"报表类型"`
|
||||
ReportDate string `json:"report_date,omitempty" dc:"统计日期,格式YYYY-MM-DD"`
|
||||
Force bool `json:"force,omitempty" dc:"是否强制重新生成"`
|
||||
}
|
||||
|
||||
// GenerateOrderStatisticsRes 生成订单统计数据响应
|
||||
type GenerateOrderStatisticsRes struct {
|
||||
Success bool `json:"success"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
// GetOrderTrendReq 获取订单趋势数据请求
|
||||
type GetOrderTrendReq struct {
|
||||
g.Meta `path:"/statistics/trend" method:"get" tags:"订单统计" summary:"获取订单趋势数据" dc:"获取指定时间范围内的订单趋势数据"`
|
||||
TenantID int64 `v:"required" json:"tenant_id" dc:"租户ID"`
|
||||
StartDate string `v:"required" json:"start_date" dc:"开始日期,格式YYYY-MM-DD"`
|
||||
EndDate string `v:"required" json:"end_date" dc:"结束日期,格式YYYY-MM-DD"`
|
||||
TrendType string `v:"required|in:revenue,orders,users" json:"trend_type" dc:"趋势类型:revenue-收入趋势,orders-订单趋势,users-用户趋势"`
|
||||
}
|
||||
|
||||
// GetOrderTrendRes 获取订单趋势数据响应
|
||||
type GetOrderTrendRes struct {
|
||||
TrendData []*TrendDataPoint `json:"trend_data"`
|
||||
}
|
||||
|
||||
// TrendDataPoint 趋势数据点
|
||||
type TrendDataPoint struct {
|
||||
Date string `json:"date"`
|
||||
Value int64 `json:"value"`
|
||||
Label string `json:"label,omitempty"`
|
||||
}
|
||||
|
||||
// GetTopAssetsReq 获取热门资产请求
|
||||
type GetTopAssetsReq struct {
|
||||
g.Meta `path:"/statistics/top-assets" method:"get" tags:"订单统计" summary:"获取热门资产" dc:"获取指定时间范围内的热门资产排行"`
|
||||
TenantID int64 `v:"required" json:"tenant_id" dc:"租户ID"`
|
||||
StartDate string `v:"required" json:"start_date" dc:"开始日期,格式YYYY-MM-DD"`
|
||||
EndDate string `v:"required" json:"end_date" dc:"结束日期,格式YYYY-MM-DD"`
|
||||
Limit int `json:"limit,omitempty" dc:"返回数量限制,默认10"`
|
||||
}
|
||||
|
||||
// GetTopAssetsRes 获取热门资产响应
|
||||
type GetTopAssetsRes struct {
|
||||
TopAssets []*AssetRanking `json:"top_assets"`
|
||||
}
|
||||
|
||||
// AssetRanking 资产排行
|
||||
type AssetRanking struct {
|
||||
AssetID string `json:"asset_id"`
|
||||
AssetName string `json:"asset_name"`
|
||||
AssetType string `json:"asset_type"`
|
||||
OrderCount int64 `json:"order_count"`
|
||||
TotalAmount int64 `json:"total_amount"`
|
||||
Quantity int64 `json:"quantity"`
|
||||
Rank int `json:"rank"`
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"time"
|
||||
|
||||
"gitee.com/red-future---jilin-g/common/do"
|
||||
)
|
||||
|
||||
// OrderBase 订单基础信息
|
||||
@@ -12,18 +13,16 @@ import (
|
||||
// 例如:orders_pending, orders_paid, orders_shipped, orders_completed, orders_cancelled
|
||||
|
||||
type OrderBase struct {
|
||||
ID bson.ObjectID `bson:"_id,omitempty" json:"id"`
|
||||
TenantID string `bson:"tenant_id" json:"tenant_id"` // 租户ID
|
||||
OrderNo string `bson:"order_no" json:"order_no"` // 订单号
|
||||
UserID string `bson:"user_id" json:"user_id"` // 用户ID
|
||||
TotalAmount int64 `bson:"total_amount" json:"total_amount"` // 订单总金额(分)
|
||||
PayAmount int64 `bson:"pay_amount" json:"pay_amount"` // 实付金额(分)
|
||||
OrderType string `bson:"order_type" json:"order_type"` // 订单类型:normal-普通订单
|
||||
Subject string `bson:"subject" json:"subject"` // 订单标题
|
||||
Description string `bson:"description" json:"description"` // 订单描述
|
||||
CreatedAt time.Time `bson:"created_at" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `bson:"updated_at" json:"updated_at"` // 更新时间
|
||||
ExpiredAt *time.Time `bson:"expired_at,omitempty" json:"expired_at"` // 过期时间
|
||||
do.MongoBaseDO `bson:",inline"`
|
||||
OrderNo string `bson:"order_no" json:"order_no"` // 订单号
|
||||
UserID int64 `bson:"user_id" json:"user_id"` // 用户ID
|
||||
TotalAmount int64 `bson:"total_amount" json:"total_amount"` // 订单总金额(分)
|
||||
PayAmount int64 `bson:"pay_amount" json:"pay_amount"` // 实付金额(分)
|
||||
OrderType string `bson:"order_type" json:"order_type"` // 订单类型:normal-普通订单
|
||||
Subject string `bson:"subject" json:"subject"` // 订单标题
|
||||
Description string `bson:"description" json:"description"` // 订单描述
|
||||
OrderItems []OrderItem `bson:"order_items" json:"order_items"` // 订单商品项
|
||||
ExpiredAt *time.Time `bson:"expired_at,omitempty" json:"expired_at"` // 过期时间
|
||||
}
|
||||
|
||||
// OrderItem 订单商品项
|
||||
|
||||
47
model/entity/order_daily_statistics.go
Normal file
47
model/entity/order_daily_statistics.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitee.com/red-future---jilin-g/common/do"
|
||||
)
|
||||
|
||||
// OrderDailyStatistics 订单日统计数据实体
|
||||
type OrderDailyStatistics struct {
|
||||
do.MongoBaseDO `bson:",inline"`
|
||||
ReportDate time.Time `bson:"report_date" json:"report_date"` // 统计日期
|
||||
Period string `bson:"period" json:"period"` // 统计周期描述: 2024-01-01
|
||||
|
||||
// 订单基础统计
|
||||
TotalOrders int64 `bson:"total_orders" json:"total_orders"` // 总订单数
|
||||
CompletedOrders int64 `bson:"completed_orders" json:"completed_orders"` // 已完成订单数
|
||||
CancelledOrders int64 `bson:"cancelled_orders" json:"cancelled_orders"` // 已取消订单数
|
||||
PaidOrders int64 `bson:"paid_orders" json:"paid_orders"` // 已支付订单数
|
||||
|
||||
// 金额统计(单位:分)
|
||||
TotalAmount int64 `bson:"total_amount" json:"total_amount"` // 订单总金额
|
||||
PaidAmount int64 `bson:"paid_amount" json:"paid_amount"` // 已支付金额
|
||||
RefundAmount int64 `bson:"refund_amount" json:"refund_amount"` // 退款金额
|
||||
NetAmount int64 `bson:"net_amount" json:"net_amount"` // 净收入金额
|
||||
|
||||
// 业务指标
|
||||
AverageOrderValue int64 `bson:"average_order_value" json:"average_order_value"` // 平均客单价
|
||||
PaymentRate float64 `bson:"payment_rate" json:"payment_rate"` // 支付成功率
|
||||
CompletionRate float64 `bson:"completion_rate" json:"completion_rate"` // 完成率
|
||||
|
||||
// 用户统计
|
||||
UniqueUsers int64 `bson:"unique_users" json:"unique_users"` // 唯一用户数
|
||||
NewUsers int64 `bson:"new_users" json:"new_users"` // 新用户数
|
||||
ReturningUsers int64 `bson:"returning_users" json:"returning_users"` // 回头用户数
|
||||
|
||||
// 商品统计
|
||||
TotalItems int64 `bson:"total_items" json:"total_items"` // 商品总数量
|
||||
UniqueAssets int64 `bson:"unique_assets" json:"unique_assets"` // 唯一资产数
|
||||
TopAssetID string `bson:"top_asset_id,omitempty" json:"top_asset_id"` // 热门资产ID
|
||||
TopAssetName string `bson:"top_asset_name,omitempty" json:"top_asset_name"` // 热门资产名称
|
||||
TopAssetCount int64 `bson:"top_asset_count,omitempty" json:"top_asset_count"` // 热门资产销量
|
||||
|
||||
// 时段统计
|
||||
HourlyOrders []int64 `bson:"hourly_orders,omitempty" json:"hourly_orders"` // 24小时订单分布
|
||||
PeakHour int `bson:"peak_hour,omitempty" json:"peak_hour"` // 高峰时段
|
||||
}
|
||||
51
model/entity/order_monthly_statistics.go
Normal file
51
model/entity/order_monthly_statistics.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitee.com/red-future---jilin-g/common/do"
|
||||
)
|
||||
|
||||
// OrderMonthlyStatistics 订单月统计数据实体
|
||||
type OrderMonthlyStatistics struct {
|
||||
do.MongoBaseDO `bson:",inline"`
|
||||
ReportDate time.Time `bson:"report_date" json:"report_date"` // 统计日期(月份第一天)
|
||||
Period string `bson:"period" json:"period"` // 统计周期描述: 2024-01
|
||||
|
||||
// 订单基础统计
|
||||
TotalOrders int64 `bson:"total_orders" json:"total_orders"` // 总订单数
|
||||
CompletedOrders int64 `bson:"completed_orders" json:"completed_orders"` // 已完成订单数
|
||||
CancelledOrders int64 `bson:"cancelled_orders" json:"cancelled_orders"` // 已取消订单数
|
||||
PaidOrders int64 `bson:"paid_orders" json:"paid_orders"` // 已支付订单数
|
||||
|
||||
// 金额统计(单位:分)
|
||||
TotalAmount int64 `bson:"total_amount" json:"total_amount"` // 订单总金额
|
||||
PaidAmount int64 `bson:"paid_amount" json:"paid_amount"` // 已支付金额
|
||||
RefundAmount int64 `bson:"refund_amount" json:"refund_amount"` // 退款金额
|
||||
NetAmount int64 `bson:"net_amount" json:"net_amount"` // 净收入金额
|
||||
|
||||
// 业务指标
|
||||
AverageOrderValue int64 `bson:"average_order_value" json:"average_order_value"` // 平均客单价
|
||||
PaymentRate float64 `bson:"payment_rate" json:"payment_rate"` // 支付成功率
|
||||
CompletionRate float64 `bson:"completion_rate" json:"completion_rate"` // 完成率
|
||||
|
||||
// 用户统计
|
||||
UniqueUsers int64 `bson:"unique_users" json:"unique_users"` // 唯一用户数
|
||||
NewUsers int64 `bson:"new_users" json:"new_users"` // 新用户数
|
||||
ReturningUsers int64 `bson:"returning_users" json:"returning_users"` // 回头用户数
|
||||
|
||||
// 商品统计
|
||||
TotalItems int64 `bson:"total_items" json:"total_items"` // 商品总数量
|
||||
UniqueAssets int64 `bson:"unique_assets" json:"unique_assets"` // 唯一资产数
|
||||
TopAssetID string `bson:"top_asset_id,omitempty" json:"top_asset_id"` // 热门资产ID
|
||||
TopAssetName string `bson:"top_asset_name,omitempty" json:"top_asset_name"` // 热门资产名称
|
||||
TopAssetCount int64 `bson:"top_asset_count,omitempty" json:"top_asset_count"` // 热门资产销量
|
||||
|
||||
// 月度趋势
|
||||
DailyOrders []int64 `bson:"daily_orders,omitempty" json:"daily_orders"` // 每日订单数(31天)
|
||||
DailyAmounts []int64 `bson:"daily_amounts,omitempty" json:"daily_amounts"` // 每日金额(31天)
|
||||
PeakDay int `bson:"peak_day,omitempty" json:"peak_day"` // 高峰日
|
||||
|
||||
// 环比增长率
|
||||
MonthOverMonthGrowth float64 `bson:"month_over_month_growth" json:"month_over_month_growth"` // 环比增长率
|
||||
}
|
||||
53
model/entity/order_quarterly_statistics.go
Normal file
53
model/entity/order_quarterly_statistics.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitee.com/red-future---jilin-g/common/do"
|
||||
)
|
||||
|
||||
// OrderQuarterlyStatistics 订单季度统计数据实体
|
||||
type OrderQuarterlyStatistics struct {
|
||||
do.MongoBaseDO `bson:",inline"`
|
||||
ReportDate time.Time `bson:"report_date" json:"report_date"` // 统计日期(季度第一天)
|
||||
Period string `bson:"period" json:"period"` // 统计周期描述: 2024-Q1
|
||||
Quarter int `bson:"quarter" json:"quarter"` // 季度: 1,2,3,4
|
||||
|
||||
// 订单基础统计
|
||||
TotalOrders int64 `bson:"total_orders" json:"total_orders"` // 总订单数
|
||||
CompletedOrders int64 `bson:"completed_orders" json:"completed_orders"` // 已完成订单数
|
||||
CancelledOrders int64 `bson:"cancelled_orders" json:"cancelled_orders"` // 已取消订单数
|
||||
PaidOrders int64 `bson:"paid_orders" json:"paid_orders"` // 已支付订单数
|
||||
|
||||
// 金额统计(单位:分)
|
||||
TotalAmount int64 `bson:"total_amount" json:"total_amount"` // 订单总金额
|
||||
PaidAmount int64 `bson:"paid_amount" json:"paid_amount"` // 已支付金额
|
||||
RefundAmount int64 `bson:"refund_amount" json:"refund_amount"` // 退款金额
|
||||
NetAmount int64 `bson:"net_amount" json:"net_amount"` // 净收入金额
|
||||
|
||||
// 业务指标
|
||||
AverageOrderValue int64 `bson:"average_order_value" json:"average_order_value"` // 平均客单价
|
||||
PaymentRate float64 `bson:"payment_rate" json:"payment_rate"` // 支付成功率
|
||||
CompletionRate float64 `bson:"completion_rate" json:"completion_rate"` // 完成率
|
||||
|
||||
// 用户统计
|
||||
UniqueUsers int64 `bson:"unique_users" json:"unique_users"` // 唯一用户数
|
||||
NewUsers int64 `bson:"new_users" json:"new_users"` // 新用户数
|
||||
ReturningUsers int64 `bson:"returning_users" json:"returning_users"` // 回头用户数
|
||||
|
||||
// 商品统计
|
||||
TotalItems int64 `bson:"total_items" json:"total_items"` // 商品总数量
|
||||
UniqueAssets int64 `bson:"unique_assets" json:"unique_assets"` // 唯一资产数
|
||||
TopAssetID string `bson:"top_asset_id,omitempty" json:"top_asset_id"` // 热门资产ID
|
||||
TopAssetName string `bson:"top_asset_name,omitempty" json:"top_asset_name"` // 热门资产名称
|
||||
TopAssetCount int64 `bson:"top_asset_count,omitempty" json:"top_asset_count"` // 热门资产销量
|
||||
|
||||
// 月度分解
|
||||
MonthlyOrders []int64 `bson:"monthly_orders,omitempty" json:"monthly_orders"` // 月度订单数(3个月)
|
||||
MonthlyAmounts []int64 `bson:"monthly_amounts,omitempty" json:"monthly_amounts"` // 月度金额(3个月)
|
||||
PeakMonth int `bson:"peak_month,omitempty" json:"peak_month"` // 高峰月份
|
||||
|
||||
// 环比/同比增长率
|
||||
QuarterOverQuarterGrowth float64 `bson:"quarter_over_quarter_growth" json:"quarter_over_quarter_growth"` // 环比增长率
|
||||
YearOverYearGrowth float64 `bson:"year_over_year_growth" json:"year_over_year_growth"` // 同比增长率
|
||||
}
|
||||
63
model/entity/order_statistics.go
Normal file
63
model/entity/order_statistics.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitee.com/red-future---jilin-g/common/do"
|
||||
)
|
||||
|
||||
// OrderStatistics 订单统计数据实体
|
||||
type OrderStatistics struct {
|
||||
do.MongoBaseDO `bson:",inline"`
|
||||
ReportType string `bson:"report_type" json:"report_type"` // 报表类型: daily, monthly, quarterly, yearly
|
||||
ReportDate time.Time `bson:"report_date" json:"report_date"` // 统计日期
|
||||
Period string `bson:"period" json:"period"` // 统计周期描述: 2024-01-01, 2024-01, 2024-Q1, 2024
|
||||
|
||||
// 订单基础统计
|
||||
TotalOrders int64 `bson:"total_orders" json:"total_orders"` // 总订单数
|
||||
CompletedOrders int64 `bson:"completed_orders" json:"completed_orders"` // 已完成订单数
|
||||
CancelledOrders int64 `bson:"cancelled_orders" json:"cancelled_orders"` // 已取消订单数
|
||||
PaidOrders int64 `bson:"paid_orders" json:"paid_orders"` // 已支付订单数
|
||||
|
||||
// 金额统计(单位:分)
|
||||
TotalAmount int64 `bson:"total_amount" json:"total_amount"` // 订单总金额
|
||||
PaidAmount int64 `bson:"paid_amount" json:"paid_amount"` // 已支付金额
|
||||
RefundAmount int64 `bson:"refund_amount" json:"refund_amount"` // 退款金额
|
||||
NetAmount int64 `bson:"net_amount" json:"net_amount"` // 净收入金额
|
||||
|
||||
// 业务指标
|
||||
AverageOrderValue int64 `bson:"average_order_value" json:"average_order_value"` // 平均客单价
|
||||
PaymentRate float64 `bson:"payment_rate" json:"payment_rate"` // 支付成功率
|
||||
CompletionRate float64 `bson:"completion_rate" json:"completion_rate"` // 完成率
|
||||
|
||||
// 用户统计
|
||||
UniqueUsers int64 `bson:"unique_users" json:"unique_users"` // 唯一用户数
|
||||
NewUsers int64 `bson:"new_users" json:"new_users"` // 新用户数
|
||||
ReturningUsers int64 `bson:"returning_users" json:"returning_users"` // 回头用户数
|
||||
|
||||
// 商品统计
|
||||
TotalItems int64 `bson:"total_items" json:"total_items"` // 商品总数量
|
||||
UniqueAssets int64 `bson:"unique_assets" json:"unique_assets"` // 唯一资产数
|
||||
TopAssetID string `bson:"top_asset_id,omitempty" json:"top_asset_id"` // 热门资产ID
|
||||
TopAssetName string `bson:"top_asset_name,omitempty" json:"top_asset_name"` // 热门资产名称
|
||||
TopAssetCount int64 `bson:"top_asset_count,omitempty" json:"top_asset_count"` // 热门资产销量
|
||||
}
|
||||
|
||||
// OrderStatisticsUserStats 用户统计明细
|
||||
type OrderStatisticsUserStats struct {
|
||||
UserID int64 `bson:"user_id" json:"user_id"`
|
||||
OrderCount int64 `bson:"order_count" json:"order_count"`
|
||||
TotalAmount int64 `bson:"total_amount" json:"total_amount"`
|
||||
FirstOrder time.Time `bson:"first_order" json:"first_order"`
|
||||
LastOrder time.Time `bson:"last_order" json:"last_order"`
|
||||
}
|
||||
|
||||
// OrderStatisticsAssetStats 资产统计明细
|
||||
type OrderStatisticsAssetStats struct {
|
||||
AssetID string `bson:"asset_id" json:"asset_id"`
|
||||
AssetName string `bson:"asset_name" json:"asset_name"`
|
||||
AssetType string `bson:"asset_type" json:"asset_type"`
|
||||
OrderCount int64 `bson:"order_count" json:"order_count"`
|
||||
TotalAmount int64 `bson:"total_amount" json:"total_amount"`
|
||||
Quantity int64 `bson:"quantity" json:"quantity"`
|
||||
}
|
||||
56
model/entity/order_yearly_statistics.go
Normal file
56
model/entity/order_yearly_statistics.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitee.com/red-future---jilin-g/common/do"
|
||||
)
|
||||
|
||||
// OrderYearlyStatistics 订单年度统计数据实体
|
||||
type OrderYearlyStatistics struct {
|
||||
do.MongoBaseDO `bson:",inline"`
|
||||
ReportDate time.Time `bson:"report_date" json:"report_date"` // 统计日期(年度第一天)
|
||||
Period string `bson:"period" json:"period"` // 统计周期描述: 2024
|
||||
Year int `bson:"year" json:"year"` // 年份
|
||||
|
||||
// 订单基础统计
|
||||
TotalOrders int64 `bson:"total_orders" json:"total_orders"` // 总订单数
|
||||
CompletedOrders int64 `bson:"completed_orders" json:"completed_orders"` // 已完成订单数
|
||||
CancelledOrders int64 `bson:"cancelled_orders" json:"cancelled_orders"` // 已取消订单数
|
||||
PaidOrders int64 `bson:"paid_orders" json:"paid_orders"` // 已支付订单数
|
||||
|
||||
// 金额统计(单位:分)
|
||||
TotalAmount int64 `bson:"total_amount" json:"total_amount"` // 订单总金额
|
||||
PaidAmount int64 `bson:"paid_amount" json:"paid_amount"` // 已支付金额
|
||||
RefundAmount int64 `bson:"refund_amount" json:"refund_amount"` // 退款金额
|
||||
NetAmount int64 `bson:"net_amount" json:"net_amount"` // 净收入金额
|
||||
|
||||
// 业务指标
|
||||
AverageOrderValue int64 `bson:"average_order_value" json:"average_order_value"` // 平均客单价
|
||||
PaymentRate float64 `bson:"payment_rate" json:"payment_rate"` // 支付成功率
|
||||
CompletionRate float64 `bson:"completion_rate" json:"completion_rate"` // 完成率
|
||||
|
||||
// 用户统计
|
||||
UniqueUsers int64 `bson:"unique_users" json:"unique_users"` // 唯一用户数
|
||||
NewUsers int64 `bson:"new_users" json:"new_users"` // 新用户数
|
||||
ReturningUsers int64 `bson:"returning_users" json:"returning_users"` // 回头用户数
|
||||
|
||||
// 商品统计
|
||||
TotalItems int64 `bson:"total_items" json:"total_items"` // 商品总数量
|
||||
UniqueAssets int64 `bson:"unique_assets" json:"unique_assets"` // 唯一资产数
|
||||
TopAssetID string `bson:"top_asset_id,omitempty" json:"top_asset_id"` // 热门资产ID
|
||||
TopAssetName string `bson:"top_asset_name,omitempty" json:"top_asset_name"` // 热门资产名称
|
||||
TopAssetCount int64 `bson:"top_asset_count,omitempty" json:"top_asset_count"` // 热门资产销量
|
||||
|
||||
// 季度分解
|
||||
QuarterlyOrders []int64 `bson:"quarterly_orders,omitempty" json:"quarterly_orders"` // 季度订单数(4个季度)
|
||||
QuarterlyAmounts []int64 `bson:"quarterly_amounts,omitempty" json:"quarterly_amounts"` // 季度金额(4个季度)
|
||||
PeakQuarter int `bson:"peak_quarter,omitempty" json:"peak_quarter"` // 高峰季度
|
||||
|
||||
// 月度分解
|
||||
MonthlyOrders []int64 `bson:"monthly_orders,omitempty" json:"monthly_orders"` // 月度订单数(12个月)
|
||||
MonthlyAmounts []int64 `bson:"monthly_amounts,omitempty" json:"monthly_amounts"` // 月度金额(12个月)
|
||||
|
||||
// 同比增长率
|
||||
YearOverYearGrowth float64 `bson:"year_over_year_growth" json:"year_over_year_growth"` // 同比增长率
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package entity
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
|
||||
"gitee.com/red-future---jilin-g/common/do"
|
||||
)
|
||||
|
||||
// PaymentConfig 支付配置
|
||||
@@ -9,12 +11,11 @@ import (
|
||||
// 支持微信支付和支付宝支付
|
||||
|
||||
type PaymentConfig struct {
|
||||
ID bson.ObjectID `bson:"_id,omitempty" json:"id"`
|
||||
TenantID string `bson:"tenant_id" json:"tenant_id"` // 租户ID
|
||||
PayMethod string `bson:"pay_method" json:"pay_method"` // 支付方式:wechat/alipay
|
||||
ConfigName string `bson:"config_name" json:"config_name"` // 配置名称
|
||||
Description string `bson:"description" json:"description"` // 配置描述
|
||||
Enabled bool `bson:"enabled" json:"enabled"` // 是否启用
|
||||
do.MongoBaseDO `bson:",inline"`
|
||||
PayMethod string `bson:"pay_method" json:"pay_method"` // 支付方式:wechat/alipay
|
||||
ConfigName string `bson:"config_name" json:"config_name"` // 配置名称
|
||||
Description string `bson:"description" json:"description"` // 配置描述
|
||||
Enabled bool `bson:"enabled" json:"enabled"` // 是否启用
|
||||
|
||||
// 通用配置
|
||||
AppID string `bson:"app_id" json:"app_id"` // 应用ID
|
||||
@@ -46,37 +47,31 @@ type PaymentConfig struct {
|
||||
// 记录每次支付操作的结果
|
||||
|
||||
type PaymentRecord struct {
|
||||
ID bson.ObjectID `bson:"_id,omitempty" json:"id"`
|
||||
TenantID string `bson:"tenant_id" json:"tenant_id"` // 租户ID
|
||||
OrderID bson.ObjectID `bson:"order_id" json:"order_id"` // 订单ID
|
||||
OrderNo string `bson:"order_no" json:"order_no"` // 订单号
|
||||
PayMethod string `bson:"pay_method" json:"pay_method"` // 支付方式
|
||||
PayType string `bson:"pay_type" json:"pay_type"` // 支付类型
|
||||
Amount int64 `bson:"amount" json:"amount"` // 支付金额(分)
|
||||
TransactionID string `bson:"transaction_id" json:"transaction_id"` // 支付平台交易号
|
||||
OutTradeNo string `bson:"out_trade_no" json:"out_trade_no"` // 商户订单号
|
||||
TradeNo string `bson:"trade_no" json:"trade_no"` // 交易号
|
||||
PrepayID string `bson:"prepay_id,omitempty" json:"prepay_id"` // 预支付ID
|
||||
Status string `bson:"status" json:"status"` // 支付状态:success/failed
|
||||
ErrorMsg string `bson:"error_msg,omitempty" json:"error_msg"` // 错误信息
|
||||
CreatedAt int64 `bson:"created_at" json:"created_at"` // 创建时间
|
||||
UpdatedAt int64 `bson:"updated_at" json:"updated_at"` // 更新时间
|
||||
do.MongoBaseDO `bson:",inline"`
|
||||
OrderID bson.ObjectID `bson:"order_id" json:"order_id"` // 订单ID
|
||||
OrderNo string `bson:"order_no" json:"order_no"` // 订单号
|
||||
PayMethod string `bson:"pay_method" json:"pay_method"` // 支付方式
|
||||
PayType string `bson:"pay_type" json:"pay_type"` // 支付类型
|
||||
Amount int64 `bson:"amount" json:"amount"` // 支付金额(分)
|
||||
TransactionID string `bson:"transaction_id" json:"transaction_id"` // 支付平台交易号
|
||||
OutTradeNo string `bson:"out_trade_no" json:"out_trade_no"` // 商户订单号
|
||||
TradeNo string `bson:"trade_no" json:"trade_no"` // 交易号
|
||||
PrepayID string `bson:"prepay_id,omitempty" json:"prepay_id"` // 预支付ID
|
||||
Status string `bson:"status" json:"status"` // 支付状态:success/failed
|
||||
ErrorMsg string `bson:"error_msg,omitempty" json:"error_msg"` // 错误信息
|
||||
}
|
||||
|
||||
// RefundRecord 退款记录
|
||||
// 记录每次退款操作的结果
|
||||
|
||||
type RefundRecord struct {
|
||||
ID bson.ObjectID `bson:"_id,omitempty" json:"id"`
|
||||
TenantID string `bson:"tenant_id" json:"tenant_id"` // 租户ID
|
||||
OrderID bson.ObjectID `bson:"order_id" json:"order_id"` // 订单ID
|
||||
OrderNo string `bson:"order_no" json:"order_no"` // 订单号
|
||||
RefundNo string `bson:"refund_no" json:"refund_no"` // 退款单号
|
||||
RefundID string `bson:"refund_id" json:"refund_id"` // 退款ID
|
||||
RefundAmount int64 `bson:"refund_amount" json:"refund_amount"` // 退款金额(分)
|
||||
Reason string `bson:"reason" json:"reason"` // 退款原因
|
||||
Status string `bson:"status" json:"status"` // 退款状态:success/failed
|
||||
ErrorMsg string `bson:"error_msg,omitempty" json:"error_msg"` // 错误信息
|
||||
CreatedAt int64 `bson:"created_at" json:"created_at"` // 创建时间
|
||||
UpdatedAt int64 `bson:"updated_at" json:"updated_at"` // 更新时间
|
||||
do.MongoBaseDO `bson:",inline"`
|
||||
OrderID bson.ObjectID `bson:"order_id" json:"order_id"` // 订单ID
|
||||
OrderNo string `bson:"order_no" json:"order_no"` // 订单号
|
||||
RefundNo string `bson:"refund_no" json:"refund_no"` // 退款单号
|
||||
RefundID string `bson:"refund_id" json:"refund_id"` // 退款ID
|
||||
RefundAmount int64 `bson:"refund_amount" json:"refund_amount"` // 退款金额(分)
|
||||
Reason string `bson:"reason" json:"reason"` // 退款原因
|
||||
Status string `bson:"status" json:"status"` // 退款状态:success/failed
|
||||
ErrorMsg string `bson:"error_msg,omitempty" json:"error_msg"` // 错误信息
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user