MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / queryRemain

Method queryRemain

daily/chinaUnicom.py:587–627  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

585 return False
586
587 def queryRemain(self):
588 try:
589 if not self.ecs_token:
590 if not self.onLine():
591 self.log("❌ 无法获取 ecs_token,跳过查询")
592 return
593 self.log("==== 资产查询 ====")
594 self.log("正在查询套餐余量...")
595 url = "https://m.client.10010.com/servicequerybusiness/balancenew/accountBalancenew.htm"
596 headers = {
597 "User-Agent": COMMON_CONSTANTS["MARKET_UA"],
598 "Cookie": f"ecs_token={self.ecs_token}"
599 }
600 res = self.request("get", url, headers=headers)
601 if not res: return
602 result = res.json()
603 if result.get('code') == '0000':
604 current_balance = "0.00"
605 real_time_fee = "0.00"
606 if result.get('curntbalancecust'):
607 current_balance = str(result['curntbalancecust'])
608 if result.get('realfeecust'):
609 real_time_fee = str(result['realfeecust'])
610 self.log(f"💰 [资产-话费] 当前余额: {current_balance}元, 实时话费: {real_time_fee}元", notify=True)
611 pkg_list = result.get('realTimeFeeSpecialFlagThree', [])
612 if pkg_list and isinstance(pkg_list, list):
613 self.log(f" 📋 [套餐详情]:", notify=True)
614 for item in pkg_list:
615 sub_items = item.get('subItems', [])
616 if sub_items:
617 for sub in sub_items:
618 bill = sub.get('bill', {})
619 if bill:
620 name = bill.get('integrateitem', '未知项')
621 fee = bill.get('realfee', '0.00')
622 self.log(f" - {name}: {fee}元", notify=True)
623 else:
624 msg = result.get('desc') or result.get('msg') or "未知错误"
625 self.log(f"套餐余量查询失败: {msg}")
626 except Exception as e:
627 self.log(f"queryRemain 异常: {str(e)}")
628
629 def onLine(self):
630 if not self.token_online:

Callers 1

execute_daily_tasksMethod · 0.95

Calls 4

onLineMethod · 0.95
logMethod · 0.95
requestMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected