尝试修复积分系统

This commit is contained in:
2025-10-29 12:36:20 +08:00
parent 0c2638e948
commit 5e2afca960
7 changed files with 6 additions and 293 deletions

View File

@@ -362,13 +362,9 @@ class Database:
# 更新用户积分
cursor.execute("""
INSERT INTO user_points (user_id, points, created_at, updated_at)
VALUES (?, ?, ?, ?)
ON CONFLICT(user_id)
DO UPDATE SET
points = points + ?,
updated_at = ?
""", (user_id, points, current_time, current_time, points, current_time))
INSERT OR REPLACE INTO user_points (user_id, points, created_at, updated_at)
VALUES (?, COALESCE((SELECT points FROM user_points WHERE user_id = ?), 0) + ?, ?, ?)
""", (user_id, user_id, points, current_time, current_time))
logger.info(f"用户 {user_id} 成功获得 {points} 积分,来源:{source}")
return True
@@ -468,14 +464,9 @@ class Database:
# 更新积分和签到日期
cursor.execute("""
INSERT INTO user_points (user_id, points, last_checkin_date, created_at, updated_at)
VALUES (?, ?, ?, ?, ?)
ON CONFLICT(user_id)
DO UPDATE SET
points = points + ?,
last_checkin_date = ?,
updated_at = ?
""", (user_id, points, today, current_time, current_time, points, today, current_time))
INSERT OR REPLACE INTO user_points (user_id, points, last_checkin_date, created_at, updated_at)
VALUES (?, COALESCE((SELECT points FROM user_points WHERE user_id = ?), 0) + ?, ?, ?, ?)
""", (user_id, user_id, points, today, current_time, current_time))
# 验证积分是否真的增加了
points_after = self.get_user_points(user_id)