qrpa 1.1.3__tar.gz → 1.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of qrpa might be problematic. Click here for more details.

Files changed (37) hide show
  1. {qrpa-1.1.3 → qrpa-1.1.5}/PKG-INFO +1 -1
  2. {qrpa-1.1.3 → qrpa-1.1.5}/pyproject.toml +1 -1
  3. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/shein_excel.py +85 -0
  4. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/shein_lib.py +72 -0
  5. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/time_utils.py +11 -0
  6. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa.egg-info/PKG-INFO +1 -1
  7. {qrpa-1.1.3 → qrpa-1.1.5}/README.md +0 -0
  8. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/RateLimitedSender.py +0 -0
  9. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/__init__.py +0 -0
  10. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/db_migrator.py +0 -0
  11. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/feishu_bot_app.py +0 -0
  12. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/feishu_client.py +0 -0
  13. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/feishu_logic.py +0 -0
  14. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/fun_base.py +0 -0
  15. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/fun_excel.py +0 -0
  16. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/fun_file.py +0 -0
  17. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/fun_web.py +0 -0
  18. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/fun_win.py +0 -0
  19. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/mysql_module/__init__.py +0 -0
  20. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/mysql_module/shein_product_model.py +0 -0
  21. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/mysql_module/shein_return_order_model.py +0 -0
  22. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/shein_daily_report_model.py +0 -0
  23. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/shein_mysql.py +0 -0
  24. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/shein_sqlite.py +0 -0
  25. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/shein_ziniao.py +0 -0
  26. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/temu_chrome.py +0 -0
  27. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/temu_excel.py +0 -0
  28. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/temu_lib.py +0 -0
  29. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/time_utils_example.py +0 -0
  30. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa/wxwork.py +0 -0
  31. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa.egg-info/SOURCES.txt +0 -0
  32. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa.egg-info/dependency_links.txt +0 -0
  33. {qrpa-1.1.3 → qrpa-1.1.5}/qrpa.egg-info/top_level.txt +0 -0
  34. {qrpa-1.1.3 → qrpa-1.1.5}/setup.cfg +0 -0
  35. {qrpa-1.1.3 → qrpa-1.1.5}/setup.py +0 -0
  36. {qrpa-1.1.3 → qrpa-1.1.5}/tests/test_db_migrator.py +0 -0
  37. {qrpa-1.1.3 → qrpa-1.1.5}/tests/test_wxwork.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qrpa
3
- Version: 1.1.3
3
+ Version: 1.1.5
4
4
  Summary: qsir's rpa library
5
5
  Author: QSir
6
6
  Author-email: QSir <1171725650@qq.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "qrpa"
7
- version = "1.1.3"
7
+ version = "1.1.5"
8
8
  description = "qsir's rpa library"
9
9
  authors = [{ name = "QSir", email = "1171725650@qq.com" }]
10
10
  readme = "README.md"
@@ -15,6 +15,91 @@ class SheinExcel:
15
15
  self.bridge = bridge
16
16
  pass
17
17
 
18
+ def get_supplier_name(self, store_username):
19
+ cache_file = f'{self.config.auto_dir}/shein/dict/supplier_data.json'
20
+ info = read_dict_from_file_ex(cache_file, store_username)
21
+ return info['supplier_name']
22
+
23
+ def write_withdraw_report_2024(self):
24
+ excel_path = create_file_path(self.config.excel_withdraw_2024)
25
+ dict_store = read_dict_from_file(self.config.shein_store_alias)
26
+
27
+ header = ['店铺名称', '店铺账号', '供应商名称', '交易单号', '提现时间', '提现成功时间', '更新时间', '提现明细单号',
28
+ '收款帐户', '收款帐户所在地', '净金额', '保证金', '手续费', '汇率', '收款金额', '提现状态']
29
+ summary_excel_data = [header]
30
+ # 先读取提现明细列表写入
31
+ first_day, last_day = TimeUtils.get_year_range_time(2024)
32
+ cache_file = f'{self.config.auto_dir}/shein/cache/withdraw_list_{first_day}_{last_day}.json'
33
+ dict_withdraw = read_dict_from_file(cache_file)
34
+ account_list = []
35
+ for store_username, list_withdraw in dict_withdraw.items():
36
+ store_name = dict_store.get(store_username)
37
+ supplier_name = self.get_supplier_name(store_username)
38
+ for withdraw in list_withdraw:
39
+ row_item = []
40
+ row_item.append(store_name)
41
+ row_item.append(store_username)
42
+ row_item.append(supplier_name)
43
+ row_item.append(withdraw['withdrawNo'])
44
+ row_item.append(TimeUtils.convert_timestamp_to_str(withdraw['createTime']))
45
+ row_item.append(TimeUtils.convert_timestamp_to_str(withdraw.get('transferSuccessTime')))
46
+ row_item.append(TimeUtils.convert_timestamp_to_str(withdraw['lastUpdateTime']))
47
+ row_item.append(withdraw['transferNo'])
48
+ account = withdraw['sourceAccountValue']
49
+ if account not in account_list:
50
+ account_list.append(account)
51
+ row_item.append(account)
52
+ row_item.append(withdraw['accountAreaCode'])
53
+ row_item.append(withdraw['netAmount'])
54
+ row_item.append(withdraw['depositAmount'])
55
+ row_item.append(withdraw['commissionAmount'])
56
+ row_item.append(withdraw['exchangeRate'])
57
+ row_item.append(withdraw['receivingAmount'])
58
+ row_item.append(withdraw['withdrawStatusDesc'])
59
+ summary_excel_data.append(row_item)
60
+ sheet_name = '提现明细汇总'
61
+
62
+ operations = [
63
+ [sheet_name, 'write', summary_excel_data, ],
64
+ [sheet_name, 'format', self.format_withdraw_detail]
65
+ ]
66
+
67
+ header = [
68
+ ['收款账户', '总收款金额'],
69
+ ['汇总', ''],
70
+ ]
71
+ summary_excel_data = header
72
+ for account in account_list:
73
+ row_item = []
74
+ row_item.append(account)
75
+ row_item.append('')
76
+ summary_excel_data.append(row_item)
77
+
78
+ sheet_name = '汇总2024'
79
+
80
+ operations.append([sheet_name, 'write', summary_excel_data])
81
+ operations.append([sheet_name, 'format', self.format_withdraw_2024])
82
+ operations.append([sheet_name, 'move', 1])
83
+ operations.append(['Sheet1', 'delete'])
84
+
85
+ batch_excel_operations(excel_path, operations)
86
+
87
+ def format_withdraw_detail(self, sheet):
88
+ beautify_title(sheet)
89
+ column_to_right(sheet, ['金额'])
90
+ format_to_money(sheet, ['金额', '保证金', '手续费'])
91
+ format_to_datetime(sheet, ['时间'])
92
+ add_borders(sheet)
93
+
94
+ def format_withdraw_2024(self, sheet):
95
+ beautify_title(sheet)
96
+ column_to_right(sheet, ['金额'])
97
+ format_to_money(sheet, ['金额'])
98
+ format_to_datetime(sheet, ['时间'])
99
+ add_sum_for_cell(sheet, ['总收款金额'])
100
+ add_formula_for_column(sheet, '总收款金额', "=SUMIF('提现明细汇总'!I:I, A3, '提现明细汇总'!O:O)", 3)
101
+ add_borders(sheet)
102
+
18
103
  def write_product(self):
19
104
  erp = self.config.erp_source
20
105
  excel_path = create_file_path(self.config.excel_shein_skc_profit)
@@ -281,6 +281,78 @@ class SheinLib:
281
281
 
282
282
  return info
283
283
 
284
+ # 获取供货商信息
285
+ def get_supplier_data(self):
286
+ self.web_page.goto('https://sso.geiwohuo.com/#/mws/seller/new-account-overview')
287
+ self.web_page.wait_for_load_state('load')
288
+ cache_file = f'{self.config.auto_dir}/shein/dict/supplier_data.json'
289
+ info = read_dict_from_file_ex(cache_file, self.store_username, 3600 * 24 * 10)
290
+ if len(info) > 0:
291
+ return info
292
+
293
+ log(f'正在获取 {self.store_name} 供货商信息')
294
+ url = "https://sso.geiwohuo.com/mgs-api-prefix/supplierGrowth/querySupplierCommonData"
295
+ payload = {}
296
+ response_text = fetch(self.web_page, url, payload)
297
+ error_code = response_text.get('code')
298
+ if str(error_code) != '0':
299
+ raise send_exception(json.dumps(response_text, ensure_ascii=False))
300
+ info = response_text.get('info')
301
+
302
+ write_dict_to_file_ex(cache_file, {self.store_username: info}, [self.store_username])
303
+
304
+ return info
305
+
306
+ def get_withdraw_list(self, supplier_id, mode='month'):
307
+ self.web_page.goto('https://sso.geiwohuo.com/#/mws/seller/new-account-overview')
308
+ self.web_page.wait_for_load_state("load")
309
+
310
+ if mode == 'month':
311
+ first_day, last_day = TimeUtils.get_last_month_range_time()
312
+ else:
313
+ first_day, last_day = TimeUtils.get_year_range_time(2024)
314
+
315
+ cache_file = f'{self.config.auto_dir}/shein/cache/withdraw_list_{first_day}_{last_day}.json'
316
+ withdraw_list = read_dict_from_file_ex(cache_file, self.store_username, 3600 * 12)
317
+ if len(withdraw_list) > 0:
318
+ return withdraw_list
319
+
320
+ page_num = 1
321
+ page_size = 200
322
+
323
+ url = f"https://sso.geiwohuo.com/mws/mwms/sso/withdraw/transferRecordList"
324
+ payload = {
325
+ "reqSystemCode" : "mws-front",
326
+ "supplierId" : supplier_id,
327
+ "pageNum" : page_num,
328
+ "pageSize" : page_size,
329
+ "createTimeStart" : first_day,
330
+ "createTimeEnd" : last_day,
331
+ "withdrawStatusList": [30]
332
+ }
333
+ log(payload)
334
+ response_text = fetch(self.web_page, url, payload)
335
+ log(response_text)
336
+ error_code = response_text.get('code')
337
+ if str(error_code) != '0':
338
+ raise send_exception(json.dumps(response_text, ensure_ascii=False))
339
+
340
+ withdraw_list = response_text['info']['list']
341
+ total = response_text['info']['count']
342
+ totalPage = math.ceil(total / page_size)
343
+
344
+ for page in range(2, totalPage + 1):
345
+ log(f'获取提现列表 第{page}/{totalPage}页')
346
+ page_num = page
347
+ payload['pageNum'] = page_num
348
+ response_text = fetch(self.web_page, url, payload)
349
+ withdraw_list = response_text['info']['list']
350
+ time.sleep(0.1)
351
+
352
+ write_dict_to_file_ex(cache_file, {self.store_username: withdraw_list}, [self.store_username])
353
+
354
+ return withdraw_list
355
+
284
356
  # 获取质检报告pdf地址
285
357
  def get_qc_report_url(self, deliverCode, purchaseCode):
286
358
  log(f'获取质检报告:{deliverCode} {purchaseCode}')
@@ -358,6 +358,17 @@ class TimeUtils:
358
358
 
359
359
  return start_timestamp, end_timestamp
360
360
 
361
+ @staticmethod
362
+ def get_year_range_time(year=2024):
363
+ """获取某一整年的第一天和最后一天的毫秒级时间戳"""
364
+ first_day = datetime(year, 1, 1, 0, 0, 0)
365
+ last_day = datetime(year, 12, 31, 0, 0, 0, 0)
366
+
367
+ start_timestamp = int(first_day.timestamp() * 1000)
368
+ end_timestamp = int(last_day.timestamp() * 1000)
369
+
370
+ return start_timestamp, end_timestamp
371
+
361
372
  @staticmethod
362
373
  def is_in_month(time_str: str, month: int, fmt: str = "%Y-%m-%d") -> bool:
363
374
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qrpa
3
- Version: 1.1.3
3
+ Version: 1.1.5
4
4
  Summary: qsir's rpa library
5
5
  Author: QSir
6
6
  Author-email: QSir <1171725650@qq.com>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes