fix(douyu): 补齐成功后刷新和精英宝典批量选择

This commit is contained in:
yml
2026-11-21 14:54:36 +08:00
parent 7396126c73
commit d199e04d27
8 changed files with 103 additions and 3 deletions
@@ -74,6 +74,7 @@ class DonateMixin:
last_points = refresh_result["points"]
result.update(refresh_result)
result["gift_points_refresh_count"] = index
result["points_refreshed_after_gift"] = True
if target_points is None or (
last_points is not None and last_points >= target_points
):
@@ -93,6 +94,7 @@ class DonateMixin:
break
result["gift_points_confirmed"] = False
result["points_refreshed_after_gift"] = last_points is not None
result["points"] = last_points
return refresh_result
@@ -310,6 +312,7 @@ class DonateMixin:
)
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
refresh_errors.append(f"积分: {exc}")
result["points_refreshed_after_gift"] = False
if refresh_errors:
result["refresh_errors"] = refresh_errors
account.updated_at = datetime.now(UTC)
+26
View File
@@ -302,6 +302,8 @@ class GoldMixin:
amount=amount,
status=2,
balance_confirmed=True,
cookie=cookie,
gold_already_refreshed=bool(gold_result),
)
return
if supplier_error:
@@ -331,6 +333,8 @@ class GoldMixin:
result,
amount=amount,
status=status,
cookie=cookie,
gold_already_refreshed=bool(gold_result),
)
return
if gold_error:
@@ -356,8 +360,29 @@ class GoldMixin:
amount: int,
status: int | None,
balance_confirmed: bool = False,
cookie: str | None = None,
gold_already_refreshed: bool = False,
) -> None:
if status == 2 or balance_confirmed:
refreshed_after_success = balance_confirmed or gold_already_refreshed
if status == 2 and not refreshed_after_success and cookie:
try:
result.update(
self._refresh_account_gold_balance(
self._client(cookie, direct=True),
account,
)
)
refreshed_after_success = True
self._push_log(
"info",
"供应商直充成功,已刷新鱼翅余额: "
f"{account.gold_balance if account.gold_balance is not None else '-'}",
)
except Exception as exc: # noqa: BLE001 充值成功后刷新失败不翻盘
result["gold_refresh_after_success_error"] = str(exc)
self._push_log("warning", f"供应商直充成功后刷新鱼翅失败: {exc}")
result["gold_refreshed_after_success"] = refreshed_after_success
account.updated_at = datetime.now(UTC)
record_recharge(
db,
@@ -573,6 +598,7 @@ class GoldMixin:
result,
amount=amount,
status=status,
cookie=cookie,
)
return
self._schedule_payment_poll(
@@ -174,6 +174,23 @@ class ManualMixin:
result["payment_polling"] = False
result["elite_opened"] = True
account.elite_opened = True
# 到账判定本身已经调用过积分接口;成功后再收口一次,确保任务结果
# 和账号积分反映的是开通完成后的最终值。
try:
final_points = self._refresh_account_points(
client, account, cookie, ctn=ctn
)
result.update(final_points)
result["points_refreshed_after_elite_opened"] = True
self._push_log(
"info",
"精英宝典开通成功,已刷新积分: "
f"{account.points if account.points is not None else '-'}",
)
except Exception as exc: # noqa: BLE001 开通成功后刷新失败不翻盘
result["points_refreshed_after_elite_opened"] = False
result["elite_open_points_refresh_error"] = str(exc)
self._push_log("warning", f"精英宝典开通后刷新积分失败: {exc}")
account.updated_at = datetime.now(UTC)
spent = _points_spent(baseline_points, account.points)
emit(