qrpa 1.0.27__py3-none-any.whl → 1.0.28__py3-none-any.whl

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.

qrpa/temu_excel.py CHANGED
@@ -3,6 +3,7 @@ from .fun_base import log
3
3
  from .fun_file import read_dict_from_file, read_dict_from_file_ex, write_dict_to_file, write_dict_to_file_ex, delete_file
4
4
  from .time_utils import TimeUtils
5
5
  from .wxwork import WxWorkBot
6
+ import os
6
7
 
7
8
  class TemuExcel:
8
9
 
@@ -47,9 +48,9 @@ class TemuExcel:
47
48
  autofit_column(sheet, ['店铺名称', '商品信息'])
48
49
  column_to_left(sheet, ['商品信息'])
49
50
  InsertImageV2(sheet, ['SKC图片', 'SKU图片'], 'temu', 120)
50
- if sheet.used_range.rows.count > 330:
51
- log('表格数据行数超过了330行,将删除SKC图片')
52
- remove_excel_columns(sheet, ['SKC图片'])
51
+ # if sheet.used_range.rows.count > 330:
52
+ # log('表格数据行数超过了330行,将删除SKC图片')
53
+ # remove_excel_columns(sheet, ['SKC图片'])
53
54
 
54
55
  def write_purchase_advise(self, erp='mb'):
55
56
  cache_file = f'{self.config.auto_dir}/temu/cache/warehouse_list_{TimeUtils.today_date()}.json'
@@ -59,19 +60,23 @@ class TemuExcel:
59
60
 
60
61
  header = ['店铺名称', 'SKC图片', 'SKU图片', '商品信息', '现有库存数量', '已采购数量', '近7日销量', '平均日销', '本地和采购可售天数', '生产天数', '建议采购', '产品起定量', '备货周期(天)', 'SKC', '导出时间']
61
62
  new_excel_path_list = []
63
+
62
64
  for mall_id, subOrderList in dict.items():
63
65
  excel_data = []
64
66
  mall_name = store_info.get(mall_id)[1]
67
+
65
68
  for product in subOrderList:
66
69
  spu = str(product['productId']) # temu平台 spu_id
67
70
  skc = str(product['productSkcId']) # temu平台 skc_id
68
71
  skcExtCode = product['skcExtCode'] # 商家 SKC货号
69
72
  category = product['category'] # 叶子类目
70
73
  onSalesDurationOffline = product['onSalesDurationOffline'] # 加入站点时长
74
+
71
75
  for sku in product['skuQuantityDetailList']:
72
76
  priceReviewStatus = sku['priceReviewStatus']
73
77
  if priceReviewStatus == 3: # 过滤 开款价格状态 已作废的 2是已生效
74
78
  continue
79
+
75
80
  mall_info = f'{mall_name}\n{mall_id}'
76
81
  productSkcPicture = product['productSkcPicture'] # skc图片
77
82
  skuExtCode = str(sku['skuExtCode']) # sku货号
@@ -98,15 +103,37 @@ class TemuExcel:
98
103
  row_item.append(TimeUtils.current_datetime())
99
104
  excel_data.append(row_item)
100
105
 
101
- new_excel_path = str(self.config.excel_purcase_advice_temu).replace('#store_name#', mall_name).replace(' ', '_')
102
- new_excel_path_list.append(new_excel_path)
103
- sheet_name = 'Sheet1'
104
- data = [header] + excel_data
105
- close_excel_file(new_excel_path)
106
- log(new_excel_path)
107
- batch_excel_operations(new_excel_path, [
108
- (sheet_name, 'write', sort_by_column(data, 6, 1), ['N']),
109
- (sheet_name, 'format', self.format_purchase_advise_batch)
110
- ])
106
+ # 按近7日销量排序
107
+ excel_data = sort_by_column(excel_data, 6, 1)
108
+
109
+ # 计算需要多少个文件(每个文件最多320行数据,包含表头)
110
+ max_data_rows = 320 - 1 # 减去表头行
111
+ total_files = (len(excel_data) + max_data_rows - 1) // max_data_rows # 通过加(max_data_rows-1)实现向上取整
112
+
113
+ for file_index in range(total_files):
114
+ start_idx = file_index * max_data_rows
115
+ end_idx = min((file_index + 1) * max_data_rows, len(excel_data))
116
+ current_data = excel_data[start_idx:end_idx]
117
+
118
+ # 生成文件名,如果超过一个文件则添加序号
119
+ if total_files == 1:
120
+ new_excel_path = str(self.config.excel_purcase_advice_temu).replace('#store_name#', mall_name).replace(' ', '_')
121
+ else:
122
+ # 在文件名后添加 _2, _3 等序号
123
+ base_path = str(self.config.excel_purcase_advice_temu).replace('#store_name#', mall_name).replace(' ', '_')
124
+ file_name, file_ext = os.path.splitext(base_path)
125
+ new_excel_path = f"{file_name}_{file_index + 1}{file_ext}"
126
+
127
+ new_excel_path_list.append(new_excel_path)
128
+ sheet_name = 'Sheet1'
129
+ data = [header] + current_data
130
+
131
+ close_excel_file(new_excel_path)
132
+ log(f"创建文件: {new_excel_path}, 数据行数: {len(current_data)}")
133
+
134
+ batch_excel_operations(new_excel_path, [
135
+ (sheet_name, 'write', data, ['N']),
136
+ (sheet_name, 'format', self.format_purchase_advise_batch)
137
+ ])
111
138
 
112
139
  return new_excel_path_list
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qrpa
3
- Version: 1.0.27
3
+ Version: 1.0.28
4
4
  Summary: qsir's rpa library
5
5
  Author: QSir
6
6
  Author-email: QSir <1171725650@qq.com>
@@ -13,12 +13,12 @@ qrpa/shein_lib.py,sha256=rbrJDO48KoZZBlmlBotQpXp1i_zY2o6q9HN_9aVjAKI,101008
13
13
  qrpa/shein_sqlite.py,sha256=ZQwD0Gz81q9WY7tY2HMEYvSF9r3N_G_Aur3bYfST9WY,5707
14
14
  qrpa/shein_ziniao.py,sha256=nSqqcEPh4nVQtUxUnIRzeZfTLyXywGPjPZn5pP-w57U,18309
15
15
  qrpa/temu_chrome.py,sha256=CbtFy1QPan9xJdJcNZj-EsVGhUvv3ZTEPVDEA4-im40,2803
16
- qrpa/temu_excel.py,sha256=Y76f2qFImTrqdtRJ5PXZX1c4UC3S55Ws_zEw3vBP6PA,5623
16
+ qrpa/temu_excel.py,sha256=ssAQvhtRGaTOLAVM3gS-AnmHPkIiHCT6gTsK1hoi-_8,6990
17
17
  qrpa/temu_lib.py,sha256=hYB59zsLS3m3NTic_duTwPMOTSxlHyQVa8OhHnHm-1g,7199
18
18
  qrpa/time_utils.py,sha256=ef0hhbN_6b-gcnz5ETIVOoxemIMvcxGVGGIRnHnGaBo,29564
19
19
  qrpa/time_utils_example.py,sha256=shHOXKKF3QSzb0SHsNc34M61wEkkLuM30U9X1THKNS8,8053
20
20
  qrpa/wxwork.py,sha256=Vy8PGEtlTWt4-1laVhuqpJUGCFH2JymgbjvH00aaBog,10946
21
- qrpa-1.0.27.dist-info/METADATA,sha256=2Y3QohUGL6P1VFBJ9zVjmfVSxvzyrPd94XHdYj-eZbU,231
22
- qrpa-1.0.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- qrpa-1.0.27.dist-info/top_level.txt,sha256=F6T5igi0fhXDucPPUbmmSC0qFCDEsH5eVijfVF48OFU,5
24
- qrpa-1.0.27.dist-info/RECORD,,
21
+ qrpa-1.0.28.dist-info/METADATA,sha256=9Ruc1VWX2khZoETKzoLTmxkRmQCdW3d2Ie0979gNQ_E,231
22
+ qrpa-1.0.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ qrpa-1.0.28.dist-info/top_level.txt,sha256=F6T5igi0fhXDucPPUbmmSC0qFCDEsH5eVijfVF48OFU,5
24
+ qrpa-1.0.28.dist-info/RECORD,,
File without changes