sc-common-interface 2.6.0__tar.gz → 2.6.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.6.0
3
+ Version: 2.6.2
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -7,6 +7,121 @@ import random
7
7
  import hmac
8
8
  from hashlib import sha1
9
9
  import random
10
+ from PostCommonInterface import *
11
+
12
+
13
+ def delete_relate_post(data):
14
+ """删除串接的facebook或fb group 避免影响串接"""
15
+ env = data["env"]
16
+ headers = data["headers"]
17
+ url = "%s/api/posts/post/sales" % env
18
+ sales_type = "LIVE"
19
+ if "sales_type" in data:
20
+ sales_type = data["sales_type"]
21
+ param = {"page_num": 1, "page_size": 100, "sales_type": sales_type}
22
+ platform = "facebook"
23
+ post_id = data["post_id"]
24
+ if "platform" in data:
25
+ platform = data["platform"].upper()
26
+ param["platforms"] = platform
27
+ if "search" in data:
28
+ search_word = data["search"]
29
+ param["search_word"] = search_word
30
+ response = requests.get(url, headers=headers, params=param).json()
31
+ # print("url",url)
32
+ # print("param", param)
33
+ # print("response",response)
34
+ sales_data = response["data"]["list"]
35
+ print("sales_data",sales_data)
36
+ status = [1,2]
37
+ if "status" in data:
38
+ status = data["status"]
39
+ for i in sales_data:
40
+ platforms = i["platforms"]
41
+ post_sale_status = i["post_sale_status"]
42
+ if platforms == [platform.upper()] and post_sale_status in status:
43
+ sales_id = i["id"]
44
+ data["sales_id"] = sales_id
45
+ # print(sales_id)
46
+ response = get_live_info(data)
47
+ relatedPostList = response["data"]["relatedPostList"]
48
+ if platform.lower() == "facebook":
49
+ for i in relatedPostList:
50
+ fb_post_id = i["post_id"]
51
+ # print("fb_post_id",fb_post_id)
52
+ # print("post_id", post_id)
53
+ if fb_post_id.strip()==post_id.strip():
54
+ print("找到串接的帖文:%s"%sales_id)
55
+ res = delete_post(data)
56
+ # print(res)
57
+ return res
58
+ elif platform.lower()=="fb_group":
59
+ for i in relatedPostList:
60
+ permalink_url = i["permalink_url"]
61
+ post_id = post_id.split("posts/")[-1]
62
+ # print("permalink_url",permalink_url)
63
+ # print("post_id", post_id)
64
+ if post_id.strip() in permalink_url:
65
+ print("找到串接的帖文:%s" % sales_id)
66
+ res = delete_post(data)
67
+ return res
68
+
69
+
70
+
71
+
72
+
73
+
74
+ def get_sales_id(data):
75
+ """"查询返回指定直播间的salse_id
76
+ status:准备中 0,直播中 1 已结束 2 断线中 4
77
+ """
78
+
79
+ env = data["env"]
80
+ headers = data["headers"]
81
+ url = "%s/api/posts/post/sales"%env
82
+ param = {"page_num":1,"page_size":100,"sales_type":"LIVE"}
83
+ platform = "LINE"
84
+ if "platform" in data:
85
+ platform = data["platform"].upper()
86
+ param["platforms"] = platform
87
+ if "search" in data:
88
+ search_word = data["search"]
89
+ param["search_word"] = search_word
90
+ response = requests.get(url,headers=headers,params=param).json()
91
+ # print("url",url)
92
+ # print("param", param)
93
+ # print("response",response)
94
+ sales_data = response["data"]["list"]
95
+ if "status" in data:
96
+ status = data["status"]
97
+ for i in sales_data:
98
+ platforms = i["platforms"]
99
+ post_sale_status = i["post_sale_status"]
100
+ if platforms == [platform.upper()] and post_sale_status == status:
101
+ sales_id = i["id"]
102
+ data["sales_id"] = sales_id
103
+ if "type" in data:
104
+ type = data["type"]
105
+ response = get_live_info(data)
106
+ platform_sub_type = response["data"]["sales"]["platform_sub_type"]
107
+ if platform_sub_type == type.upper():
108
+ return sales_id, response
109
+ else:
110
+ return sales_id, response
111
+ else:
112
+ for i in sales_data:
113
+ platforms = i["platforms"]
114
+ if platforms == [platform.upper()]:
115
+ sales_id = i["id"]
116
+ data["sales_id"] = sales_id
117
+ if "type" in data:
118
+ type = data["type"]
119
+ response = get_live_info(data)
120
+ platform_sub_type = response["data"]["sales"]["platform_sub_type"]
121
+ if platform_sub_type == type.upper():
122
+ return sales_id, response
123
+ else:
124
+ return sales_id, response
10
125
 
11
126
 
12
127
  def create_activity(data):
@@ -66,7 +181,7 @@ def send__live_comment(data):
66
181
  post_id = data['post_id']
67
182
  if "group_id" in data:
68
183
  post_id = data['group_id']
69
- if page_id == "" or post_id == "":
184
+ if page_id == "" or post_id == "key":
70
185
  info = get_live_info(data)
71
186
  platform_list = jsonpath(info, "$..relatedPostList..platform")
72
187
  i = platform_list.index(platform.upper())
@@ -315,7 +430,7 @@ def live_search_oa_product(data):
315
430
  if quantitys!=0 or unlimited_quantity==True:
316
431
  product_info = items[a]
317
432
  spu_id = items[a]["id"]
318
- sku_id = jsonpath(items[a]["variations"],"$..id")
433
+ sku_id = jsonpath(items[a]["variations"],"$.._id")
319
434
  sku_id_quantity = jsonpath(items[a]["variations"],"$..total_orderable_quantity")
320
435
  break
321
436
  elif type == "spu" and b == [] and quantity == 0:
@@ -716,9 +831,19 @@ def create_live(data):
716
831
  sales_id = response.json()["data"]["sales"]["id"]
717
832
  return sales_id
718
833
  else:
834
+ time.sleep(1)
719
835
  count=count+1
720
836
  if count>10:
721
- return response
837
+ platform = "facebook"
838
+ status = 0
839
+ if "platform" in data:
840
+ platform = data["platform"]
841
+ if "status" in data:
842
+ status = data["status"]
843
+ data["platform"] = platform
844
+ data["status"] = status
845
+ sales_id,__ = get_sales_id(data)
846
+ return sales_id
722
847
 
723
848
  # print(json.dumps(body))
724
849
 
@@ -1445,6 +1570,7 @@ def remove_live_product(data):
1445
1570
 
1446
1571
 
1447
1572
  def change_keyword_status(data):
1573
+ """生效普通商品状态"""
1448
1574
  env = data["env"]
1449
1575
  headers = data["headers"]
1450
1576
  sales_id = data["sales_id"]
@@ -1744,7 +1870,7 @@ def add_all_product_set_to_live(data):
1744
1870
  print("出现异常")
1745
1871
  lastPage = set_list_res["data"]["pageInfo"]["lastPage"]
1746
1872
  pageNum = set_list_res["data"]["pageInfo"]["pageNum"]
1747
- print("加前的pagenum",pageNum)
1873
+ # print("加前的pagenum",pageNum)
1748
1874
  # print(lastPage)
1749
1875
  if lastPage == False:
1750
1876
  pageNum = pageNum + 1
@@ -1753,7 +1879,8 @@ def add_all_product_set_to_live(data):
1753
1879
  else:
1754
1880
  break
1755
1881
 
1882
+
1883
+
1884
+
1756
1885
  if __name__=="__main__":
1757
- a =1
1758
- a+=1
1759
- print(a)
1886
+ pass
@@ -1691,4 +1691,6 @@ def edit_message(data):
1691
1691
 
1692
1692
 
1693
1693
  if __name__=="__main__":
1694
- pass
1694
+ pass
1695
+
1696
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.6.0
3
+ Version: 2.6.2
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='sc-common-interface',
5
- version='2.6.0',
5
+ version='2.6.2',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),