qq 登录修复
This commit is contained in:
@@ -212,11 +212,16 @@ def save_payment_status(path: Path, document: dict, baseline: dict[str, bool], m
|
||||
path.write_text(json.dumps(record, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
||||
|
||||
|
||||
def save_payment_meta(path: Path, order: dict[str, str], baseline: dict[str, bool], document: dict) -> None:
|
||||
def save_payment_meta(path: Path, order: dict[str, str], baseline: dict[str, bool],
|
||||
document: dict, portal_serial_no: str = "") -> None:
|
||||
"""Persist the order identifiers and pre-payment baseline needed by a later check.
|
||||
|
||||
``check`` only re-reads this file and never touches web_save, so re-running a
|
||||
check is side-effect free.
|
||||
|
||||
The official order list (GetPrivateDomainOrderList) exposes its own ``order_id``
|
||||
which equals web_save's ``portal_serial_no``; save it under ``order_id`` so the
|
||||
completion check can match precisely instead of guessing by "newly completed".
|
||||
"""
|
||||
from pyvm.order_status import order_ids
|
||||
|
||||
@@ -225,6 +230,7 @@ def save_payment_meta(path: Path, order: dict[str, str], baseline: dict[str, boo
|
||||
"token_id": order.get("token_id", ""),
|
||||
"transaction_id": order.get("transaction_id", ""),
|
||||
"out_trade_no": order.get("out_trade_no", ""),
|
||||
"order_id": portal_serial_no,
|
||||
},
|
||||
"baseline_order_states": baseline,
|
||||
"baseline_order_ids": sorted(order_ids(document)),
|
||||
@@ -295,7 +301,7 @@ def main() -> int:
|
||||
parser.add_argument("--wait", type=int, default=12, help="jsdom 等待 DeviceFP 的秒数")
|
||||
parser.add_argument("--zone-id", default="1", help="所选游戏区服 ID")
|
||||
parser.add_argument("--pf", default="", help="所选 Android/iOS 支付平台标识")
|
||||
parser.add_argument("--amount-fen", type=int, required=True, help="所选点券的价格,单位分")
|
||||
parser.add_argument("--amount-fen", type=int, default=0, help="所选点券的价格,单位分(check-only 模式不需要)")
|
||||
parser.add_argument("--dry-run", action="store_true", help="仅拉取页面并生成 DeviceFP,不上报或创建付款码")
|
||||
parser.add_argument("--payment-timeout", type=float, default=300,
|
||||
help="付款码生成后等待订单完成的最长秒数")
|
||||
@@ -315,6 +321,8 @@ def main() -> int:
|
||||
if args.check_only:
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
return cmd_check_only(session_path, out_dir)
|
||||
if args.amount_fen <= 0:
|
||||
raise ValueError("充值金额必须为正数")
|
||||
|
||||
session = load_json(session_path)
|
||||
cookies = dict(session.get("cookies", {}))
|
||||
@@ -420,6 +428,8 @@ def main() -> int:
|
||||
if not sign.startswith("weixin://"):
|
||||
print("[jsdom-pay] web_save 成功,但响应没有微信付款链接")
|
||||
return 1
|
||||
info = response_json.get("info", {}) or {}
|
||||
portal_serial_no = str(info.get("portal_serial_no", "") or "")
|
||||
qr_path = Path(args.qr) if args.qr else out_dir / "wechat-pay.png"
|
||||
make_qr(sign, qr_path)
|
||||
print("[jsdom-pay] 微信付款码已生成")
|
||||
@@ -435,7 +445,7 @@ def main() -> int:
|
||||
baseline_document = {"list": []}
|
||||
baseline_states = {}
|
||||
print("[jsdom-pay] 记录付款前订单基线与本次订单标识...")
|
||||
save_payment_meta(out_dir / "payment-meta.json", order, baseline_states, baseline_document)
|
||||
save_payment_meta(out_dir / "payment-meta.json", order, baseline_states, baseline_document, portal_serial_no)
|
||||
if args.skip_payment_check:
|
||||
print("[jsdom-pay] 已保存基线;后台将单独执行只读到账检测")
|
||||
return 0
|
||||
|
||||
@@ -123,10 +123,17 @@ class Cmall:
|
||||
def roles(self, zone_id: str) -> list[dict[str, str]]:
|
||||
response = self.query("15", use_currency_offerid="1", zoneid=zone_id)
|
||||
roles = response.get("role_info") or response.get("role_list") or []
|
||||
return [{"role_id": str(item.get("role_id", "")),
|
||||
"name": unquote(str(item.get("role_name", ""))),
|
||||
"ban_status": str(item.get("ban_status", ""))}
|
||||
for item in roles if isinstance(item, dict) and item.get("role_id")]
|
||||
# QQ 平台和平精英的 area 与 zoneid 不同(如 area=2, zoneid=1);
|
||||
# PlaceOrder 校验角色时需要该分区信息,随角色一并返回。
|
||||
partition = response.get("partition_info") or {}
|
||||
return [{
|
||||
"role_id": str(item.get("role_id", "")),
|
||||
"name": unquote(str(item.get("role_name", ""))),
|
||||
"ban_status": str(item.get("ban_status", "")),
|
||||
"area": str(partition.get("area", "")),
|
||||
"partition": str(partition.get("partition", "")),
|
||||
"platid": str(partition.get("platid", "")),
|
||||
} for item in roles if isinstance(item, dict) and item.get("role_id")]
|
||||
|
||||
|
||||
def choose(label: str, options: list[dict], display) -> dict:
|
||||
|
||||
@@ -242,6 +242,10 @@ def _payment_flow(job_id: str, selection: dict) -> None:
|
||||
"--role-id", str(selection["role_id"]), "--role-name", str(selection["role_name"]),
|
||||
"--zone-id", str(selection["zone_id"]), "--zone-name", str(selection["zone_name"]),
|
||||
"--output", str(response)]
|
||||
if selection.get("area"):
|
||||
order_cmd.extend(["--area", str(selection["area"])])
|
||||
if selection.get("partition"):
|
||||
order_cmd.extend(["--partition", str(selection["partition"])])
|
||||
if selection.get("order_pf"):
|
||||
order_cmd.extend(["--pf", str(selection["order_pf"])])
|
||||
if not _payment_stage(job_id, order_cmd, "order", "正在创建商城订单", "创建商城订单失败"):
|
||||
@@ -413,6 +417,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
"product_id": product["product_id"], "offer_id": product["offer_id"],
|
||||
"zone_id": zone["zone_id"], "zone_name": zone["name"],
|
||||
"role_id": role["role_id"], "role_name": role["name"],
|
||||
"area": role.get("area", ""), "partition": role.get("partition", ""),
|
||||
"order_pf": selector.PLATFORMS[body["platform"]]["order_pf"],
|
||||
}
|
||||
_jobs[job_id]["phase"] = "payment"
|
||||
|
||||
Reference in New Issue
Block a user