|
|
|
@@ -1,396 +1,345 @@
|
|
|
|
|
_B5='get_door_daily_bill_api'
|
|
|
|
|
_B4='startTime'
|
|
|
|
|
_B3='constType'
|
|
|
|
|
_B2='provinceCode'
|
|
|
|
|
_B1='access_token'
|
|
|
|
|
_B0='businessType'
|
|
|
|
|
_A_='qrCodeSerial'
|
|
|
|
|
_Az='redirect_url'
|
|
|
|
|
_Ay='_access_token'
|
|
|
|
|
_Ax='dataVersion'
|
|
|
|
|
_Aw='refresh_interval'
|
|
|
|
|
_Av='doorAccountDict'
|
|
|
|
|
_Au='refreshToken'
|
|
|
|
|
_At='accessToken'
|
|
|
|
|
_As='/osg-web0004/member/c24/f01'
|
|
|
|
|
_Ar='BCP_00026'
|
|
|
|
|
_Aq='serviceCode_smt'
|
|
|
|
|
_Ap='WEBA10070900'
|
|
|
|
|
_Ao='serviceType'
|
|
|
|
|
_An='jM_custType'
|
|
|
|
|
_Am='jM_busiTypeCode'
|
|
|
|
|
_Al='doorNumberManeger'
|
|
|
|
|
_Ak='month_t_ele_num'
|
|
|
|
|
_Aj='month_n_ele_num'
|
|
|
|
|
_Ai='month_v_ele_num'
|
|
|
|
|
_Ah='month_p_ele_num'
|
|
|
|
|
_Ag='month_ele_num'
|
|
|
|
|
_Af='thisTPq'
|
|
|
|
|
_Ae='thisNPq'
|
|
|
|
|
_Ad='thisVPq'
|
|
|
|
|
_Ac='thisPPq'
|
|
|
|
|
_Ab='%Y%m%d'
|
|
|
|
|
_Aa='params4'
|
|
|
|
|
_AZ='params3'
|
|
|
|
|
_AY='params1'
|
|
|
|
|
_AX='queryYear'
|
|
|
|
|
_AW='userAccountId'
|
|
|
|
|
_AV='elecTypeCode'
|
|
|
|
|
_AU='powerUserList'
|
|
|
|
|
_AT='publicKey'
|
|
|
|
|
_AS='WEBA10070800'
|
|
|
|
|
_AR='timeDay'
|
|
|
|
|
_AQ='WEBA10070700'
|
|
|
|
|
_AP='channelNo'
|
|
|
|
|
_AO='dayElePq'
|
|
|
|
|
_AN='sevenEleList'
|
|
|
|
|
_AM='month'
|
|
|
|
|
_AL='yearTotalCost'
|
|
|
|
|
_AK='consType'
|
|
|
|
|
_AJ='0000'
|
|
|
|
|
_AI='refresh_token'
|
|
|
|
|
_AH='skey'
|
|
|
|
|
_AG='userInfo'
|
|
|
|
|
_AF='0101046'
|
|
|
|
|
_AE='billYear'
|
|
|
|
|
_AD='proCode'
|
|
|
|
|
_AC='loginAccount'
|
|
|
|
|
_AB='list'
|
|
|
|
|
_AA='keyCode'
|
|
|
|
|
_A9='querytypeCode'
|
|
|
|
|
_A8='01010049'
|
|
|
|
|
_A7='account'
|
|
|
|
|
_A6='daily_bill_list'
|
|
|
|
|
_A5='account_balance'
|
|
|
|
|
_A4='provinceId'
|
|
|
|
|
_A3='userName'
|
|
|
|
|
_A2='acctId'
|
|
|
|
|
_A1='resultCode'
|
|
|
|
|
_A0='BCP_000026'
|
|
|
|
|
_z='app'
|
|
|
|
|
_y='WEBALIPAY_01'
|
|
|
|
|
_x='order'
|
|
|
|
|
_w='state_grid'
|
|
|
|
|
_v='latestBillMonth'
|
|
|
|
|
_u='quInfo'
|
|
|
|
|
_t='authFlag'
|
|
|
|
|
_s='09'
|
|
|
|
|
_r='0101183'
|
|
|
|
|
_q='stepelect'
|
|
|
|
|
_p='consNo'
|
|
|
|
|
_o=True
|
|
|
|
|
_n='0101154'
|
|
|
|
|
_m='monthBillList'
|
|
|
|
|
_l='bizrt'
|
|
|
|
|
_k='token'
|
|
|
|
|
_j='timestamp'
|
|
|
|
|
_i=False
|
|
|
|
|
_h='month_ele'
|
|
|
|
|
_g='consNo_dst'
|
|
|
|
|
_f='errmsg'
|
|
|
|
|
_e='clearCache'
|
|
|
|
|
_d='SGAPP'
|
|
|
|
|
_c='orgNo'
|
|
|
|
|
_b='promotCode'
|
|
|
|
|
_a='01'
|
|
|
|
|
_Z='devciceId'
|
|
|
|
|
_Y='devciceIp'
|
|
|
|
|
_X='proNo'
|
|
|
|
|
_W='tenant'
|
|
|
|
|
_V='member'
|
|
|
|
|
_U='promotType'
|
|
|
|
|
_T='getday'
|
|
|
|
|
_S='srvrt'
|
|
|
|
|
_R='userId'
|
|
|
|
|
_Q='subBusiTypeCode'
|
|
|
|
|
_P='target'
|
|
|
|
|
_O='serCat'
|
|
|
|
|
_N='serialNo'
|
|
|
|
|
_M='0902'
|
|
|
|
|
_L='srvCode'
|
|
|
|
|
_K='busiTypeCode'
|
|
|
|
|
_J='uscInfo'
|
|
|
|
|
_I='channelCode'
|
|
|
|
|
_H='code'
|
|
|
|
|
_G='1'
|
|
|
|
|
_F=None
|
|
|
|
|
_E='source'
|
|
|
|
|
_D='funcCode'
|
|
|
|
|
_C='errcode'
|
|
|
|
|
_B='serviceCode'
|
|
|
|
|
_A='data'
|
|
|
|
|
import json,time,aiohttp,urllib.parse,datetime
|
|
|
|
|
from.const import VERSION
|
|
|
|
|
from.utils.logger import LOGGER
|
|
|
|
|
from.utils.store import async_save_to_store
|
|
|
|
|
from.utils.crypt import a,b,c,d,e
|
|
|
|
|
configuration={_J:{_V:_M,_Y:'',_Z:'',_W:_w},_E:_d,_P:'32101',_I:_M,_AP:_M,'toPublish':_a,'siteId':'2012000000033700',_L:'',_N:'',_D:'',_B:{_x:_n,'uploadPic':'0101296','pauseSCode':'0101250','pauseTCode':'0101251','listconsumers':'0101093','messageList':'0101343','submit':'0101003','sbcMsg':'0101210','powercut':'0104514','BkAuth01':'f15','BkAuth02':'f18','BkAuth03':'f02','BkAuth04':'f17','BkAuth05':'f05','BkAuth06':'f16','BkAuth07':'f01','BkAuth08':'f03'},'electricityArchives':{'servicecode':'0104505',_E:_M},'subscriptionList':{_L:'APP_SGPMS_05_030',_N:'22',_I:_M,_D:'22',_P:'-1'},'userInformation':{_B:'01008183',_E:_d},'userInform':{_B:_r,_E:_d},'elesum':{_I:_M,_D:_y,_b:_G,_U:_G,_B:'0101143',_E:_z},_A7:{_I:_M,_D:'WEBA1007200'},_Al:{_E:_M,_P:'-1',_I:_s,_AP:_s,_B:_A8,_D:'WEBA40050000',_J:{_V:_M,_Y:'',_Z:'',_W:_w}},'doorAuth':{_E:_d,_B:'f04'},'xinZ':{_O:'101',_Am:'101','fJ_busiTypeCode':'102',_An:'03','fJ_custType':'02',_Ao:_a,_Q:'',_D:_AQ,_x:_n,_E:_d,_A9:_G},'onedo':{_B:_AF,_E:_d,_D:_AQ,'queryType':'03'},'xinHuTongDian':{_O:'110',_K:'211',_Q:'21102',_D:'WEBA10071200',_I:_M,_E:_s,_B:_r},'company':{_O:'104',_D:_AQ,_Ao:'02',_A9:_G,_t:_G,_E:_d,_x:_n},'charge':{_I:_s,_D:'WEBA10071300',_AP:'0901',_O:'102',_An:_a,_Am:'102'},'other':{_I:_s,_D:'WEBA10079700',_O:'129',_K:'999',_Q:'21501',_B:_A0,_L:'',_N:''},'vatchange':{'submit':'0101003',_K:'320',_Q:'',_O:'115',_D:'WEBA10074000',_t:_G},'bill':{_e:_G,_D:_y,_U:_G,_B:_A0},_q:{_I:_M,_D:_y,_U:_G,_e:_s,_B:_A0,_E:_z},_T:{_I:_M,_e:'11',_D:_y,_b:_G,_U:_G,_B:_A0,_E:_z},'mouthOut':{_I:_M,_e:'11',_D:_y,_b:_G,_U:_G,_B:_A0,_E:_z},'meter':{_O:'114',_K:'304',_D:'WEBA10071000',_Q:'',_B:_AF,_N:''},'complaint':{_K:'005','srvMode':_M,'anonymousFlag':'0','replyMode':_a,'retvisitFlag':_a},'report':{_K:'006'},'tradewinds':{_K:'019'},'somesay':{_K:'091'},'faultrepair':{_D:_Ap,_B:_r,_O:'111',_K:'001',_Q:'21505'},'electronicInvoice':{_O:'105',_K:'0'},'rename':{_B:_AF,_D:'WEBA10076100',_K:'210',_O:'109',_t:_G,'gh_busiTypeCode':'211','gh_subusi':'21101',_N:'',_L:''},'pause':{_Q:'',_B:_A8,_D:'WEBA10073600',_O:'107',_K:'203','jr_busi':'201',_N:'',_L:''},'capacityRecovery':{_B:_A8,_E:_d,_L:'',_N:'',_D:'WEBA10073700','busiTypeCode_stop':'204','busiTypeCode_less':'202',_K:'202',_Q:'',_O:'108',_AR:'5',_t:_G},'electricityPriceChange':{_B:_r,_K:'215',_Q:'21502',_O:'113',_t:_G,_AR:'15',_D:'WEBA10073900WEB',_L:'',_N:''},'electricityPriceStrategyChange':{_B:'01008183',_K:'215',_Q:'21506',_O:'160',_D:'WEBV00000517WEB',_L:'',_N:''},'eemandValueAdjustment':{_B:_r,_L:'',_N:'',_O:'112',_D:'WEBA10073800',_K:'215',_Q:'21504',_t:_G,_AR:'5','getMonthServiceCode':_AF},'businessProgress':{_B:_r,_L:_a,_D:'WEB01'},'increase':{_E:_d,_N:'',_L:'',_Aq:_A8,_B:_n,_x:_n,_D:_AS,_A9:_G,_O:'106',_K:'111',_Q:''},'fjincrea':{_O:'105',_K:'110',_Q:'',_E:_d,_D:_AS,_N:'',_L:'',_Aq:_A8,_B:_n,_x:_n,_A9:_G},'persIncrea':{_O:'105',_K:'109',_x:_n,_Q:'',_E:_d,_D:_AS,_A9:_G},'fgdChange':{_B:_r,_L:_a,_I:_s,_D:_Ap,_K:'215',_Q:'21505',_O:'111',_t:_G},'createOrder':{_I:_M,_D:_y,_L:'BCP_000001','chargeMode':'02','conType':_a,'bizTypeId':'BT_ELEC'},'largePopulation':{_K:'383',_D:'WEBA10076800',_Q:'',_L:'',_U:'',_b:'',_I:'0901',_O:'383',_B:'',_N:''},'biaoJiCode':{_B:'0104507',_E:'1704',_I:'1704'},'twoGuar':{_K:'402',_Q:'40201',_D:'web_twoGuar'},'electTrend':{_B:_Ar,_I:_M},'emergency':{_B:_Ar,_D:'A10000000',_I:_M},'infoPublic':{_B:'2545454',_E:_z}}
|
|
|
|
|
appKey='3def6c365d284881bf1a9b2b502ee68c'
|
|
|
|
|
appSecret='ab7357dae64944a197ace37398897f64'
|
|
|
|
|
baseApi='https://www.95598.cn/api'
|
|
|
|
|
get_request_key_api='/oauth2/outer/c02/f02'
|
|
|
|
|
get_qr_code_api='/osg-open-uc0001/member/c8/f24'
|
|
|
|
|
get_qr_code_status_api='/osg-web0004/open/c50/f02'
|
|
|
|
|
get_qr_code_token_api='/osg-uc0013/member/c4/f04'
|
|
|
|
|
send_code_api='/osg-open-uc0001/member/c8/f04'
|
|
|
|
|
code_login_api='/osg-uc0013/member/c4/f02'
|
|
|
|
|
getCertificationApi='/osg-open-uc0001/member/c8/f11'
|
|
|
|
|
get_request_authorize_api='/oauth2/oauth/authorize'
|
|
|
|
|
get_web_token_api='/oauth2/outer/getWebToken'
|
|
|
|
|
refresh_web_token_api='/oauth2/outer/refresh_web_token'
|
|
|
|
|
get_door_number_api='/osg-open-uc0001/member/c9/f02'
|
|
|
|
|
get_door_balance_api='/osg-open-bc0001/member/c05/f01'
|
|
|
|
|
get_door_bill_api='/osg-open-bc0001/member/c01/f02'
|
|
|
|
|
get_door_ladder_api='/osg-open-bc0001/member/c04/f03'
|
|
|
|
|
getJiaoFeiRecordApi=_As
|
|
|
|
|
get_door_daily_bill_api=_As
|
|
|
|
|
sessionIdControlApiList=[get_qr_code_api,get_qr_code_status_api,get_qr_code_token_api,send_code_api,code_login_api]
|
|
|
|
|
keyCodeControlApiList=[get_qr_code_status_api,get_qr_code_token_api,send_code_api,code_login_api,getCertificationApi,get_request_authorize_api,get_web_token_api,refresh_web_token_api,get_door_number_api,get_door_balance_api,get_door_bill_api,get_door_ladder_api,getJiaoFeiRecordApi,get_door_daily_bill_api]
|
|
|
|
|
authControlApiList=[get_door_number_api,get_door_balance_api,get_door_bill_api,get_door_ladder_api,getJiaoFeiRecordApi,get_door_daily_bill_api]
|
|
|
|
|
tControlApiList=[getCertificationApi,get_door_balance_api,get_door_bill_api,get_door_ladder_api,getJiaoFeiRecordApi,get_door_daily_bill_api]
|
|
|
|
|
def json_dumps(data):return json.dumps(data,separators=(',',':'),ensure_ascii=_i)
|
|
|
|
|
def normal_round(num,ndigits=0):
|
|
|
|
|
A=ndigits
|
|
|
|
|
if A==0:return int(num+.5)
|
|
|
|
|
else:B=10**A;return int(num*B+.5)/B
|
|
|
|
|
def catchFloat(data,key):
|
|
|
|
|
BZ='params4'
|
|
|
|
|
BY='params3'
|
|
|
|
|
BX='params1'
|
|
|
|
|
BW='queryYear'
|
|
|
|
|
BV='provinceCode'
|
|
|
|
|
BU='sceneType'
|
|
|
|
|
BT='consNoSrc'
|
|
|
|
|
BS='access_token'
|
|
|
|
|
BR='codeKey'
|
|
|
|
|
BQ='businessType'
|
|
|
|
|
BP='Channels'
|
|
|
|
|
BO='qrCodeSerial'
|
|
|
|
|
BN='redirect_url'
|
|
|
|
|
BM='_access_token'
|
|
|
|
|
BL='is_debug'
|
|
|
|
|
BK='refresh_interval'
|
|
|
|
|
BJ='doorAccountDict'
|
|
|
|
|
BI='refreshToken'
|
|
|
|
|
BH='accessToken'
|
|
|
|
|
BG='/osg-web0004/member/c24/f01'
|
|
|
|
|
BF='BCP_00026'
|
|
|
|
|
BE='serviceCode_smt'
|
|
|
|
|
BD='WEBA10070900'
|
|
|
|
|
BC='serviceType'
|
|
|
|
|
BB='jM_custType'
|
|
|
|
|
BA='jM_busiTypeCode'
|
|
|
|
|
B9='01008183'
|
|
|
|
|
B8='0101003'
|
|
|
|
|
B7='submit'
|
|
|
|
|
B2='consType'
|
|
|
|
|
B1='constType'
|
|
|
|
|
B0='powerUserList'
|
|
|
|
|
A_='publicKey'
|
|
|
|
|
Az='WEBA10070800'
|
|
|
|
|
Ay='timeDay'
|
|
|
|
|
Ax='105'
|
|
|
|
|
Aw='111'
|
|
|
|
|
Av='0901'
|
|
|
|
|
Au='WEBA10070700'
|
|
|
|
|
At='102'
|
|
|
|
|
As='0101143'
|
|
|
|
|
Ar='channelNo'
|
|
|
|
|
Ae='latestBillMonth'
|
|
|
|
|
Ad='yearTotalCost'
|
|
|
|
|
Ac='accountBalance'
|
|
|
|
|
Ab='userAccountId'
|
|
|
|
|
Aa='0000'
|
|
|
|
|
AZ='refresh_token'
|
|
|
|
|
AY='web'
|
|
|
|
|
AX='skey'
|
|
|
|
|
AW='userInfo'
|
|
|
|
|
AV=True
|
|
|
|
|
AU='215'
|
|
|
|
|
AT='0101046'
|
|
|
|
|
AJ='proCode'
|
|
|
|
|
AI='loginAccount'
|
|
|
|
|
AH='keyCode'
|
|
|
|
|
AG='querytypeCode'
|
|
|
|
|
AF='01010049'
|
|
|
|
|
AE='doorNumberManeger'
|
|
|
|
|
AD='monthBillList'
|
|
|
|
|
AC='list'
|
|
|
|
|
AB='userName'
|
|
|
|
|
AA='acctId'
|
|
|
|
|
A9='resultCode'
|
|
|
|
|
A8='quInfo'
|
|
|
|
|
A7='BCP_000026'
|
|
|
|
|
A6='app'
|
|
|
|
|
A5='WEBALIPAY_01'
|
|
|
|
|
A4='order'
|
|
|
|
|
A3='state_grid'
|
|
|
|
|
z=False
|
|
|
|
|
y='authFlag'
|
|
|
|
|
x='09'
|
|
|
|
|
w='0101183'
|
|
|
|
|
v='stepelect'
|
|
|
|
|
u='account'
|
|
|
|
|
t=len
|
|
|
|
|
s='consNo_dst'
|
|
|
|
|
r='token'
|
|
|
|
|
q='0101154'
|
|
|
|
|
p='getday'
|
|
|
|
|
n='consNo'
|
|
|
|
|
m='bizrt'
|
|
|
|
|
l='clearCache'
|
|
|
|
|
j='timestamp'
|
|
|
|
|
i='errmsg'
|
|
|
|
|
h='promotCode'
|
|
|
|
|
g='01'
|
|
|
|
|
f='SGAPP'
|
|
|
|
|
e='devciceId'
|
|
|
|
|
d='devciceIp'
|
|
|
|
|
c='orgNo'
|
|
|
|
|
b='tenant'
|
|
|
|
|
a='member'
|
|
|
|
|
Z=str
|
|
|
|
|
Y='daily_bill_list'
|
|
|
|
|
X='proNo'
|
|
|
|
|
W='promotType'
|
|
|
|
|
V='target'
|
|
|
|
|
U='userId'
|
|
|
|
|
T='srvrt'
|
|
|
|
|
S='subBusiTypeCode'
|
|
|
|
|
Q='serCat'
|
|
|
|
|
P='serialNo'
|
|
|
|
|
O='0902'
|
|
|
|
|
N='srvCode'
|
|
|
|
|
M='uscInfo'
|
|
|
|
|
L=None
|
|
|
|
|
K='busiTypeCode'
|
|
|
|
|
J='code'
|
|
|
|
|
I='channelCode'
|
|
|
|
|
H='1'
|
|
|
|
|
G='source'
|
|
|
|
|
E='funcCode'
|
|
|
|
|
D='serviceCode'
|
|
|
|
|
C='errcode'
|
|
|
|
|
B='data'
|
|
|
|
|
A=''
|
|
|
|
|
import json as AK,time as Af,aiohttp as Ag,urllib.parse,datetime as k
|
|
|
|
|
from.utils.logger import LOGGER as A0
|
|
|
|
|
from.utils.store import async_save_to_store as Ba
|
|
|
|
|
from.utils.crypt import a as AL,b as B3,c as A1,d as AM,e as Ah
|
|
|
|
|
o='3def6c365d284881bf1a9b2b502ee68c'
|
|
|
|
|
Ai='ab7357dae64944a197ace37398897f64'
|
|
|
|
|
F={M:{a:O,d:A,e:A,b:A3},G:f,V:'32101',I:O,Ar:O,'toPublish':g,'siteId':'2012000000033700',N:A,P:A,E:A,D:{A4:q,'uploadPic':'0101296','pauseSCode':'0101250','pauseTCode':'0101251','listconsumers':'0101093','messageList':'0101343',B7:B8,'sbcMsg':'0101210','powercut':'0104514','BkAuth01':'f15','BkAuth02':'f18','BkAuth03':'f02','BkAuth04':'f17','BkAuth05':'f05','BkAuth06':'f16','BkAuth07':'f01','BkAuth08':'f03'},'electricityArchives':{'servicecode':'0104505',G:O},'subscriptionList':{N:'APP_SGPMS_05_030',P:'22',I:O,E:'22',V:'-1'},'userInformation':{D:B9,G:f},'userInform':{D:w,G:f},'elesum':{I:O,E:A5,h:H,W:H,D:As,G:A6},u:{I:O,E:'WEBA1007200'},AE:{G:O,V:'-1',I:x,Ar:x,D:AF,E:'WEBA40050000',M:{a:O,d:A,e:A,b:A3}},'doorAuth':{G:f,D:'f04'},'xinZ':{Q:'101',BA:'101','fJ_busiTypeCode':At,BB:'03','fJ_custType':'02',BC:g,S:A,E:Au,A4:q,G:f,AG:H},'onedo':{D:AT,G:f,E:Au,'queryType':'03'},'xinHuTongDian':{Q:'110',K:'211',S:'21102',E:'WEBA10071200',I:O,G:x,D:w},'company':{Q:'104',E:Au,BC:'02',AG:H,y:H,G:f,A4:q},'charge':{I:x,E:'WEBA10071300',Ar:Av,Q:At,BB:g,BA:At},'other':{I:x,E:'WEBA10079700',Q:'129',K:'999',S:'21501',D:A7,N:A,P:A},'vatchange':{B7:B8,K:'320',S:A,Q:'115',E:'WEBA10074000',y:H},'bill':{l:H,E:A5,W:H,D:A7},v:{I:O,E:A5,W:H,l:x,D:A7,G:A6},p:{I:O,l:'11',E:A5,h:H,W:H,D:A7,G:A6},'mouthOut':{I:O,l:'11',E:A5,h:H,W:H,D:A7,G:A6},'meter':{Q:'114',K:'304',E:'WEBA10071000',S:A,D:AT,P:A},'complaint':{K:'005','srvMode':O,'anonymousFlag':'0','replyMode':g,'retvisitFlag':g},'report':{K:'006'},'tradewinds':{K:'019'},'somesay':{K:'091'},'faultrepair':{E:BD,D:w,Q:Aw,K:'001',S:'21505'},'electronicInvoice':{Q:Ax,K:'0'},'rename':{D:AT,E:'WEBA10076100',K:'210',Q:'109',y:H,'gh_busiTypeCode':'211','gh_subusi':'21101',P:A,N:A},'pause':{S:A,D:AF,E:'WEBA10073600',Q:'107',K:'203','jr_busi':'201',P:A,N:A},'capacityRecovery':{D:AF,G:f,N:A,P:A,E:'WEBA10073700','busiTypeCode_stop':'204','busiTypeCode_less':'202',K:'202',S:A,Q:'108',Ay:'5',y:H},'electricityPriceChange':{D:w,K:AU,S:'21502',Q:'113',y:H,Ay:'15',E:'WEBA10073900WEB',N:A,P:A},'electricityPriceStrategyChange':{D:B9,K:AU,S:'21506',Q:'160',E:'WEBV00000517WEB',N:A,P:A},'eemandValueAdjustment':{D:w,N:A,P:A,Q:'112',E:'WEBA10073800',K:AU,S:'21504',y:H,Ay:'5','getMonthServiceCode':AT},'businessProgress':{D:w,N:g,E:'WEB01'},'increase':{G:f,P:A,N:A,BE:AF,D:q,A4:q,E:Az,AG:H,Q:'106',K:Aw,S:A},'fjincrea':{Q:Ax,K:'110',S:A,G:f,E:Az,P:A,N:A,BE:AF,D:q,A4:q,AG:H},'persIncrea':{Q:Ax,K:'109',A4:q,S:A,G:f,E:Az,AG:H},'fgdChange':{D:w,N:g,I:x,E:BD,K:AU,S:'21505',Q:Aw,y:H},'createOrder':{I:O,E:A5,N:'BCP_000001','chargeMode':'02','conType':g,'bizTypeId':'BT_ELEC'},'largePopulation':{K:'383',E:'WEBA10076800',S:A,N:A,W:A,h:A,I:Av,Q:'383',D:A,P:A},'biaoJiCode':{D:'0104507',G:'1704',I:'1704'},'twoGuar':{K:'402',S:'40201',E:'web_twoGuar'},'electTrend':{D:BF,I:O},'emergency':{D:BF,E:'A10000000',I:O},'infoPublic':{D:'2545454',G:A6}}
|
|
|
|
|
B4='https://www.95598.cn/api'
|
|
|
|
|
B5='/oauth2/outer/c02/f02'
|
|
|
|
|
Aj='/osg-open-uc0001/member/c8/f24'
|
|
|
|
|
Ak='/osg-web0004/open/c50/f02'
|
|
|
|
|
Al='/osg-uc0013/member/c4/f04'
|
|
|
|
|
Am='/osg-open-uc0001/member/c8/f04'
|
|
|
|
|
An='/osg-uc0013/member/c4/f02'
|
|
|
|
|
B6='/osg-open-uc0001/member/c8/f11'
|
|
|
|
|
Ao='/oauth2/oauth/authorize'
|
|
|
|
|
AN='/oauth2/outer/getWebToken'
|
|
|
|
|
Ap='/oauth2/outer/refresh_web_token'
|
|
|
|
|
Aq='/osg-open-uc0001/member/c9/f02'
|
|
|
|
|
AO='/osg-open-bc0001/member/c05/f01'
|
|
|
|
|
AP='/osg-open-bc0001/member/c01/f02'
|
|
|
|
|
AQ='/osg-open-bc0001/member/c04/f03'
|
|
|
|
|
AR=BG
|
|
|
|
|
AS=BG
|
|
|
|
|
Bb=[Aj,Ak,Al,Am,An]
|
|
|
|
|
Bc=[Ak,Al,Am,An,B6,Ao,AN,Ap,Aq,AO,AP,AQ,AR,AS]
|
|
|
|
|
Bd=[Aq,AO,AP,AQ,AR,AS]
|
|
|
|
|
Be=[B6,AO,AP,AQ,AR,AS]
|
|
|
|
|
def A2(data):return AK.dumps(data,separators=(',',':'),ensure_ascii=z)
|
|
|
|
|
def R(data,key):
|
|
|
|
|
if key in data:
|
|
|
|
|
try:return normal_round(float(data[key]),2)
|
|
|
|
|
try:return float(data[key])
|
|
|
|
|
except:return 0
|
|
|
|
|
else:return 0
|
|
|
|
|
class StateGridDataClient:
|
|
|
|
|
hass=_F;coordinator=_F;session=_F;dataVersion=_F;keyCode=_F;publicKey=_F;need_login=_i;retry_times=0;phone=_F;codeKey=_F;serialNo=_F;qrCodeSerial=_F;userInfo=_F;accountInfo=_F;powerUserList=_F;doorAccountDict={};cookie=[];timestamp=int(time.time()*1000);accessToken=_F;refreshToken=_F;token=_F;expirationDate=_F;refresh_interval=6;is_debug=_i
|
|
|
|
|
def __init__(A,hass,config=_F):
|
|
|
|
|
B=config;A.hass=hass;C=aiohttp.TCPConnector(ssl=_i);D=aiohttp.CookieJar(quote_cookie=_o);A.session=aiohttp.ClientSession(cookie_jar=D,connector=C)
|
|
|
|
|
if B is not _F:
|
|
|
|
|
try:A.keyCode=B[_AA];A.publicKey=B[_AT];A.accessToken=B[_At];A.refreshToken=B[_Au];A.token=B[_k];A.userInfo=B[_AG];A.powerUserList=B[_AU];A.doorAccountDict=B[_Av];A.refresh_interval=B[_Aw];A.is_debug=B['is_debug'];A.dataVersion=B[_Ax]
|
|
|
|
|
except Exception as E:LOGGER.error(E)
|
|
|
|
|
async def save_data(B):A={};A[_AA]=B.keyCode;A[_AT]=B.publicKey;A[_At]=B.accessToken;A[_Au]=B.refreshToken;A[_k]=B.token;A[_AG]=B.userInfo;A[_AU]=B.powerUserList;A[_Av]=B.doorAccountDict;A[_Aw]=B.refresh_interval;A['is_debug']=B.is_debug;A[_Ax]=VERSION;await async_save_to_store(B.hass,'state_grid.config',A)
|
|
|
|
|
def encrypt_post_data(A,data):B={_Ay:A.accessToken[len(A.accessToken)//2:]if A.accessToken else'','_t':A.token[len(A.token)//2:]if A.token else'','_data':data,_j:A.timestamp};return A.encrypt_wapper_data(B)
|
|
|
|
|
def encrypt_wapper_data(A,data):B=a(json_dumps(data),A.keyCode);return{_A:B+c(B+str(A.timestamp)),_AH:d(A.keyCode,A.publicKey),_j:str(A.timestamp)}
|
|
|
|
|
def handle_request_result_message(E,api,result):
|
|
|
|
|
D='message';C='resultMessage';A=result;B=_F
|
|
|
|
|
if _A in A and _S in A[_A]and C in A[_A][_S]:B=A[_A][_S][C]
|
|
|
|
|
elif _S in A and C in A[_S]:B=A[_S][C]
|
|
|
|
|
elif D in A:B=A[D]
|
|
|
|
|
else:B=json_dumps(A)
|
|
|
|
|
if E.is_debug:LOGGER.error(api+': '+B);LOGGER.error(json_dumps(A))
|
|
|
|
|
return B
|
|
|
|
|
async def __fetch_safe(C,api,data):
|
|
|
|
|
B=await C.__fetch(api,data)
|
|
|
|
|
if _H not in B:return B
|
|
|
|
|
A=B[_H]
|
|
|
|
|
if 10015==A or 10108==A or 10009==A or 10207==A or 10005==A or 10010==A or 30010==A or 10002==A:
|
|
|
|
|
await C.__refresh_token()
|
|
|
|
|
if C.need_login is _o:return B
|
|
|
|
|
else:return await C.__fetch(api,data)
|
|
|
|
|
else:return B
|
|
|
|
|
async def __fetch(B,api,data,header=_F):
|
|
|
|
|
T='encryptData';S='464606a4-184c-4beb-b442-2ab7761d0796';R='key_code';Q='state';P='sign';O='grant_type';N='application/json;charset=UTF-8';M='Content-Type';L=header;K='client_secret';I='client_id';E=api;B.timestamp=int(time.time()*1000);D=B.timestamp
|
|
|
|
|
if B.keyCode is _F:B.keyCode=e(32,16,2)
|
|
|
|
|
F=B.keyCode;G={'User-Agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Mobile Safari/537.36','Accept':N,M:N,'version':'1.0',_E:'0901',_j:str(D),'wsgwType':'web','appKey':appKey};A=data
|
|
|
|
|
if E==get_request_key_api:A={I:appKey,K:appSecret};H=a(json_dumps(A),F);A={_A:H+c(H+str(D)),_AH:d(F,'042BC7AD510BF9793B7744C8854C56A8C95DD1027EE619247A332EC6ED5B279F435A23D62441FE861F4B0C963347ECD5792F380B64CA084BE8BE41151F8B8D19C8'),I:appKey,_j:str(D)}
|
|
|
|
|
elif E==get_qr_code_api:A={_Ay:'','_t':'','_data':A,_j:D}
|
|
|
|
|
elif E==get_request_authorize_api:
|
|
|
|
|
A={I:appKey,'response_type':_H,_Az:'/test',_j:D,'rsi':B.token};A=urllib.parse.urlencode(A);G[M]='application/x-www-form-urlencoded; charset=UTF-8';G[_AA]=F
|
|
|
|
|
async with B.session.post(baseApi+E,data=A,headers=G)as J:B.session.cookie_jar.update_cookies(J.cookies);C=await J.json();C=b(C[_A],B.token);C=json.loads(C);return C
|
|
|
|
|
elif E==get_web_token_api:A={O:'authorization_code',P:c(appKey+str(D)),K:appSecret,Q:S,R:F,I:appKey,_j:D,_H:A[_H]};H=a(json_dumps(A),F);A={_A:H+c(H+str(D)),_AH:d(F,B.publicKey),_j:str(D)}
|
|
|
|
|
elif E==refresh_web_token_api:A={O:_AI,P:c(appKey+str(D)),K:appSecret,Q:S,R:F,I:appKey,_j:D,_AI:B.refreshToken};H=a(json_dumps(A),F);A={_A:H+c(H+str(D)),_AH:d(F,B.publicKey),_j:str(D)};E=get_web_token_api
|
|
|
|
|
else:A=B.encrypt_post_data(A)
|
|
|
|
|
if L is not _F:G.update(L)
|
|
|
|
|
if E in sessionIdControlApiList:G['sessionId']='web'+str(D)
|
|
|
|
|
if E in keyCodeControlApiList:G[_AA]=F
|
|
|
|
|
if E in authControlApiList:G['Authorization']='Bearer '+B.accessToken[:len(B.accessToken)//2]
|
|
|
|
|
if E in tControlApiList:G['t']=B.token[:len(B.token)//2]
|
|
|
|
|
async with B.session.post(baseApi+E,json=A,headers=G)as J:
|
|
|
|
|
C=await J.text()
|
|
|
|
|
if C.startswith('{'):
|
|
|
|
|
C=json.loads(C)
|
|
|
|
|
if T in C:C=b(C[T],F);C=json.loads(C)
|
|
|
|
|
return C
|
|
|
|
|
hass=L;session=L;keyCode=L;publicKey=L;need_login=z;phone=L;codeKey=L;serialNo=L;qrCodeSerial=L;userInfo=L;accountInfo=L;powerUserList=L;doorAccountDict={};cookie=[];timestamp=int(Af.time()*1000);accessToken=L;refreshToken=L;token=L;expirationDate=L;refresh_interval=12;is_debug=z
|
|
|
|
|
def __init__(A,hass,config=L):
|
|
|
|
|
B=config;A.hass=hass;C=Ag.TCPConnector(ssl=z);D=Ag.CookieJar(quote_cookie=AV);A.session=Ag.ClientSession(cookie_jar=D,connector=C)
|
|
|
|
|
if B is not L:
|
|
|
|
|
try:A.keyCode=B[AH];A.publicKey=B[A_];A.accessToken=B[BH];A.refreshToken=B[BI];A.token=B[r];A.userInfo=B[AW];A.powerUserList=B[B0];A.doorAccountDict=B[BJ];A.refresh_interval=B[BK];A.is_debug=B[BL]
|
|
|
|
|
except Exception as E:A0.error(E)
|
|
|
|
|
async def save_data(A):B={};B[AH]=A.keyCode;B[A_]=A.publicKey;B[BH]=A.accessToken;B[BI]=A.refreshToken;B[r]=A.token;B[AW]=A.userInfo;B[B0]=A.powerUserList;B[BJ]=A.doorAccountDict;B[BK]=A.refresh_interval;B[BL]=A.is_debug;await Ba(A.hass,'state_grid.config',B)
|
|
|
|
|
def encrypt_post_data(B,data):C={BM:B.accessToken[t(B.accessToken)//2:]if B.accessToken else A,'_t':B.token[t(B.token)//2:]if B.token else A,'_data':data,j:B.timestamp};return B.encrypt_wapper_data(C)
|
|
|
|
|
def encrypt_wapper_data(A,data):C=AL(A2(data),A.keyCode);return{B:C+A1(C+Z(A.timestamp)),AX:AM(A.keyCode,A.publicKey),j:Z(A.timestamp)}
|
|
|
|
|
def handle_request_result_message(F,api,result):
|
|
|
|
|
E='message';D='resultMessage';A=result;C=L
|
|
|
|
|
if B in A and T in A[B]and D in A[B][T]:C=A[B][T][D]
|
|
|
|
|
elif T in A and D in A[T]:C=A[T][D]
|
|
|
|
|
elif E in A:C=A[E]
|
|
|
|
|
else:C=A2(A)
|
|
|
|
|
if F.is_debug:A0.error(api+': '+C);A0.error(A2(A))
|
|
|
|
|
return C
|
|
|
|
|
async def fetch(D,api,data,header=L):
|
|
|
|
|
Y='encryptData';X='464606a4-184c-4beb-b442-2ab7761d0796';W='key_code';V='state';U='sign';T='grant_type';S='application/json;charset=UTF-8';R='Content-Type';Q=header;P='client_secret';N='client_id';H=api;D.timestamp=int(Af.time()*1000);F=D.timestamp
|
|
|
|
|
if D.keyCode is L:D.keyCode=Ah(32,16,2)
|
|
|
|
|
I=D.keyCode;K={'User-Agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Mobile Safari/537.36','Accept':S,R:S,'version':'1.0',G:Av,j:Z(F),'wsgwType':AY,'appKey':o};C=data
|
|
|
|
|
if H==B5:C={N:o,P:Ai};M=AL(A2(C),I);C={B:M+A1(M+Z(F)),AX:AM(I,'042BC7AD510BF9793B7744C8854C56A8C95DD1027EE619247A332EC6ED5B279F435A23D62441FE861F4B0C963347ECD5792F380B64CA084BE8BE41151F8B8D19C8'),N:o,j:Z(F)}
|
|
|
|
|
elif H==Aj:C={BM:A,'_t':A,'_data':C,j:F}
|
|
|
|
|
elif H==Ao:
|
|
|
|
|
C={N:o,'response_type':J,BN:'/test',j:F,'rsi':D.token};C=urllib.parse.urlencode(C);K[R]='application/x-www-form-urlencoded; charset=UTF-8';K[AH]=I
|
|
|
|
|
async with D.session.post(B4+H,data=C,headers=K)as O:D.session.cookie_jar.update_cookies(O.cookies);E=await O.json();E=B3(E[B],D.token);E=AK.loads(E);return E
|
|
|
|
|
elif H==AN:C={T:'authorization_code',U:A1(o+Z(F)),P:Ai,V:X,W:I,N:o,j:F,J:C[J]};M=AL(A2(C),I);C={B:M+A1(M+Z(F)),AX:AM(I,D.publicKey),j:Z(F)}
|
|
|
|
|
elif H==Ap:C={T:AZ,U:A1(o+Z(F)),P:Ai,V:X,W:I,N:o,j:F,AZ:D.refreshToken};M=AL(A2(C),I);C={B:M+A1(M+Z(F)),AX:AM(I,D.publicKey),j:Z(F)};H=AN
|
|
|
|
|
else:C=D.encrypt_post_data(C)
|
|
|
|
|
if Q is not L:K.update(Q)
|
|
|
|
|
if H in Bb:K['sessionId']=AY+Z(F)
|
|
|
|
|
if H in Bc:K[AH]=I
|
|
|
|
|
if H in Bd:K['Authorization']='Bearer '+D.accessToken[:t(D.accessToken)//2]
|
|
|
|
|
if H in Be:K['t']=D.token[:t(D.token)//2]
|
|
|
|
|
async with D.session.post(B4+H,json=C,headers=K)as O:
|
|
|
|
|
E=await O.text()
|
|
|
|
|
if E.startswith('{'):
|
|
|
|
|
E=AK.loads(E)
|
|
|
|
|
if Y in E:E=B3(E[Y],I);E=AK.loads(E)
|
|
|
|
|
return E
|
|
|
|
|
async def __get_request_key(A):
|
|
|
|
|
A.keyCode=_F;B=await A.__fetch(get_request_key_api,{});C=A.handle_request_result_message('get_request_key_api',B)
|
|
|
|
|
if B[_H]==_G:A.keyCode=B[_A][_AA];A.publicKey=B[_A][_AT];return{_C:0}
|
|
|
|
|
return{_C:1,_f:C}
|
|
|
|
|
async def __get_qr_code(B):
|
|
|
|
|
C={_J:{_Y:'',_W:_w,_V:_M,_Z:''},_u:{'optType':_a,_N:e(28,10,1)}};A=await B.__fetch(get_qr_code_api,C);D=B.handle_request_result_message('get_qr_code_api',A)
|
|
|
|
|
if A[_H]==1:
|
|
|
|
|
if A[_A]and A[_A][_S]and A[_A][_S][_A1]==_AJ:B.qrCodeSerial=A[_A][_l][_A_];E=A[_A][_l]['qrCode'];return{_C:0,_A:E}
|
|
|
|
|
return{_C:1,_f:D}
|
|
|
|
|
async def __get_qr_code_status(B):
|
|
|
|
|
C={_l:{_A_:B.qrCodeSerial}};D={_k:'98'+e(10,10,1)};A=await B.__fetch(get_qr_code_status_api,C,D);E=B.handle_request_result_message('get_qr_code_status_api',A)
|
|
|
|
|
if _H in A and A[_H]==1:
|
|
|
|
|
if _A in A and A[_A]!='null':B.token=A[_A];return{_C:0}
|
|
|
|
|
else:return{_C:1,_f:'未使用网上国网 App 扫码或确认登录'}
|
|
|
|
|
return{_C:1,_f:E}
|
|
|
|
|
A.keyCode=L;D=await A.fetch(B5,{});E=A.handle_request_result_message('get_request_key_api',D)
|
|
|
|
|
if D[J]==H:A.keyCode=D[B][AH];A.publicKey=D[B][A_];return{C:0}
|
|
|
|
|
return{C:1,i:E}
|
|
|
|
|
async def __get_qr_code(E):
|
|
|
|
|
F={M:{d:A,b:A3,a:O,e:A},A8:{'optType':g,P:Ah(28,10,1)}};D=await E.fetch(Aj,F);G=E.handle_request_result_message('get_qr_code_api',D)
|
|
|
|
|
if D[J]==1:
|
|
|
|
|
if D[B]and D[B][T]and D[B][T][A9]==Aa:E.qrCodeSerial=D[B][m][BO];H=D[B][m]['qrCode'];return{C:0,B:H}
|
|
|
|
|
return{C:1,i:G}
|
|
|
|
|
async def __get_qr_code_status(D):
|
|
|
|
|
E={m:{BO:D.qrCodeSerial}};F={r:'98'+Ah(10,10,1)};A=await D.fetch(Ak,E,F);G=D.handle_request_result_message('get_qr_code_status_api',A)
|
|
|
|
|
if J in A and A[J]==1:
|
|
|
|
|
if B in A and A[B]!='null':D.token=A[B];return{C:0}
|
|
|
|
|
else:return{C:1,i:'未使用网上国网 App 扫码或确认登录'}
|
|
|
|
|
return{C:1,i:G}
|
|
|
|
|
async def __get_qr_code_token(B):
|
|
|
|
|
C={_J:{_W:_w,_V:_M,'isEncrypt':_o},_k:B.token};A=await B.__fetch(get_qr_code_token_api,C);D=B.handle_request_result_message('get_qr_code_token_api',A)
|
|
|
|
|
if _S in A and _A1 in A[_S]and A[_S][_A1]==_AJ:B.userInfo=A[_l][_AG];return{_C:0}
|
|
|
|
|
return{_C:1,_f:D}
|
|
|
|
|
async def __send_code(B,phone):
|
|
|
|
|
C=phone;B.phone=C;D={_J:{_Y:'',_W:_w,_V:_M,_Z:''},_u:{'sendType':'0',_A7:C,_B0:'login','accountType':''},'Channels':'web'};A=await B.__fetch(send_code_api,D);E=B.handle_request_result_message('send_code_api',A)
|
|
|
|
|
if A[_H]==1:
|
|
|
|
|
if A[_A]and A[_A][_S]and A[_A][_S][_A1]==_AJ:B.codeKey=A[_A][_l]['codeKey'];return{_C:0}
|
|
|
|
|
return{_C:1,_f:E}
|
|
|
|
|
async def __verfiy_code(A,code):
|
|
|
|
|
C={_J:{_Y:'',_W:_w,_V:_M,_Z:''},_u:{_A7:A.phone,_B0:'login',_H:code,'optSys':'ios','pushId':'00000','codeKey':A.codeKey},'Channels':'web'};B=await A.__fetch(code_login_api,C);D=A.handle_request_result_message('code_login_api',B)
|
|
|
|
|
if _S in B and _A1 in B[_S]and B[_S][_A1]==_AJ:A.token=B[_l][_k];A.userInfo=B[_l][_AG][0];return{_C:0}
|
|
|
|
|
return{_C:1,_f:D}
|
|
|
|
|
async def __get_request_authorize(B):
|
|
|
|
|
A=await B.__fetch(get_request_authorize_api,{});E=B.handle_request_result_message('get_request_authorize_api',A)
|
|
|
|
|
if _H in A and A[_H]==_G:C=A[_A][_Az];D=C.rfind('code=');B.authorizeCode=C[D+5:D+5+32];return{_C:0}
|
|
|
|
|
return{_C:1,_f:E}
|
|
|
|
|
D={M:{b:A3,a:O,'isEncrypt':AV},r:B.token};A=await B.fetch(Al,D);E=B.handle_request_result_message('get_qr_code_token_api',A)
|
|
|
|
|
if T in A and A9 in A[T]and A[T][A9]==Aa:B.userInfo=A[m][AW];return{C:0}
|
|
|
|
|
return{C:1,i:E}
|
|
|
|
|
async def __send_code(E,phone):
|
|
|
|
|
F=phone;E.phone=F;G={M:{d:A,b:A3,a:O,e:A},A8:{'sendType':'0',u:F,BQ:'login','accountType':A},BP:AY};D=await E.fetch(Am,G);H=E.handle_request_result_message('send_code_api',D)
|
|
|
|
|
if D[J]==1:
|
|
|
|
|
if D[B]and D[B][T]and D[B][T][A9]==Aa:E.codeKey=D[B][m][BR];return{C:0}
|
|
|
|
|
return{C:1,i:H}
|
|
|
|
|
async def __verfiy_code(B,code):
|
|
|
|
|
E={M:{d:A,b:A3,a:O,e:A},A8:{u:B.phone,BQ:'login',J:code,'optSys':'ios','pushId':'00000',BR:B.codeKey},BP:AY};D=await B.fetch(An,E);F=B.handle_request_result_message('code_login_api',D)
|
|
|
|
|
if T in D and A9 in D[T]and D[T][A9]==Aa:B.token=D[m][r];B.userInfo=D[m][AW][0];return{C:0}
|
|
|
|
|
return{C:1,i:F}
|
|
|
|
|
async def __get_request_authorize(D):
|
|
|
|
|
A=await D.fetch(Ao,{});G=D.handle_request_result_message('get_request_authorize_api',A)
|
|
|
|
|
if J in A and A[J]==H:E=A[B][BN];F=E.rfind('code=');D.authorizeCode=E[F+5:F+5+32];return{C:0}
|
|
|
|
|
return{C:1,i:G}
|
|
|
|
|
async def __get_web_token(A):
|
|
|
|
|
C={_H:A.authorizeCode};B=await A.__fetch(get_web_token_api,C);D=A.handle_request_result_message('get_web_token_api',B)
|
|
|
|
|
if _H in B and B[_H]==_G:A.accessToken=B[_A][_B1];A.refreshToken=B[_A][_AI];return{_C:0}
|
|
|
|
|
return{_C:1,_f:D}
|
|
|
|
|
async def __refresh_web_token(B):
|
|
|
|
|
A=await B.__fetch(refresh_web_token_api,{});C=B.handle_request_result_message('refresh_web_token_api',A)
|
|
|
|
|
if _H in A and A[_H]==_G:B.accessToken=A[_A][_B1];B.refreshToken=A[_A][_AI];return{_C:0}
|
|
|
|
|
return{_C:1,_f:C}
|
|
|
|
|
async def __get_door_number(A):
|
|
|
|
|
B=configuration[_Al];G={_B:B[_B],_E:B[_E],_P:B[_P],_J:{_V:B[_J][_V],_Y:B[_J][_Y],_Z:B[_J][_Z],_W:B[_J][_W]},_u:{_R:A.userInfo[_R]},_k:A.token};C=await A.__fetch_safe(get_door_number_api,G);H=A.handle_request_result_message('get_door_number_api',C)
|
|
|
|
|
if _H in C and C[_H]==1 and _A in C and _l in C[_A]:
|
|
|
|
|
E={}
|
|
|
|
|
if A.powerUserList is not _F:E={A[_g]:A for A in A.powerUserList}
|
|
|
|
|
F=[]
|
|
|
|
|
for D in C[_A][_l][_AU]:
|
|
|
|
|
if D[_g]in E:F.append(E[D[_g]])
|
|
|
|
|
elif _AV in D and D[_AV]!='05':F.append(D)
|
|
|
|
|
A.powerUserList=F;return{_C:0}
|
|
|
|
|
return{_C:1,_f:H}
|
|
|
|
|
async def __get_door_balance(B,door_account):
|
|
|
|
|
A=door_account;E={_A:{_L:'',_N:'',_I:configuration[_A7][_I],_D:configuration[_A7][_D],_A2:B.userInfo[_R],_A3:B.userInfo.get(_AC,B.userInfo.get('nickname',_F)),_U:_G,_b:_G,_AW:B.userInfo[_R],_AB:[{'consNoSrc':A[_g],_AD:A.get(_X,A.get(_A4,_F)),'sceneType':A.get('consSortCode',A.get(_AV,_F)),_p:A[_p],_c:A[_c]}]},_B:'0101143',_E:configuration[_E],_P:A.get(_X,A.get(_A4,_F))};C=await B.__fetch_safe(get_door_balance_api,E);B.handle_request_result_message('get_door_balance_api',C)
|
|
|
|
|
if _H in C and C[_H]==1 and _A in C and _AB in C[_A]:
|
|
|
|
|
D=C[_A][_AB]
|
|
|
|
|
if len(D)!=0:A[_A5]=D[0]
|
|
|
|
|
async def __get_door_bill(C,door_account,monthDate):
|
|
|
|
|
I='dataInfo';G='mothEleList';E=monthDate;A=door_account;J={_A:{_A2:C.userInfo[_R],_I:configuration[_I],_e:'11',_AK:A[_B3],_D:'ALIPAY_01',_c:A[_c],_AD:A[_X],_b:_G,_U:_G,_N:'',_L:'',_A3:'',_B2:A[_X],_AW:C.userInfo[_R],_p:A[_p],_AX:E.year},_B:_A0,_E:_z,_P:A[_X]};B=await C.__fetch_safe(get_door_bill_api,J);C.handle_request_result_message('get_door_bill_api',B)
|
|
|
|
|
if _H in B and B[_H]==1 and _A in B:
|
|
|
|
|
if I in B[_A]:A[_AL]=B[_A][I]
|
|
|
|
|
if G in B[_A]:
|
|
|
|
|
if _AE not in A or A[_AE]!=E.year:A[_m]=B[_A][G];A[_AE]=E.year
|
|
|
|
|
else:
|
|
|
|
|
F={A.month:A for A in A[_m]};H=B[_A][G]
|
|
|
|
|
for D in H:
|
|
|
|
|
if D.month in F and _h in F[D.month]:D[_h]=F[D.month][_h]
|
|
|
|
|
A[_m]=H
|
|
|
|
|
if len(A[_m])>0:A[_v]=A[_m][-1]
|
|
|
|
|
async def __get_door_ladder(C,door_account,monthBill):
|
|
|
|
|
E=monthBill;A=door_account;I=A[_g];F=datetime.datetime.strptime(E[_AM],'%Y%m');G=f"{F.year}-{F.month:02d}";H={_A:{_I:configuration[_q][_I],_D:configuration[_q][_D],_U:configuration[_q][_U],_e:configuration[_q][_e],_p:A[_g],_b:A[_X],_c:A[_c],'queryDate':G,_B2:A[_X],_AK:A[_B3],_AW:C.userInfo[_R],_N:'',_L:'',_A3:C.userInfo[_AC],_A2:C.userInfo[_R]},_B:configuration[_q][_B],_E:configuration[_q][_E],_P:A[_X]};B=await C.__fetch(get_door_ladder_api,H);J=C.handle_request_result_message('get_door_ladder_api',B)
|
|
|
|
|
if _H in B and B[_H]==1 and _A in B and _AB in B[_A]:
|
|
|
|
|
D=B[_A][_AB]
|
|
|
|
|
if len(D)!=0:D=D[0];E['ladder']=D
|
|
|
|
|
async def __get_door_mouth_daily_bill(B,door_account,monthBill):
|
|
|
|
|
I=monthBill;C=door_account;A=datetime.datetime.strptime(I[_AM],'%Y%m');H=datetime.date(A.year,A.month,1)
|
|
|
|
|
if A.month==12:D=datetime.date(A.year+1,1,1)
|
|
|
|
|
else:D=datetime.date(A.year,A.month+1,1)
|
|
|
|
|
D=D-datetime.timedelta(days=1);O=f"{H.year}-{H.month:02d}-{H.day:02d}";P=f"{D.year}-{D.month:02d}-{D.day:02d}";Q={_AY:{_B:configuration[_B],_E:configuration[_E],_P:configuration[_P],_J:{_V:configuration[_J][_V],_Y:configuration[_J][_Y],_Z:configuration[_J][_Z],_W:configuration[_J][_W]},_u:{_R:B.userInfo[_R]},_k:B.token},_AZ:{_A:{_A2:B.userInfo[_R],_p:C[_g],_AK:_a,'endTime':P,_c:C[_c],_AX:str(A.year),_AD:C.get(_X,C.get(_A4,_F)),_N:'',_L:'',_B4:O,_A3:B.userInfo[_AC],_D:configuration[_T][_D],_I:configuration[_T][_I],_e:configuration[_T][_e],_b:configuration[_T][_b],_U:configuration[_T][_U]},_B:configuration[_T][_B],_E:configuration[_T][_E],_P:C.get(_X,C.get(_A4,_F))},_Aa:'010103'};E=await B.__fetch_safe(get_door_daily_bill_api,Q);R=B.handle_request_result_message(_B5,E)
|
|
|
|
|
if _H in E and E[_H]==1 and _A in E and _AN in E[_A]:
|
|
|
|
|
J=0;K=0;L=0;M=0;N=0
|
|
|
|
|
for F in E[_A][_AN]:S=datetime.datetime.strptime(F['day'],_Ab);J+=catchFloat(F,_AO);K+=catchFloat(F,_Ac);L+=catchFloat(F,_Ad);M+=catchFloat(F,_Ae);N+=catchFloat(F,_Af)
|
|
|
|
|
G={};G[_Ag]=normal_round(J,2);G[_Ah]=normal_round(K,2);G[_Ai]=normal_round(L,2);G[_Aj]=normal_round(M,2);G[_Ak]=normal_round(N,2);I[_h]=G
|
|
|
|
|
async def __get_door_daily_bill(B,door_account,year,start_date,end_date):
|
|
|
|
|
A=door_account;D={_AY:{_B:configuration[_B],_E:configuration[_E],_P:configuration[_P],_J:{_V:configuration[_J][_V],_Y:configuration[_J][_Y],_Z:configuration[_J][_Z],_W:configuration[_J][_W]},_u:{_R:B.userInfo[_R]},_k:B.token},_AZ:{_A:{_A2:B.userInfo[_R],_p:A[_g],_AK:_a,'endTime':end_date,_c:A[_c],_AX:year,_AD:A.get(_X,A.get(_A4,_F)),_N:'',_L:'',_B4:start_date,_A3:B.userInfo[_AC],_D:configuration[_T][_D],_I:configuration[_T][_I],_e:configuration[_T][_e],_b:configuration[_T][_b],_U:configuration[_T][_U]},_B:configuration[_T][_B],_E:configuration[_T][_E],_P:A.get(_X,A.get(_A4,_F))},_Aa:'010103'};C=await B.__fetch_safe(get_door_daily_bill_api,D);E=B.handle_request_result_message(_B5,C)
|
|
|
|
|
if _H in C and C[_H]==1 and _A in C and _AN in C[_A]:A[_A6]=C[_A][_AN]
|
|
|
|
|
async def __get_door_pay_record(A,door_account):B=door_account;D=B[_g];C={_AY:{_B:configuration[_B],_E:configuration[_E],_P:configuration[_P],_J:{_V:configuration[_J][_V],_Y:configuration[_J][_Y],_Z:configuration[_J][_Z],_W:configuration[_J][_W]},_u:{_R:A.userInfo[_R]},_k:A.token},_AZ:{_A:{_A2:A.userInfo[_R],'bgnPayDate':'2023-04-24',_I:configuration[_I],_p:B[_g],'endPayDate':'2024-04-24',_D:'webALIPAY_01','number':100,_c:B[_c],'page':_G,_AD:B[_X],_b:_G,_U:_G,_N:'',_L:'',_A3:A.userInfo[_AC]},_B:'0101051',_E:_a,_P:B[_X]},_Aa:'010104'};E=await A.__fetch(getJiaoFeiRecordApi,C)
|
|
|
|
|
E={J:A.authorizeCode};D=await A.fetch(AN,E);F=A.handle_request_result_message('get_web_token_api',D)
|
|
|
|
|
if J in D and D[J]==H:A.accessToken=D[B][BS];A.refreshToken=D[B][AZ];return{C:0}
|
|
|
|
|
return{C:1,i:F}
|
|
|
|
|
async def __refresh_web_token(D):
|
|
|
|
|
A=await D.fetch(Ap,{});E=D.handle_request_result_message('refresh_web_token_api',A)
|
|
|
|
|
if J in A and A[J]==H:D.accessToken=A[B][BS];D.refreshToken=A[B][AZ];return{C:0}
|
|
|
|
|
return{C:1,i:E}
|
|
|
|
|
async def __get_door_number(E):
|
|
|
|
|
H={D:F[D],G:F[G],V:F[V],M:{a:F[AE][M][a],d:F[AE][M][d],e:F[AE][M][e],b:F[AE][M][b]},A8:{U:E.userInfo[U]},r:E.token};A=await E.fetch(Aq,H);I=E.handle_request_result_message('get_door_number_api',A)
|
|
|
|
|
if J in A and A[J]==1 and B in A and m in A[B]:E.powerUserList=A[B][m][B0];return{C:0}
|
|
|
|
|
return{C:1,i:I}
|
|
|
|
|
async def __get_door_balance(L,door_account):
|
|
|
|
|
C=door_account;O={B:{N:A,P:A,I:F[u][I],E:F[u][E],AA:L.userInfo[U],AB:L.userInfo[AI],W:H,h:H,Ab:L.userInfo[U],AC:[{BT:C[s],AJ:C[X],BU:C[B1],n:C[n],c:C[c]}]},D:As,G:F[G],V:C[X]};K=await L.fetch(AO,O);L.handle_request_result_message('get_door_balance_api',K)
|
|
|
|
|
if J in K and K[J]==1 and B in K and AC in K[B]:
|
|
|
|
|
M=K[B][AC]
|
|
|
|
|
if t(M)!=0:C[Ac]=M[0]
|
|
|
|
|
async def __get_door_bill(L,door_account,year):
|
|
|
|
|
Q='dataInfo';M='mothEleList';C=door_account;O={B:{N:A,P:A,I:F[u][I],E:F[u][E],AA:L.userInfo[U],AB:L.userInfo[AI],W:H,h:H,Ab:L.userInfo[U],AC:[{BT:C[s],AJ:C[X],BU:C['consSortCode'],n:C[n],c:C[c]}]},D:As,G:F[G],V:C[X]};O={B:{AA:L.userInfo[U],I:F[I],l:'11',B2:C[B1],E:'ALIPAY_01',c:C[c],AJ:C[X],h:H,W:H,P:A,N:A,AB:A,BV:C[X],Ab:L.userInfo[U],n:C[n],BW:year},D:A7,G:A6,V:C[X]};K=await L.fetch(AP,O);L.handle_request_result_message('get_door_bill_api',K)
|
|
|
|
|
if J in K and K[J]==1 and B in K:
|
|
|
|
|
if Q in K[B]:C[Ad]=K[B][Q]
|
|
|
|
|
if M in K[B]:C[AD]=K[B][M];C[Ae]=K[B][M][-1]['month']
|
|
|
|
|
async def __get_door_ladder(H,door_account,month):
|
|
|
|
|
O='ladder_flag';M=month;C=door_account;Q=C[s];R={B:{I:F[v][I],E:F[v][E],W:F[v][W],l:F[v][l],n:C[s],h:C[X],c:C[c],'queryDate':M,BV:C[X],B2:C[B1],Ab:H.userInfo[U],P:A,N:A,AB:H.userInfo[AI],AA:H.userInfo[U]},D:F[v][D],G:F[v][G],V:C[X]};K=await H.fetch(AQ,R);S=H.handle_request_result_message('get_door_ladder_api',K)
|
|
|
|
|
if J in K and K[J]==1 and B in K and AC in K[B]:
|
|
|
|
|
L=K[B][AC]
|
|
|
|
|
if t(L)!=0:
|
|
|
|
|
L=L[0];L['month']=M
|
|
|
|
|
if L['electricParticulars']['levelFlag']=='2':C[O]=1
|
|
|
|
|
else:C[O]=0
|
|
|
|
|
H.doorAccountDict[Q]['ladder']=L
|
|
|
|
|
async def __get_door_daily_bill(C,door_account,year,start_date,end_date):
|
|
|
|
|
L='sevenEleList';K=door_account;O={BX:{D:F[D],G:F[G],V:F[V],M:{a:F[M][a],d:F[M][d],e:F[M][e],b:F[M][b]},A8:{U:C.userInfo[U]},r:C.token},BY:{B:{AA:C.userInfo[U],n:K[s],B2:g,'endTime':end_date,c:K[c],BW:year,AJ:K[X],P:A,N:A,'startTime':start_date,AB:C.userInfo[AI],E:F[p][E],I:F[p][I],l:F[p][l],h:F[p][h],W:F[p][W]},D:F[p][D],G:F[p][G],V:K[X]},BZ:'010103'};H=await C.fetch(AS,O);Q=C.handle_request_result_message('get_door_daily_bill_api',H)
|
|
|
|
|
if J in H and H[J]==1 and B in H and L in H[B]:K[Y]=H[B][L]
|
|
|
|
|
async def __get_door_pay_record(C,door_account):J=door_account;L=J[s];K={BX:{D:F[D],G:F[G],V:F[V],M:{a:F[M][a],d:F[M][d],e:F[M][e],b:F[M][b]},A8:{U:C.userInfo[U]},r:C.token},BY:{B:{AA:C.userInfo[U],'bgnPayDate':'2023-04-24',I:F[I],n:J[s],'endPayDate':'2024-04-24',E:'webALIPAY_01','number':100,c:J[c],'page':H,AJ:J[X],h:H,W:H,P:A,N:A,AB:C.userInfo[AI]},D:'0101051',G:g,V:J[X]},BZ:'010104'};O=await C.fetch(AR,K)
|
|
|
|
|
async def get_qr_code(B):
|
|
|
|
|
A=await B.__get_request_key()
|
|
|
|
|
if _C in A and A[_C]!=0:return A
|
|
|
|
|
if C in A and A[C]!=0:return A
|
|
|
|
|
return await B.__get_qr_code()
|
|
|
|
|
async def check_qr_code(B):
|
|
|
|
|
A=await B.__get_qr_code_status()
|
|
|
|
|
if _C in A and A[_C]!=0:return A
|
|
|
|
|
if C in A and A[C]!=0:return A
|
|
|
|
|
A=await B.__get_qr_code_token()
|
|
|
|
|
if _C in A and A[_C]!=0:return A
|
|
|
|
|
if C in A and A[C]!=0:return A
|
|
|
|
|
return await B.__get_token()
|
|
|
|
|
async def send_phone_code(B,phone):
|
|
|
|
|
A=await B.__get_request_key()
|
|
|
|
|
if _C in A and A[_C]!=0:return A
|
|
|
|
|
if C in A and A[C]!=0:return A
|
|
|
|
|
return await B.__send_code(phone)
|
|
|
|
|
async def verfiy_phone_code(B,code):
|
|
|
|
|
A=await B.__verfiy_code(code)
|
|
|
|
|
if _C in A and A[_C]!=0:return A
|
|
|
|
|
if C in A and A[C]!=0:return A
|
|
|
|
|
return await B.__get_token()
|
|
|
|
|
async def __get_token(B):
|
|
|
|
|
A=await B.__get_request_key()
|
|
|
|
|
if _C in A and A[_C]!=0:return A
|
|
|
|
|
A=await B.__get_request_authorize()
|
|
|
|
|
if _C in A and A[_C]!=0:return A
|
|
|
|
|
A=await B.__get_web_token()
|
|
|
|
|
if _C in A and A[_C]!=0:return A
|
|
|
|
|
A=await B.__get_door_number()
|
|
|
|
|
if _C in A and A[_C]!=0:return A
|
|
|
|
|
B.need_login=_i;await B.save_data();return{_C:0,_A:B.powerUserList}
|
|
|
|
|
async def __refresh_token(A):
|
|
|
|
|
B=await A.__get_request_key()
|
|
|
|
|
if _C in B and B[_C]!=0:return
|
|
|
|
|
B=await A.__refresh_web_token()
|
|
|
|
|
if _C in B and B[_C]==0:A.need_login=_i;A.retry_times=0;await A.save_data()
|
|
|
|
|
elif A.retry_times>=3:A.need_login=_o
|
|
|
|
|
else:A.retry_times=A.retry_times+1
|
|
|
|
|
async def refresh_data(B,setup=_i,force_refresh=_i):
|
|
|
|
|
p='last_month_ele_cost';o='year_ele_cost';n='%Y-%m-%d %H:%M:%S';b=setup;a='last_month_ele_num';Z='daily_lasted_date';Y='refresh_time';U='year_ele_num';G='balance'
|
|
|
|
|
if b is _o:
|
|
|
|
|
if B.dataVersion!=VERSION:B.powerUserList=_F
|
|
|
|
|
c=await B.__get_door_number()
|
|
|
|
|
if _C in c and c[_C]!=0:B.need_login=_o
|
|
|
|
|
if B.need_login is _o:
|
|
|
|
|
if B.powerUserList is not _F:
|
|
|
|
|
for A in B.get_door_account_list():A[Y]='Token刷新失败,请重新登录'
|
|
|
|
|
LOGGER.error('国家电网 - Token刷新失败,请重新登录!');return
|
|
|
|
|
q=b or force_refresh or int(time.time()*1000)-B.timestamp>B.refresh_interval*3600*1000
|
|
|
|
|
if q is _i:return
|
|
|
|
|
H=datetime.datetime.now();F=H-datetime.timedelta(days=1);d=f"{F.year}-{F.month:02d}-{F.day:02d}";V=F-datetime.timedelta(days=40);r=f"{V.year}-{V.month:02d}-{V.day:02d}"
|
|
|
|
|
async def __get_token(D):
|
|
|
|
|
A=await D.__get_request_key()
|
|
|
|
|
if C in A and A[C]!=0:return A
|
|
|
|
|
A=await D.__get_request_authorize()
|
|
|
|
|
if C in A and A[C]!=0:return A
|
|
|
|
|
A=await D.__get_web_token()
|
|
|
|
|
if C in A and A[C]!=0:return A
|
|
|
|
|
A=await D.__get_door_number()
|
|
|
|
|
if C in A and A[C]!=0:return A
|
|
|
|
|
D.need_login=z;await D.save_data();return{C:0,B:D.powerUserList}
|
|
|
|
|
async def refresh_data(B,setup=z):
|
|
|
|
|
q='daily_t_ele_num';p='daily_n_ele_num';o='daily_v_ele_num';n='daily_p_ele_num';m='daily_ele_num';l='last_month_ele_cost';j='last_month_ele_num';i='year_ele_cost';h='year_ele_num';g='monthEleNum';f='thisTPq';e='thisNPq';d='thisVPq';c='thisPPq';S='balance';Q='ladder_level_num';P='ladder_level';L='%Y%m%d';K='day';I='dayElePq';r=setup or int(Af.time()*1000)-B.timestamp>B.refresh_interval*3600*1000
|
|
|
|
|
if r is z:return
|
|
|
|
|
E=await B.__get_door_number()
|
|
|
|
|
if C in E and E[C]!=0:
|
|
|
|
|
A0.warning('刷新 Token');E=await B.__get_request_key()
|
|
|
|
|
if C in E and E[C]!=0:return
|
|
|
|
|
E=await B.__refresh_web_token()
|
|
|
|
|
if C in E and E[C]==0:await B.save_data()
|
|
|
|
|
else:B.need_login=AV;A0.error('刷新 Token 失败');return
|
|
|
|
|
E=await B.__get_door_number()
|
|
|
|
|
if C in E and E[C]!=0:B.need_login=AV;A0.error('重新请求失败');return
|
|
|
|
|
T=k.datetime.now();J=T-k.timedelta(days=1);u=f"{J.year}-{J.month:02d}-{J.day:02d}";M=J-k.timedelta(days=40);v=f"{M.year}-{M.month:02d}-{M.day:02d}"
|
|
|
|
|
for A in B.powerUserList:
|
|
|
|
|
s=A[_g];B.doorAccountDict[s]=A
|
|
|
|
|
if Z in A and A[Z]==d:A[Y]=datetime.datetime.strftime(H,n);continue
|
|
|
|
|
await B.__get_door_balance(A)
|
|
|
|
|
if B.retry_times!=0:return
|
|
|
|
|
if _A5 in A:
|
|
|
|
|
t=catchFloat(A[_A5],'estiAmt');W=catchFloat(A[_A5],'prepayBal');e=catchFloat(A[_A5],'sumMoney')
|
|
|
|
|
if W==0 or W==e:A[G]=e
|
|
|
|
|
else:A[G]=W-t
|
|
|
|
|
f=catchFloat(A[_A5],'historyOwe')
|
|
|
|
|
if f>0:A[G]=-f
|
|
|
|
|
else:LOGGER.error('国家电网账户余额获取失败!')
|
|
|
|
|
if G not in A:A[G]=0
|
|
|
|
|
await B.__get_door_daily_bill(A,H.year,r,d)
|
|
|
|
|
if _A6 not in A:LOGGER.error('国家电网无法获取日用电数据!');continue
|
|
|
|
|
X=0;I=_i
|
|
|
|
|
for g in range(10):
|
|
|
|
|
D=A[_A6][g]
|
|
|
|
|
try:float(D[_AO]);I=_o;break
|
|
|
|
|
except:X=X+1
|
|
|
|
|
h=0;i=0;j=0;k=0;l=0
|
|
|
|
|
if I:
|
|
|
|
|
for g in range(X):A[_A6].pop(0)
|
|
|
|
|
D=A[_A6][0];E=datetime.datetime.strptime(D['day'],_Ab);A[Z]=f"{E.year}-{E.month:02d}-{E.day:02d}";h=catchFloat(D,_AO);i=catchFloat(D,_Ac);j=catchFloat(D,_Ad);k=catchFloat(D,_Ae);l=catchFloat(D,_Af)
|
|
|
|
|
A['daily_ele_num']=normal_round(h,2);A['daily_p_ele_num']=normal_round(i,2);A['daily_v_ele_num']=normal_round(j,2);A['daily_n_ele_num']=normal_round(k,2);A['daily_t_ele_num']=normal_round(l,2);J=0;K=0;L=0;M=0;N=0
|
|
|
|
|
if I:
|
|
|
|
|
for C in A[_A6]:
|
|
|
|
|
u=datetime.datetime.strptime(C['day'],_Ab)
|
|
|
|
|
if u.month!=E.month:break
|
|
|
|
|
J+=catchFloat(C,_AO);K+=catchFloat(C,_Ac);L+=catchFloat(C,_Ad);M+=catchFloat(C,_Ae);N+=catchFloat(C,_Af)
|
|
|
|
|
A[_Ag]=normal_round(J,2);A[_Ah]=normal_round(K,2);A[_Ai]=normal_round(L,2);A[_Aj]=normal_round(M,2);A[_Ak]=normal_round(N,2)
|
|
|
|
|
if I:
|
|
|
|
|
O=E-datetime.timedelta(days=E.day);v=f"{O.year}{O.month:02d}"
|
|
|
|
|
if _AE not in A or A[_AE]!=O.year or _v not in A or A[_v][_AM]!=v:await B.__get_door_bill(A,O)
|
|
|
|
|
if _m in A:
|
|
|
|
|
for C in A[_m]:
|
|
|
|
|
if _h not in C:await B.__get_door_mouth_daily_bill(A,C)
|
|
|
|
|
if _AL in A:A[U]=catchFloat(A[_AL],'totalEleNum');A[o]=catchFloat(A[_AL],'totalEleCost')
|
|
|
|
|
if U not in A:A[U]=0;A[o]=0
|
|
|
|
|
if _v in A:A[a]=catchFloat(A[_v],'monthEleNum');A[p]=catchFloat(A[_v],'monthEleCost');m=datetime.datetime.strptime(A[_v][_AM],'%Y%m')
|
|
|
|
|
if a not in A:A[a]=0;A[p]=0;m=F.month
|
|
|
|
|
P=0;Q=0;R=0;S=0;T=0
|
|
|
|
|
if m.month==12:P=J;Q=K;R=L;S=M;T=N
|
|
|
|
|
w=A[s];B.doorAccountDict[w]=A;await B.__get_door_balance(A);await B.__get_door_daily_bill(A,T.year,v,u);N=A[Y][0]
|
|
|
|
|
try:float(N[I])
|
|
|
|
|
except:A[Y].pop(0)
|
|
|
|
|
N=A[Y][0];F=k.datetime.strptime(N[K],L);U=0;V=0;W=0;X=0;Z=0
|
|
|
|
|
for D in A[Y]:
|
|
|
|
|
H=k.datetime.strptime(D[K],L)
|
|
|
|
|
if H.month!=F.month:break
|
|
|
|
|
U+=R(D,I);V+=R(D,c);W+=R(D,d);X+=R(D,e);Z+=R(D,f)
|
|
|
|
|
O=F-k.timedelta(days=F.day);a=f"{O.year}-{O.month:02d}"
|
|
|
|
|
if Ae not in A or A[Ae]!=a:await B.__get_door_bill(A,O.year);await B.__get_door_ladder(A,a)
|
|
|
|
|
x=k.datetime.strptime(A[Ae],'%Y%m')
|
|
|
|
|
if x.month==12:
|
|
|
|
|
G=0
|
|
|
|
|
for D in A[Y]:
|
|
|
|
|
H=k.datetime.strptime(D[K],L)
|
|
|
|
|
if H.month!=12:break
|
|
|
|
|
G+=R(D,I)
|
|
|
|
|
else:
|
|
|
|
|
if _m in A:
|
|
|
|
|
for C in A[_m]:
|
|
|
|
|
if _h in C:P+=C[_h][_Ag];Q+=C[_h][_Ah];R+=C[_h][_Ai];S+=C[_h][_Aj];T+=C[_h][_Ak]
|
|
|
|
|
P+=J;Q+=K;R+=L;S+=M;T+=N
|
|
|
|
|
A[U]=normal_round(P,2);A['year_p_ele_num']=normal_round(Q,2);A['year_v_ele_num']=normal_round(R,2);A['year_n_ele_num']=normal_round(S,2);A['year_t_ele_num']=normal_round(T,2);A[Y]=datetime.datetime.strftime(H,n)
|
|
|
|
|
G=0
|
|
|
|
|
for D in A[AD]:G+=R(D,g)
|
|
|
|
|
y=t(A[AD])
|
|
|
|
|
for D in A[Y]:
|
|
|
|
|
H=k.datetime.strptime(D[K],L)
|
|
|
|
|
if H.month<=y:break
|
|
|
|
|
G+=R(D,I)
|
|
|
|
|
if G<=2760:A[P]='第一阶梯';A[Q]=1
|
|
|
|
|
elif G<=4800:A[P]='第二阶梯';A[Q]=2
|
|
|
|
|
else:A[P]='第三阶梯';A[Q]=3
|
|
|
|
|
if Ac in A:
|
|
|
|
|
A[S]=R(A[Ac],'prepayBal');b=R(A[Ac],'historyOwe')
|
|
|
|
|
if b>0:A[S]=-b
|
|
|
|
|
else:A[S]=0
|
|
|
|
|
if Ad in A:A[h]=R(A[Ad],'totalEleNum');A[i]=R(A[Ad],'totalEleCost')
|
|
|
|
|
else:A[h]=0;A[i]=0
|
|
|
|
|
if AD in A:A[j]=R(A[AD][-1],g);A[l]=R(A[AD][-1],'monthEleCost')
|
|
|
|
|
else:A[j]=0;A[l]=0
|
|
|
|
|
if Y in A:A[m]=R(A[Y][0],I);A[n]=R(A[Y][0],c);A[o]=R(A[Y][0],d);A[p]=R(A[Y][0],e);A[q]=R(A[Y][0],f)
|
|
|
|
|
else:A[m]=0;A[n]=0;A[o]=0;A[p]=0;A[q]=0
|
|
|
|
|
A['month_ele_num']=U;A['month_p_ele_num']=V;A['month_v_ele_num']=W;A['month_n_ele_num']=X;A['month_t_ele_num']=Z;A['daily_lasted_date']=f"{F.year}-{F.month:02d}-{F.day:02d}"
|
|
|
|
|
await B.save_data()
|
|
|
|
|
def get_door_account_list(A):return list(A.doorAccountDict.values())
|
|
|
|
|
async def get_door_account_list(A):return list(A.doorAccountDict.values())
|
|
|
|
|
def get_door_account(A):return A.doorAccountDict
|