sc-common-interface 3.1.9__tar.gz → 3.2.2__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.
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/PKG-INFO +1 -1
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface/LiveCommonInterface.py +13 -6
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface/PostCommonInterface.py +9 -2
- sc_common_interface-3.2.2/sc_common_interface/pra.py +47 -0
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface.egg-info/PKG-INFO +1 -1
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface.egg-info/SOURCES.txt +1 -0
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/setup.py +1 -1
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface/CommonOa.py +0 -0
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface/McCommonInterface.py +0 -0
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface/OperaMysql.py +0 -0
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface/OperaRedis.py +0 -0
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface/ScPulsar.py +0 -0
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface/ScWebsocket.py +0 -0
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface/__init__.py +0 -0
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface.egg-info/dependency_links.txt +0 -0
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface.egg-info/requires.txt +0 -0
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface.egg-info/top_level.txt +0 -0
- {sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/setup.cfg +0 -0
{sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface/LiveCommonInterface.py
RENAMED
|
@@ -465,10 +465,11 @@ def live_search_oa_gift(data):
|
|
|
465
465
|
"""
|
|
466
466
|
env = data["env"]
|
|
467
467
|
headers = data["headers"]
|
|
468
|
-
url = "%s/
|
|
468
|
+
url = "%s/admin/api/bff-web/live/sale/718581/product/gift/list?pageNum=1&pageSize=10" % env
|
|
469
469
|
params = {"page": 1}
|
|
470
470
|
response = requests.get(url, headers=headers, params=params).json()
|
|
471
|
-
|
|
471
|
+
# print(response)
|
|
472
|
+
items = response["data"]["list"]
|
|
472
473
|
|
|
473
474
|
if items == []:
|
|
474
475
|
# 新增赠品
|
|
@@ -478,15 +479,17 @@ def live_search_oa_gift(data):
|
|
|
478
479
|
time.sleep(5)
|
|
479
480
|
# 新增后去查询
|
|
480
481
|
response = requests.get(url, headers=headers, params=params).json()
|
|
481
|
-
items = response["data"]["
|
|
482
|
+
items = response["data"]["list"]
|
|
482
483
|
|
|
483
484
|
# 返回数量不是0的赠品和spu_id
|
|
484
485
|
# print(json.dumps(items))
|
|
485
486
|
quantityList = jsonpath(items, "$..quantity")
|
|
487
|
+
# print(quantityList)
|
|
486
488
|
gift_info = items[0]
|
|
487
489
|
for a, b in enumerate(quantityList):
|
|
488
490
|
if b != 0:
|
|
489
491
|
gift_info = items[a]
|
|
492
|
+
break
|
|
490
493
|
spu_id = gift_info["id"]
|
|
491
494
|
return spu_id, gift_info, response
|
|
492
495
|
|
|
@@ -1744,12 +1747,14 @@ def get_live_product(data):
|
|
|
1744
1747
|
headers = data["headers"]
|
|
1745
1748
|
sales_id = data["sales_id"]
|
|
1746
1749
|
query = ""
|
|
1750
|
+
query_type = "PRODUCT_NAME"
|
|
1747
1751
|
if "query" in data:
|
|
1748
1752
|
query = data["query"]
|
|
1753
|
+
query_type = data["query_type"]
|
|
1749
1754
|
url = "%s/admin/api/bff-web/live/sale/%s/sale_list/product" % (env, sales_id)
|
|
1750
1755
|
params = {"salesId": sales_id, "pageIndex": 1, "pageSize": 25, }
|
|
1751
1756
|
if query != "":
|
|
1752
|
-
params["queryType"] =
|
|
1757
|
+
params["queryType"] = query_type
|
|
1753
1758
|
params["query"] = query
|
|
1754
1759
|
response = requests.get(url, headers=headers, params=params).json()
|
|
1755
1760
|
return response
|
|
@@ -1870,8 +1875,10 @@ def get_produnct_set_detail(data):
|
|
|
1870
1875
|
headers = data["headers"]
|
|
1871
1876
|
product_id = data["product_id"]
|
|
1872
1877
|
sales_id = data["sales_id"]
|
|
1878
|
+
if isinstance(product_id, list):
|
|
1879
|
+
product_id = product_id[0]
|
|
1873
1880
|
url = "%s/admin/api/bff-web/live/sale/%s/product/product_set/%s" % (env, sales_id, product_id)
|
|
1874
|
-
|
|
1881
|
+
print(url)
|
|
1875
1882
|
count = 0
|
|
1876
1883
|
while True:
|
|
1877
1884
|
response = requests.get(url, headers=headers)
|
|
@@ -1909,7 +1916,7 @@ def add_product_set_to_live(data):
|
|
|
1909
1916
|
data["product_id"] = product_id
|
|
1910
1917
|
# 查询组合商品详情信息
|
|
1911
1918
|
response = get_produnct_set_detail(data)
|
|
1912
|
-
|
|
1919
|
+
print(response)
|
|
1913
1920
|
products = []
|
|
1914
1921
|
zi_list = response["data"]
|
|
1915
1922
|
# print(zi_list)
|
{sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface/PostCommonInterface.py
RENAMED
|
@@ -1231,6 +1231,9 @@ def modelone_create_single_product(data):
|
|
|
1231
1231
|
sales_id = data["sales_id"]
|
|
1232
1232
|
quantity = 1000
|
|
1233
1233
|
price = 3
|
|
1234
|
+
keyword_type = "customKey"
|
|
1235
|
+
keyword_type = data["keyword_type"]
|
|
1236
|
+
|
|
1234
1237
|
if "quantity" in data:
|
|
1235
1238
|
quantity = data["quantity"]
|
|
1236
1239
|
url = "%s/admin/api/bff-web/live/sale/%s/sale_list/product/create" % (env, sales_id)
|
|
@@ -1242,8 +1245,12 @@ def modelone_create_single_product(data):
|
|
|
1242
1245
|
keyword = data["keyword"]
|
|
1243
1246
|
if "price" in data:
|
|
1244
1247
|
price = data["price"]
|
|
1245
|
-
|
|
1246
|
-
|
|
1248
|
+
if keyword_type=="customNumber":
|
|
1249
|
+
body = {"customNumber":keyword,"quantity":quantity,"unlimitedQuantity":False,"productName":product_name,
|
|
1250
|
+
"imageUrl":"https://s3-ap-southeast-1.amazonaws.com/static.shoplineapp.com/sc-admin/product-default.png","price":price}
|
|
1251
|
+
else:
|
|
1252
|
+
body = {"customKey":keyword,"quantity":quantity,"unlimitedQuantity":False,"productName":product_name,
|
|
1253
|
+
"imageUrl":"https://s3-ap-southeast-1.amazonaws.com/static.shoplineapp.com/sc-admin/product-default.png","price":price}
|
|
1247
1254
|
response = requests.post(url,headers=headers,json=body).json()
|
|
1248
1255
|
# print(body)
|
|
1249
1256
|
print(response)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from PIL import Image
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def adjust_to_exact_size(input_path, output_path, target_size_bytes):
|
|
6
|
+
# 打开原图并转换为 RGB 模式(避免带透明通道的图片保存出错)
|
|
7
|
+
img = Image.open(input_path).convert('RGB')
|
|
8
|
+
|
|
9
|
+
# 降质保存的临时文件路径
|
|
10
|
+
temp_path = "temp_adjusted.jpg"
|
|
11
|
+
|
|
12
|
+
# 二分法查找合适的 quality 参数 (1-100)
|
|
13
|
+
low, high = 1, 100
|
|
14
|
+
best_quality = 95
|
|
15
|
+
tolerance = 1024 # 允许 1KB 的误差
|
|
16
|
+
|
|
17
|
+
while low <= high:
|
|
18
|
+
mid = (low + high) // 2
|
|
19
|
+
# 保存为最高质量 JPEG 以增大体积,禁用优化
|
|
20
|
+
img.save(temp_path, format='JPEG', quality=mid, optimize=False)
|
|
21
|
+
|
|
22
|
+
current_size = os.path.getsize(temp_path)
|
|
23
|
+
|
|
24
|
+
if abs(current_size - target_size_bytes) <= tolerance:
|
|
25
|
+
best_quality = mid
|
|
26
|
+
break
|
|
27
|
+
elif current_size < target_size_bytes:
|
|
28
|
+
best_quality = mid
|
|
29
|
+
low = mid + 1
|
|
30
|
+
else:
|
|
31
|
+
high = mid - 1
|
|
32
|
+
|
|
33
|
+
# 使用找到的最佳质量保存最终文件
|
|
34
|
+
img.save(output_path, format='JPEG', quality=best_quality, optimize=False)
|
|
35
|
+
|
|
36
|
+
# 清理临时文件
|
|
37
|
+
if os.path.exists(temp_path):
|
|
38
|
+
os.remove(temp_path)
|
|
39
|
+
|
|
40
|
+
final_size = os.path.getsize(output_path)
|
|
41
|
+
print(f"处理完成!最终文件大小: {final_size / (1024 * 1024):.2f} MB (目标: 25 MB)")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# 执行调整
|
|
45
|
+
# 注意:将 'input.jpg' 替换为你的实际图片路径
|
|
46
|
+
adjust_to_exact_size('input.jpg', 'output_exact_25mb.jpg', 25 * 1024 * 1024)
|
|
47
|
+
|
{sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface.egg-info/SOURCES.txt
RENAMED
|
@@ -8,6 +8,7 @@ sc_common_interface/PostCommonInterface.py
|
|
|
8
8
|
sc_common_interface/ScPulsar.py
|
|
9
9
|
sc_common_interface/ScWebsocket.py
|
|
10
10
|
sc_common_interface/__init__.py
|
|
11
|
+
sc_common_interface/pra.py
|
|
11
12
|
sc_common_interface.egg-info/PKG-INFO
|
|
12
13
|
sc_common_interface.egg-info/SOURCES.txt
|
|
13
14
|
sc_common_interface.egg-info/dependency_links.txt
|
|
File without changes
|
{sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface/McCommonInterface.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface.egg-info/requires.txt
RENAMED
|
File without changes
|
{sc_common_interface-3.1.9 → sc_common_interface-3.2.2}/sc_common_interface.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|