def _get_inner_account(self): """ 获取对应的内部账号,部分接口参数需要 :return: 校园卡号对应的系统内部账号 """ if not self.inner_account: info = self._url2json(URL.card_info(), method='post', data={'json': True}) result = json.loads(info['Msg']) self.inner_account = result['query_card']['card'][0]['account'] return self.inner_account
def get_balance(self): """ 查询余额 :return: dict { 'balance': 10.01, # 到账余额 'unsettle_balance': 0.01 # 过渡余额 'total': 10.02 # 总余额 } """ info = self._url2json(URL.card_info(), method='post', data={'json': True}) result = json.loads(info['Msg']) balance = int(result['query_card']['card'][0]['db_balance']) / 100 # 到账余额 unsettle_balance = int(result['query_card']['card'][0]['unsettle_amount']) / 100 # 过渡余额 return { 'balance': balance, # 到账余额 'unsettle_balance': unsettle_balance, # 过渡余额 'total': balance + unsettle_balance, # 总余额 }