feat(huya): 统一积分兑换并完善兑换记录
This commit is contained in:
@@ -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())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user