新增匹配次数管理功能,优化用户匹配体验。通过服务端计算用户的匹配配额,更新用户状态以反映剩余匹配次数。同时,调整匹配页面逻辑,确保在匹配次数用尽时提示用户购买更多次数。更新相关API以支持匹配记录的存储与查询,提升系统稳定性。
This commit is contained in:
@@ -276,6 +276,9 @@ func UserPurchaseStatus(c *gin.Context) {
|
||||
purchasedSections = append(purchasedSections, r.ProductID)
|
||||
}
|
||||
}
|
||||
// 匹配次数配额:纯计算(订单 + match_records)
|
||||
freeLimit := getFreeMatchLimit(db)
|
||||
matchQuota := GetMatchQuota(db, userId, freeLimit)
|
||||
earnings := 0.0
|
||||
if user.Earnings != nil {
|
||||
earnings = *user.Earnings
|
||||
@@ -288,8 +291,17 @@ func UserPurchaseStatus(c *gin.Context) {
|
||||
"hasFullBook": user.HasFullBook != nil && *user.HasFullBook,
|
||||
"purchasedSections": purchasedSections,
|
||||
"purchasedCount": len(purchasedSections),
|
||||
"earnings": earnings,
|
||||
"pendingEarnings": pendingEarnings,
|
||||
"matchCount": matchQuota.PurchasedTotal,
|
||||
"matchQuota": gin.H{
|
||||
"purchasedTotal": matchQuota.PurchasedTotal,
|
||||
"purchasedUsed": matchQuota.PurchasedUsed,
|
||||
"matchesUsedToday": matchQuota.MatchesUsedToday,
|
||||
"freeRemainToday": matchQuota.FreeRemainToday,
|
||||
"purchasedRemain": matchQuota.PurchasedRemain,
|
||||
"remainToday": matchQuota.RemainToday,
|
||||
},
|
||||
"earnings": earnings,
|
||||
"pendingEarnings": pendingEarnings,
|
||||
}})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user