feat(admin): 运营数据 - 增加余额消耗统计、通知排序与用户积分汇总
This commit is contained in:
1 parent
00fdd9e879
commit
e0778ef727
14 files changed
+84
-27
No files matched your search
@@ -17,10 +17,12 @@ var (
|
||||
)
|
||||
|
||||
type AdminUserCounts struct {
|
||||
LedgerEntries int64 `json:"ledgerEntries"`
|
||||
Tasks int64 `json:"tasks"`
|
||||
APICalls int64 `json:"apiCalls"`
|
||||
AuditEvents int64 `json:"auditEvents"`
|
||||
LedgerEntries int64 `json:"ledgerEntries"`
|
||||
Tasks int64 `json:"tasks"`
|
||||
APICalls int64 `json:"apiCalls"`
|
||||
AuditEvents int64 `json:"auditEvents"`
|
||||
RechargeMicrocredits int64 `json:"rechargeMicrocredits"`
|
||||
CheckinMicrocredits int64 `json:"checkinMicrocredits"`
|
||||
}
|
||||
|
||||
func (r *Repository) AppendAdminAudit(event *model.AdminAuditEvent) error {
|
||||
@@ -112,6 +114,14 @@ func (r *Repository) AdminUserCounts(userID string) (AdminUserCounts, error) {
|
||||
return AdminUserCounts{}, err
|
||||
}
|
||||
}
|
||||
for entryType, target := range map[model.CreditLedgerType]*int64{
|
||||
model.CreditLedgerPaymentTopup: &counts.RechargeMicrocredits,
|
||||
model.CreditLedgerCheckinBonus: &counts.CheckinMicrocredits,
|
||||
} {
|
||||
if err := r.db.Model(&model.CreditLedgerEntry{}).Where("user_id = ? AND type = ?", userID, entryType).Select("COALESCE(SUM(amount_microcredits), 0)").Scan(target).Error; err != nil {
|
||||
return AdminUserCounts{}, err
|
||||
}
|
||||
}
|
||||
return counts, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user