sc-common-interface 2.9.8__tar.gz → 3.0.0__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-2.9.8 → sc_common_interface-3.0.0}/PKG-INFO +1 -1
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface/CommonOa.py +3 -2
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface/LiveCommonInterface.py +76 -18
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface/OperaMysql.py +8 -5
- sc_common_interface-3.0.0/sc_common_interface/OperaRedis.py +43 -0
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface/PostCommonInterface.py +0 -7
- sc_common_interface-3.0.0/sc_common_interface/__init__.py +0 -0
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface.egg-info/PKG-INFO +1 -1
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface.egg-info/SOURCES.txt +2 -1
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/setup.py +1 -1
- sc_common_interface-2.9.8/sc_common_interface/Platform.py +0 -7
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface/McCommonInterface.py +0 -0
- /sc_common_interface-2.9.8/sc_common_interface/__init__.py → /sc_common_interface-3.0.0/sc_common_interface/ScPulsar.py +0 -0
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface/ScWebsocket.py +0 -0
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface.egg-info/dependency_links.txt +0 -0
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface.egg-info/requires.txt +0 -0
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface.egg-info/top_level.txt +0 -0
- {sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/setup.cfg +0 -0
|
@@ -69,15 +69,16 @@ def get_product(data):
|
|
|
69
69
|
res = requests.get(url, headers=oa_headers).json()
|
|
70
70
|
return res
|
|
71
71
|
|
|
72
|
-
|
|
73
72
|
def edit_product_spu(data):
|
|
74
|
-
""""
|
|
73
|
+
""""
|
|
74
|
+
编辑商品名称、隐藏价格、限购数量、预售时间,spu维度的编辑
|
|
75
75
|
hide_price:false true
|
|
76
76
|
隐藏商品/下架商品[status]: hidden、active、draft
|
|
77
77
|
限购数量【max_order_quantity】:-1【不限购】
|
|
78
78
|
商品名称格式:
|
|
79
79
|
{'vi': '商品名称1734667300--多规格---编辑', 'th': '商品名称1734667300', 'zh-hant': '商品名称1734667300---编辑繁体', 'en': '商品名称1734667300-----编辑英文', 'id': '商品名称1734624132',
|
|
80
80
|
'fr': '商品名称1734624132', 'zh-cn': '商品名称1734667300----多篇规格简体中文'}
|
|
81
|
+
|
|
81
82
|
available_start_time 预购开始时间:格式:"2024-12-25T15:00:00.000+00:00"
|
|
82
83
|
available_end_time 预购结束时间:用不过期为null
|
|
83
84
|
------无规格商品编辑商品预购库存、无限库存-------
|
{sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface/LiveCommonInterface.py
RENAMED
|
@@ -8,6 +8,7 @@ import random
|
|
|
8
8
|
import hmac
|
|
9
9
|
from hashlib import sha1
|
|
10
10
|
import random
|
|
11
|
+
import json,hashlib,hmac
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
def delete_post(data):
|
|
@@ -18,7 +19,6 @@ def delete_post(data):
|
|
|
18
19
|
res = requests.delete(url, headers=headers).json()
|
|
19
20
|
return res
|
|
20
21
|
|
|
21
|
-
|
|
22
22
|
def delete_relate_post(data):
|
|
23
23
|
"""删除串接的facebook或fb group 避免影响串接"""
|
|
24
24
|
env = data["env"]
|
|
@@ -92,9 +92,6 @@ def delete_relate_post(data):
|
|
|
92
92
|
if count>=len(id_list):
|
|
93
93
|
return res
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
95
|
def get_sales_id(data):
|
|
99
96
|
""""查询返回指定直播间的salse_id
|
|
100
97
|
status:准备中 0,直播中 1 已结束 2 断线中 4
|
|
@@ -143,16 +140,15 @@ def get_sales_id(data):
|
|
|
143
140
|
else:
|
|
144
141
|
return sales_id, response
|
|
145
142
|
|
|
146
|
-
|
|
147
143
|
def create_activity(data):
|
|
148
144
|
env = data["env"]
|
|
149
145
|
headers = data["headers"]
|
|
150
146
|
body = data["body"]
|
|
151
147
|
sales_id = data["sales_id"]
|
|
152
148
|
url = "%s/admin/api/bff-web/live/activity/%s"%(env,sales_id)
|
|
153
|
-
platform = "FACEBOOK"
|
|
154
|
-
if "platform" in data:
|
|
155
|
-
|
|
149
|
+
# platform = "FACEBOOK"
|
|
150
|
+
# if "platform" in data:
|
|
151
|
+
# platform = data["platform"].upper()
|
|
156
152
|
response = requests.post(url,headers=headers,json=body)
|
|
157
153
|
# print(response.json())
|
|
158
154
|
if response.status_code==200:
|
|
@@ -222,7 +218,6 @@ def get_page_info(data):
|
|
|
222
218
|
page_info["permalink_url"] = permalink_url
|
|
223
219
|
return page_info
|
|
224
220
|
|
|
225
|
-
|
|
226
221
|
def send__live_comment(data):
|
|
227
222
|
env = data["env"]
|
|
228
223
|
key = data["key"]
|
|
@@ -240,6 +235,7 @@ def send__live_comment(data):
|
|
|
240
235
|
keyword = data.get("keyword", keyword)
|
|
241
236
|
# sales_type = data.get("sales_type", "live")
|
|
242
237
|
relationUrl = data.get("relationUrl","")
|
|
238
|
+
comment_type = data.get("comment_type","comment")
|
|
243
239
|
if page_id == "" or post_id == "key":
|
|
244
240
|
page_info = get_page_info(data)
|
|
245
241
|
page_id = page_info["page_id"]
|
|
@@ -277,8 +273,19 @@ def send__live_comment(data):
|
|
|
277
273
|
body = {"object":"page","entry":[{"id":page_id,"time":t_time,"messaging":[{"recipient":{"id":page_id},"message":keyword,
|
|
278
274
|
"from":{"id":user_id,"name":name},"group_id":group_id,"post_id":post_id,"comment_id":comment_id,"created_time":stamp,"item":"comment",
|
|
279
275
|
"verb":"add","parent_id":post_id,"field":"group_feed"}]}]}
|
|
276
|
+
elif platform.upper()=="FACEBOOK":
|
|
277
|
+
if "comment_type"=="comment":
|
|
278
|
+
body = {"object": "page", "entry": [{"id": page_id, "time": stamp, "changes": [{"field": "feed", "value": {
|
|
279
|
+
"from": {"id": user_id, "name": name},
|
|
280
|
+
"post": {"status_type": "added_video", "is_published": True, "updated_time": "2022-11-18T09:57:26+0000",
|
|
281
|
+
"permalink_url": "https://www.facebook.com/permalink.php?story_fbid=pfbid02jLK3e6YdFSXp2DmD7j7vtStLXoBzTi8rxKrp6jFhVMUTTEgz6qvZA8soR9Uwydd8l&id=107977035056574",
|
|
282
|
+
"promotion_status": "inactive", "id": post_id}, "message": keyword, "item": "comment",
|
|
283
|
+
"verb": "add", "post_id": post_id, "comment_id": comment_id,
|
|
284
|
+
"created_time": stamp, "parent_id": post_id}}]}]}
|
|
285
|
+
elif "comment_type"=="like":
|
|
286
|
+
body = {"entry": [{"id": page_id, "time": stamp, "changes": [{"value": {"from": {"id": user_id, "name": name}, "post_id": post_id, "created_time": stamp, "item": "reaction", "parent_id": post_id, "reaction_type": "like", "verb": "add"}, "field": "feed"}]}], "object": "page"}
|
|
280
287
|
|
|
281
|
-
print(body)
|
|
288
|
+
# print(body)
|
|
282
289
|
url = "%s/facebook/webhook" % env
|
|
283
290
|
sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
|
|
284
291
|
signData = sign_text.hexdigest()
|
|
@@ -341,6 +348,23 @@ def send_mc_message(data):
|
|
|
341
348
|
# print(body)
|
|
342
349
|
return user_id, name
|
|
343
350
|
|
|
351
|
+
def send_sl_comment(data):
|
|
352
|
+
env = data["env"]
|
|
353
|
+
headers = data["headers"]
|
|
354
|
+
sales_id = data["sales_id"]
|
|
355
|
+
url = "%s/api/posts/live/viewer/%s/send/comments"%(env,sales_id)
|
|
356
|
+
content = data.get("content","sl留言")
|
|
357
|
+
headers["content-type"] = "application/json"
|
|
358
|
+
body = {
|
|
359
|
+
"content": content
|
|
360
|
+
}
|
|
361
|
+
response = requests.post(url,headers=headers,json=body).json()
|
|
362
|
+
if response["code"]=="SUCCESS":
|
|
363
|
+
comment_id = response["data"]["comment_id"]
|
|
364
|
+
return comment_id
|
|
365
|
+
return response
|
|
366
|
+
|
|
367
|
+
|
|
344
368
|
|
|
345
369
|
|
|
346
370
|
def get_live_info(data):
|
|
@@ -364,8 +388,6 @@ def get_live_info(data):
|
|
|
364
388
|
return response.json()
|
|
365
389
|
|
|
366
390
|
|
|
367
|
-
|
|
368
|
-
|
|
369
391
|
def get_activity_detail(data):
|
|
370
392
|
"""
|
|
371
393
|
type:
|
|
@@ -494,7 +516,6 @@ def live_search_oa_product(data):
|
|
|
494
516
|
return spu_id,sku_id,sku_id_quantity,product_info
|
|
495
517
|
|
|
496
518
|
|
|
497
|
-
|
|
498
519
|
def get_merchant_info(data):
|
|
499
520
|
env = data["env"]
|
|
500
521
|
headers = data["headers"]
|
|
@@ -2444,18 +2465,55 @@ def add_product_to_live(data):
|
|
|
2444
2465
|
return response
|
|
2445
2466
|
|
|
2446
2467
|
|
|
2447
|
-
def get_merchant_currency(data):
|
|
2448
|
-
env = data["env"]
|
|
2449
|
-
headers = data["headers"]
|
|
2450
2468
|
|
|
2451
2469
|
|
|
2470
|
+
def send_comment():
|
|
2471
|
+
timStamp = int(time.time())
|
|
2472
|
+
|
|
2473
|
+
key = "a2f4cae7b637eb42967ef5ab6a6a3ff7"
|
|
2474
|
+
url = "https://front-service.shoplinestg.com/facebook/webhook"
|
|
2475
|
+
post_id = "119305964434044_9672903432799494"
|
|
2476
|
+
page_id = "119305964434044"
|
|
2477
|
+
|
|
2478
|
+
# message = "fb文3本消息%d"%timStamp
|
|
2479
|
+
# message = "%d" % random.randint(3, 999)
|
|
2480
|
+
message = "个哈哈哈"
|
|
2481
|
+
|
|
2482
|
+
#生产
|
|
2483
|
+
# key = 'a2f4cae7b637eb42967ef5ab6a6a3ff7'
|
|
2484
|
+
# url = 'https://front-admin.shoplineapp.com/facebook/webhook'
|
|
2485
|
+
# post_id = "107977035056574_1226869379002413"
|
|
2486
|
+
# page_id = "107977035056574"
|
|
2487
|
+
|
|
2488
|
+
|
|
2489
|
+
randnum = random.randint(1,1000)
|
|
2490
|
+
user_id = "4724508317%d%d" % (timStamp,randnum)
|
|
2491
|
+
# user_id = "47245083171744792310"0
|
|
2492
|
+
name = "️%d%dtest" % (randnum,timStamp)
|
|
2493
|
+
contentbody = {"entry": [{"id": page_id, "time": timStamp, "changes": [{"value": {
|
|
2494
|
+
"from": {"id": user_id, "name": name},
|
|
2495
|
+
"post": {"status_type": "added_video", "is_published": True, "updated_time": "2024-10-16T13:28:29+0000",
|
|
2496
|
+
"permalink_url": "https://www.facebook.com/161726309710099/videos/3266941630279674",
|
|
2497
|
+
"promotion_status": "inactive", "id": post_id}, "message": message, "post_id": post_id,
|
|
2498
|
+
"comment_id": "%s_350%d%d" % (page_id, int(time.time() * 1000),random.randint(4, 1000)), "created_time": timStamp, "item": "comment",
|
|
2499
|
+
"parent_id": post_id, "verb": "add"}, "field": "feed"}]}], "object": "page"}
|
|
2500
|
+
# print("contentbody", contentbody)
|
|
2501
|
+
# contentbody["entry"][0]["time"] = time
|
|
2452
2502
|
|
|
2503
|
+
signdata = hmac.new(key.encode('utf-8'), json.dumps(contentbody).encode('utf-8'), hashlib.sha1).hexdigest()
|
|
2504
|
+
signdata = signdata
|
|
2505
|
+
contentbody = json.dumps(contentbody)
|
|
2506
|
+
headers = {"Content-Type":"application/json","x-hub-signature":"sha1=%s"%signdata}
|
|
2507
|
+
res =requests.post(url,headers=headers,data=contentbody)
|
|
2508
|
+
print(res.content)
|
|
2453
2509
|
|
|
2454
2510
|
|
|
2455
2511
|
|
|
2456
2512
|
if __name__=="__main__":
|
|
2457
|
-
data = {
|
|
2458
|
-
|
|
2513
|
+
# data = {"env":"https://front-service.shoplinestg.com","sales_id":"91371","headers":{"cookie":"viewerLogin_6229a7baea70642a8b65ebda=6998469593053840441"}}
|
|
2514
|
+
# res = send_sl_comment(data)
|
|
2515
|
+
# print(res)
|
|
2516
|
+
pass
|
|
2459
2517
|
|
|
2460
2518
|
|
|
2461
2519
|
|
|
@@ -18,7 +18,7 @@ class OperaMysql():
|
|
|
18
18
|
self.port = port
|
|
19
19
|
self.con = pymysql.connect(host=self.host,user=self.username,password=self.password,database=self.db,port=self.port)
|
|
20
20
|
#whatsapp 广播
|
|
21
|
-
def whatsapp_broadcast_update(self,num,merchantId,waba,phone,country_code="86"):
|
|
21
|
+
def whatsapp_broadcast_update(self,num,merchantId,waba,phone,country_code="86",interaction_time=None):
|
|
22
22
|
"""
|
|
23
23
|
:param num: 要插入的数据条数
|
|
24
24
|
:param merchantId:店铺ID
|
|
@@ -37,6 +37,8 @@ class OperaMysql():
|
|
|
37
37
|
# 准备批量插入的数据
|
|
38
38
|
insert_data = []
|
|
39
39
|
formatted_time =get_strf_time()
|
|
40
|
+
if interaction_time==None:
|
|
41
|
+
interaction_time = get_strf_time()
|
|
40
42
|
# print(id)
|
|
41
43
|
for i in range(num):
|
|
42
44
|
phone+=1
|
|
@@ -52,7 +54,7 @@ class OperaMysql():
|
|
|
52
54
|
phone_str,
|
|
53
55
|
phone_str,
|
|
54
56
|
2,
|
|
55
|
-
|
|
57
|
+
interaction_time,
|
|
56
58
|
None,
|
|
57
59
|
None,
|
|
58
60
|
phone_str,
|
|
@@ -83,12 +85,13 @@ class OperaMysql():
|
|
|
83
85
|
cur.close()
|
|
84
86
|
self.con.close()
|
|
85
87
|
#line、faceboook 、instagram 平台广播
|
|
86
|
-
def other_broadcast_update(self,num,page_id,platform):
|
|
88
|
+
def other_broadcast_update(self,num,page_id,platform,interaction_time=None):
|
|
87
89
|
"""
|
|
88
90
|
page_id、platform 需要替换成自己店铺的数据,
|
|
89
91
|
num 为 插入的条数
|
|
90
92
|
"""
|
|
91
|
-
interaction_time
|
|
93
|
+
if interaction_time==None:
|
|
94
|
+
interaction_time = get_strf_time()
|
|
92
95
|
cur = self.con.cursor()
|
|
93
96
|
select_sql = """
|
|
94
97
|
select max(id) from sl_uc_test.uc_user_interaction ;
|
|
@@ -129,7 +132,6 @@ class OperaMysql():
|
|
|
129
132
|
cur.close()
|
|
130
133
|
self.con.close()
|
|
131
134
|
|
|
132
|
-
|
|
133
135
|
def select(self,select_sql):
|
|
134
136
|
# con = con_mysql()
|
|
135
137
|
cur = self.con.cursor()
|
|
@@ -137,6 +139,7 @@ class OperaMysql():
|
|
|
137
139
|
data = cur.fetchall()
|
|
138
140
|
return data
|
|
139
141
|
|
|
142
|
+
|
|
140
143
|
def generate_random_string(length):
|
|
141
144
|
characters = string.ascii_letters + string.digits
|
|
142
145
|
return ''.join(secrets.choice(characters) for _ in range(length))
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import redis
|
|
2
|
+
import time,random
|
|
3
|
+
import csv
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class OperaRedis():
|
|
7
|
+
def __init__(self,redis_host,redis_port,redis_password = None):
|
|
8
|
+
self.redis_host = redis_host
|
|
9
|
+
self.redis_port = redis_port
|
|
10
|
+
self.redis_password = redis_password
|
|
11
|
+
self.connect = redis.Redis(host=redis_host, db=1, port=redis_port, password=redis_password)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def set_key(self,set_key,set_value):
|
|
15
|
+
try:
|
|
16
|
+
self.connect.set(set_key, set_value) # 设置键值对
|
|
17
|
+
except Exception as e:
|
|
18
|
+
print(f"Error: {e}")
|
|
19
|
+
finally:
|
|
20
|
+
self.connect.close()
|
|
21
|
+
|
|
22
|
+
def get_key(self,key):
|
|
23
|
+
try:
|
|
24
|
+
keys = self.connect.keys(key) # 设置键值对
|
|
25
|
+
data_list = []
|
|
26
|
+
for key in keys:
|
|
27
|
+
data = str(key.decode()).replace("_", "=").replace(":", "_")
|
|
28
|
+
data_list.append(data)
|
|
29
|
+
write_to_csv(data_list)
|
|
30
|
+
except Exception as e:
|
|
31
|
+
print(f"Error: {e}")
|
|
32
|
+
finally:
|
|
33
|
+
self.connect.close()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def write_to_csv(data,file_name = "../test_data/view_cookie.csv"):
|
|
37
|
+
with open(file_name, mode='w', newline='', encoding='utf-8') as file:
|
|
38
|
+
writer = csv.writer(file)
|
|
39
|
+
# 写入多行数据
|
|
40
|
+
writer.writerows(data)
|
|
41
|
+
|
|
42
|
+
if __name__=="__main__":
|
|
43
|
+
pass
|
{sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface/PostCommonInterface.py
RENAMED
|
@@ -35,7 +35,6 @@ def create_general_post(data):
|
|
|
35
35
|
patternModel = "INCLUDE_MATCH"
|
|
36
36
|
if "patternModel" in data:
|
|
37
37
|
patternModel = data["patternModel"]
|
|
38
|
-
headers = data["headers"]
|
|
39
38
|
title = "接口自动化创建的普通贴文%d"%int(time.time())
|
|
40
39
|
if "title" in data:
|
|
41
40
|
title = data["title"]
|
|
@@ -424,8 +423,6 @@ def get_page_post(data):
|
|
|
424
423
|
return response
|
|
425
424
|
|
|
426
425
|
|
|
427
|
-
|
|
428
|
-
|
|
429
426
|
def relate_post(data):
|
|
430
427
|
"""
|
|
431
428
|
链接贴文,只链接返回的第一个可链接的贴文
|
|
@@ -819,8 +816,6 @@ def send_post_comment(data):
|
|
|
819
816
|
response = requests.post(url, headers=header, data=json.dumps(body))
|
|
820
817
|
return user_id,name,comment_id
|
|
821
818
|
|
|
822
|
-
|
|
823
|
-
|
|
824
819
|
def get_payment(data):
|
|
825
820
|
"""
|
|
826
821
|
获取店铺的付款方式,默认查询10条
|
|
@@ -913,7 +908,6 @@ def post_edit_cart(data):
|
|
|
913
908
|
response = requests.post(url, headers=headers, json=body).json()
|
|
914
909
|
return response
|
|
915
910
|
|
|
916
|
-
|
|
917
911
|
def search_customer(data):
|
|
918
912
|
env = data["env"]
|
|
919
913
|
headers = data["headers"]
|
|
@@ -964,7 +958,6 @@ def merge_customer(data):
|
|
|
964
958
|
customer_id = response.json()["data"]["id"]
|
|
965
959
|
return response,customer_id
|
|
966
960
|
|
|
967
|
-
|
|
968
961
|
def manual_order(data):
|
|
969
962
|
"""
|
|
970
963
|
创建会员,若存在则合并会员
|
|
File without changes
|
{sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface.egg-info/SOURCES.txt
RENAMED
|
@@ -3,8 +3,9 @@ sc_common_interface/CommonOa.py
|
|
|
3
3
|
sc_common_interface/LiveCommonInterface.py
|
|
4
4
|
sc_common_interface/McCommonInterface.py
|
|
5
5
|
sc_common_interface/OperaMysql.py
|
|
6
|
-
sc_common_interface/
|
|
6
|
+
sc_common_interface/OperaRedis.py
|
|
7
7
|
sc_common_interface/PostCommonInterface.py
|
|
8
|
+
sc_common_interface/ScPulsar.py
|
|
8
9
|
sc_common_interface/ScWebsocket.py
|
|
9
10
|
sc_common_interface/__init__.py
|
|
10
11
|
sc_common_interface.egg-info/PKG-INFO
|
{sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface/McCommonInterface.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface.egg-info/requires.txt
RENAMED
|
File without changes
|
{sc_common_interface-2.9.8 → sc_common_interface-3.0.0}/sc_common_interface.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|