This commit is contained in:
Alex-larget
2026-03-24 15:44:08 +08:00
parent 346e8ab057
commit 28ad08da84
62 changed files with 814 additions and 840 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"
"time"
"soul-api/internal/database"
@@ -165,12 +166,22 @@ func MatchUsers(c *gin.Context) {
return
}
db := database.DB()
// 全书用户无限制,否则校验今日剩余次数
var user model.User
skipQuota := false
if err := db.Where("id = ?", body.UserID).First(&user).Error; err == nil {
skipQuota = user.HasFullBook != nil && *user.HasFullBook
if err := db.Where("id = ?", body.UserID).First(&user).Error; err != nil {
c.JSON(http.StatusBadRequest, gin.H{"success": false, "message": "用户不存在"})
return
}
phoneOK := user.Phone != nil && strings.TrimSpace(*user.Phone) != ""
wechatOK := user.WechatID != nil && strings.TrimSpace(*user.WechatID) != ""
if !phoneOK && !wechatOK {
c.JSON(http.StatusOK, gin.H{
"success": false,
"message": "请先完善手机号或微信号后再发起匹配",
"errorCode": "ERR_PROFILE_INCOMPLETE",
})
return
}
skipQuota := user.HasFullBook != nil && *user.HasFullBook
if !skipQuota {
freeLimit := getFreeMatchLimit(db)
quota := GetMatchQuota(db, body.UserID, freeLimit)