sc-common-interface 2.6.1__tar.gz → 2.6.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.6.1
3
+ Version: 2.6.3
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -7,6 +7,77 @@ import random
7
7
  import hmac
8
8
  from hashlib import sha1
9
9
  import random
10
+ from PostCommonInterface import *
11
+
12
+ # def delete_post(data):
13
+ # env = data["env"]
14
+ # headers = data["headers"]
15
+ # sales_id = data["sales_id"]
16
+ # url = "%s/api/posts/post/sales/%s"%(env,sales_id)
17
+ # res = requests.delete(url, headers=headers).json()
18
+ # return res
19
+
20
+ def delete_relate_post(data):
21
+ """删除串接的facebook或fb group 避免影响串接"""
22
+ env = data["env"]
23
+ headers = data["headers"]
24
+ url = "%s/api/posts/post/sales" % env
25
+ sales_type = "LIVE"
26
+ if "sales_type" in data:
27
+ sales_type = data["sales_type"]
28
+ param = {"page_num": 1, "page_size": 100, "sales_type": sales_type}
29
+ platform = "facebook"
30
+ post_id = data["post_id"]
31
+ if "platform" in data:
32
+ platform = data["platform"].upper()
33
+ param["platforms"] = platform
34
+ if "search" in data:
35
+ search_word = data["search"]
36
+ param["search_word"] = search_word
37
+ response = requests.get(url, headers=headers, params=param).json()
38
+ # print("url",url)
39
+ # print("param", param)
40
+ # print("response",response)
41
+ sales_data = response["data"]["list"]
42
+ print("sales_data",sales_data)
43
+ status = [1,2]
44
+ if "status" in data:
45
+ status = data["status"]
46
+ for i in sales_data:
47
+ platforms = i["platforms"]
48
+ post_sale_status = i["post_sale_status"]
49
+ if platforms == [platform.upper()] and post_sale_status in status:
50
+ sales_id = i["id"]
51
+ data["sales_id"] = sales_id
52
+ # print(sales_id)
53
+ response = get_live_info(data)
54
+ relatedPostList = response["data"]["relatedPostList"]
55
+ if platform.lower() == "facebook":
56
+ for i in relatedPostList:
57
+ fb_post_id = i["post_id"]
58
+ # print("fb_post_id",fb_post_id)
59
+ # print("post_id", post_id)
60
+ if fb_post_id.strip() in post_id:
61
+ print("找到串接的帖文:%s"%sales_id)
62
+ res = delete_post(data)
63
+ # print(res)
64
+ return res
65
+ elif platform.lower()=="fb_group":
66
+ for i in relatedPostList:
67
+ permalink_url = i["permalink_url"]
68
+ permalink_url = permalink_url.split("permalink/")[-1]
69
+ id_list = []
70
+ for id in post_id:
71
+ idData = id.split("posts/")[-1]
72
+ id_list.append(idData)
73
+ # print("permalink_url",permalink_url)
74
+ # print("post_id", post_id)
75
+ if permalink_url.strip() in id_list:
76
+ print("找到串接的帖文:%s" % sales_id)
77
+ res = delete_post(data)
78
+ return res
79
+
80
+
10
81
 
11
82
 
12
83
 
@@ -15,6 +86,7 @@ def get_sales_id(data):
15
86
  """"查询返回指定直播间的salse_id
16
87
  status:准备中 0,直播中 1 已结束 2 断线中 4
17
88
  """
89
+
18
90
  env = data["env"]
19
91
  headers = data["headers"]
20
92
  url = "%s/api/posts/post/sales"%env
@@ -369,7 +441,7 @@ def live_search_oa_product(data):
369
441
  if quantitys!=0 or unlimited_quantity==True:
370
442
  product_info = items[a]
371
443
  spu_id = items[a]["id"]
372
- sku_id = jsonpath(items[a]["variations"],"$..id")
444
+ sku_id = jsonpath(items[a]["variations"],"$.._id")
373
445
  sku_id_quantity = jsonpath(items[a]["variations"],"$..total_orderable_quantity")
374
446
  break
375
447
  elif type == "spu" and b == [] and quantity == 0:
@@ -770,9 +842,19 @@ def create_live(data):
770
842
  sales_id = response.json()["data"]["sales"]["id"]
771
843
  return sales_id
772
844
  else:
845
+ time.sleep(1)
773
846
  count=count+1
774
847
  if count>10:
775
- return 1000
848
+ platform = "facebook"
849
+ status = 0
850
+ if "platform" in data:
851
+ platform = data["platform"]
852
+ if "status" in data:
853
+ status = data["status"]
854
+ data["platform"] = platform
855
+ data["status"] = status
856
+ sales_id,__ = get_sales_id(data)
857
+ return sales_id
776
858
 
777
859
  # print(json.dumps(body))
778
860
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.6.1
3
+ Version: 2.6.3
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -1,2 +1,3 @@
1
1
  requests>=2.0.0
2
2
  jsonpath>=0.82
3
+ sc-common-interface>=2.6.2
@@ -2,12 +2,13 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='sc-common-interface',
5
- version='2.6.1',
5
+ version='2.6.3',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),
9
9
  install_requires=[
10
10
  "requests>=2.0.0",
11
11
  "jsonpath>=0.82",
12
+ "sc-common-interface>=2.6.2"
12
13
  ],
13
14
  )