sc-common-interface 2.6.5__tar.gz → 2.6.7__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.6.5 → sc-common-interface-2.6.7}/PKG-INFO +1 -1
- {sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface/LiveCommonInterface.py +151 -29
- {sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface/PostCommonInterface.py +5 -3
- {sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface.egg-info/PKG-INFO +1 -1
- {sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface.egg-info/requires.txt +0 -1
- {sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/setup.py +2 -3
- {sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface/McCommonInterface.py +0 -0
- {sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface/Platform.py +0 -0
- {sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface/__init__.py +0 -0
- {sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface.egg-info/SOURCES.txt +0 -0
- {sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface.egg-info/dependency_links.txt +0 -0
- {sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface.egg-info/top_level.txt +0 -0
- {sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/setup.cfg +0 -0
{sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface/LiveCommonInterface.py
RENAMED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import datetime
|
|
2
|
+
import re
|
|
3
|
+
|
|
2
4
|
import requests
|
|
3
5
|
import json
|
|
4
6
|
from jsonpath import jsonpath
|
|
@@ -39,45 +41,55 @@ def delete_relate_post(data):
|
|
|
39
41
|
# print("param", param)
|
|
40
42
|
# print("response",response)
|
|
41
43
|
sales_data = response["data"]["list"]
|
|
42
|
-
print("sales_data",sales_data)
|
|
44
|
+
# print("sales_data",sales_data)
|
|
43
45
|
status = [1,2]
|
|
44
46
|
if "status" in data:
|
|
45
47
|
status = data["status"]
|
|
46
48
|
for i in sales_data:
|
|
47
49
|
platforms = i["platforms"]
|
|
48
50
|
post_sale_status = i["post_sale_status"]
|
|
49
|
-
|
|
51
|
+
live_sdk = i["live_sdk"]
|
|
52
|
+
if (platforms==[platform.upper()] or live_sdk==platform.upper()) and post_sale_status in status:
|
|
50
53
|
sales_id = i["id"]
|
|
51
54
|
data["sales_id"] = sales_id
|
|
52
55
|
# print(sales_id)
|
|
53
56
|
response = get_live_info(data)
|
|
54
|
-
|
|
57
|
+
# print("查询详情返回,",response)
|
|
58
|
+
global relatedPostList
|
|
59
|
+
if sales_type.lower()=="live":
|
|
60
|
+
relatedPostList = response["data"]["relatedPostList"]
|
|
61
|
+
elif sales_type.lower()=="post":
|
|
62
|
+
relatedPostList = response["data"]["related_post_list"]
|
|
55
63
|
if platform.lower() == "facebook":
|
|
64
|
+
count=0
|
|
56
65
|
for i in relatedPostList:
|
|
57
66
|
fb_post_id = i["post_id"]
|
|
58
67
|
# print("fb_post_id",fb_post_id)
|
|
59
68
|
# print("post_id", post_id)
|
|
60
69
|
if fb_post_id.strip() in post_id:
|
|
61
70
|
print("找到串接的帖文:%s"%sales_id)
|
|
71
|
+
count+=1
|
|
62
72
|
res = delete_post(data)
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
if count>=len(post_id):
|
|
74
|
+
return res
|
|
65
75
|
elif platform.lower()=="fb_group":
|
|
76
|
+
count = 0
|
|
77
|
+
id_list = []
|
|
78
|
+
for id in post_id:
|
|
79
|
+
idData = id.split("posts/")[-1]
|
|
80
|
+
id_list.append(idData)
|
|
66
81
|
for i in relatedPostList:
|
|
67
82
|
permalink_url = i["permalink_url"]
|
|
68
83
|
permalink_url = permalink_url.split("permalink/")[-1]
|
|
69
|
-
|
|
70
|
-
for id in post_id:
|
|
71
|
-
idData = id.split("posts/")[-1]
|
|
72
|
-
id_list.append(idData)
|
|
84
|
+
|
|
73
85
|
# print("permalink_url",permalink_url)
|
|
74
86
|
# print("post_id", post_id)
|
|
75
87
|
if permalink_url.strip() in id_list:
|
|
76
88
|
print("找到串接的帖文:%s" % sales_id)
|
|
77
89
|
res = delete_post(data)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
count +=1
|
|
91
|
+
if count>=len(id_list):
|
|
92
|
+
return res
|
|
81
93
|
|
|
82
94
|
|
|
83
95
|
|
|
@@ -192,14 +204,28 @@ def send__live_comment(data):
|
|
|
192
204
|
post_id = data['post_id']
|
|
193
205
|
if "group_id" in data:
|
|
194
206
|
post_id = data['group_id']
|
|
207
|
+
sales_type = "live"
|
|
208
|
+
if "sales_type" in data:
|
|
209
|
+
sales_type = data["sales_type"]
|
|
195
210
|
if page_id == "" or post_id == "key":
|
|
196
211
|
info = get_live_info(data)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
212
|
+
# print("info",info)
|
|
213
|
+
global platform_list
|
|
214
|
+
if sales_type.lower()=="live":
|
|
215
|
+
platform_list = jsonpath(info, "$..relatedPostList..platform")
|
|
216
|
+
i = platform_list.index(platform.upper())
|
|
217
|
+
page_id = info["data"]["relatedPostList"][i]["page_id"]
|
|
218
|
+
platform = info["data"]["relatedPostList"][i]["platform"]
|
|
219
|
+
post_id = info["data"]["relatedPostList"][i]["post_id"]
|
|
220
|
+
group_id = info["data"]["relatedPostList"][i]["group_id"]
|
|
221
|
+
elif sales_type.lower()=="post":
|
|
222
|
+
platform_list = jsonpath(info, "$..related_post_list..platform")
|
|
223
|
+
i = platform_list.index(platform.upper())
|
|
224
|
+
page_id = info["data"]["related_post_list"][i]["page_id"]
|
|
225
|
+
platform = info["data"]["related_post_list"][i]["platform"]
|
|
226
|
+
post_id = info["data"]["related_post_list"][i]["post_id"]
|
|
227
|
+
group_id = info["data"]["related_post_list"][i]["group_id"]
|
|
228
|
+
|
|
203
229
|
# info = get_live_info(data)
|
|
204
230
|
# related_post_list = info["data"]["relatedPostList"][0]
|
|
205
231
|
# page_id = related_post_list["page_id"]
|
|
@@ -236,7 +262,13 @@ def send__live_comment(data):
|
|
|
236
262
|
"field": "comments"}]}], "object": "instagram"}
|
|
237
263
|
elif platform.upper() == "FB_GROUP":
|
|
238
264
|
t_time = stamp*1000
|
|
239
|
-
|
|
265
|
+
if "-" in post_id:
|
|
266
|
+
post_id = post_id.split("_")[-1]
|
|
267
|
+
else:
|
|
268
|
+
relationUrl = data["relationUrl"]
|
|
269
|
+
match = re.search(r'groups/(\d+)/posts/(\d+)/', relationUrl)
|
|
270
|
+
group_id = match.group(1)
|
|
271
|
+
post_id = match.group(2)
|
|
240
272
|
comment_id = "%d%d" % ( stamp, num)
|
|
241
273
|
body = {"object":"page","entry":[{"id":page_id,"time":t_time,"messaging":[{"recipient":{"id":page_id},"message":keyword,
|
|
242
274
|
"from":{"id":user_id,"name":name},"group_id":group_id,"post_id":post_id,"comment_id":comment_id,"created_time":stamp,"item":"comment",
|
|
@@ -322,7 +354,10 @@ def get_live_info(data):
|
|
|
322
354
|
env = data["env"]
|
|
323
355
|
headers = data["headers"]
|
|
324
356
|
sales_id = data["sales_id"]
|
|
325
|
-
|
|
357
|
+
sales_type = "live"
|
|
358
|
+
if "sales_type" in data:
|
|
359
|
+
sales_type = data["sales_type"]
|
|
360
|
+
url = "%s/api/posts/%s/sales/%s" % (env,sales_type.lower(), sales_id)
|
|
326
361
|
count = 0
|
|
327
362
|
while True:
|
|
328
363
|
response = requests.get(url,headers=headers)
|
|
@@ -877,14 +912,14 @@ def add_live(data):
|
|
|
877
912
|
return response
|
|
878
913
|
|
|
879
914
|
|
|
880
|
-
def get_live_info(data):
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
915
|
+
# def get_live_info(data):
|
|
916
|
+
# """查询直播间信息"""
|
|
917
|
+
# env = data["env"]
|
|
918
|
+
# headers = data["headers"]
|
|
919
|
+
# sales_id = data["sales_id"]
|
|
920
|
+
# url = "%s/api/posts/live/sales/%s" % (env, sales_id)
|
|
921
|
+
# response = requests.get(url,headers=headers).json()
|
|
922
|
+
# return response
|
|
888
923
|
|
|
889
924
|
def edit_live_info(data):
|
|
890
925
|
"""
|
|
@@ -1890,8 +1925,95 @@ def add_all_product_set_to_live(data):
|
|
|
1890
1925
|
else:
|
|
1891
1926
|
break
|
|
1892
1927
|
|
|
1928
|
+
def add_all_product_set_to_keyword(data):
|
|
1929
|
+
env = data["env"]
|
|
1930
|
+
headers = data["headers"]
|
|
1931
|
+
sales_id = data["sales_id"]
|
|
1932
|
+
while True:
|
|
1933
|
+
print(data)
|
|
1934
|
+
set_list_res = get_product_set(data)
|
|
1935
|
+
print(set_list_res)
|
|
1936
|
+
data_list = set_list_res["data"]["list"]
|
|
1937
|
+
for product_info in data_list:
|
|
1938
|
+
product_id = product_info["id"]
|
|
1939
|
+
childrenInfo = product_info["childrenInfo"]
|
|
1940
|
+
spu_ids = list(childrenInfo.keys())
|
|
1941
|
+
# necessaryQuantitys = jsonpath(data_list, "$..necessaryQuantity")
|
|
1942
|
+
data["spu_ids"] = spu_ids
|
|
1943
|
+
#查询子商品信息
|
|
1944
|
+
response = get_produnct_set_detail(data)
|
|
1945
|
+
products = []
|
|
1946
|
+
zi_list = response["data"]["list"]
|
|
1947
|
+
# print(vars["childrenInfo"])
|
|
1948
|
+
for i in zi_list:
|
|
1949
|
+
product = {}
|
|
1950
|
+
spu_id = i["id"]
|
|
1951
|
+
product["count"] = childrenInfo[spu_id]["necessaryQuantity"]
|
|
1952
|
+
product["spuId"] = spu_id
|
|
1953
|
+
variations = i["variations"]
|
|
1954
|
+
if variations == []:
|
|
1955
|
+
product["skuId"] = spu_id
|
|
1956
|
+
else:
|
|
1957
|
+
sku_id = variations[0]["id"]
|
|
1958
|
+
product["skuId"] = sku_id
|
|
1959
|
+
products.append(product)
|
|
1960
|
+
url = "%s/admin/api/bff-web/keyword/product_set"%(env)
|
|
1961
|
+
keyword = "python添加商品关键子%d"%int(time.time())
|
|
1962
|
+
add_body = {
|
|
1963
|
+
"productKeywordList": [
|
|
1964
|
+
{
|
|
1965
|
+
"id": "%s"%product_id,
|
|
1966
|
+
"defaultKey": "",
|
|
1967
|
+
"combinationList": [
|
|
1968
|
+
{
|
|
1969
|
+
"products": products,
|
|
1970
|
+
"keywords": [
|
|
1971
|
+
"%s"%keyword
|
|
1972
|
+
],
|
|
1973
|
+
"skuId": ""
|
|
1974
|
+
}
|
|
1975
|
+
]
|
|
1976
|
+
}
|
|
1977
|
+
]
|
|
1978
|
+
}
|
|
1979
|
+
try:
|
|
1980
|
+
data_res = requests.post(url,headers=headers,json=add_body).json()
|
|
1981
|
+
print(data_res)
|
|
1982
|
+
except Exception:
|
|
1983
|
+
print("出现异常")
|
|
1984
|
+
lastPage = set_list_res["data"]["pageInfo"]["lastPage"]
|
|
1985
|
+
pageNum = set_list_res["data"]["pageInfo"]["pageNum"]
|
|
1986
|
+
# print("加前的pagenum",pageNum)
|
|
1987
|
+
# print(lastPage)
|
|
1988
|
+
if lastPage == False:
|
|
1989
|
+
pageNum = pageNum + 1
|
|
1990
|
+
data["pageNum"] = pageNum
|
|
1991
|
+
print("pageNum=",pageNum)
|
|
1992
|
+
else:
|
|
1993
|
+
break
|
|
1994
|
+
|
|
1893
1995
|
|
|
1894
1996
|
|
|
1895
1997
|
|
|
1896
1998
|
if __name__=="__main__":
|
|
1897
|
-
|
|
1999
|
+
from sc_common_interface.PostCommonInterface import *
|
|
2000
|
+
data = {'env': 'https://front-admin-preview.shoplineapp.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkZmQxYjNiMDc0M2JmYWU4YTFkODk4NzczNjgyZWVkZCIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVlYjkwMzVhYjA5ZDEyNjU4NTFmOTU2ZiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.Y90xLfYVAp9yByHo7Vc7A3hHrp6hX9X9Lg4mg_WiE_I', 'lang': 'en'}, 'platform': 'FB_GROUP', 'page_id': '106411048594439', 'relationUrl': 'https://www.facebook.com/groups/3592205981019493/posts/3868975560009199/', 'post_id': ['https://www.facebook.com/groups/3592205981019493/posts/3868976186675803/', 'https://www.facebook.com/groups/3592205981019493/posts/3868975560009199/', 'https://www.facebook.com/groups/3592205981019493/posts/3869121803327908/'], 'sales_type': 'POST'}
|
|
2001
|
+
__,sales_id = create_general_post(data)
|
|
2002
|
+
print(data)
|
|
2003
|
+
delete_relate_post(data)
|
|
2004
|
+
data["sales_id"] = sales_id
|
|
2005
|
+
res = relate_post(data)
|
|
2006
|
+
print(res)
|
|
2007
|
+
data["quantity"] = 100
|
|
2008
|
+
modelone_create_single_product(data)
|
|
2009
|
+
del data["post_id"]
|
|
2010
|
+
publish_post(data)
|
|
2011
|
+
|
|
2012
|
+
|
|
2013
|
+
|
|
2014
|
+
|
|
2015
|
+
|
|
2016
|
+
|
|
2017
|
+
|
|
2018
|
+
|
|
2019
|
+
|
{sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface/PostCommonInterface.py
RENAMED
|
@@ -57,13 +57,14 @@ def create_general_post(data):
|
|
|
57
57
|
if response.status_code==200:
|
|
58
58
|
break
|
|
59
59
|
except Exception as e:
|
|
60
|
+
print(e)
|
|
60
61
|
time.sleep(1)
|
|
61
62
|
finally:
|
|
62
63
|
count += 1
|
|
63
64
|
if count > num:
|
|
64
65
|
break
|
|
65
66
|
response = response.json()
|
|
66
|
-
print("创建贴文返回",response)
|
|
67
|
+
# print("创建贴文返回",response)
|
|
67
68
|
sales_id = response["data"]["id"]
|
|
68
69
|
return response,sales_id
|
|
69
70
|
|
|
@@ -109,6 +110,7 @@ def create_commerce_post(data):
|
|
|
109
110
|
response.raise_for_status()
|
|
110
111
|
break
|
|
111
112
|
except requests.exceptions.RequestException as e:
|
|
113
|
+
print(e)
|
|
112
114
|
time.sleep(1)
|
|
113
115
|
finally:
|
|
114
116
|
count +=1
|
|
@@ -422,7 +424,7 @@ def relate_post(data):
|
|
|
422
424
|
response = get_page_post(data)
|
|
423
425
|
available_post_list = []
|
|
424
426
|
related_sales = jsonpath(response,"$..related_sales")
|
|
425
|
-
print("查询到的贴文信息",related_sales)
|
|
427
|
+
# print("查询到的贴文信息",related_sales)
|
|
426
428
|
for index,value in enumerate(related_sales):
|
|
427
429
|
if value==False:
|
|
428
430
|
available_post_list.append(response["data"]["data"][index])
|
|
@@ -784,7 +786,7 @@ def send_post_comment(data):
|
|
|
784
786
|
url = "%s/facebook/webhook"%env
|
|
785
787
|
sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
|
|
786
788
|
signData = sign_text.hexdigest()
|
|
787
|
-
print("body",json.dumps(body))
|
|
789
|
+
# print("body",json.dumps(body))
|
|
788
790
|
header = {"Content-Type": "application/json", "x-hub-signature": "sha1=%s" % signData}
|
|
789
791
|
response = requests.post(url, headers=header, data=json.dumps(body))
|
|
790
792
|
return user_id,name,comment_id
|
|
@@ -2,13 +2,12 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name='sc-common-interface',
|
|
5
|
-
version='2.6.
|
|
5
|
+
version='2.6.7',
|
|
6
6
|
description='SC贴文销售公用的接口',
|
|
7
7
|
author='river',
|
|
8
8
|
packages=find_packages(),
|
|
9
9
|
install_requires=[
|
|
10
10
|
"requests>=2.0.0",
|
|
11
|
-
"jsonpath>=0.82"
|
|
12
|
-
"sc-common-interface>=2.6.2"
|
|
11
|
+
"jsonpath>=0.82"
|
|
13
12
|
],
|
|
14
13
|
)
|
{sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface/McCommonInterface.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{sc-common-interface-2.6.5 → sc-common-interface-2.6.7}/sc_common_interface.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|