ey-commerce-lib 1.0.12__py3-none-any.whl → 1.0.13__py3-none-any.whl

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.

Potentially problematic release.


This version of ey-commerce-lib might be problematic. Click here for more details.

@@ -4,6 +4,7 @@ from httpx import AsyncClient, Timeout
4
4
 
5
5
  from ey_commerce_lib.dxm.constant.order import DxmOrderRuleType
6
6
  from ey_commerce_lib.dxm.parser.common import get_page_info, get_purchase_pagination_info
7
+ from ey_commerce_lib.dxm.parser.count import parse_count
7
8
  from ey_commerce_lib.dxm.parser.order import list_order_base_by_html, list_order_rule, get_rule_detail, \
8
9
  get_order_detail_by_html
9
10
  from ey_commerce_lib.dxm.parser.purchase import list_purchasing_all, list_1688_purchase_order_number, \
@@ -631,6 +632,39 @@ class DxmClient:
631
632
  raise Exception(f'添加订单标记数据失败错误原因{add_comment_res.json().get("msg")}')
632
633
  return data
633
634
 
635
+ async def get_state_count_api(self):
636
+ """
637
+ 获取订单各个状态统计api
638
+ :return:
639
+ """
640
+ async with self.__sem:
641
+ get_state_res = await self.__async_client.post('/package/getStateCount.json')
642
+ return get_state_res.json()
643
+
644
+ async def __stat_index(self):
645
+ """
646
+ 获取店小秘订单统计页api
647
+ :return:
648
+ """
649
+ async with self.__sem:
650
+ params = {
651
+ 'shopIds': 'all',
652
+ 'isIndex': '1',
653
+ 'currency': 'USD',
654
+ }
655
+ stat_index_res = await self.__async_client.get('/stat/order/orderPerform.htm', params=params)
656
+ stat_index_html = stat_index_res.text
657
+
658
+ return parse_count(stat_index_html)
659
+
660
+ async def list_order_count(self):
661
+ """
662
+ 获取店小秘订单统计
663
+ :return:
664
+ """
665
+
666
+ return await self.__stat_index()
667
+
634
668
  async def __aenter__(self):
635
669
  return self
636
670
 
@@ -0,0 +1,43 @@
1
+ from lxml import html
2
+
3
+
4
+ def parse_count(html_content: str):
5
+ tree = html.fromstring(html_content)
6
+ data_list = tree.xpath("//tr[@class='content']")
7
+ result = []
8
+ for data in data_list:
9
+ date = data.xpath('./td/text()')[0].strip()
10
+ order_number = data.xpath('./td/text()')[1].strip()
11
+ # 订单总金额
12
+ total_amount = data.xpath('./td/text()')[2].strip()
13
+ # 订单手续费
14
+ fee = data.xpath('./td/text()')[3].strip()
15
+ # 物流费用
16
+ logistics = data.xpath('./td/text()')[4].strip()
17
+ # 利润
18
+ profit = data.xpath('./td/text()')[5].strip()
19
+ # 退单数量
20
+ return_number = data.xpath('./td/text()')[6].strip()
21
+ # 退单金额
22
+ return_amount = data.xpath('./td/text()')[7].strip()
23
+ # 退款率
24
+ return_rate = data.xpath('./td/text()')[8].strip()
25
+ # 成本利润
26
+ cost_profit = data.xpath('./td/text()')[9].strip()
27
+ # 销售利润
28
+ sale_profit = data.xpath('./td/text()')[10].strip()
29
+ # 添加数据
30
+ result.append({
31
+ 'date': date,
32
+ 'order_number': order_number,
33
+ 'total_amount': total_amount,
34
+ 'fee': fee,
35
+ 'logistics': logistics,
36
+ 'profit': profit,
37
+ 'return_number': return_number,
38
+ 'return_amount': return_amount,
39
+ 'return_rate': return_rate,
40
+ 'cost_profit': cost_profit,
41
+ 'sale_profit': sale_profit
42
+ })
43
+ return result
File without changes
@@ -0,0 +1,26 @@
1
+ LOGIN_HEADERS = {
2
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,'
3
+ '*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
4
+ 'Accept-Language': 'zh-CN,zh;q=0.9',
5
+ 'Cache-Control': 'no-cache',
6
+ 'Connection': 'keep-alive',
7
+ 'Content-Type': 'application/x-www-form-urlencoded',
8
+ 'Origin': 'http://k5.takesend.com:8180',
9
+ 'Pragma': 'no-cache',
10
+ 'Referer': 'http://k5.takesend.com:8180/c_index.jsp',
11
+ 'Upgrade-Insecure-Requests': '1',
12
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
13
+ }
14
+
15
+ EDIT_HEADERS = {
16
+ 'Accept': 'application/json, text/javascript, */*; q=0.01',
17
+ 'Accept-Language': 'zh-CN,zh;q=0.9',
18
+ 'Cache-Control': 'no-cache',
19
+ 'Connection': 'keep-alive',
20
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
21
+ 'Origin': 'http://k5.takesend.com:8180',
22
+ 'Pragma': 'no-cache',
23
+ 'Referer': 'http://k5.takesend.com:8180/client/Logon?action=initMenu',
24
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
25
+ 'X-Requested-With': 'XMLHttpRequest',
26
+ }
@@ -0,0 +1,52 @@
1
+ from httpx import AsyncClient, Timeout
2
+
3
+ from ey_commerce_lib.takesend.config import LOGIN_HEADERS, EDIT_HEADERS
4
+
5
+
6
+ class TakeSendClient(object):
7
+
8
+ def __init__(self, username: str, password: str):
9
+ timeout = Timeout(connect=5.0, read=20.0, write=10.0, pool=10.0)
10
+ self.__async_client = AsyncClient(
11
+ base_url="http://k5.takesend.com:8180",
12
+ timeout=timeout)
13
+ self.__username = username
14
+ self.__password = password
15
+
16
+ async def login(self):
17
+ """
18
+ 自动登录
19
+ :return:
20
+ """
21
+ # 1. 先访问首页更新JESSIONID
22
+ await self.__async_client.get("/c_index.jsp")
23
+ # 2.在登录
24
+ params = {
25
+ 'action': 'logon'
26
+ }
27
+ data = {
28
+ 'userid': self.__username,
29
+ 'password': self.__password
30
+ }
31
+ await self.__async_client.post("//client/Logon", params=params, data=data, headers=LOGIN_HEADERS)
32
+
33
+ async def __client_cc_order(self, excel_data: list):
34
+ """
35
+ 修改泰嘉产品上传重量数据
36
+ :param excel_data:
37
+ :return:
38
+ """
39
+
40
+ params = {
41
+ 'action': 'updateDweight',
42
+ }
43
+ data = {
44
+ 'excel[]': excel_data,
45
+ }
46
+ return await self.__async_client.post("/Client/CCOrder", params=params, data=data, headers=EDIT_HEADERS)
47
+
48
+ async def __aenter__(self):
49
+ return self
50
+
51
+ async def __aexit__(self, exc_type, exc_val, exc_tb):
52
+ await self.__async_client.aclose()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ey-commerce-lib
3
- Version: 1.0.12
3
+ Version: 1.0.13
4
4
  Summary: eeyoung电商客户端调用封装
5
5
  Author-email: 饶奇奇 <1124393197@qq.com>
6
6
  Requires-Python: >=3.10
@@ -2,7 +2,7 @@ ey_commerce_lib/__init__.py,sha256=QTYqXqSTHFRkM9TEgpDFcHvwLbvqHDqvqfQ9EiXkcAM,2
2
2
  ey_commerce_lib/model.py,sha256=0ZCE68502blzRDsQ38AIswc8kPk7H34Am5x8IiDi2DU,232
3
3
  ey_commerce_lib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  ey_commerce_lib/dxm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- ey_commerce_lib/dxm/main.py,sha256=WNqAelT64nYX1Tka6_3zN1IgAL7VuBFPSJU4OARADk4,24728
5
+ ey_commerce_lib/dxm/main.py,sha256=ie_F4VGuIB6o4gVkNAkD-5mFbT5JH8AvVNzX0WQpZho,25755
6
6
  ey_commerce_lib/dxm/order.py,sha256=hMdNm9X5h9tbvMWFnyE5hcSF4butzn7m-akGqLQUD0k,35
7
7
  ey_commerce_lib/dxm/constant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  ey_commerce_lib/dxm/constant/order.py,sha256=U-2NYnkIcqukzMtOFpfqvzIktu_t7jYEms_n9LgKMlY,2213
@@ -10,6 +10,7 @@ ey_commerce_lib/dxm/exception/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
10
10
  ey_commerce_lib/dxm/exception/common.py,sha256=DM5vItHdZCGK2Piqp2S5TFxPm3pioMzzlV-1RTxty00,159
11
11
  ey_commerce_lib/dxm/parser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  ey_commerce_lib/dxm/parser/common.py,sha256=-xfnaYhMStuvR-XEJTWAgTN2H88xflGtWXIrxDqbq0Q,3037
13
+ ey_commerce_lib/dxm/parser/count.py,sha256=WOrGeA6DP6_IBtiF1TEZhW528f8kHxlT2cpmg_7FKPM,1561
13
14
  ey_commerce_lib/dxm/parser/order.py,sha256=pivRDYgN-pBdFziOw4aiz6G4zR9uegikH9SLxMhe_qg,17457
14
15
  ey_commerce_lib/dxm/parser/purchase.py,sha256=lmcC41HtdUqCgGamFASPnzHatUziLFaenTJmazsiMm0,5750
15
16
  ey_commerce_lib/dxm/parser/warehouse.py,sha256=oQVojPX8VKHUphdV1KY5ZK1PCFtOY2zwkyLNUeJ3JT0,3310
@@ -39,11 +40,14 @@ ey_commerce_lib/kogan/schemas/query/product.py,sha256=nqFQh9IuFYwbM_cJxl-Ed_JYBl
39
40
  ey_commerce_lib/kogan/schemas/response/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
41
  ey_commerce_lib/kogan/schemas/response/order.py,sha256=ATWks8Erv9HmW9t_UklYRMn4sNbzYptmE8jTU_uCeyc,4718
41
42
  ey_commerce_lib/kogan/schemas/response/product.py,sha256=IVC1QSHSYZyHa4lCYz20rTdtmPvpPoqJsQP88hu48S4,2773
43
+ ey_commerce_lib/takesend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
+ ey_commerce_lib/takesend/config.py,sha256=doR1mzVL3hrDY8luVT1_hRIGAc2_ZaTgYS8-SBU__Js,1260
45
+ ey_commerce_lib/takesend/main.py,sha256=Omz7Wmo0bBzQvMA-_zVQG1sH-W-RsX5AeetFE2a1S0M,1569
42
46
  ey_commerce_lib/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
47
  ey_commerce_lib/utils/close.py,sha256=-De_H1I-gryytKYhLMsC3HfW67W852XkP1ckK2gLsFs,141
44
48
  ey_commerce_lib/utils/dxm.py,sha256=jVNltK_Pm_yMzXReD0Aw5VW6kzIZ5Bn23RucS0DKBI0,1196
45
49
  ey_commerce_lib/utils/list_util.py,sha256=R1w7B1m3sEXr38zSHWp-15C3xAs5ykYCCpvwmnRW4xs,545
46
50
  ey_commerce_lib/utils/str.py,sha256=939xE0y8U7KEWjwbEezMlaWJNBsfb2BSb-dBpYbOD8Q,138
47
- ey_commerce_lib-1.0.12.dist-info/METADATA,sha256=4FjehL0P_6j7xreBQoErb7WK7eyboLXw3qZKqth3BOI,391
48
- ey_commerce_lib-1.0.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
49
- ey_commerce_lib-1.0.12.dist-info/RECORD,,
51
+ ey_commerce_lib-1.0.13.dist-info/METADATA,sha256=QHlcTaUayz5CBL1uibTclawqQq2GEWFuWWiZRirHxyw,391
52
+ ey_commerce_lib-1.0.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
53
+ ey_commerce_lib-1.0.13.dist-info/RECORD,,