feat(weibo): 增加协作 CK 失效筛选与实时同步开关
This commit is contained in:
@@ -48,6 +48,7 @@ from ..schemas import (
|
||||
)
|
||||
from ..services import weibo_collab_service as collab
|
||||
from ..services.weibo_collab_events import collab_events
|
||||
from ..services.weibo_service import mark_weibo_account_refresh_failure
|
||||
|
||||
router = APIRouter(prefix="/api/weibo", tags=["微博外部单协作"])
|
||||
WEIBO_DEFAULT_ACTIVITY = os.getenv("WEIBO_DEFAULT_ACTIVITY", "").strip()
|
||||
@@ -320,6 +321,7 @@ def list_external_orders(
|
||||
page_size: int = Query(20, ge=1, le=200),
|
||||
archive_scope: str = Query("active"),
|
||||
status: str = Query(""),
|
||||
ck_status: str = Query(""),
|
||||
shop: str = Query(""),
|
||||
owner_id: int | None = Query(None),
|
||||
goods_name: str = Query(""),
|
||||
@@ -334,6 +336,7 @@ def list_external_orders(
|
||||
page_size=page_size,
|
||||
archive_scope=archive_scope,
|
||||
status=status,
|
||||
ck_status=ck_status,
|
||||
shop=shop,
|
||||
owner_id=owner_id,
|
||||
goods_name=goods_name,
|
||||
@@ -397,30 +400,44 @@ def verify_external_orders_batch(
|
||||
rows = collab.list_orders_by_ids(db, ids)
|
||||
results: list[dict] = []
|
||||
for order in rows:
|
||||
ck_status = ""
|
||||
try:
|
||||
with db.begin_nested():
|
||||
collab.verify_order_account(
|
||||
account = collab.verify_order_account(
|
||||
db,
|
||||
current,
|
||||
order,
|
||||
activity=WEIBO_DEFAULT_ACTIVITY,
|
||||
commit=False,
|
||||
)
|
||||
ck_status = account.ck_check_status
|
||||
results.append(
|
||||
{
|
||||
"id": order.id,
|
||||
"order_no": order.order_no,
|
||||
"success": True,
|
||||
"message": "",
|
||||
"ck_status": ck_status,
|
||||
}
|
||||
)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
if order.account_id:
|
||||
account = (
|
||||
db.query(WeiboAccount)
|
||||
.filter(WeiboAccount.id == order.account_id)
|
||||
.first()
|
||||
)
|
||||
if account and mark_weibo_account_refresh_failure(
|
||||
db, account, exc, commit=False
|
||||
):
|
||||
ck_status = account.ck_check_status
|
||||
results.append(
|
||||
{
|
||||
"id": order.id,
|
||||
"order_no": order.order_no,
|
||||
"success": False,
|
||||
"message": str(exc),
|
||||
"ck_status": ck_status,
|
||||
}
|
||||
)
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user