sc-common-interface 2.5.7__tar.gz → 2.5.9__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.5.7
3
+ Version: 2.5.9
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -429,7 +429,7 @@ def create_live(data):
429
429
  stamp = int(time.time())
430
430
  title = "接口创建的直播活动名称%d"%stamp
431
431
  salesDescription = "接口创建的直播活动介绍%d"%stamp
432
- salesOwner = "接口创建的直播主%d"%stamp
432
+ salesOwner = "接口创建的直播主%d"%stamp
433
433
  platform = "FB_GROUP"
434
434
  patternModel = "INCLUDE_MATCH"
435
435
  keywordValidInLive = True
@@ -1004,7 +1004,7 @@ def edit_live_info(data):
1004
1004
  "salesOwner": salesOwner,
1005
1005
  "salesDescription": salesDescription,
1006
1006
  "platforms": [
1007
- platform
1007
+ platform.upper()
1008
1008
  ],
1009
1009
  "platformSubType": "",
1010
1010
  "platformChannels": platformChannels,
@@ -1114,6 +1114,7 @@ def edit_live_info(data):
1114
1114
  }
1115
1115
  }
1116
1116
  }
1117
+ print(body)
1117
1118
  response = requests.put(url, headers=headers, json=body).json()
1118
1119
  return response
1119
1120
 
@@ -1474,18 +1475,41 @@ def get_live_product(data):
1474
1475
  return response
1475
1476
 
1476
1477
  def search_product_set(data):
1478
+ """查询直播间组合商品列表"""
1477
1479
  env = data["env"]
1478
1480
  headers = data["headers"]
1479
1481
  sales_id = data["sales_id"]
1480
1482
  query = ""
1483
+ pageNum = 1
1484
+ if "pageNum" in data:
1485
+ pageNum = data["pageNum"]
1481
1486
  if "query" in data:
1482
1487
  query = data["query"]
1483
1488
  url = "%s/admin/api/bff-web/live/sale/%s/sale_list/product_set"%(env,sales_id)
1484
- param = {"pageNum":1,"pageSize":10,"query":query,"queryType":"PRODUCT_NAME"}
1489
+ param = {"pageNum":pageNum,"pageSize":10,"query":query,"queryType":"PRODUCT_NAME"}
1485
1490
  # print(param)
1486
1491
  res = requests.get(url,headers=headers,params=param).json()
1487
1492
  return res
1488
1493
 
1494
+ def get_product_set(data):
1495
+ """查询来添加组合商品"""
1496
+ env = data["env"]
1497
+ headers = data["headers"]
1498
+ sales_id = data["sales_id"]
1499
+ query = ""
1500
+ pageNum = 1
1501
+ if "pageNum" in data:
1502
+ pageNum = data["pageNum"]
1503
+ if "query" in data:
1504
+ query = data["query"]
1505
+ url = "%s/admin/api/bff-web/live/sale/%s/product/product_set/list"%(env,sales_id)
1506
+ param = {"pageNum":pageNum,"pageSize":10,"query":query}
1507
+ # print(param)
1508
+ while True:
1509
+ res = requests.get(url, headers=headers, params=param)
1510
+ if res.status_code==200:
1511
+ return res.json()
1512
+
1489
1513
  def get_sales_keyword(data):
1490
1514
  env = data["env"]
1491
1515
  headers = data["headers"]
@@ -1507,7 +1531,7 @@ def get_stock_product_set(res,type="stock"):
1507
1531
  if quantity==-1:
1508
1532
  # print("库存无限数量")
1509
1533
  pass
1510
- elif quantity<count:
1534
+ elif quantity>count:
1511
1535
  break
1512
1536
  keyword = combination["keywords"][0]
1513
1537
  product_id = i["id"]
@@ -1546,9 +1570,161 @@ def change_product_set_keyword_status(data):
1546
1570
  return response
1547
1571
 
1548
1572
 
1573
+ def get_produnct_set_detail(data):
1574
+ # print(data)
1575
+ env = data["env"]
1576
+ headers = data["headers"]
1577
+ spu_ids = data["spu_ids"]
1578
+ sales_id = data["sales_id"]
1579
+ url = "%s/admin/api/bff-web/live/sale/%s/product/product/list" % (env, sales_id)
1580
+ body = {
1581
+ "ids": spu_ids,
1582
+ "pageNum": 1,
1583
+ "pageSize": 101
1584
+ }
1585
+ while True:
1586
+ response = requests.post(url, headers=headers, json=body)
1587
+ if response.status_code==200:
1588
+ return response.json()
1549
1589
 
1550
1590
 
1591
+ def add_specific_product_set_to_live(data):
1592
+ env = data["env"]
1593
+ headers = data["headers"]
1594
+ sales_id = data["sales_id"]
1595
+ set_list_res = get_product_set(data)
1596
+ data_list = set_list_res["data"]["list"]
1597
+ arr = 0
1598
+ if "arr" in data:
1599
+ arr = data["arr"]
1600
+ if arr >len(data_list)-1:
1601
+ arr = 0
1602
+ product_info = data_list[arr]
1603
+ product_id = product_info["id"]
1604
+ childrenInfo = product_info["childrenInfo"]
1605
+ title = product_info["title"]
1606
+ spu_ids = list(childrenInfo.keys())
1607
+ # necessaryQuantitys = jsonpath(data_list, "$..necessaryQuantity")
1608
+ data["spu_ids"] = spu_ids
1609
+ # 查询子商品信息
1610
+ response = get_produnct_set_detail(data)
1611
+ products = []
1612
+ zi_list = response["data"]["list"]
1613
+ # print(vars["childrenInfo"])
1614
+ for i in zi_list:
1615
+ product = {}
1616
+ spu_id = i["id"]
1617
+ product["count"] = childrenInfo[spu_id]["necessaryQuantity"]
1618
+ product["spuId"] = spu_id
1619
+ variations = i["variations"]
1620
+ if variations == []:
1621
+ product["skuId"] = spu_id
1622
+ else:
1623
+ sku_id = variations[0]["id"]
1624
+ product["skuId"] = sku_id
1625
+ products.append(product)
1626
+
1627
+ url = "%s/admin/api/bff-web/live/sale/%s/sale_list/product_set" % (env, sales_id)
1628
+ keyword = "python添加商品关键子%d" % int(time.time())
1629
+ add_body = {
1630
+ "spuList": [
1631
+ {
1632
+ "id": "%s" % product_id,
1633
+ "defaultKey": "",
1634
+ "combinationList": [
1635
+ {
1636
+ "products": products,
1637
+ "keywords": [
1638
+ "%s" % keyword
1639
+ ],
1640
+ "skuId": ""
1641
+ }
1642
+ ]
1643
+ }
1644
+ ]
1645
+ }
1646
+ try:
1647
+ #先删除再添加
1648
+ data["product_id"] = product_id
1649
+ delete_product_set(data)
1650
+ time.sleep(2)
1651
+ data_res = requests.post(url, headers=headers, json=add_body).json()
1652
+ return product_id,products,keyword,title,data_res
1653
+ except Exception:
1654
+ print("出现异常")
1655
+
1656
+ def add_mutil_product_set_to_live(data):
1657
+ """添加多规格商品的全部"""
1658
+ pass
1659
+
1660
+
1661
+ def add_all_product_set_to_live(data):
1662
+ env = data["env"]
1663
+ headers = data["headers"]
1664
+ sales_id = data["sales_id"]
1665
+ while True:
1666
+ print(data)
1667
+ set_list_res = get_product_set(data)
1668
+ print(set_list_res)
1669
+ data_list = set_list_res["data"]["list"]
1670
+ for product_info in data_list:
1671
+ product_id = product_info["id"]
1672
+ childrenInfo = product_info["childrenInfo"]
1673
+ spu_ids = list(childrenInfo.keys())
1674
+ # necessaryQuantitys = jsonpath(data_list, "$..necessaryQuantity")
1675
+ data["spu_ids"] = spu_ids
1676
+ #查询子商品信息
1677
+ response = get_produnct_set_detail(data)
1678
+ products = []
1679
+ zi_list = response["data"]["list"]
1680
+ # print(vars["childrenInfo"])
1681
+ for i in zi_list:
1682
+ product = {}
1683
+ spu_id = i["id"]
1684
+ product["count"] = childrenInfo[spu_id]["necessaryQuantity"]
1685
+ product["spuId"] = spu_id
1686
+ variations = i["variations"]
1687
+ if variations == []:
1688
+ product["skuId"] = spu_id
1689
+ else:
1690
+ sku_id = variations[0]["id"]
1691
+ product["skuId"] = sku_id
1692
+ products.append(product)
1693
+ url = "%s/admin/api/bff-web/live/sale/%s/sale_list/product_set"%(env,sales_id)
1694
+ keyword = "python添加商品关键子%d"%int(time.time())
1695
+ add_body = {
1696
+ "spuList": [
1697
+ {
1698
+ "id": "%s"%product_id,
1699
+ "defaultKey": "",
1700
+ "combinationList": [
1701
+ {
1702
+ "products": products,
1703
+ "keywords": [
1704
+ "%s"%keyword
1705
+ ],
1706
+ "skuId": ""
1707
+ }
1708
+ ]
1709
+ }
1710
+ ]
1711
+ }
1712
+ try:
1713
+ data_res = requests.post(url,headers=headers,json=add_body).json()
1714
+ print(data_res)
1715
+ except Exception:
1716
+ print("出现异常")
1717
+ lastPage = set_list_res["data"]["pageInfo"]["lastPage"]
1718
+ pageNum = set_list_res["data"]["pageInfo"]["pageNum"]
1719
+ print("加前的pagenum",pageNum)
1720
+ # print(lastPage)
1721
+ if lastPage == False:
1722
+ pageNum = pageNum + 1
1723
+ data["pageNum"] = pageNum
1724
+ print("pageNum=",pageNum)
1725
+ else:
1726
+ break
1727
+
1551
1728
  if __name__=="__main__":
1552
- data = {'headers': {'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIzN2Y2MjY2M2IyMTI1MjIzMWZlMTc4MTE2ODhkNDliYSIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MjI5YTdiYWVhNzA2NDJhOGI2NWViZGEiLCJhcHBsaWNhdGlvbl9pZCI6IjYwZWVjNWViZjhkYzkyMDAwNjUyZTAwNiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMteXkuc2hvcGxpbmVzdGcuY29tIiwiYXVkIjpbXSwic3ViIjoiNjIyOWE3YmFlYTcwNjQyYThiNjVlYmRhIn0.FwtntG1dAYWNUcEZf6WSehXQveEw_rvTSGPEM3xV9FA', 'lang': 'en', 'Content-Type': 'application/json'}, 'product_id': '66f413a8f1e8240039b7bdf6', 'env': 'https://front-service.shoplinestg.com', 'sales_id': '67088', 'key': '4f6b54deff90cdc9966cbe7b82731b3b'}
1553
- res = change_product_set_keyword_status(data)
1554
- print(res)
1729
+ pass
1730
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.5.7
3
+ Version: 2.5.9
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.5.7',
5
+ version='2.5.9',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),