Browse Source

✨ feat: 增加乐跑次数明细统计

Pchen0 2 months ago
parent
commit
9a8d8f7f78
1 changed files with 11 additions and 1 deletions
  1. 11 1
      apis/Lepao/Count/Ledger/AdminList.js

+ 11 - 1
apis/Lepao/Count/Ledger/AdminList.js

@@ -115,15 +115,25 @@ class AdminList extends API {
             LEFT JOIN users u ON u.uuid = l.user_uuid COLLATE utf8mb4_general_ci
             WHERE ${whereSql}
         `
+        const summarySql = `
+            SELECT
+                COALESCE(SUM(l.delta), 0) AS total_delta,
+                COUNT(*) AS total_records
+            FROM lepao_count_ledger l
+            LEFT JOIN users u ON u.uuid = l.user_uuid COLLATE utf8mb4_general_ci
+            WHERE ${whereSql}
+        `
         const rows = await db.query(listSql, params)
         const countRows = await db.query(countSql, params)
-        if (!rows || !countRows) {
+        const summaryRows = await db.query(summarySql, params)
+        if (!rows || !countRows || !summaryRows) {
             return res.json({ ...BaseStdResponse.DATABASE_ERR })
         }
 
         return res.json({
             ...BaseStdResponse.OK,
             data: rows,
+            summary: summaryRows[0] || { total_delta: 0, total_records: 0 },
             pagination: {
                 current,
                 pagesize,