sync: soul-api 接口逻辑 | 原因: 后端接口逻辑修改

This commit is contained in:
卡若
2026-03-08 10:24:56 +08:00
parent 9faab51394
commit 0865b1df5e

View File

@@ -28,13 +28,23 @@ func DBMatchRecordsList(c *gin.Context) {
db.Model(&model.MatchRecord{}).Select("match_type as match_type, count(*) as count").Group("match_type").Scan(&byType)
var uniqueUsers int64
db.Model(&model.MatchRecord{}).Distinct("user_id").Count(&uniqueUsers)
// 匹配收益product_type=match 且 status=paid 的订单金额总和
var matchRevenue float64
db.Model(&model.Order{}).Where("product_type = ? AND status = ?", "match", "paid").
Select("COALESCE(SUM(amount), 0)").Scan(&matchRevenue)
var paidMatchCount int64
db.Model(&model.Order{}).Where("product_type = ? AND status = ?", "match", "paid").Count(&paidMatchCount)
c.JSON(http.StatusOK, gin.H{
"success": true,
"data": gin.H{
"totalMatches": totalMatches,
"todayMatches": todayMatches,
"byType": byType,
"uniqueUsers": uniqueUsers,
"totalMatches": totalMatches,
"todayMatches": todayMatches,
"byType": byType,
"uniqueUsers": uniqueUsers,
"matchRevenue": matchRevenue,
"paidMatchCount": paidMatchCount,
},
})
return