feat: 添加租户创建功能,支持设置管理员及有效期,新增订单统计接口

This commit is contained in:
2025-12-23 23:03:49 +08:00
parent d09a9374ee
commit bcb8c822f1
15 changed files with 377 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ import (
"time"
"quyun/v2/app/errorx"
superdto "quyun/v2/app/http/super/dto"
"quyun/v2/app/http/tenant/dto"
jobs_args "quyun/v2/app/jobs/args"
"quyun/v2/app/requests"
@@ -233,6 +234,38 @@ type order struct {
job *provider_job.Job
}
// SuperStatistics 平台侧订单统计(不限定 tenant_id
func (s *order) SuperStatistics(ctx context.Context) (*superdto.OrderStatisticsResponse, error) {
tbl, query := models.OrderQuery.QueryContext(ctx)
var rows []*superdto.OrderStatisticsRow
err := query.Select(
tbl.Status,
tbl.ID.Count().As("count"),
tbl.AmountPaid.Sum().As("amount_paid_sum"),
).Group(tbl.Status).Scan(&rows)
if err != nil {
return nil, err
}
var totalCount int64
var totalAmountPaidSum int64
for _, row := range rows {
if row == nil {
continue
}
row.StatusDescription = row.Status.Description()
totalCount += row.Count
totalAmountPaidSum += row.AmountPaidSum
}
return &superdto.OrderStatisticsResponse{
TotalCount: totalCount,
TotalAmountPaidSum: totalAmountPaidSum,
ByStatus: rows,
}, nil
}
type ProcessRefundingOrderParams struct {
// TenantID 租户ID。
TenantID int64