sc-common-interface 2.8.0__tar.gz → 2.8.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.
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/PKG-INFO +1 -1
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface/LiveCommonInterface.py +215 -45
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface.egg-info/PKG-INFO +1 -1
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/setup.py +1 -1
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface/CommonOa.py +0 -0
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface/McCommonInterface.py +0 -0
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface/Platform.py +0 -0
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface/PostCommonInterface.py +0 -0
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface/__init__.py +0 -0
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface.egg-info/SOURCES.txt +0 -0
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface.egg-info/dependency_links.txt +0 -0
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface.egg-info/requires.txt +0 -0
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface.egg-info/top_level.txt +0 -0
- {sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/setup.cfg +0 -0
{sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface/LiveCommonInterface.py
RENAMED
|
@@ -99,7 +99,6 @@ def get_sales_id(data):
|
|
|
99
99
|
""""查询返回指定直播间的salse_id
|
|
100
100
|
status:准备中 0,直播中 1 已结束 2 断线中 4
|
|
101
101
|
"""
|
|
102
|
-
|
|
103
102
|
env = data["env"]
|
|
104
103
|
headers = data["headers"]
|
|
105
104
|
url = "%s/api/posts/post/sales"%env
|
|
@@ -362,7 +361,7 @@ def get_live_info(data):
|
|
|
362
361
|
count=count+1
|
|
363
362
|
if count>10:
|
|
364
363
|
print("查询报错:",response)
|
|
365
|
-
return response.
|
|
364
|
+
return response.json()
|
|
366
365
|
|
|
367
366
|
|
|
368
367
|
|
|
@@ -971,14 +970,31 @@ def add_live(data):
|
|
|
971
970
|
headers = data["headers"]
|
|
972
971
|
sales_id = data["sales_id"]
|
|
973
972
|
url = "%s/api/posts/live/sales/%s/addLive"%(env,sales_id)
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
"
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
973
|
+
platform = data.get("platform","FB_GROUP")
|
|
974
|
+
body = {}
|
|
975
|
+
if platform.upper()=="FB_GROUP":
|
|
976
|
+
pageId = data["page_id"]
|
|
977
|
+
relationUrl = data["relationUrl"]
|
|
978
|
+
body = {
|
|
979
|
+
"pageId": pageId,
|
|
980
|
+
"platform": "FB_GROUP",
|
|
981
|
+
"relationUrl": relationUrl
|
|
982
|
+
}
|
|
983
|
+
elif platform.upper()=="FACEBOOK":
|
|
984
|
+
postId = data["post_id"]
|
|
985
|
+
liveVideoId = data["liveVideoId"]
|
|
986
|
+
pageId = data["page_id"]
|
|
987
|
+
pageName = data["page_name"]
|
|
988
|
+
permalinkUrl = data["permalinkUrl"]
|
|
989
|
+
body = {
|
|
990
|
+
"postId": postId,
|
|
991
|
+
"liveVideoId": liveVideoId,
|
|
992
|
+
"pageId": pageId,
|
|
993
|
+
"pageName": pageName,
|
|
994
|
+
"permalinkUrl": permalinkUrl,
|
|
995
|
+
"status": "LIVE",
|
|
996
|
+
"platform": platform.upper()
|
|
997
|
+
}
|
|
982
998
|
response = requests.post(url,headers=headers,json=body).json()
|
|
983
999
|
return response
|
|
984
1000
|
|
|
@@ -1096,7 +1112,7 @@ def edit_live_info(data):
|
|
|
1096
1112
|
platformChannel = {
|
|
1097
1113
|
"platformChannelName": platformChannelName,
|
|
1098
1114
|
"platformChannelId": platformChannelId,
|
|
1099
|
-
"platform": platform
|
|
1115
|
+
"platform": platform.upper()
|
|
1100
1116
|
}
|
|
1101
1117
|
platformChannels.append(platformChannel)
|
|
1102
1118
|
if platform.upper()=="FB_GROUP":
|
|
@@ -1271,7 +1287,7 @@ def edit_live_info(data):
|
|
|
1271
1287
|
"productPinningStyle": None
|
|
1272
1288
|
},
|
|
1273
1289
|
"postConfigMap": {
|
|
1274
|
-
|
|
1290
|
+
platform.upper(): {
|
|
1275
1291
|
"message": {
|
|
1276
1292
|
"needSendMessage": need_send_message,
|
|
1277
1293
|
"hasInteractionMessage": {
|
|
@@ -1334,7 +1350,7 @@ def edit_live_info(data):
|
|
|
1334
1350
|
}
|
|
1335
1351
|
}
|
|
1336
1352
|
}
|
|
1337
|
-
|
|
1353
|
+
print(body)
|
|
1338
1354
|
response = requests.put(url, headers=headers, json=body).json()
|
|
1339
1355
|
return response
|
|
1340
1356
|
|
|
@@ -1701,6 +1717,7 @@ def get_sales_keyword(data):
|
|
|
1701
1717
|
return res
|
|
1702
1718
|
|
|
1703
1719
|
def get_stock_product_set(res,type="stock"):
|
|
1720
|
+
"""直播间查询OA组合商品信息"""
|
|
1704
1721
|
list_data = res["data"]["list"]
|
|
1705
1722
|
if type=="stock":
|
|
1706
1723
|
for i in list_data:
|
|
@@ -1734,6 +1751,7 @@ def get_stock_product_set(res,type="stock"):
|
|
|
1734
1751
|
return keyword, product_id, combination_id,i
|
|
1735
1752
|
|
|
1736
1753
|
def change_product_set_keyword_status(data):
|
|
1754
|
+
"修改组合商品关键字生效状态"
|
|
1737
1755
|
env = data["env"]
|
|
1738
1756
|
headers = data["headers"]
|
|
1739
1757
|
sales_id = data["sales_id"]
|
|
@@ -1753,20 +1771,17 @@ def change_product_set_keyword_status(data):
|
|
|
1753
1771
|
|
|
1754
1772
|
|
|
1755
1773
|
def get_produnct_set_detail(data):
|
|
1774
|
+
"""直播间查询OA组合商品详情"""
|
|
1756
1775
|
# print(data)
|
|
1757
1776
|
env = data["env"]
|
|
1758
1777
|
headers = data["headers"]
|
|
1759
|
-
|
|
1778
|
+
product_id = data["product_id"]
|
|
1760
1779
|
sales_id = data["sales_id"]
|
|
1761
|
-
url = "%s/admin/api/bff-web/live/sale/%s/product/
|
|
1762
|
-
|
|
1763
|
-
"ids": spu_ids,
|
|
1764
|
-
"pageNum": 1,
|
|
1765
|
-
"pageSize": 101
|
|
1766
|
-
}
|
|
1780
|
+
url = "%s/admin/api/bff-web/live/sale/%s/product/product_set/%s" % (env, sales_id,product_id)
|
|
1781
|
+
# print(url)
|
|
1767
1782
|
count = 0
|
|
1768
1783
|
while True:
|
|
1769
|
-
response = requests.
|
|
1784
|
+
response = requests.get(url, headers=headers)
|
|
1770
1785
|
if response.status_code==200:
|
|
1771
1786
|
return response.json()
|
|
1772
1787
|
else:
|
|
@@ -1776,35 +1791,44 @@ def get_produnct_set_detail(data):
|
|
|
1776
1791
|
return response
|
|
1777
1792
|
|
|
1778
1793
|
|
|
1779
|
-
def
|
|
1794
|
+
def add_product_set_to_live(data):
|
|
1795
|
+
"添加商品到直播间"
|
|
1780
1796
|
env = data["env"]
|
|
1781
1797
|
headers = data["headers"]
|
|
1782
1798
|
sales_id = data["sales_id"]
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1799
|
+
keyword = data.get("keyword", "python添加商品关键子%d" % int(time.time()))
|
|
1800
|
+
product_id = data.get("product_id","")
|
|
1801
|
+
if product_id=="":
|
|
1802
|
+
set_list_res = get_product_set(data)
|
|
1803
|
+
data_list = set_list_res["data"]["list"]
|
|
1804
|
+
arr = 0
|
|
1805
|
+
if "arr" in data:
|
|
1806
|
+
arr = data["arr"]
|
|
1807
|
+
if arr >len(data_list)-1:
|
|
1808
|
+
arr = 0
|
|
1809
|
+
product_info = data_list[arr]
|
|
1810
|
+
product_id = product_info["id"]
|
|
1811
|
+
childrenInfo = product_info["childrenInfo"]
|
|
1812
|
+
title = product_info["title"]
|
|
1813
|
+
spu_ids = list(childrenInfo.keys())
|
|
1814
|
+
# necessaryQuantitys = jsonpath(data_list, "$..necessaryQuantity")
|
|
1815
|
+
data["product_id"] = product_id
|
|
1816
|
+
|
|
1817
|
+
# 查询组合商品详情信息
|
|
1798
1818
|
response = get_produnct_set_detail(data)
|
|
1819
|
+
# print(response)
|
|
1799
1820
|
products = []
|
|
1800
|
-
zi_list = response["data"]
|
|
1801
|
-
# print(
|
|
1802
|
-
|
|
1821
|
+
zi_list = response["data"]
|
|
1822
|
+
# print(zi_list)
|
|
1823
|
+
childrenInfo = zi_list["childrenInfo"]
|
|
1824
|
+
childrenProducts = zi_list["childrenProducts"]
|
|
1825
|
+
for children in childrenProducts:
|
|
1826
|
+
# print(children)
|
|
1803
1827
|
product = {}
|
|
1804
|
-
spu_id =
|
|
1828
|
+
spu_id = children["id"]
|
|
1805
1829
|
product["count"] = childrenInfo[spu_id]["necessaryQuantity"]
|
|
1806
1830
|
product["spuId"] = spu_id
|
|
1807
|
-
variations =
|
|
1831
|
+
variations = children["variations"]
|
|
1808
1832
|
if variations == []:
|
|
1809
1833
|
product["skuId"] = spu_id
|
|
1810
1834
|
else:
|
|
@@ -1813,7 +1837,7 @@ def add_specific_product_set_to_live(data):
|
|
|
1813
1837
|
products.append(product)
|
|
1814
1838
|
|
|
1815
1839
|
url = "%s/admin/api/bff-web/live/sale/%s/sale_list/product_set" % (env, sales_id)
|
|
1816
|
-
keyword = "python添加商品关键子%d" % int(time.time())
|
|
1840
|
+
# keyword = "python添加商品关键子%d" % int(time.time())
|
|
1817
1841
|
add_body = {
|
|
1818
1842
|
"spuList": [
|
|
1819
1843
|
{
|
|
@@ -1831,13 +1855,15 @@ def add_specific_product_set_to_live(data):
|
|
|
1831
1855
|
}
|
|
1832
1856
|
]
|
|
1833
1857
|
}
|
|
1858
|
+
# print(add_body)
|
|
1834
1859
|
try:
|
|
1835
1860
|
#先删除再添加
|
|
1836
1861
|
data["product_id"] = product_id
|
|
1837
1862
|
delete_product_set(data)
|
|
1838
1863
|
time.sleep(2)
|
|
1839
1864
|
data_res = requests.post(url, headers=headers, json=add_body).json()
|
|
1840
|
-
|
|
1865
|
+
# print(data_res)
|
|
1866
|
+
return product_id,products,keyword,data_res
|
|
1841
1867
|
except Exception:
|
|
1842
1868
|
print("出现异常")
|
|
1843
1869
|
|
|
@@ -2132,12 +2158,156 @@ def handler_bidding(data):
|
|
|
2132
2158
|
delate_activity(data)
|
|
2133
2159
|
|
|
2134
2160
|
|
|
2161
|
+
def check_14_day(data):
|
|
2162
|
+
response = get_live_info(data)
|
|
2163
|
+
start_time_timestamp = response["data"]["sales"]["start_time_timestamp"]
|
|
2164
|
+
# 将毫秒转换为秒
|
|
2165
|
+
start_time_timestamp = start_time_timestamp / 1000
|
|
2166
|
+
# 计算 14 天的秒数
|
|
2167
|
+
fourteen_days_seconds = 13 * 24 * 60 * 60
|
|
2168
|
+
# 获取当前时间戳(秒)
|
|
2169
|
+
current_time_seconds = time.time()
|
|
2170
|
+
flag = False
|
|
2171
|
+
if (current_time_seconds - start_time_timestamp) >= fourteen_days_seconds:
|
|
2172
|
+
flag =True
|
|
2173
|
+
return flag
|
|
2174
|
+
|
|
2175
|
+
def get_fb_sales_id(data):
|
|
2176
|
+
""""查询返回指定直播间的salse_id
|
|
2177
|
+
status:准备中 0,直播中 1 已结束 2 断线中 4
|
|
2178
|
+
"""
|
|
2179
|
+
env = data["env"]
|
|
2180
|
+
headers = data["headers"]
|
|
2181
|
+
url = "%s/api/posts/post/sales"%env
|
|
2182
|
+
param = {"page_num":1,"page_size":100,"sales_type":"LIVE"}
|
|
2183
|
+
platform = data.get("platform","FACEBOOK")
|
|
2184
|
+
param["platforms"] =platform.upper()
|
|
2185
|
+
if "search" in data:
|
|
2186
|
+
search_word = data["search"]
|
|
2187
|
+
param["search_word"] = search_word
|
|
2188
|
+
response = requests.get(url,headers=headers,params=param).json()
|
|
2189
|
+
sales_data = response["data"]["list"]
|
|
2190
|
+
if "status" in data:
|
|
2191
|
+
status = data["status"]
|
|
2192
|
+
for i in sales_data:
|
|
2193
|
+
real_platform = i["platform"]
|
|
2194
|
+
platforms = i["platforms"]
|
|
2195
|
+
post_sale_status = i["post_sale_status"]
|
|
2196
|
+
if real_platform=="SHOPLINE"and platforms==["SHOPLINE", "FACEBOOK"] and post_sale_status in status:
|
|
2197
|
+
sales_id = i["id"]
|
|
2198
|
+
return sales_id
|
|
2199
|
+
elif platform.upper()=="FACEBOOK" and platforms==["FACEBOOK"] and post_sale_status in status:
|
|
2200
|
+
sales_id = i["id"]
|
|
2201
|
+
return sales_id
|
|
2202
|
+
else:
|
|
2203
|
+
if len(sales_data)>0:
|
|
2204
|
+
return sales_data[0]["id"]
|
|
2135
2205
|
|
|
2136
2206
|
|
|
2207
|
+
def get_receipt_sales_id(data):
|
|
2208
|
+
sales_id = data["sales_id"]
|
|
2209
|
+
flag = check_14_day(data)
|
|
2210
|
+
if flag:
|
|
2211
|
+
#先从列表查出一个最新结束的直播间,还是不返回要求再创建直播和链接直播
|
|
2212
|
+
sales_id = get_fb_sales_id(data)
|
|
2213
|
+
data["sales_id"] = sales_id
|
|
2214
|
+
flag2 = check_14_day(data)
|
|
2215
|
+
if flag2:
|
|
2216
|
+
# 超过14天,创建一个直播间,并串接,然后结束直播
|
|
2217
|
+
data["platform"] = "FACEBOOK"
|
|
2218
|
+
sales_id = create_live(data)
|
|
2219
|
+
# 串接
|
|
2220
|
+
#先删除已被串接的
|
|
2221
|
+
delete_relate_post(data)
|
|
2222
|
+
time.sleep(2)
|
|
2223
|
+
data["sales_id"] = sales_id
|
|
2224
|
+
add_live(data)
|
|
2225
|
+
# 结束直播
|
|
2226
|
+
end_live(data)
|
|
2227
|
+
return sales_id
|
|
2228
|
+
else:
|
|
2229
|
+
return sales_id
|
|
2230
|
+
|
|
2231
|
+
def delete_keyword_product_set(data):
|
|
2232
|
+
"删除关键字组件里的组合商品"
|
|
2233
|
+
"product_id为:[]"
|
|
2234
|
+
env = data["env"]
|
|
2235
|
+
headers = data["headers"]
|
|
2236
|
+
product_id = data["product_id"]
|
|
2237
|
+
url = "%s/admin/api/bff-web/keyword/product_set"%env
|
|
2238
|
+
body = {
|
|
2239
|
+
"ids": product_id
|
|
2240
|
+
}
|
|
2241
|
+
response = requests.delete(url,headers=headers,json=body).json()
|
|
2242
|
+
return response
|
|
2243
|
+
|
|
2244
|
+
|
|
2245
|
+
def get_keyword_product_set(data):
|
|
2246
|
+
"查询关键字组件里的组合商品"
|
|
2247
|
+
env = data["env"]
|
|
2248
|
+
headers = data["headers"]
|
|
2249
|
+
url = "%s/admin/api/bff-web/keyword/product_set/list"%env
|
|
2250
|
+
pageNum = data.get("pageNum",1)
|
|
2251
|
+
pageSize = data.get("pageSize", 25)
|
|
2252
|
+
param = {"pageNum":pageNum,"pageSize":pageSize}
|
|
2253
|
+
if "title" in data:
|
|
2254
|
+
title = data.get("title")
|
|
2255
|
+
param["title"] = title
|
|
2256
|
+
response = requests.get(url,headers=headers,params=param).json()
|
|
2257
|
+
return response
|
|
2258
|
+
|
|
2259
|
+
def get_oa_product_set(data):
|
|
2260
|
+
"查询OA组合商品列表"
|
|
2261
|
+
env = data["env"]
|
|
2262
|
+
headers = data["headers"]
|
|
2263
|
+
pageNum = data.get("pageNum", 1)
|
|
2264
|
+
pageSize = data.get("pageSize", 10)
|
|
2265
|
+
param = {"pageNum": pageNum, "pageSize": pageSize}
|
|
2266
|
+
if "query" in data:
|
|
2267
|
+
query = data.get("query")
|
|
2268
|
+
param["query"] = query
|
|
2269
|
+
url = "%s/admin/api/bff-web/keyword/product/product_set/list"%env
|
|
2270
|
+
response = requests.get(url, headers=headers, params=param).json()
|
|
2271
|
+
return response
|
|
2272
|
+
|
|
2273
|
+
def get_product_set_detail(data):
|
|
2274
|
+
"查询OA组合商品详情信息"
|
|
2275
|
+
env = data["env"]
|
|
2276
|
+
headers = data["headers"]
|
|
2277
|
+
product_id = data["product_id"]
|
|
2278
|
+
url = "%s/admin/api/bff-web/keyword/product/product_set/detail?id=%s"%(env,product_id)
|
|
2279
|
+
response = requests.get(url, headers=headers).json()
|
|
2280
|
+
return response
|
|
2281
|
+
|
|
2282
|
+
|
|
2283
|
+
def get_not_exist_keyword_set(data):
|
|
2284
|
+
pageNum = 1
|
|
2285
|
+
while True:
|
|
2286
|
+
response = get_oa_product_set(data)
|
|
2287
|
+
data_list = response["data"]["list"]
|
|
2288
|
+
for set in data_list:
|
|
2289
|
+
title = set["title"]
|
|
2290
|
+
product_id = set["id"]
|
|
2291
|
+
data["title"] = title
|
|
2292
|
+
res = get_keyword_product_set(data)
|
|
2293
|
+
set_id_list = [item["id"] for item in res["data"]["list"]]
|
|
2294
|
+
if product_id not in set_id_list:
|
|
2295
|
+
return product_id,title
|
|
2296
|
+
pageNum += 1
|
|
2297
|
+
data["pageNum"] = pageNum
|
|
2298
|
+
|
|
2137
2299
|
|
|
2138
2300
|
|
|
2139
2301
|
if __name__=="__main__":
|
|
2140
|
-
|
|
2302
|
+
data = {'env': 'https://front-admin-preview.shoplineapp.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkZmQxYjNiMDc0M2JmYWU4YTFkODk4NzczNjgyZWVkZCIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVlYjkwMzVhYjA5ZDEyNjU4NTFmOTU2ZiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.Y90xLfYVAp9yByHo7Vc7A3hHrp6hX9X9Lg4mg_WiE_I', 'lang': 'en'}, 'platform': 'FACEBOOK', 'sales_id': '95828'}
|
|
2303
|
+
response = get_keyword_product_set(data)
|
|
2304
|
+
product_id = response['data']["list"][0]["id"]
|
|
2305
|
+
data["product_id"] = [product_id]
|
|
2306
|
+
delete_keyword_product_set(data)
|
|
2307
|
+
data["product_id"] = product_id
|
|
2308
|
+
__,__,__,res = add_product_set_to_live(data)
|
|
2309
|
+
print(res)
|
|
2310
|
+
|
|
2141
2311
|
|
|
2142
2312
|
|
|
2143
2313
|
|
|
File without changes
|
{sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface/McCommonInterface.py
RENAMED
|
File without changes
|
|
File without changes
|
{sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface/PostCommonInterface.py
RENAMED
|
File without changes
|
|
File without changes
|
{sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface.egg-info/requires.txt
RENAMED
|
File without changes
|
{sc_common_interface-2.8.0 → sc_common_interface-2.8.2}/sc_common_interface.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|