feat: 添加租户创建功能,支持设置管理员及有效期,新增订单统计接口
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user