From 682a3b0edb16356d1df4216258029d81bdd78299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A1=E8=8B=A5?= Date: Sun, 8 Mar 2026 08:59:13 +0800 Subject: [PATCH] =?UTF-8?q?sync:=20soul-api=20=E6=8E=A5=E5=8F=A3=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20|=20=E5=8E=9F=E5=9B=A0:=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- soul-api/internal/handler/admin_rfm.go | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/soul-api/internal/handler/admin_rfm.go b/soul-api/internal/handler/admin_rfm.go index 2ee4860d..f7041c2d 100644 --- a/soul-api/internal/handler/admin_rfm.go +++ b/soul-api/internal/handler/admin_rfm.go @@ -264,3 +264,43 @@ func DBUserRFMSingle(c *gin.Context) { }) } +// DBUsersJourneyStats GET /api/db/users/journey-stats — 各旅程阶段人数 +func DBUsersJourneyStats(c *gin.Context) { + db := database.DB() + stats := make(map[string]int64) + + var reg int64 + db.Table("users").Count(®) + stats["register"] = reg + + var browse int64 + db.Table("user_tracks").Where("action = ?", "view_chapter").Distinct("user_id").Count(&browse) + stats["browse"] = browse + + var bindPhone int64 + db.Table("users").Where("phone IS NOT NULL AND phone != ''").Count(&bindPhone) + stats["bind_phone"] = bindPhone + + var firstPay int64 + db.Table("orders").Where("status IN ?", []string{"paid", "success", "completed"}).Distinct("user_id").Count(&firstPay) + stats["first_pay"] = firstPay + + var fillProfile int64 + db.Table("users").Where("mbti IS NOT NULL OR industry IS NOT NULL").Count(&fillProfile) + stats["fill_profile"] = fillProfile + + var match int64 + db.Table("user_tracks").Where("action = ?", "match").Distinct("user_id").Count(&match) + stats["match"] = match + + var vip int64 + db.Table("users").Where("is_vip = 1").Count(&vip) + stats["vip"] = vip + + var dist int64 + db.Table("users").Where("referral_code IS NOT NULL AND referral_code != '' AND earnings > 0").Count(&dist) + stats["distribution"] = dist + + c.JSON(http.StatusOK, gin.H{"success": true, "stats": stats}) +} +