sc-common-interface 3.1.7__tar.gz → 3.2.1__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.7 → sc_common_interface-3.2.1}/PKG-INFO +1 -1
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface/LiveCommonInterface.py +21 -11
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface/PostCommonInterface.py +13 -4
- sc_common_interface-3.2.1/sc_common_interface/pra.py +47 -0
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface.egg-info/PKG-INFO +1 -1
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface.egg-info/SOURCES.txt +1 -0
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/setup.py +1 -1
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface/CommonOa.py +0 -0
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface/McCommonInterface.py +0 -0
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface/OperaMysql.py +0 -0
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface/OperaRedis.py +0 -0
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface/ScPulsar.py +0 -0
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface/ScWebsocket.py +0 -0
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface/__init__.py +0 -0
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface.egg-info/dependency_links.txt +0 -0
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface.egg-info/requires.txt +0 -0
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface.egg-info/top_level.txt +0 -0
- {sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/setup.cfg +0 -0
{sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface/LiveCommonInterface.py
RENAMED
|
@@ -361,14 +361,18 @@ def send_mc_message(data):
|
|
|
361
361
|
"text": "%s" % message}}]}]}
|
|
362
362
|
elif type == "postback" and platform.upper() in ("FB_GROUP", "FACEBOOK"):
|
|
363
363
|
# t_time = stamp * 1000
|
|
364
|
+
message = "fb--continue"
|
|
365
|
+
message = data.get("message", message)
|
|
364
366
|
body = {"object": "page", "entry": [{"time": stamp, "id": "%s" % page_id, "messaging": [
|
|
365
367
|
{"sender": {"id": "%s" % user_id}, "recipient": {"id": "%s" % page_id}, "timestamp": stamp,
|
|
366
|
-
"postback": {"title":
|
|
368
|
+
"postback": {"title": message, "payload": payload,
|
|
367
369
|
"mid": "m_w6KNGd0PMndK0LvCw7Hzy1zsVSWT0fpN3ievQ9LtB0NxnnTQGDMyKI5DFeVbaJIRni1cqqJYXIJ-wq98aw%d" % stamp}}]}]}
|
|
368
370
|
elif type == "postback" and platform.lower() == "instagram":
|
|
371
|
+
message = "ig--continue"
|
|
372
|
+
message = data.get("message", message)
|
|
369
373
|
body = {"object": "instagram", "entry": [{"time": stamp, "id": "%s" % page_id, "messaging": [
|
|
370
374
|
{"sender": {"id": "%s" % user_id}, "recipient": {"id": "%s" % page_id}, "timestamp": stamp,
|
|
371
|
-
"postback": {"title":
|
|
375
|
+
"postback": {"title": message, "payload": payload,
|
|
372
376
|
"mid": "m_w6KNGd0PMndK0LvCw7Hzy1zsVSWT0fpN3ievQ9LtB0NxnnTQGDMyKI5DFeVbaJIRni1cqqJYXIJ-wq98aw%d" % stamp}}]}]}
|
|
373
377
|
|
|
374
378
|
url = "%s/facebook/webhook" % env
|
|
@@ -377,7 +381,7 @@ def send_mc_message(data):
|
|
|
377
381
|
header = {"Content-Type": "application/json", "x-hub-signature": "sha1=%s" % signData}
|
|
378
382
|
response = requests.post(url, headers=header, data=json.dumps(body))
|
|
379
383
|
# print(response.text)
|
|
380
|
-
|
|
384
|
+
print(body)
|
|
381
385
|
return user_id, name
|
|
382
386
|
|
|
383
387
|
|
|
@@ -461,10 +465,11 @@ def live_search_oa_gift(data):
|
|
|
461
465
|
"""
|
|
462
466
|
env = data["env"]
|
|
463
467
|
headers = data["headers"]
|
|
464
|
-
url = "%s/
|
|
468
|
+
url = "%s/admin/api/bff-web/live/sale/718581/product/gift/list?pageNum=1&pageSize=10" % env
|
|
465
469
|
params = {"page": 1}
|
|
466
470
|
response = requests.get(url, headers=headers, params=params).json()
|
|
467
|
-
|
|
471
|
+
# print(response)
|
|
472
|
+
items = response["data"]["list"]
|
|
468
473
|
|
|
469
474
|
if items == []:
|
|
470
475
|
# 新增赠品
|
|
@@ -474,15 +479,17 @@ def live_search_oa_gift(data):
|
|
|
474
479
|
time.sleep(5)
|
|
475
480
|
# 新增后去查询
|
|
476
481
|
response = requests.get(url, headers=headers, params=params).json()
|
|
477
|
-
items = response["data"]["
|
|
482
|
+
items = response["data"]["list"]
|
|
478
483
|
|
|
479
484
|
# 返回数量不是0的赠品和spu_id
|
|
480
485
|
# print(json.dumps(items))
|
|
481
486
|
quantityList = jsonpath(items, "$..quantity")
|
|
487
|
+
# print(quantityList)
|
|
482
488
|
gift_info = items[0]
|
|
483
489
|
for a, b in enumerate(quantityList):
|
|
484
490
|
if b != 0:
|
|
485
491
|
gift_info = items[a]
|
|
492
|
+
break
|
|
486
493
|
spu_id = gift_info["id"]
|
|
487
494
|
return spu_id, gift_info, response
|
|
488
495
|
|
|
@@ -1740,12 +1747,14 @@ def get_live_product(data):
|
|
|
1740
1747
|
headers = data["headers"]
|
|
1741
1748
|
sales_id = data["sales_id"]
|
|
1742
1749
|
query = ""
|
|
1750
|
+
query_type = "PRODUCT_NAME"
|
|
1743
1751
|
if "query" in data:
|
|
1744
1752
|
query = data["query"]
|
|
1753
|
+
query_type = data["query_type"]
|
|
1745
1754
|
url = "%s/admin/api/bff-web/live/sale/%s/sale_list/product" % (env, sales_id)
|
|
1746
1755
|
params = {"salesId": sales_id, "pageIndex": 1, "pageSize": 25, }
|
|
1747
1756
|
if query != "":
|
|
1748
|
-
params["queryType"] =
|
|
1757
|
+
params["queryType"] = query_type
|
|
1749
1758
|
params["query"] = query
|
|
1750
1759
|
response = requests.get(url, headers=headers, params=params).json()
|
|
1751
1760
|
return response
|
|
@@ -2482,7 +2491,7 @@ def add_product_to_live(data):
|
|
|
2482
2491
|
sales_id = data["sales_id"]
|
|
2483
2492
|
keyword = ["pythonaddkeyword%d" % int(time.time())]
|
|
2484
2493
|
keyword = data.get("keyword", keyword)
|
|
2485
|
-
url = "%s/api/
|
|
2494
|
+
url = "%s/admin/api/bff-web/live/sale/%s/sale_list/product" % (env, sales_id)
|
|
2486
2495
|
product_id = data["product_id"]
|
|
2487
2496
|
missCommonKey = data.get("missCommonKey", True)
|
|
2488
2497
|
customNumber = data.get("customNumber", [])
|
|
@@ -2689,7 +2698,7 @@ def syn_line_product(data):
|
|
|
2689
2698
|
sales_id = data["sales_id"]
|
|
2690
2699
|
product_id = data["product_id"]
|
|
2691
2700
|
line_status = data.get("line_status","HIDDEN")
|
|
2692
|
-
url = "%s/api/
|
|
2701
|
+
url = "%s/admin/api/bff-web/live/sale/%s/%s/status?status=%s"%(env,sales_id,product_id,line_status)
|
|
2693
2702
|
response = requests.post(url,headers=headers).json()
|
|
2694
2703
|
return response
|
|
2695
2704
|
|
|
@@ -2761,8 +2770,9 @@ def get_live_global(data):
|
|
|
2761
2770
|
|
|
2762
2771
|
|
|
2763
2772
|
if __name__ == "__main__":
|
|
2764
|
-
|
|
2765
|
-
|
|
2773
|
+
data = {'env': 'https://front-admin-preview.shoplineapp.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI4MDczNjE1NGQyMTMwYjUzODJiMWQ1MTE3YjdlMTY4ZiIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjYyN2M3NTBhMDYyMzcwMDAwYWZlNWVmZCJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.uvHtcxIhhvoy_0ll8yt566qdKJPddEJJsWo_siCtCI0', 'lang': 'en', 'user-agent': 'ShoplineQuality/1.5-python'}, 'sales_id': 725225}
|
|
2774
|
+
res = live_search_oa_gift(data)
|
|
2775
|
+
print(res)
|
|
2766
2776
|
|
|
2767
2777
|
|
|
2768
2778
|
|
{sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/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)
|
|
@@ -1337,7 +1344,7 @@ def modelone_create_mutil_product(data):
|
|
|
1337
1344
|
combinations.extend(itertools.product(custom_keys[i], custom_keys[j]))
|
|
1338
1345
|
for i in range(len(combinations)):
|
|
1339
1346
|
variantion = {}
|
|
1340
|
-
variantion["price"] = price
|
|
1347
|
+
variantion["price"] = str(price)
|
|
1341
1348
|
variantion["quantity"] = quantity
|
|
1342
1349
|
variantion["keyList"] = [keyword + "%d" % i]
|
|
1343
1350
|
variantion["variantOptionKeys"] = list(combinations[i])
|
|
@@ -1353,7 +1360,9 @@ def modelone_create_mutil_product(data):
|
|
|
1353
1360
|
"variations": variations,
|
|
1354
1361
|
"price": 0
|
|
1355
1362
|
}
|
|
1363
|
+
print(body)
|
|
1356
1364
|
response = requests.post(url, headers=headers, json=body).json()
|
|
1365
|
+
print(response)
|
|
1357
1366
|
spu_id = response["data"]
|
|
1358
1367
|
return spu_id
|
|
1359
1368
|
|
|
@@ -1732,4 +1741,4 @@ def edit_message(data):
|
|
|
1732
1741
|
|
|
1733
1742
|
|
|
1734
1743
|
if __name__=="__main__":
|
|
1735
|
-
|
|
1744
|
+
pass
|
|
@@ -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.7 → sc_common_interface-3.2.1}/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.7 → sc_common_interface-3.2.1}/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.7 → sc_common_interface-3.2.1}/sc_common_interface.egg-info/requires.txt
RENAMED
|
File without changes
|
{sc_common_interface-3.1.7 → sc_common_interface-3.2.1}/sc_common_interface.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|