sc-common-interface 2.5.8__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.8
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
@@ -1475,18 +1475,41 @@ def get_live_product(data):
1475
1475
  return response
1476
1476
 
1477
1477
  def search_product_set(data):
1478
+ """查询直播间组合商品列表"""
1478
1479
  env = data["env"]
1479
1480
  headers = data["headers"]
1480
1481
  sales_id = data["sales_id"]
1481
1482
  query = ""
1483
+ pageNum = 1
1484
+ if "pageNum" in data:
1485
+ pageNum = data["pageNum"]
1482
1486
  if "query" in data:
1483
1487
  query = data["query"]
1484
1488
  url = "%s/admin/api/bff-web/live/sale/%s/sale_list/product_set"%(env,sales_id)
1485
- param = {"pageNum":1,"pageSize":10,"query":query,"queryType":"PRODUCT_NAME"}
1489
+ param = {"pageNum":pageNum,"pageSize":10,"query":query,"queryType":"PRODUCT_NAME"}
1486
1490
  # print(param)
1487
1491
  res = requests.get(url,headers=headers,params=param).json()
1488
1492
  return res
1489
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
+
1490
1513
  def get_sales_keyword(data):
1491
1514
  env = data["env"]
1492
1515
  headers = data["headers"]
@@ -1547,342 +1570,161 @@ def change_product_set_keyword_status(data):
1547
1570
  return response
1548
1571
 
1549
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()
1550
1589
 
1551
1590
 
1552
- if __name__=="__main__":
1553
- data = {
1554
- "success": True,
1555
- "code": "SUCCESS",
1556
- "message": "success",
1557
- "data": {
1558
- "pageInfo": {
1559
- "pageNum": 1,
1560
- "pageSize": 10,
1561
- "total": 5,
1562
- "lastPage": True
1563
- },
1564
- "list": [
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": [
1565
1631
  {
1566
- "id": "6741acc0cfda6a000ead3544",
1567
- "image": "https://shoplineimg.com/61a87c9763b70c005106fbd0/6741acb473b250000b26861a/50xf.webp?source_format=jpeg\u0026cheap_resize=1",
1568
- "title": "无库存组合商品",
1569
- "recommend": {
1570
- "isActivity": True,
1571
- "recommendTime": True
1572
- },
1573
- "effectiveKey": True,
1632
+ "id": "%s" % product_id,
1574
1633
  "defaultKey": "",
1575
1634
  "combinationList": [
1576
1635
  {
1577
- "id": "943947ecdfff37355535ecea0bd17c11",
1578
- "price": {
1579
- "originCents": 900,
1580
- "origin": "900 ₫",
1581
- "salesCents": 500,
1582
- "sales": "500 ₫"
1583
- },
1584
- "keywords": [
1585
- "组合商品关键字1732366855"
1586
- ],
1587
- "products": [
1588
- {
1589
- "spuId": "674153b778cb880011e7dc9b",
1590
- "skuId": "674153b778cb880011e7dc9b",
1591
- "count": 2,
1592
- "name": "商品名称1732334518",
1593
- "quantity": 99,
1594
- "unlimitedQuantity": True
1595
- },
1596
- {
1597
- "spuId": "65e855cbaf49be000ee315a9",
1598
- "skuId": "65e855cbaf49be000ee315a9",
1599
- "count": 2,
1600
- "name": "无库存商品(不要删除)",
1601
- "quantity": 0,
1602
- "unlimitedQuantity": True
1603
- }
1604
- ],
1605
- "buyerProductCount": 0
1606
- }
1607
- ],
1608
- "availableStartTime": True,
1609
- "availableEndTime": True,
1610
- "tempPrice": {
1611
- "originCents": 900,
1612
- "origin": "900 ₫",
1613
- "salesCents": 500,
1614
- "sales": "500 ₫"
1615
- },
1616
- "childrenInfo": {
1617
- "65e855cbaf49be000ee315a9": {
1618
- "necessaryQuantity": 2,
1619
- "variations": []
1620
- },
1621
- "674153b778cb880011e7dc9b": {
1622
- "necessaryQuantity": 2,
1623
- "variations": []
1624
- }
1625
- },
1626
- "status": "active"
1627
- },
1628
- {
1629
- "id": "670fbd3dac9b6acdb37c8192",
1630
- "image": "https://shoplineimg.com/61a87c9763b70c005106fbd0/670fbd1fac9b6a65377c874a/50xf.webp?source_format=jpeg\u0026cheap_resize=1",
1631
- "title": "dyy组合商品变动-子商品从无规格变成多规格",
1632
- "recommend": {
1633
- "isActivity": True,
1634
- "recommendTime": "2024-11-23T20:26:54+08:00"
1635
- },
1636
- "effectiveKey": True,
1637
- "defaultKey": "C",
1638
- "combinationList": [
1639
- {
1640
- "id": "fc37396e6a9d294cec87752911092300",
1641
- "price": {
1642
- "originCents": 222,
1643
- "origin": "222 ₫",
1644
- "salesCents": 90,
1645
- "sales": "90 ₫"
1646
- },
1647
- "keywords": [
1648
- "C1"
1649
- ],
1650
- "products": [
1651
- {
1652
- "spuId": "670fbced7fb2d151ef8f665a",
1653
- "skuId": "670fc098b34584000d03a595",
1654
- "count": 2,
1655
- "name": "dyy商品从无规格变成多规格(蓝)",
1656
- "quantity": -1,
1657
- "unlimitedQuantity": True
1658
- },
1659
- {
1660
- "spuId": "670fbb5227a445000f12b050",
1661
- "skuId": "670fbb517e0510001fd941c9",
1662
- "count": 2,
1663
- "name": "模式4接口自动化添加的多规格商品1729084241(红,M)",
1664
- "quantity": 55,
1665
- "unlimitedQuantity": True
1666
- }
1667
- ],
1668
- "buyerProductCount": 1
1669
- }
1670
- ],
1671
- "availableStartTime": True,
1672
- "availableEndTime": True,
1673
- "tempPrice": {
1674
- "originCents": 222,
1675
- "origin": "222 ₫",
1676
- "salesCents": 90,
1677
- "sales": "90 ₫"
1678
- },
1679
- "childrenInfo": {
1680
- "670fbb5227a445000f12b050": {
1681
- "necessaryQuantity": 2,
1682
- "variations": [
1683
- "670fbb517e0510001fd941c9",
1684
- "670fbb517e0510001fd941ca",
1685
- "670fbb517e0510001fd941cb",
1686
- "670fbb517e0510001fd941cc"
1687
- ]
1688
- },
1689
- "670fbced7fb2d151ef8f665a": {
1690
- "necessaryQuantity": 2,
1691
- "variations": [
1692
- "670fc098b34584000d03a595",
1693
- "670fc098b34584000d03a596"
1694
- ]
1695
- }
1696
- },
1697
- "status": "active"
1698
- },
1699
- {
1700
- "id": "670f9464ac9b6ad8fd7c806b",
1701
- "image": "https://shoplineimg.com/61a87c9763b70c005106fbd0/670f9448ac9b6ad4297c80df/50xf.webp?source_format=jpeg\u0026cheap_resize=1",
1702
- "title": "dyy组合商品变动(子商品下的子规格被删除)0000",
1703
- "recommend": {
1704
- "isActivity": True,
1705
- "recommendTime": True
1706
- },
1707
- "effectiveKey": True,
1708
- "defaultKey": "B",
1709
- "combinationList": [
1710
- {
1711
- "id": "b7d9e9e56797242331a71e39f5b8ed4b",
1712
- "price": {
1713
- "originCents": 100,
1714
- "origin": "100 ₫",
1715
- "salesCents": 90,
1716
- "sales": "90 ₫"
1717
- },
1636
+ "products": products,
1718
1637
  "keywords": [
1719
- "B1"
1720
- ],
1721
- "products": [
1722
- {
1723
- "spuId": "670f94397fb2d18edc8f61bc",
1724
- "skuId": "670f9439a6ddbb00093ef3fa",
1725
- "count": 2,
1726
- "name": "dyy商品变动(子规格被删除)(紫色)",
1727
- "quantity": -1,
1728
- "unlimitedQuantity": True
1729
- }
1638
+ "%s" % keyword
1730
1639
  ],
1731
- "buyerProductCount": 0
1640
+ "skuId": ""
1732
1641
  }
1733
- ],
1734
- "availableStartTime": True,
1735
- "availableEndTime": True,
1736
- "tempPrice": {
1737
- "originCents": 100,
1738
- "origin": "100 ₫",
1739
- "salesCents": 90,
1740
- "sales": "90 ₫"
1741
- },
1742
- "childrenInfo": {
1743
- "670f94397fb2d18edc8f61bc": {
1744
- "necessaryQuantity": 2,
1745
- "variations": [
1746
- "670f9439a6ddbb00093ef3fa"
1747
- ]
1748
- }
1749
- },
1750
- "status": "active"
1751
- },
1752
- {
1753
- "id": "670f8a6c7fb2d15f7b8f6431",
1754
- "image": "https://shoplineimg.com/61a87c9763b70c005106fbd0/670f8a57b7b2cb000a26a9f6/50xf.webp?source_format=jpeg\u0026cheap_resize=1",
1755
- "title": "dyy超长的组合商品yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
1756
- "recommend": {
1757
- "isActivity": True,
1758
- "recommendTime": True
1759
- },
1760
- "effectiveKey": True,
1761
- "defaultKey": "A",
1762
- "combinationList": [
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": [
1763
1697
  {
1764
- "id": "c536c6eaffa7364a1dac2743aeff518a",
1765
- "price": {
1766
- "originCents": 100,
1767
- "origin": "100 ₫",
1768
- "salesCents": 90,
1769
- "sales": "90 ₫"
1770
- },
1771
- "keywords": [
1772
- "A1"
1773
- ],
1774
- "products": [
1775
- {
1776
- "spuId": "670f8a48b7b2cb384126a9bc",
1777
- "skuId": "670f8a48db1762000bcedfc8",
1778
- "count": 2,
1779
- "name": "dyy超长的商品yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy(dyy超长的商品yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy)",
1780
- "quantity": -1,
1781
- "unlimitedQuantity": True
1782
- },
1698
+ "id": "%s"%product_id,
1699
+ "defaultKey": "",
1700
+ "combinationList": [
1783
1701
  {
1784
- "spuId": "670f84314149e400117b3c6a",
1785
- "skuId": "670f84314bd7dd001035d0ea",
1786
- "count": 1,
1787
- "name": "多规格商品名称1729070129(红)",
1788
- "quantity": 50,
1789
- "unlimitedQuantity": True
1790
- }
1791
- ],
1792
- "buyerProductCount": 0
1793
- }
1794
- ],
1795
- "availableStartTime": True,
1796
- "availableEndTime": True,
1797
- "tempPrice": {
1798
- "originCents": 100,
1799
- "origin": "100 ₫",
1800
- "salesCents": 90,
1801
- "sales": "90 ₫"
1802
- },
1803
- "childrenInfo": {
1804
- "670f84314149e400117b3c6a": {
1805
- "necessaryQuantity": 1,
1806
- "variations": [
1807
- "670f84314bd7dd001035d0ea"
1808
- ]
1809
- },
1810
- "670f8a48b7b2cb384126a9bc": {
1811
- "necessaryQuantity": 2,
1812
- "variations": [
1813
- "670f8a48db1762000bcedfc8",
1814
- "670f8a48db1762000bcedfc9"
1702
+ "products": products,
1703
+ "keywords": [
1704
+ "%s"%keyword
1705
+ ],
1706
+ "skuId": ""
1707
+ }
1708
+ ]
1709
+ }
1815
1710
  ]
1816
1711
  }
1817
- },
1818
- "status": "active"
1819
- },
1820
- {
1821
- "id": "673c889f3dc982185de87d1c",
1822
- "image": "https://shoplineimg.com/61a87c9763b70c005106fbd0/673c889b52b9d600110bfc1c/50xf.webp?source_format=png\u0026cheap_resize=1",
1823
- "title": "ffsssdsfsfsf",
1824
- "recommend": {
1825
- "isActivity": True,
1826
- "recommendTime": True
1827
- },
1828
- "effectiveKey": True,
1829
- "defaultKey": "",
1830
- "combinationList": [
1831
- {
1832
- "id": "46df6fa5b6af8bcbec7aa28db26f1eae",
1833
- "price": {
1834
- "originCents": 455,
1835
- "origin": "455 ₫",
1836
- "salesCents": 55,
1837
- "sales": "55 ₫"
1838
- },
1839
- "keywords": [
1840
- "厨房风格"
1841
- ],
1842
- "products": [
1843
- {
1844
- "spuId": "673c311f52b9d659d30bf878",
1845
- "skuId": "673c311f52b9d659d30bf878",
1846
- "count": 2,
1847
- "name": "inbox自定义商品",
1848
- "quantity": 999999,
1849
- "unlimitedQuantity": True
1850
- },
1851
- {
1852
- "spuId": "673c2e5a3dc982185de87b57",
1853
- "skuId": "673c2e5a3dc982185de87b57",
1854
- "count": 2,
1855
- "name": "自定义商品哈哈哈",
1856
- "quantity": -1,
1857
- "unlimitedQuantity": True
1858
- }
1859
- ],
1860
- "buyerProductCount": 0
1861
- }
1862
- ],
1863
- "availableStartTime": True,
1864
- "availableEndTime": True,
1865
- "tempPrice": {
1866
- "originCents": 455,
1867
- "origin": "455 ₫",
1868
- "salesCents": 55,
1869
- "sales": "55 ₫"
1870
- },
1871
- "childrenInfo": {
1872
- "673c2e5a3dc982185de87b57": {
1873
- "necessaryQuantity": 2,
1874
- "variations": []
1875
- },
1876
- "673c311f52b9d659d30bf878": {
1877
- "necessaryQuantity": 2,
1878
- "variations": []
1879
- }
1880
- },
1881
- "status": "active"
1882
- }
1883
- ]
1884
- },
1885
- "traceId": "019833d17de727ab192e0fe3582c372e"
1886
- }
1887
- keyword, product_id,combination_id, __ = get_stock_product_set(data)
1888
- print(keyword)
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
+
1728
+ if __name__=="__main__":
1729
+ pass
1730
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.5.8
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.8',
5
+ version='2.5.9',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),