feat(huya): 统一积分兑换并完善兑换记录

This commit is contained in:
yml
2026-11-13 19:03:55 +08:00
parent b89ee4fd18
commit 711be0e2b6
17 changed files with 2064 additions and 193 deletions
+16 -3
View File
@@ -165,11 +165,24 @@ def list_goods(
db: Session = Depends(get_db),
current: User = Depends(require_permission("huya:task")),
):
"""查看已缓存的虎牙商品快照。"""
rows = db.query(HuyaGoodsSnapshot).order_by(HuyaGoodsSnapshot.id.desc()).all()
"""查看最近一次从积分中心 ``queryAllocation`` 刷新的商品快照。"""
rows = (
db.query(HuyaGoodsSnapshot)
.filter(HuyaGoodsSnapshot.account_id.is_not(None))
.order_by(
HuyaGoodsSnapshot.updated_at.desc(),
HuyaGoodsSnapshot.id.desc(),
)
.all()
)
if not rows:
return []
newest = rows[0].updated_at
latest = {}
for row in rows:
latest.setdefault((row.sid, row.product_id), row)
if row.updated_at != newest:
continue
latest.setdefault(row.product_id, row)
return list(latest.values())