-
Notifications
You must be signed in to change notification settings - Fork 188
/
YHSH.py
executable file
·1163 lines (1069 loc) · 44.8 KB
/
YHSH.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'''
!/usr/bin/python3
-- coding: utf-8 --
-------------------------------
✨✨✨ @Author CHERWIN✨✨✨
cron "51 8,21 * * *" script-path=xxx.py,tag=匹配cron用
const $ = new Env('永辉生活')
'''
import hashlib
import json
import os
import random
import time
import urllib
from os import environ, path
from sys import exit
from urllib.parse import quote, urlparse, parse_qs
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
# 禁用安全请求警告
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
IS_DEV = False
if os.path.isfile('DEV_ENV.py'):
import DEV_ENV
IS_DEV = True
if os.path.isfile('notify.py'):
from notify import send
print("加载通知服务成功!")
else:
print("加载通知服务失败!")
send_msg = ''
one_msg=''
def Log(cont=''):
global send_msg,one_msg
print(cont)
if cont:
one_msg += f'{cont}\n'
send_msg += f'{cont}\n'
inviteCode = {}
GameCode=[]
PRIZEID = ''
class RUN:
def __init__(self, info,index):
global one_msg
one_msg = ''
split_info = info.split('@')
token = split_info[0]
len_split_info = len(split_info)
last_info = split_info[len_split_info - 1]
self.send_UID =None
if len_split_info > 0 and "UID_" in last_info:
self.send_UID = last_info
self.index = index + 1
self.s = requests.session()
self.s.verify = False
self.UA = 'Mozilla/5.0 (Linux; Android 11; Mi9 Pro 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/113.0.5672.162 Mobile Safari/537.36YhStore/9.6.0.14 cn.yonghui.hyd/2022946000 (client/phone; Android 30; Xiaomi/Mi9 Pro 5G)'
self.headers = {
'Host': 'api.yonghuivip.com',
'Connection': 'keep-alive',
'User-Agent': self.UA,
'X-YH-Context': 'origin=h5&morse=1',
'Accept': '*/*',
'Origin': 'https://m.yonghuivip.com',
'X-Requested-With': 'cn.yonghui.hyd',
'Sec-Fetch-Site': 'same-site',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Referer': 'https://m.yonghuivip.com/',
# 'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
}
# 创建一个字典来存储参数
data = {}
# 解析第一个URL并提取参数
parsed_url1 = urlparse(token)
# print(parsed_url1)
self.data_dict = parse_qs(parsed_url1.query)
# print(self.data_dict)
self.url_add = token.split('?')[1]
# print(self.data_dict)
self.fruit_is_ripe = False
self.gameCode =''
if self.data_dict.get('memberid') :
self.memberId = self.data_dict.get('memberid',[])[0]
else:
self.memberId = self.data_dict.get('memberId', [])[0]
if self.data_dict.get('shopid') :
self.shopid = self.data_dict.get('shopid',[])[0]
else:
self.shopid = '9M7M'
self.url_add =f'{self.url_add}&shopid={self.shopid}'
print(self.shopid)
self.gamecode_li = []
self.canJoinTeam = True
self.canhelp_coup = True
self.teamCode = ''
# 将参数转换为字典
def create_dict_from_string(self, data_string):
params = {}
key_value_pairs = data_string.split(',')
for pair in key_value_pairs:
key, value = pair.split('=')
params[key] = value
return params
# 发送请求函数
def do_request(self, url, data={}, req_type='post', headers={}):
if headers == {}:
headers = self.headers
try:
if req_type.lower() == 'get':
response = self.s.get(url, headers=headers)
elif req_type.lower() == 'post':
response = self.s.post(url, headers=headers, json=data)
else:
raise ValueError('Invalid req_type: %s' % req_type)
res = response.json()
return res
except requests.exceptions.RequestException as e:
print('Request failed:', e)
return None
except json.JSONDecodeError as e:
print('JSON decoding failed:', e)
return None
def getCredit(self):
Log(f'\n>>>>>>获取积分信息')
headers = {
'Accept': '*/*'
}
url = f'https://api.yonghuivip.com/web/coupon/credit/details/?page=0&{self.url_add}'
response = self.do_request(url, req_type='get', headers=headers)
# print(response)
if 'code' in response and response.get('code','') == 0:
credit = response.get('data')['credit']
self.sign_count = response.get('data')['count']
Log(f'>当前用户:{self.memberId}\n>当前积分:{credit}')
# Log(f'>>>累计签到:{self.sign_count}天')
return True
elif response.get("message", "") == '登录状态已失效,请重新登录':
if send:send('永辉生活账号失效通知', f'账号:{self.index} ID:{self.memberId}已失效,请重新抓包')
else:
Log(f'>获取积分信息失败')
# print(response)
return False
def sign(self):
Log(f'\n>>>>>>开始执行签到')
headers = {
'Accept': 'application/json'
}
data = {
"memberId": self.memberId,
"shopid": self.shopid,
"missionid": "39"
}
url = f'https://api.yonghuivip.com/web/coupon/signreward/sign?{self.url_add}'
response = self.do_request(url, headers=headers,data=data)
# print(response)
if 'code' in response and response.get('code') == 0:
Log(f'>签到成功')
Log(f'>累计签到:{int(self.sign_count) + 1}天')
self.getCredit()
return True
elif '任务已完成,请勿重复点击' in response:
Log(f'>今日已签到')
else:
Log(f'>签到失败,{response.get("message")}')
return False
def teamDetail(self):
Log(f'\n>>>>>>开始获取组队详情')
headers = {
'Accept': 'application/json'
}
data = {
"createTeamFlag": True,
"shopId": self.shopid,
}
url = f'https://api.yonghuivip.com/web/coupon/credit/dividePoint/teamDetail?{self.url_add}'
response = self.do_request(url, headers=headers,data=data)
# print(response)
if 'code' in response and response.get('code') == 0:
data = response.get('data',{})
if data != {}:
self.teamCode = data.get('teamCode','')
subTitle = data.get('subTitle','')
print(f'战队ID:【{self.teamCode}】 状态:【{subTitle}】')
new_data={
self.memberId:{
'teamCode':self.teamCode
}
}
inviteCode.update(new_data)
print(inviteCode)
else:
print('未查询到战队,开始创建')
self.creatTeam()
else:
print(f'>创建战队失败,{response.get("message")}')
def creatTeam(self):
Log(f'\n>>>>>>开始组队任务')
headers = {
'Accept': 'application/json'
}
data = {
"shopId": self.shopid,
}
url = f'https://api.yonghuivip.com/web/coupon/credit/dividePoint/createTeam?{self.url_add}'
response = self.do_request(url, headers=headers,data=data)
# print(response)
if 'code' in response and response.get('code') == 0:
data = response.get('data',{})
self.teamCode = data.get('teamCode', '')
subTitle = data.get('subTitle', '')
Log(f'创建战队成功,ID:【{self.teamCode}】 状态:【{subTitle}】')
new_data = {
self.memberId: {
'teamCode': self.teamCode
}
}
inviteCode.update(new_data)
else:
print(f'>创建战队失败,{response.get("message")}')
def joinAuthorTeam(self):
print(f'>>>开始加入作者队伍')
headers = {
'Accept': 'application/json'
}
if len(AuthorCode) >0 :
for code in AuthorCode:
if not self.canJoinTeam:break
data = {
"teamCode": code.get('teamCode'),
"shopId": self.shopid
}
url = f'https://api.yonghuivip.com/web/coupon/credit/dividePoint/joinTheParty?{self.url_add}'
response = self.do_request(url, headers=headers, data=data)
if 'code' in response and response.get('code') == 0:
print(f'加入战队成功')
break
elif response.get('message') == '达到1天内组队上限':
self.canJoinTeam = False
def joinTeam(self):
Log(f'>>>开始本地账号组队')
headers = {
'Accept': 'application/json'
}
inviteCode_li = list(inviteCode.values())
# print(inviteCode_li)
for code in inviteCode_li:
if not self.canJoinTeam:
print('达到1天内组队上限')
break
data = {
"teamCode": code.get('teamCode'),
"shopId": self.shopid
}
url = f'https://api.yonghuivip.com/web/coupon/credit/dividePoint/joinTheParty?{self.url_add}'
response = self.do_request(url, headers=headers, data=data)
if 'code' in response and response.get('code') == 0:
Log(f'组队成功')
break
elif response.get("message","") == '会员专享功能,请先登录':
break
elif response.get('message') == '达到1天内组队上限':
self.canJoinTeam = False
else:
Log(f'>组队失败,{response.get("message")}')
def farmInfo(self):
headers = {
'Accept': '*/*'
}
url = f'https://activity.yonghuivip.com/api/web/flow/farm/info?{self.url_add}'
response = self.do_request(url, headers=headers, req_type='get')
# print(response)
if 'code' in response and response.get('code') == 0:
self.parentId = response.get('data',[])['parentId']
self.memberAmount = response.get('data',[])['memberAmount']
self.ladderText = response.get('data',[]).get('ladderText','')
Log(f'>>>当前水滴:{self.memberAmount}')
Log(f'>>>当前水果进度:{self.ladderText}')
if self.ladderText == '再浇水0%,果树就要成熟了':
self.fruit_is_ripe = True
inviteCode[self.memberId]['fruit_is_ripe'] = self.fruit_is_ripe
return True
else:
Log(f'>>>获取果园信息失败\n{response}')
return False
def plantFruit_sign(self):
Log(f'>>>开始果园签到')
headers = {
'Accept': 'application/json'
}
data = {
"taskType": "sign",
"activityCode": "HXNC-QG",
"shopId": "",
"channel": ""
}
url = f'https://activity.yonghuivip.com/api/web/flow/farm/doTask?{self.url_add}'
response = self.do_request(url, headers=headers, data=data)
# print(response)
if 'code' in response and response.get('code') == 0:
signText = response.get('data')['signText']
Log(f'>>>{signText}')
return True
else:
Log(f'>>>果园签到失败\n{response}')
return False
def plantFruit_getTaskList(self):
print(f'>>>获取任务列表')
headers = {
'Accept': '*/*'
}
url = f'https://activity.yonghuivip.com/api/web/flow/farm/task/list?activityCode=HXNC-QG&&parentId={self.parentId}&{self.url_add}'
response = self.do_request(url, headers=headers, req_type='get')
# print(response)
if 'code' in response and response.get('code') == 0:
data = response.get('data')
for i in data:
subType = i['subType']
title = i['title']
finished = i['finished']
self.taskId = i['taskId']
self.rewardid = i.get('rewardId', '')
# print(self.rewardid)
if subType == 'activityPage' and finished != 1:
actionUrl = i['actionUrl']
# 解码URL
decoded_url = urllib.parse.unquote(actionUrl)
decoded_url = decoded_url.replace('pid=null', f'pid={self.parentId}')
# print(decoded_url)
parsed_url = urllib.parse.urlparse(decoded_url)
query_params = urllib.parse.parse_qs(parsed_url.query)
self.aid = query_params.get("aid", [None])[0]
self.taskid = query_params.get("taskid", [None])[0]
# print(self.aid)
# 提取aid后面的字符串
index = decoded_url.find("&aid=")
if index != -1:
toUrl = f'?aid={decoded_url[index + 5:]}'
else:
toUrl = ""
self.doFruitTask(title, toUrl)
if self.rewardid != '':
print('检测到有可收取任务')
self.receive_water()
return True
else:
print(response)
return False
def doFruitTask(self, title, toUrl):
print(f'>>>开始做任务{title}')
params = {"platform": "android",
"v": "9.6.0.14",
"channel": "2",
"distinctId": "",
"proportion": 2.75,
"screen": "1080.75*2340.25",
"pagesize": 6,
"networkType": "wifi",
"aid": self.aid,
"versionpro": "2",
"appType": "h5",
"model": "Mi9 Pro 5G",
"os": "android",
"osVersion": "android30",
"channelSub": "",
"brand": "Xiaomi",
"productLine": "YhStore",
"salesChannel": "",
"deviceid": "",
"sellerid": "7",
"shopid": "90B3",
"uid": "",
"access_token": "",
"showmultiseller": "",
"shopName": "",
"isOldEdition": False,
"userid": "",
"pageid": self.aid,
"pid": self.parentId,
"taskid": self.taskid,
"sceneValue": "4",
"memberId": ""
}
headers = {
'Accept': 'application/json, text/plain, */*',
"Content-Type": "application/json;charset=UTF-8",
"Connection": "keep-alive",
"Connection": "keep-alive"
}
url = f'https://api.yonghuivip.com/web/coupon/dailyreward/browse{toUrl}&{self.url_add}'
response = self.do_request(url, headers=headers, data=params)
# print(response)
if 'code' in response and response.get('code') == 0:
data = response.get('data')['title']
Log(f'>{data}')
return True
else:
return False
def receive_inviteWater(self):
headers = {
'Accept': '*/*'
}
url = f'https://activity.yonghuivip.com/api/web/flow/farm/invitation/bubble?activityCode=HXNC-QG&{self.url_add}'
# print(url)
response =self.do_request(url, headers=headers,req_type='get')
# print(response)
if 'code' in response and response.get('code') == 0:
data = response['data']['inviteWaterBubble']
if data != []:
Log(f'>>>开始领取邀请奖励')
for task in data:
url = f'https://activity.yonghuivip.com/api/web/flow/farm/receiveWater?{self.url_add}'
headers = {
"Content-Type": "application/json",
"Accept": "application/json"
}
data = {"taskId": task['taskId'], "id": task['rewardId'], "activityCode": "HXNC-QG"}
response = requests.post(url, headers=headers, json=data,verify=False).json()
if 'code' in response and response.get('code') == 0:
receiveAmount = response['data']['receiveAmount']
print(f'>成功收取【{receiveAmount}】水滴')
else:
print(f'>收取失败,{response}')
else:
print('>没有可领取的邀请奖励')
else:
print(f'>领取邀请奖励失败,{response}')
def receive_water(self,taskType=None):
print(f'>>>开始领取奖励')
headers = {
"Content-Type": "application/json",
"Accept": "application/json"
}
data = {
"taskId": self.taskId,
"id": self.rewardid,
"activityCode": "HXNC-QG"}
if taskType != None:
data['taskType'] = "activityPage"
url = f'https://activity.yonghuivip.com/api/web/flow/farm/receiveWater?{self.url_add}'
# print(url)
response =self.do_request(url, headers=headers, data=data)
# response =requests.post(url, headers=headers, json=data)
# if response:
# response = response.json()
if 'code' in response and response.get('code') == 0:
receiveAmount = response['data']['receiveAmount']
print(f'>成功收取【{receiveAmount}】水滴')
else:
print(f'>收取失败,{response}')
def watering(self):
self.farmInfo()
if int(self.memberAmount / 10) > 1 :
print(f'>>>开始浇水')
headers = {
'Accept': 'application/json'
}
data = {"activityCode": "HXNC-QG", "shopId": "", "channel": "", "inviteTicket": "", "inviteShopId": ""}
url = f'https://activity.yonghuivip.com/api/web/flow/farm/watering?{self.url_add}'
for i in range(int(self.memberAmount / 10)):
response = self.do_request(url, headers=headers, data=data)
# print(response.text)
if 'code' in response and response.get('code') == 0:
print(f'>第{i + 1}次浇水成功')
elif response.get('message') == '果树已经成熟啦,快去领取奖励吧':
print(f'>果树已经成熟啦')
self.fruit_is_ripe = True
inviteCode[self.memberId]['fruit_is_ripe'] = self.fruit_is_ripe
break
else:
print(f'>浇水失败,{response}')
else:
print('>水滴不足,停止浇水')
def get_inviteTicket(self):
print(f'>>>开始获取果园邀请码')
headers = {
'Accept': 'application/json'
}
data = {"inviteAction": "802"}
url = f'https://activity.yonghuivip.com/api/web/flow/farm/invite/ticket?{self.url_add}'
response = self.do_request(url, headers=headers, data=data)
# print(response)
if 'code' in response and response.get('code','') == 0:
self.inviteTicket = response.get('data')
print(f'果园邀请码:{self.inviteTicket}')
inviteCode[self.memberId]['inviteCode']=self.inviteTicket
inviteCode[self.memberId]['shopId']=self.shopid
else:
print(f'>获取果园邀请码失败,{response}')
def helpAuthor(self):
print(f'>>>开始助力作者')
headers = {
'Accept': 'application/json'
}
for code in AuthorCode:
if code.get('memberId', '') == self.memberId: continue
if code.get('fruit_is_ripe',False):break
data={
"activityCode":"HXNC-QG",
"shopId":self.shopid,
"channel":"512",
"inviteTicket":code.get('inviteCode',''),"inviteAction":"watering","inviteShopId":code.get('shopId','')
}
url = f'https://activity.yonghuivip.com/api/web/flow/farm/watering?inviteTicket={code}&{self.url_add}'
response = self.do_request(url, headers=headers,data=data)
# print(response)
if 'code' in response and response.get('code') == 0:
Log(f'>助力作者成功')
break
elif response.get("message","") == '会员专享功能,请先登录':
break
else:
pass
# Log(f'>助力作者失败,{response.get("message","")}')
def helpOther(self):
Log(f'>>>开始本地账号互助')
headers = {
'Accept': 'application/json'
}
inviteCode_li = list(inviteCode.values())
# print(inviteCode_li)
for code in inviteCode_li:
if code.get('memberId', '') == self.memberId:continue
if code.get('fruit_is_ripe', False): break
data = {"activityCode": "HXNC-QG",
"shopId": self.shopid,
"channel": "512",
"inviteTicket": code.get('inviteCode', ''), "inviteAction": "watering",
"inviteShopId": code.get('shopId', '')
}
url = f'https://activity.yonghuivip.com/api/web/flow/farm/watering?inviteTicket={code}&{self.url_add}'
response = self.do_request(url, headers=headers, data=data)
# print(response.text)
if 'code' in response and response.get('code') == 0:
Log(f'>助力成功')
elif response.get("message","") == '会员专享功能,请先登录':
break
else:
Log(f'>助力失败,{response.get("message","")}')
######################成长值任务
def get_GrowthValue(self):
Log(f'\n>>>>>>开始成长任务')
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
data = {
"businessCode": "membershipSystem"
}
url = f'https://api.yonghuivip.com/web/member/level/benefit/queryMemberGrowthValueProcess?{self.url_add}'
response = self.do_request(url, headers=headers, data=data)
if 'code' in response and response.get('code') == 0:
# print(response['data'])
data = response.get('data',[])
self.levelNeedGrowthValues = data.get('levelNeedGrowthValues',[])
if self.levelNeedGrowthValues != None:
for li in self.levelNeedGrowthValues:
isCurrentLevel = li.get('isCurrentLevel','')
# print(isCurrentLevel)
if isCurrentLevel == True:
self.levelName = li.get('levelName', '')
# print(self.levelName)
currentTotalGrowthValue = li.get('currentTotalGrowthValue', '')
nextLevelMinGrowthValue = li.get('nextLevelMinGrowthValue', '')
count = int(nextLevelMinGrowthValue)-int(currentTotalGrowthValue)
print(f'当前等级:【{self.levelName}】 积分:【{currentTotalGrowthValue}】 升级需要【{count}】')
break
else:
print('--------------')
else:
Log(f'>获取失败,{response}')
def get_GrowthtaskList(self):
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
data = {
"businessCode": "membershipSystem",
"shopId": self.shopid,
"isOpenPublishNotice": True
}
url = f'https://api.yonghuivip.com/web/member/task/listTasks?{self.url_add}'
response = self.do_request(url, headers=headers, data=data)
if 'code' in response and response.get('code') == 0:
# print(response['data'])
data = response.get('data',[])
self.taskCode = data.get('taskCode','')
# Log(f'>获取到当前签到任务ID:【{self.taskID}】 编码:【{self.taskCode}】')
if data.get("subTasks",[]) != None:
for li in data.get("subTasks",[]):
self.taskID = li.get('taskId','')
self.taskTitle = li.get('taskTitle','')
self.doSignTask()
else:
print('>>未发现成长值任务')
else:
Log(f'>获取失败,{response}')
######################签到任务
def get_taskList(self):
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
data = {
"shopId": self.shopid
}
url = f'https://api.yonghuivip.com/web/coupon/credit/task/queryTaskInfo?{self.url_add}'
response = self.do_request(url, headers=headers, data=data)
if 'code' in response and response.get('code') == 0:
# print(response['data'])
data = response.get('data',[])
if data:
self.taskStatus = data.get('taskStatus','')
self.taskID = data.get('taskId','')
self.taskTitle = data.get('taskTitle','')
if self.taskID and self.taskStatus ==0:
self.doTask()
else:
print('>>未发现任务')
else:
Log(f'>获取失败,{response}')
def doTask(self):
Log(f'>>>执行{self.taskTitle}')
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
data = {
"taskId": self.taskID,
"shopId": self.shopid
}
url = f'https://api.yonghuivip.com/web/coupon/credit/task/completeTask?{self.url_add}'
response = self.do_request(url, headers=headers, data=data)
if 'code' in response and response.get('code') == 0:
data = response['data']
success = data['success']
sendNum = data['sendNum']
if success:
Log(f'>获取到【{sendNum}】积分')
elif response.get('message','')=='任务已完成,请勿重复点击':
Log(f'>今日已签到')
else:
Log(f'>签到失败,{response}')
def doSignTask(self):
Log(f'>>>执行{self.taskTitle}')
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
data = {
"taskId": self.taskID,
"shopId": self.shopid,
"taskCode": self.taskCode
}
url = f'https://api.yonghuivip.com/web/member/task/doTask?{self.url_add}'
response = self.do_request(url, headers=headers, data=data)
if 'code' in response and response.get('code') == 0:
recive_data = response['data']
Log(f'>签到成功获取到【{recive_data}】成长值')
elif response.get('message','')=='任务已完成,请勿重复点击':
Log(f'>今日已签到')
else:
Log(f'>签到失败,{response}')
#########助力券任务
#获取助力券列表
def listBoostCouponByPage(self):
global PRIZEID
print(f'>>>>>>开始获取助力券列表>>>>>>')
print('默认发起普通用户助力券')
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
data = {
"current": 1,
"size": 20
}
url = f'https://api.yonghuivip.com/web/marketing/boostcoupon/listBoostCouponByPage?{self.url_add}'
response = self.do_request(url, headers=headers, data=data)
# print(response)
if 'code' in response and response.get('code') == 0:
# print(response)
coupList = response.get('data')['records']
for li in coupList:
#助力券ID
self.prizeId = li['prizeGameDTO']['prizeId']
self.needBoostNum = li['prizeGameDTO']['needBoostNum']
self.remainBoostNum = li['prizeGameDTO']['remainBoostNum']
self.gameCode = li['prizeGameDTO']['gameCode']
# boosterType 2 新人助力 1普通助力
self.boosterType = li['prizeGameDTO']['boosterType']
self.boosterType ="新人" if self.boosterType == 2 else "普通用户"
self.amount = li['boostCouponVO']['amount']
self.coupName = li['boostCouponVO']['name']
# 剩余张数
self.availableCount = li['boostCouponVO']['availableCount']
# 使用限制
self.couponDescription = li['boostCouponVO']['couponDescription']
self.applicationScope = li['boostCouponVO']['applicationScope']
self.canApply = li['boostCouponVO']['canApply']
copuname = f'{self.amount}元{self.coupName}'
# if COPU_NAME == copuname:
# PRIZEID = self.prizeId
self.canApply = "可发起" if self.canApply != -1 else "不可发起"
if self.canApply != -1 and self.boosterType == '普通用户':
self.getGameCode()
if self.gameCode:
gamecode_data = {
'name': f'{self.amount}元{self.coupName}',
'prizeId': self.prizeId,
'gameCode': self.gameCode
}
self.gamecode_li.append(gamecode_data)
if self.index == 1:
GameCode.append(gamecode_data)
print(f'-----【{self.amount}元{self.coupName}】----')
print(f'prizeId:【{self.prizeId}】\n需要【{self.needBoostNum}】个[{self.boosterType}]助力,仍需:【{self.remainBoostNum}】 {self.canApply}】 \n使用限制:【{self.couponDescription} {self.applicationScope}】\ngameCode:【{self.gameCode}】')
# print('第一个账号gamecodeli:',GameCode)
# print(self.gamecode_li)
print(f'>>>>>>获取助力券列表结束>>>>>>')
#根据prizeId获取gameCode
def getGameCode(self):
global GameCode
# print(f'>>开始获取prizeID:【{self.prizeId}】gameCode')
headers = {
"Accept": "*/*"
}
url = f'https://api.yonghuivip.com/web/marketing/boostcoupon/getGameCode?prizeId={self.prizeId}&gameCode=&{self.url_add}'
response = self.do_request(url, headers=headers, req_type='get')
# print(response)
if 'code' in response and response.get('code') == 0:
# print(response)
self.gameCode = response.get('data')
#保存到json
if self.gameCode:
gamecode_data ={
'name':f'{self.amount}元{self.coupName}',
'prizeId':self.prizeId,
'gameCode':self.gameCode
}
if self.index == 1:
GameCode.append(gamecode_data)
print(f'>>获取到gameCode:【{self.gameCode}】')
else:
print('>>未获取到gameCode')
elif response.get('message','') =='您今日发起活动次数已达上限,请明日再来':
self.canDoApply = False
else:
print(response.get('message'))
#助力助力券
def Boostcoupon(self,gameCodeLi=None):
global AuthorCode
print(f'>>>开始领券助力')
# print('GameCode:',GameCode)
# print('AuthorCode:',inviteCode)
if gameCodeLi==None:
print('>>第一个账号开始为作者助力')
for codeli in AuthorCode:
if not self.canhelp_coup:
print(f'>>>助力次数上限')
return
# print(codeli)
gameCode = codeli.get('gameCode', [{}])
memberId = codeli.get('memberId', '')
if memberId == self.memberId: continue
for Codes in gameCode:
code = Codes.get('gameCode', '')
self.copuHelp(code)
else:
code_list = list(inviteCode.values())
print('>>开始为第一个账号助力')
if not self.canhelp_coup:
print(f'>>>助力次数上限')
return
gameCode = code_list[0].get('gameCode', [{}])
for Codes in gameCode:
code = Codes.get('gameCode', '')
self.copuHelp(code)
# for codeli in GameCode:
# if not self.canhelp_coup: return
# print(codeli)
# code = codeli.get('gameCode', [{}])
# self.copuHelp(code)
def copuHelp(self,code):
headers = {
"Accept": "*/*"
}
url = f'https://api.yonghuivip.com/web/marketing/boostcoupon/boost?gameCode={code}&{self.url_add}'
response = self.do_request(url, headers=headers, req_type='get')
if 'code' in response and response.get('code') == 0:
# print(response)
Log(f'>{code},助力成功!')
return True
elif response.get('message') == '每日助力次数超过限制':
self.canhelp_coup = False
return False
else:
# print(f">{code},助力失败{response.get('message')}!")
return False
#########试用任务
def tryList(self,levelName=None):
if not levelName:
self.levelName = '黄金'
if self.levelName == '普通':
Log(f'当前等级【{self.levelName}】不达标,停止试用申请')
else:
Log(f'>>>开始试用申请')
headers = {
'Accept': '*/*'
}
url = f'https://api.yonghuivip.com/web/marketing/free/trial/issue/prize/landing/page?{self.url_add}'
response = self.do_request(url, headers=headers, req_type='get')
if 'code' in response and response.get('code') == 0:
# print(response)
if response['data']['tip'] == '本期活动报名已结束,敬请期待下期活动':
Log('>>本期活动报名已结束,敬请期待下期活动')
return False
goodsList = response['data']['currTab']['landingPagePrizeVOList']
for liId in goodsList:
buttonStateName = liId['buttonStateName']
self.skuTitle = liId['skuTitle']
self.prizeId = liId['prizeId']
if buttonStateName != '已报名':
print(f'>>产品:【{self.skuTitle}】 ID:【{self.prizeId}】【可申请】')
self.doTry()
else:
print(f'>>产品:【{self.skuTitle}】【已申请,跳过】')
else:
Log(f'>获取失败,{response}')
def doTry(self):
print(f'>>开始申请【{self.skuTitle}】')
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
data = {
"prizeId": self.prizeId
}
url = f'https://api.yonghuivip.com/web/marketing/free/trial/sign/up/fire?{self.url_add}'
response = self.do_request(url, headers=headers, data=data)
if 'code' in response and response.get('code') == 0:
# print(response)
Log(f'>{self.skuTitle},申请成功!')
else:
Log(f'>{self.skuTitle},申请失败,{response}')
def get_WinTryList(self):
print(f'>>>>>>获取已中奖列表>>>>>>')
headers = {
'Accept': '*/*',
}
url = f'https://api.yonghuivip.com/web/marketing/free/trial/issue/participated/detail?fromType=1&pageNum=1&{self.url_add}'
response = self.do_request(url, headers=headers,req_type='get')
if 'code' in response and response.get('code') == 0:
data = response.get('data')
participatedVOList = data.get('participatedVOList')
for li in participatedVOList:
skuTitle = li['skuTitle']
skuPrice = li['skuPrice']
status = li['status']
#1已报名 2待领券 3未中奖 4待兑换
if status == 2:
Log(f'商品:【{skuTitle}】 价格:【{skuPrice}】 【待领券】')
elif status == 4:
Log(f'商品:【{skuTitle}】 价格:【{skuPrice}】 【待兑换】')
elif status == 6:
print(f'商品:【{skuTitle}】 价格:【{skuPrice}】 【已过期】')
elif status == 5:
print(f'商品:【{skuTitle}】 价格:【{skuPrice}】 【已兑换】')
else:
print(f'商品:【{skuTitle}】 价格:【{skuPrice}】')
# print(response)
else:
print(f'>申请失败,{response}')
def sixYears_getTask(self):
print(f'>>开始获取6周年任务列表')
headers = {
'Accept': '*/*'
}
url = f'https://api.yonghuivip.com/web/marketing/quick/task/loadTask?activityId=3572&{self.url_add}'
response = self.do_request(url, headers=headers, req_type='get')
if 'code' in response and response.get('code') == 0:
data = response.get('data',[{}])
for task in data:
taskId = task.get('taskId','')
taskType = task.get('taskType','')
taskStatus = task.get('taskStatus','')
taskTitle = task.get('taskTitle','')
if taskStatus == 0:
print(f'任务[{taskTitle}]已完成')
continue
self.sixYears_doTask(taskId,taskType,taskTitle)
else:
Log(f'获取6周年任务列表,{response}')
def sixYears_doTask(self,taskId,taskType,taskTitle):
print(f'>>开始执行{taskTitle}任务')
headers= self.headers.copy()
headers_new = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
headers.update(headers_new)
data = {
"activityId": '3572',
"activityCode": "FJ-MD-05",
"taskId": taskId,
"taskType": taskType
}
url = f'https://api.yonghuivip.com/web/marketing/quick/task/doTask?{self.url_add}'
response = self.do_request(url, headers=headers,data=data)
if 'code' in response and response.get('code') == 0:
data = response.get('data',{})
count = data.get('count',0)
print(f'获得【{count}】次抽奖机会')
else: