和平小店可以返回所有商品
This commit is contained in:
@@ -437,8 +437,20 @@ class DouyuBatchRunner:
|
||||
db.commit()
|
||||
|
||||
def _upsert_xpd_goods(self, db: Session, goods: list[dict]) -> None:
|
||||
"""写入和平小店商品快照。"""
|
||||
"""同步和平小店商品快照,移除上一次热门抢购等遗留商品。"""
|
||||
now = datetime.now(timezone.utc)
|
||||
commodity_ids = {
|
||||
str(raw.get("commodity_id") or raw.get("iGoodsId") or "")
|
||||
for raw in goods
|
||||
}
|
||||
commodity_ids.discard("")
|
||||
query = db.query(DouyuXpdGoodsSnapshot)
|
||||
if commodity_ids:
|
||||
query.filter(~DouyuXpdGoodsSnapshot.commodity_id.in_(commodity_ids)).delete(
|
||||
synchronize_session=False,
|
||||
)
|
||||
else:
|
||||
query.delete(synchronize_session=False)
|
||||
for raw in goods:
|
||||
commodity_id = str(raw.get("commodity_id") or raw.get("iGoodsId") or "")
|
||||
if not commodity_id:
|
||||
@@ -1458,7 +1470,8 @@ class DouyuBatchRunner:
|
||||
currency = "点券" if pay_type == 1 else "扭蛋碎片"
|
||||
self._mark_task(db, task, "failed", f"该商品不支持使用{currency}兑换")
|
||||
return
|
||||
if goods.goods_left is not None and goods.goods_left <= 0:
|
||||
# iGoodsLeft=-1 表示活动未公开库存,不是售罄;只有 0 才阻止兑换。
|
||||
if goods.goods_left == 0:
|
||||
self._mark_task(db, task, "failed", "该商品库存不足,请刷新商品列表后重试")
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user