sc-common-interface 2.9.8__tar.gz → 2.9.9__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.
Files changed (18) hide show
  1. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/PKG-INFO +1 -1
  2. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/sc_common_interface/CommonOa.py +3 -2
  3. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/sc_common_interface/LiveCommonInterface.py +64 -19
  4. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/sc_common_interface/OperaMysql.py +8 -5
  5. sc_common_interface-2.9.9/sc_common_interface/OperaRedis.py +43 -0
  6. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/sc_common_interface/PostCommonInterface.py +0 -7
  7. sc_common_interface-2.9.9/sc_common_interface/__init__.py +0 -0
  8. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/sc_common_interface.egg-info/PKG-INFO +1 -1
  9. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/sc_common_interface.egg-info/SOURCES.txt +2 -1
  10. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/setup.py +1 -1
  11. sc_common_interface-2.9.8/sc_common_interface/Platform.py +0 -7
  12. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/sc_common_interface/McCommonInterface.py +0 -0
  13. /sc_common_interface-2.9.8/sc_common_interface/__init__.py → /sc_common_interface-2.9.9/sc_common_interface/ScPulsar.py +0 -0
  14. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/sc_common_interface/ScWebsocket.py +0 -0
  15. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/sc_common_interface.egg-info/dependency_links.txt +0 -0
  16. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/sc_common_interface.egg-info/requires.txt +0 -0
  17. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/sc_common_interface.egg-info/top_level.txt +0 -0
  18. {sc_common_interface-2.9.8 → sc_common_interface-2.9.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc_common_interface
3
- Version: 2.9.8
3
+ Version: 2.9.9
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -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
- """"编辑商品名称、隐藏价格、限购数量、预售时间,spu维度的编辑
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
  ------无规格商品编辑商品预购库存、无限库存-------
@@ -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
- platform = data["platform"].upper()
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"]
@@ -277,8 +272,7 @@ def send__live_comment(data):
277
272
  body = {"object":"page","entry":[{"id":page_id,"time":t_time,"messaging":[{"recipient":{"id":page_id},"message":keyword,
278
273
  "from":{"id":user_id,"name":name},"group_id":group_id,"post_id":post_id,"comment_id":comment_id,"created_time":stamp,"item":"comment",
279
274
  "verb":"add","parent_id":post_id,"field":"group_feed"}]}]}
280
-
281
- print(body)
275
+ # print(body)
282
276
  url = "%s/facebook/webhook" % env
283
277
  sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
284
278
  signData = sign_text.hexdigest()
@@ -341,6 +335,23 @@ def send_mc_message(data):
341
335
  # print(body)
342
336
  return user_id, name
343
337
 
338
+ def send_sl_comment(data):
339
+ env = data["env"]
340
+ headers = data["headers"]
341
+ sales_id = data["sales_id"]
342
+ url = "%s/api/posts/live/viewer/%s/send/comments"%(env,sales_id)
343
+ content = data.get("content","sl留言")
344
+ headers["content-type"] = "application/json"
345
+ body = {
346
+ "content": content
347
+ }
348
+ response = requests.post(url,headers=headers,json=body).json()
349
+ if response["code"]=="SUCCESS":
350
+ comment_id = response["data"]["comment_id"]
351
+ return comment_id
352
+ return response
353
+
354
+
344
355
 
345
356
 
346
357
  def get_live_info(data):
@@ -364,8 +375,6 @@ def get_live_info(data):
364
375
  return response.json()
365
376
 
366
377
 
367
-
368
-
369
378
  def get_activity_detail(data):
370
379
  """
371
380
  type:
@@ -494,7 +503,6 @@ def live_search_oa_product(data):
494
503
  return spu_id,sku_id,sku_id_quantity,product_info
495
504
 
496
505
 
497
-
498
506
  def get_merchant_info(data):
499
507
  env = data["env"]
500
508
  headers = data["headers"]
@@ -2444,18 +2452,55 @@ def add_product_to_live(data):
2444
2452
  return response
2445
2453
 
2446
2454
 
2447
- def get_merchant_currency(data):
2448
- env = data["env"]
2449
- headers = data["headers"]
2450
2455
 
2451
2456
 
2457
+ def send_comment():
2458
+ timStamp = int(time.time())
2459
+
2460
+ key = "a2f4cae7b637eb42967ef5ab6a6a3ff7"
2461
+ url = "https://front-service.shoplinestg.com/facebook/webhook"
2462
+ post_id = "119305964434044_9672903432799494"
2463
+ page_id = "119305964434044"
2464
+
2465
+ # message = "fb文3本消息%d"%timStamp
2466
+ # message = "%d" % random.randint(3, 999)
2467
+ message = "个哈哈哈"
2468
+
2469
+ #生产
2470
+ # key = 'a2f4cae7b637eb42967ef5ab6a6a3ff7'
2471
+ # url = 'https://front-admin.shoplineapp.com/facebook/webhook'
2472
+ # post_id = "107977035056574_1226869379002413"
2473
+ # page_id = "107977035056574"
2474
+
2475
+
2476
+ randnum = random.randint(1,1000)
2477
+ user_id = "4724508317%d%d" % (timStamp,randnum)
2478
+ # user_id = "47245083171744792310"0
2479
+ name = "️%d%dtest" % (randnum,timStamp)
2480
+ contentbody = {"entry": [{"id": page_id, "time": timStamp, "changes": [{"value": {
2481
+ "from": {"id": user_id, "name": name},
2482
+ "post": {"status_type": "added_video", "is_published": True, "updated_time": "2024-10-16T13:28:29+0000",
2483
+ "permalink_url": "https://www.facebook.com/161726309710099/videos/3266941630279674",
2484
+ "promotion_status": "inactive", "id": post_id}, "message": message, "post_id": post_id,
2485
+ "comment_id": "%s_350%d%d" % (page_id, int(time.time() * 1000),random.randint(4, 1000)), "created_time": timStamp, "item": "comment",
2486
+ "parent_id": post_id, "verb": "add"}, "field": "feed"}]}], "object": "page"}
2487
+ # print("contentbody", contentbody)
2488
+ # contentbody["entry"][0]["time"] = time
2452
2489
 
2490
+ signdata = hmac.new(key.encode('utf-8'), json.dumps(contentbody).encode('utf-8'), hashlib.sha1).hexdigest()
2491
+ signdata = signdata
2492
+ contentbody = json.dumps(contentbody)
2493
+ headers = {"Content-Type":"application/json","x-hub-signature":"sha1=%s"%signdata}
2494
+ res =requests.post(url,headers=headers,data=contentbody)
2495
+ print(res.content)
2453
2496
 
2454
2497
 
2455
2498
 
2456
2499
  if __name__=="__main__":
2457
- data = {'env': 'https://front-service.shoplinestg.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIwMzkzZTdlODQ2MDMzZmUyOTViMjllY2I1OWVjOTgwOSIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MjI5YTdiYWVhNzA2NDJhOGI2NWViZGEiLCJhcHBsaWNhdGlvbl9pZCI6IjYwZWVjNWViZjhkYzkyMDAwNjUyZTAwNiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMteXkuc2hvcGxpbmVzdGcuY29tIiwiYXVkIjpbXSwic3ViIjoiNjIyOWE3YmFlYTcwNjQyYThiNjVlYmRhIn0.pKkJD01uFDUfiVR2gBJQFd_EtIvQkHR2ScJzRTTOxxg', 'lang': 'en'}, 'sales_id': '90566', 'arr': 0}
2458
- add_product_set_to_live(data)
2500
+ # data = {"env":"https://front-service.shoplinestg.com","sales_id":"91371","headers":{"cookie":"viewerLogin_6229a7baea70642a8b65ebda=6998469593053840441"}}
2501
+ # res = send_sl_comment(data)
2502
+ # print(res)
2503
+ pass
2459
2504
 
2460
2505
 
2461
2506
 
@@ -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
- None,
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 = get_strf_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
@@ -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
  创建会员,若存在则合并会员
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.9.8
3
+ Version: 2.9.9
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -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/Platform.py
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
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='sc_common_interface',
5
- version='2.9.8',
5
+ version='2.9.9',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),
@@ -1,7 +0,0 @@
1
- from enum import Enum
2
-
3
-
4
- class Platform(Enum):
5
- FACEBOOK = 1
6
- INSTAGRAM = 2
7
- FB_GROUP = 3