sc-common-interface 2.8.1__tar.gz → 2.8.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.
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/PKG-INFO +1 -1
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface/LiveCommonInterface.py +164 -39
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface.egg-info/PKG-INFO +1 -1
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/setup.py +1 -1
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface/CommonOa.py +0 -0
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface/McCommonInterface.py +0 -0
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface/Platform.py +0 -0
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface/PostCommonInterface.py +0 -0
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface/__init__.py +0 -0
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface.egg-info/SOURCES.txt +0 -0
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface.egg-info/dependency_links.txt +0 -0
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface.egg-info/requires.txt +0 -0
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface.egg-info/top_level.txt +0 -0
- {sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/setup.cfg +0 -0
{sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface/LiveCommonInterface.py
RENAMED
|
@@ -1717,6 +1717,7 @@ def get_sales_keyword(data):
|
|
|
1717
1717
|
return res
|
|
1718
1718
|
|
|
1719
1719
|
def get_stock_product_set(res,type="stock"):
|
|
1720
|
+
"""直播间查询OA组合商品信息"""
|
|
1720
1721
|
list_data = res["data"]["list"]
|
|
1721
1722
|
if type=="stock":
|
|
1722
1723
|
for i in list_data:
|
|
@@ -1750,6 +1751,7 @@ def get_stock_product_set(res,type="stock"):
|
|
|
1750
1751
|
return keyword, product_id, combination_id,i
|
|
1751
1752
|
|
|
1752
1753
|
def change_product_set_keyword_status(data):
|
|
1754
|
+
"修改组合商品关键字生效状态"
|
|
1753
1755
|
env = data["env"]
|
|
1754
1756
|
headers = data["headers"]
|
|
1755
1757
|
sales_id = data["sales_id"]
|
|
@@ -1769,20 +1771,17 @@ def change_product_set_keyword_status(data):
|
|
|
1769
1771
|
|
|
1770
1772
|
|
|
1771
1773
|
def get_produnct_set_detail(data):
|
|
1774
|
+
"""直播间查询OA组合商品详情"""
|
|
1772
1775
|
# print(data)
|
|
1773
1776
|
env = data["env"]
|
|
1774
1777
|
headers = data["headers"]
|
|
1775
|
-
|
|
1778
|
+
product_id = data["product_id"]
|
|
1776
1779
|
sales_id = data["sales_id"]
|
|
1777
|
-
url = "%s/admin/api/bff-web/live/sale/%s/product/
|
|
1778
|
-
|
|
1779
|
-
"ids": spu_ids,
|
|
1780
|
-
"pageNum": 1,
|
|
1781
|
-
"pageSize": 101
|
|
1782
|
-
}
|
|
1780
|
+
url = "%s/admin/api/bff-web/live/sale/%s/product/product_set/%s" % (env, sales_id,product_id)
|
|
1781
|
+
# print(url)
|
|
1783
1782
|
count = 0
|
|
1784
1783
|
while True:
|
|
1785
|
-
response = requests.
|
|
1784
|
+
response = requests.get(url, headers=headers)
|
|
1786
1785
|
if response.status_code==200:
|
|
1787
1786
|
return response.json()
|
|
1788
1787
|
else:
|
|
@@ -1792,35 +1791,44 @@ def get_produnct_set_detail(data):
|
|
|
1792
1791
|
return response
|
|
1793
1792
|
|
|
1794
1793
|
|
|
1795
|
-
def
|
|
1794
|
+
def add_product_set_to_live(data):
|
|
1795
|
+
"添加商品到直播间"
|
|
1796
1796
|
env = data["env"]
|
|
1797
1797
|
headers = data["headers"]
|
|
1798
1798
|
sales_id = data["sales_id"]
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
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
|
+
# 查询组合商品详情信息
|
|
1814
1818
|
response = get_produnct_set_detail(data)
|
|
1819
|
+
# print(response)
|
|
1815
1820
|
products = []
|
|
1816
|
-
zi_list = response["data"]
|
|
1817
|
-
# print(
|
|
1818
|
-
|
|
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)
|
|
1819
1827
|
product = {}
|
|
1820
|
-
spu_id =
|
|
1828
|
+
spu_id = children["id"]
|
|
1821
1829
|
product["count"] = childrenInfo[spu_id]["necessaryQuantity"]
|
|
1822
1830
|
product["spuId"] = spu_id
|
|
1823
|
-
variations =
|
|
1831
|
+
variations = children["variations"]
|
|
1824
1832
|
if variations == []:
|
|
1825
1833
|
product["skuId"] = spu_id
|
|
1826
1834
|
else:
|
|
@@ -1829,7 +1837,7 @@ def add_specific_product_set_to_live(data):
|
|
|
1829
1837
|
products.append(product)
|
|
1830
1838
|
|
|
1831
1839
|
url = "%s/admin/api/bff-web/live/sale/%s/sale_list/product_set" % (env, sales_id)
|
|
1832
|
-
keyword = "python添加商品关键子%d" % int(time.time())
|
|
1840
|
+
# keyword = "python添加商品关键子%d" % int(time.time())
|
|
1833
1841
|
add_body = {
|
|
1834
1842
|
"spuList": [
|
|
1835
1843
|
{
|
|
@@ -1847,13 +1855,15 @@ def add_specific_product_set_to_live(data):
|
|
|
1847
1855
|
}
|
|
1848
1856
|
]
|
|
1849
1857
|
}
|
|
1858
|
+
# print(add_body)
|
|
1850
1859
|
try:
|
|
1851
1860
|
#先删除再添加
|
|
1852
1861
|
data["product_id"] = product_id
|
|
1853
1862
|
delete_product_set(data)
|
|
1854
1863
|
time.sleep(2)
|
|
1855
1864
|
data_res = requests.post(url, headers=headers, json=add_body).json()
|
|
1856
|
-
|
|
1865
|
+
# print(data_res)
|
|
1866
|
+
return product_id,products,keyword,data_res
|
|
1857
1867
|
except Exception:
|
|
1858
1868
|
print("出现异常")
|
|
1859
1869
|
|
|
@@ -2207,7 +2217,7 @@ def get_receipt_sales_id(data):
|
|
|
2207
2217
|
data["platform"] = "FACEBOOK"
|
|
2208
2218
|
sales_id = create_live(data)
|
|
2209
2219
|
# 串接
|
|
2210
|
-
|
|
2220
|
+
#先删除已被串接的
|
|
2211
2221
|
delete_relate_post(data)
|
|
2212
2222
|
time.sleep(2)
|
|
2213
2223
|
data["sales_id"] = sales_id
|
|
@@ -2218,16 +2228,131 @@ def get_receipt_sales_id(data):
|
|
|
2218
2228
|
else:
|
|
2219
2229
|
return sales_id
|
|
2220
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
|
+
|
|
2299
|
+
def search_product_by_keyword(data):
|
|
2300
|
+
env = data["env"]
|
|
2301
|
+
headers = data["headers"]
|
|
2302
|
+
keyword = data["keyword"]
|
|
2303
|
+
sales_id = data["sales_id"]
|
|
2304
|
+
url = "%s/api/posts/post/sales/%s/product/v2" % (env, sales_id)
|
|
2305
|
+
param = {"salesId": sales_id, "pageIndex": 1, "pageSize": 25, "query": keyword, "queryType": "KEYWORD"}
|
|
2306
|
+
response = requests.get(url, headers=headers, params=param).json()
|
|
2307
|
+
return response
|
|
2308
|
+
|
|
2309
|
+
def search_product_set_by_keyword(data):
|
|
2310
|
+
env = data["env"]
|
|
2311
|
+
headers = data["headers"]
|
|
2312
|
+
keyword = data["keyword"]
|
|
2313
|
+
sales_id = data["sales_id"]
|
|
2314
|
+
url = "%s/admin/api/bff-web/live/sale/%s/sale_list/product_set" % (env, sales_id)
|
|
2315
|
+
param = { "pageNum": 1, "pageSize": 25, "query": keyword, "queryType": "KEYWORD"}
|
|
2316
|
+
response = requests.get(url, headers=headers, params=param).json()
|
|
2317
|
+
return response
|
|
2318
|
+
|
|
2319
|
+
|
|
2320
|
+
def delete_product_by_keyword(data):
|
|
2321
|
+
"""根据关键字查询出商品,删除该普通商品和组合商品"""
|
|
2322
|
+
response = search_product_by_keyword(data)
|
|
2323
|
+
result = response["data"]["product_page_result"]["list"]
|
|
2324
|
+
if len(result)>0:
|
|
2325
|
+
spu_id = result[0]["spu_id"]
|
|
2326
|
+
data["product_id"] = spu_id
|
|
2327
|
+
remove_live_product(data)
|
|
2328
|
+
set_response = search_product_set_by_keyword(data)
|
|
2329
|
+
set_result = set_response["data"]["list"]
|
|
2330
|
+
if len(set_result)>0:
|
|
2331
|
+
set_spu_id = set_result[0]["id"]
|
|
2332
|
+
data["product_id"] = set_spu_id
|
|
2333
|
+
delete_product_set(data)
|
|
2334
|
+
|
|
2335
|
+
|
|
2336
|
+
|
|
2337
|
+
|
|
2338
|
+
|
|
2339
|
+
|
|
2340
|
+
|
|
2341
|
+
|
|
2342
|
+
|
|
2343
|
+
|
|
2344
|
+
|
|
2345
|
+
|
|
2346
|
+
|
|
2221
2347
|
|
|
2222
2348
|
|
|
2223
2349
|
if __name__=="__main__":
|
|
2224
|
-
data = {'env': 'https://front-
|
|
2225
|
-
data["
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
print(sales_id)
|
|
2350
|
+
data = {'env': 'https://front-admin-preview.shoplineapp.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkZmQxYjNiMDc0M2JmYWU4YTFkODk4NzczNjgyZWVkZCIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVlYjkwMzVhYjA5ZDEyNjU4NTFmOTU2ZiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.Y90xLfYVAp9yByHo7Vc7A3hHrp6hX9X9Lg4mg_WiE_I', 'lang': 'en'}, 'sales_id': '95828', 'product_id': '670fc567b7b2cb000a26ab86', 'keyword': 'fb直播间新增的关键字1739275716'}
|
|
2351
|
+
data["keyword"] = "接口自动化添加的关键字1706796410"
|
|
2352
|
+
res = delete_product_by_keyword(data)
|
|
2353
|
+
print(res)
|
|
2354
|
+
|
|
2355
|
+
|
|
2231
2356
|
|
|
2232
2357
|
|
|
2233
2358
|
|
|
File without changes
|
{sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface/McCommonInterface.py
RENAMED
|
File without changes
|
|
File without changes
|
{sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface/PostCommonInterface.py
RENAMED
|
File without changes
|
|
File without changes
|
{sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface.egg-info/requires.txt
RENAMED
|
File without changes
|
{sc_common_interface-2.8.1 → sc_common_interface-2.8.3}/sc_common_interface.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|