feat(fulfillment): 增加账号商品能力索引与生命周期事件
This commit is contained in:
@@ -34,6 +34,7 @@ from ..models import (
|
||||
User,
|
||||
)
|
||||
from .audit_service import record_audit
|
||||
from .business_events import record_account_query
|
||||
from .collab_common import apply_order_visibility, count_archived
|
||||
from .douyu_activity_query import (
|
||||
activity_client,
|
||||
@@ -1304,6 +1305,22 @@ def query_activity(
|
||||
commit=False,
|
||||
)
|
||||
|
||||
record_account_query(
|
||||
db,
|
||||
account,
|
||||
query_type="collab_activity",
|
||||
title="查询鱼翅与积分" if not include_records else "查询积分与兑换记录",
|
||||
ok=not bool(errors),
|
||||
detail={
|
||||
"order_no": order.order_no,
|
||||
"include_records": include_records,
|
||||
"verdict": verdict,
|
||||
"records": len(records),
|
||||
"errors": errors[:10],
|
||||
},
|
||||
actor_id=current.id,
|
||||
)
|
||||
|
||||
if commit:
|
||||
db.commit()
|
||||
db.refresh(order)
|
||||
@@ -1640,10 +1657,34 @@ def refresh_activity_goods(
|
||||
if account is None:
|
||||
raise CollabError("没有带 CK 的斗鱼账号,无法刷新活动商品", code="no_account")
|
||||
active_client = client or _client_for_account(account)
|
||||
goods = query_activity_goods(
|
||||
active_client, manual_id=str(config.manual_id or ""), rid=str(config.rid or "")
|
||||
)
|
||||
try:
|
||||
goods = query_activity_goods(
|
||||
active_client,
|
||||
manual_id=str(config.manual_id or ""),
|
||||
rid=str(config.rid or ""),
|
||||
)
|
||||
except Exception as exc:
|
||||
record_account_query(
|
||||
db,
|
||||
account,
|
||||
query_type="goods_refresh",
|
||||
title="刷新活动商品",
|
||||
ok=False,
|
||||
detail={"error": str(exc)[:1000]},
|
||||
actor_id=current.id,
|
||||
)
|
||||
db.commit()
|
||||
raise
|
||||
upsert_goods_snapshot(db, goods, commit=False)
|
||||
record_account_query(
|
||||
db,
|
||||
account,
|
||||
query_type="goods_refresh",
|
||||
title="刷新活动商品",
|
||||
ok=True,
|
||||
detail={"count": len(goods)},
|
||||
actor_id=current.id,
|
||||
)
|
||||
record_audit(
|
||||
db,
|
||||
current,
|
||||
|
||||
Reference in New Issue
Block a user