-
Notifications
You must be signed in to change notification settings - Fork 2
/
pupu_types.py
619 lines (491 loc) · 12.9 KB
/
pupu_types.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
from dataclasses import dataclass, field
from enum import Enum, IntEnum
from sys import _getframe as getframe
from sys import version_info as py_version
from traceback import format_exc
from typing import Optional # 确保兼容<=Python3.9
from utils import MyIntEnum
assert py_version >= (3, 9)
class BANNER_LINK_TYPE(MyIntEnum):
RECOMMEND = -10
PRODUCT_DETAIL_ACTIVITY = 0
TOPIC_ACTIVITY = 10
SEARCH_RESULT_ACTIVITY = 90
DISCOVERY_DETAIL_ACTIVITY = 220
COUPON_DETAIL_ACTIVITY = 230
COUPON_LIST = 231
GOOD_NEIGHBOR_ACTIVITY = 250
ACTIVITY_ACTIVITY = 400
INDEX_TAB_ALL_CATEGORY = 410
FLASH_SALE_ACTIVITY = 650
SCENE_PRODUCT_LIST = 700
COOKBOOK_DETAIL = 900
COOKBOOK_LIST = 901
COOKBOOK_CHANNEL = 902
OPEN_MP_LIVE = 903
NO_JUMP = 910
INDEX = 999
USER_GIFT_CARD = 1000
MY_USER_GIFT_CARD = 1001
MY_COIN = 1010
CUSTOMER_CONTACT = 1011
DELIVER_ADDRESS = 1012
INVOICE_EXPENSE = 1013
DELIVER_BELL = 1014
MY_COLLECT = 1015
ABOUT_PUPU = 1016
SHARE_PUPU = 1017
USER_TASK = 1022
CUSTOM_LOTTERY = 1023
LOGIN_PAGE = 1024
SHARE_SELF = 1025
NOVICE = 1027
GIFT_CARD_STORE_H5 = 1029
ORDER_DETAIL = 1030
kUnk_1032 = 1032
kUnk_1034 = 1034
IMPORTANT_PRODUCT_LIST = 2620
WEB = 99999
class DiscountType(MyIntEnum):
ALL = -1 # 全部
ABSOLUTE = 0 # 满减
PERCENTAGE = 10 # 百分比折扣
GIFT_PRODUCT = 20 # 买赠
EACH_GIFT_PRODUCT = 30 # 每买赠
EACH_GIFT_MONEY = 40 # 每满减
TRADE_BUY = 50 # 换购
class DeliveryReasonType(MyIntEnum):
WEATHER = 0
PEAK = 1 # 因配送高峰, 配送时间有调整, 请耐心等待
OTHER = 2
PROLONG = 4
EXHAUSTED = 5 # 没有骑手?
FUTURE_PRODUCTS = 6
PROPERTY_PROBLEM = 100
TRAFFIC_PROBLEM = 200
LONG_DISTANCE = 300
class DeliveryTimeType(MyIntEnum):
IMMEDIATE = 0
RESERVE = 10
class LOTTERY_TYPE(MyIntEnum):
SLOT = 10
FLOP = 20
DRAW = 30
class CHANCE_OBTAIN_TYPE(MyIntEnum):
RECEIVE_ORGER = 10
INVITE_NEW_USER = 20
COIN_EXCHANGE = 30 # 积分兑换
SIGN_IN = 40
INVITE_FRIEND_BOOST = 60 # 邀请助力
GO_TO_BOOST = 70
UNKNOWN_170 = 170
class RewardType(MyIntEnum):
Coupon = 10
PuPoint = 20
GiftCard = 30
Sunrise = 40
kUnk_60 = 60
class ActionTYPE(MyIntEnum):
BROWSE = 0
SHARE = 10
class TaskType(MyIntEnum):
UNKNOWN = 0
FLASH_SALE = 240
CUSTOM_LOTTERY = 250
TOPIC = 260
USER_TASK = 270
SCENE = 280
class TaskStatus(MyIntEnum):
Undone = 0
Done = 10
Expired = 20
Receive = 30
class TaskRewardType(MyIntEnum):
Credit = 0
Coupon = 10
GiftCard = 20
Lottery = 30
Card = 40
BetNum = 50
Cash = 60
打榜积分 = 70
拼桌食材 = 80
红包 = 90
NoReward = 255
class SPREAD_TAG(MyIntEnum):
UNKNOWN = -1 # 不限
NORMAL_PRODUCT = 0
NEW_PRODUCT = 10 # 新品
FLASH_SALE_PRODUCT = 20 # 限时购
DISCOUNT_PRODUCT = 30 # 折扣
NOVICE_PRODUCT = 40 # 新手专享
SPECIAL_PRODUCT = 50 # 特价
HOT_PRODUCT = 60 # 热卖
YIYUAN_BUTIE = 100
ZERO_ORDER_EXCLUSIVE = 110
ONE_ORDER_EXCLUSIVE = 120
TWO_ORDER_EXCLUSIVE = 130
THREE_ORDER_EXCLUSIVE = 140
class PURCHASE_TYPE(MyIntEnum):
ALL = -1 # 不限
GENERAL = 0 # 普通
RESERVE = 10 # 预定
class SHARE_STATUS(MyIntEnum):
UNKNOWN = 0
ERROR = 1
EXPIRED = 2
NULL = 3
NORMAL = 4
class COLLECT_CARD_STATUS(MyIntEnum):
NOT_START = 10
PROCESSING = 20
FINISHED = 30
class HideTaskType(MyIntEnum):
Null = 0
More = 10
List = 20
class PAPER_CONTENT_TYPE(MyIntEnum):
MANUAL_INPUT = 0
REF_INPUT = 10
REALATION_INPUT = 15
ROBOT_GREETING = 20
ROBOT_RECOM = 30
ROBOT_ANSWER = 40
KEYWORD_INTENTION = 50
REMIND_ORDER = 60
class ERROR_CODE(MyIntEnum):
CODE_SUCCESS = 0
NO_ENOUGH_POINT = 391
POINT_LIMIT = 392
NOT_IN_ACTIVITY_CITY = 393
IS_LIVE = 394
# COMMENT_ERROR_CODE
ERR_COMMENT_PUSH = 13000 # 写评论失败
ERR_COMMENT_HIT_KEYWORD_INTERCEPT = 13001
ERR_COMMENT_HIT_FREQ_LIMIT = 13002 # 操作太过频繁,请1分钟后再试
ERR_COMMENT_IS_BAN = 13004
ERR_COMMENT_HIT_KEYWORD_BUSINESS_INTERCEPT = 13005
ERR_COMMENT_HIT_COMMENT_DISCARD = 13006
# LOTTERY_TEAM
ERR_GET_TEAM_NO_EXIST = 32002
ERR_GET_TEAM_FAIL = 33001
ERR_JOIN_TEAM_FAIL = 33002
ERR_CHANGE_TEAM_FAIL = 33003
ERR_DO_NOT_JOIN_TEAM = 33004
ERR_JOIN_LOTTERY_FAIL = 33005
CITIVITYE_END = 100002
ACITIVITYE_UNSTART = 100010
ACITIVITYE_UNOPEN = 100011
UNNORMAL = 100026 # 被限制了
INVITE_LIMIT_DAILY = 100027
INVITE_LIMIT = 100028
ASSISTANCE_MYSELF = 100029
ASSISTANCE_REPEAT = 100030
ASSISTANCE_END = 100031
ASSISTANCE_LIMIT_DAILY = 100032
ASSISTANCE_LIMIT = 100033
ASSISTANCE_ERROR = 100034
# LOGIN 403, [200000, 300000), exinclude 200099
kForbidden = 403
OUT_TOKEN = 200001
kUnauthorized = 200208
EXPIRED_TOKEN = 200304
kRepeatedSignIn = 350011
kUnknown = -1 # 系统繁忙
BUSY = 400000 # 系统繁忙
ERROR_TASK_NOT_GENERATED = 400104
ERROR_TASK_DOES_NOT_EXIST = 400106
CODE_PRODUCT_UPDATE = 500001
@dataclass
class PCollectCardRule:
id: str
name: str
time_start: int
time_end: int
status: COLLECT_CARD_STATUS
send_status: int
enabled: bool
open_card_lottery: bool
card_lottery_activity_id: str
card_get_task_id: str
@dataclass
class PCollectCard:
card_type: int # TODO 10普通卡 20合成卡
link_type: BANNER_LINK_TYPE
name: str
rule_id: str
sort_num: int
# 以下字段仅在获取卡列表时有效
rule_card_id: Optional[str] = None
owner_user_id: Optional[str] = None
have_count: Optional[int] = None
@dataclass
class PCollectCardEntity:
already_get: list[PCollectCard]
can_composite_count: int
first_visit: bool
@dataclass
class PReceiverInfo:
id: str
address: str = ""
room_num: str = ""
lng_x: Optional[float] = 0
lat_y: Optional[float] = 0
receiver_name: str = ""
phone_number: str = ""
store_id: str = ""
place_id: str = ""
place_zip: int = 0
city_zip: int = 0
@property
def id_empty(self):
"""只判断ID"""
return not self.id or not self.store_id or not self.place_id
@dataclass
class PPrize:
level: int
name: str
type: RewardType
@dataclass
class PItem:
price: int
product_id: str
store_product_id: str
remark: str
spread_tag: int
selected_count: int
@dataclass
class PPageRule:
activity_id: str
action_type: ActionTYPE
task_type: TaskType
skim_time: int # 浏览多少秒
@dataclass
class PAnswerRule:
answer_is_done: bool
@dataclass
class PTask:
task_id: str
task_name: str # 每日打卡
task_status: TaskStatus
reward_type: TaskRewardType
link_id: str
target_code: int
page_rule: Optional[PPageRule] = None # 浏览型任务
answer_rule: Optional[PAnswerRule] = None # 答题型任务
@dataclass
class PLotteryInfo:
id: str
name: str
type: LOTTERY_TYPE
prizes: dict[int, PPrize] = field(default_factory=dict)
task_system_link_id: Optional[str] = None
@dataclass
class PChanceEntrance:
type: CHANCE_OBTAIN_TYPE
title: str
attend_count: int # 已获得次数
limit_count: int # 最大获得次数
gain_num: int # 每次完成可增加的次数
target_value: int # 需要的数量
@dataclass
class PBatch:
batch_id: str
price: int # 价格 分
spread_tag_desc: str
@dataclass
class FlashSaleInfo:
store_product_id: str
event_id: str
quantity_each_person_limit: int
progress_rate: float
price: int
@dataclass
class PProduct:
price: int # 价格 分
product_id: str
name: str
store_product_id: str
order_remarks: list[str]
spread_tag: SPREAD_TAG
stock_quantity: int # 库存
purchase_type: PURCHASE_TYPE = PURCHASE_TYPE.GENERAL
quantity_limit: Optional[int] = None # 限购数量
selected_count: int = 0 # 选购几件
sell_batches: Optional[list[PBatch]] = None # 该数组的最低价作为当前价格
remark: Optional[str] = None # 商品备注
@dataclass
class PDiscountShare:
# index: int # 第{index}个领取的人得最大优惠券
indexes: list[int] # 朴朴新规则,一个红包可能有多个最佳(确保从小到大排序)
count: int # 共{count}张优惠券
share_id: str # 红包ID
@dataclass
class PDiscountRule:
id: str
type: DiscountType
condition_amount: int # 6900
discount_amount: int # 700 满69减7元
name: Optional[str] = (
None # 230617新增用于检测是不是垃圾券,比如 “朴朴分享券(冷藏冷冻专用)”
)
@property
def tips(self):
return f"满{self.condition_amount/100}减{self.discount_amount/100}{self.name or ''}"
@dataclass
class POrder:
total_price: int
time_create: int # 1673265913282
# TODO items
discount_share: Optional[PDiscountShare] = None # 红包
@dataclass
class PBanner:
title: str
link_id: str
@dataclass
class PShareUser:
avatar: Optional[str]
name: str
best: bool # 是否最佳
time: int # 抢包时间
@dataclass
class PAnswerOptions:
sort: int
name: str
# score:Optional[int] = None
selected: Optional[int] = 0
@dataclass
class PQuestion:
id: str
question_title: str
question_notice: str
question_type: int
is_must: int
is_random: int
sort: int
start_score_desc: str
end_score_desc: str
options: list[PAnswerOptions]
content_type: PAPER_CONTENT_TYPE
option_limit: int
option_min_limit: int
question_id: Optional[str] = None
class ApiResults:
class Error:
__slots__ = ("code", "msg", "func_name")
def __init__(self, json: Optional[dict], func_name: Optional[str] = None):
if json:
self.code = json.get("errcode")
self.msg = json.get("errmsg", "")
else:
self.code = -1
self.msg = ""
self.func_name = func_name or getframe(1).f_code.co_name
def __str__(self) -> str:
return f"{self.func_name} 失败: code={self.code}, msg={self.msg}"
class Exception(Error):
__slots__ = "exception"
def __init__(self, func_name: Optional[str] = None):
super().__init__(
json=None, func_name=func_name or getframe(1).f_code.co_name
)
self.exception = format_exc()
def __str__(self) -> str:
return f"{self.func_name} 异常: {self.exception}"
@dataclass
class TokenRefreshed:
refresh_token: str
access_expires: int
changed: bool = False
@dataclass
class TokenValid:
pass
@dataclass
class SuId:
id: str
@dataclass
class UserInfo:
avatar: Optional[str]
nickname: Optional[str]
@dataclass
class ReceiverInfo:
receiver: PReceiverInfo
@dataclass
class SignIn:
coin: int
explanation: str
@dataclass
class SignPeriodInfo:
days: int
@dataclass
class Banner:
banners: list[PBanner]
@dataclass
class LotteryInfo:
lottery: PLotteryInfo
@dataclass
class TaskGroupsData:
tasks: list[PTask]
@dataclass
class TaskCompleted:
pass
@dataclass
class ChanceEntrances:
coin_balance: int
entrances: list[PChanceEntrance]
@dataclass
class CoinExchanged:
gain_num: int
@dataclass
class UserLotteryInfo:
remain_chances: int
@dataclass
class LotteryResult:
prize: PPrize
@dataclass
class ProductCollections:
total_count: int
products: list[PProduct]
@dataclass
class UsableCoupons:
coupons: list[str]
rules: list[PDiscountRule]
@dataclass
class DeliveryTime:
type: DeliveryTimeType
dtime_promise: int
@dataclass
class OrderCreated:
id: str
@dataclass
class OrdersList:
total_count: int
orders: list[POrder]
@dataclass
class WxDiscountShare:
best_luck: bool
reentry: bool
user_list: list[PShareUser]
discount: Optional[PDiscountRule]
available: bool
@dataclass
class AnswerResult:
question_id: str
standard: str # 标准答案
result: bool # 是否答对
@dataclass
class Questionnaire:
id: str
time_start_answer: int
questions: list[PQuestion]
class HttpMethod(Enum):
kPut = "PUT"
kGet = "GET"
kPost = "POST"
kDelete = "DELETE"
class ClientType(IntEnum):
kNative = 0
kWeb = 1
kMicroMsg = 2
if __name__ == "__main__":
pass