gomod引用

This commit is contained in:
2025-12-12 16:20:47 +08:00
parent 0393931e91
commit a4ba4dd715
27 changed files with 2886 additions and 87 deletions

View File

@@ -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 订单商品项

View 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"` // 高峰时段
}

View 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"` // 环比增长率
}

View 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"` // 同比增长率
}

View 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"`
}

View 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"` // 同比增长率
}

View File

@@ -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"` // 错误信息
}