ey-commerce-lib 1.0.21__py3-none-any.whl → 1.0.23__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.

@@ -1,5 +1,4 @@
1
1
  import asyncio
2
- import time
3
2
  import traceback
4
3
 
5
4
  from httpx import AsyncClient, Timeout
@@ -8,6 +7,7 @@ from playwright.async_api import async_playwright
8
7
  from ey_commerce_lib.dxm.constant.order import DxmOrderRuleType
9
8
  from ey_commerce_lib.dxm.parser.common import get_page_info, get_purchase_pagination_info, get_tracking_page_info
10
9
  from ey_commerce_lib.dxm.parser.count import parse_count
10
+ from ey_commerce_lib.dxm.parser.export_template import parse_list_export_template
11
11
  from ey_commerce_lib.dxm.parser.order import list_order_base_by_html, list_order_rule, get_rule_detail, \
12
12
  get_order_detail_by_html, parse_comm_search_list_html_get_authid_dict
13
13
  from ey_commerce_lib.dxm.parser.purchase import list_purchasing_all, list_1688_purchase_order_number, \
@@ -17,6 +17,7 @@ from ey_commerce_lib.dxm.parser.warehouse import list_warehouse_product
17
17
  from ey_commerce_lib.dxm.schemas.common import Page
18
18
  from ey_commerce_lib.dxm.schemas.dxm_commodity_product import ViewDxmCommodityProductResponse
19
19
  from ey_commerce_lib.dxm.schemas.ebay_product import DxmEbayProductModel
20
+ from ey_commerce_lib.dxm.schemas.export_package import ExportPackageOrderModel
20
21
  from ey_commerce_lib.dxm.schemas.order import DxmOrderSearchForm, DxmJsonResponse, DxmCheckProcessResponse, DxmOrderRule
21
22
  from ey_commerce_lib.dxm.schemas.tracking import TrackingPageListQuery, TrackingPageListItem
22
23
  from ey_commerce_lib.dxm.schemas.warehouse import WarehouseProduct, WarehouseProductQuery, PurchasingAllQuery
@@ -879,6 +880,53 @@ class DxmClient:
879
880
  comm_search_list_html = response.text
880
881
  return parse_comm_search_list_html_get_authid_dict(comm_search_list_html, keyword)
881
882
 
883
+ async def export_template_get_by_id_json(self, id_str: str):
884
+ """
885
+ 根据id获取导出模板配置
886
+ :param id_str: 模板id
887
+ :return:
888
+ """
889
+ async with self.__sem:
890
+ response = await self.__async_client.post('/exportTemplate/getById.json', data={
891
+ 'id': id_str
892
+ })
893
+ return response.json()
894
+
895
+ async def list_export_template(self):
896
+ """
897
+ 获取导出模板的列表
898
+ :return:
899
+ """
900
+ async with self.__sem:
901
+ response = await self.__async_client.post('/exportTemplate/index.htm')
902
+ return parse_list_export_template(response.text)
903
+
904
+ async def export_package_order(self, data: ExportPackageOrderModel):
905
+ """
906
+ 导出包裹订单
907
+ :param data: 导出参数模型类
908
+ :return:
909
+ """
910
+ async with self.__sem:
911
+ response = await self.__async_client.post('order/exportPackageOrder.json',
912
+ data=data.model_dump(by_alias=True))
913
+ uuid = response.json().get('uuid')
914
+ if not uuid:
915
+ raise Exception('导出失败')
916
+ code = 0
917
+ msg = ''
918
+ # 如果导出状态没有完成就一直循环
919
+ while code == 0:
920
+ check_process_res = await self.__check_process(uuid)
921
+ code = check_process_res.get('processMsg').get('code')
922
+ msg = check_process_res.get('processMsg').get('msg')
923
+ print(f'导出中,{check_process_res}')
924
+ await asyncio.sleep(5)
925
+ # code为1代表导出成功
926
+ if code != 1:
927
+ raise Exception(f'导出失败,失败原因:{msg}')
928
+ return msg
929
+
882
930
  async def __aenter__(self):
883
931
  return self
884
932
 
@@ -0,0 +1,17 @@
1
+ from lxml import html
2
+
3
+
4
+ def parse_list_export_template(html_content: str):
5
+ tree = html.fromstring(html_content)
6
+ export_template_element_list = tree.xpath('//div[@class="page-list no-page"]/table[@class="in-table"]/tbody/tr')
7
+ export_template_list = []
8
+ for export_template_element in export_template_element_list:
9
+ template_id = export_template_element.xpath('@id')[0].replace('tr', '')
10
+ template_name = export_template_element.xpath('./td[1]/text()')[0].strip()
11
+ field_str = export_template_element.xpath('./td[2]/text()')[0].strip()
12
+ export_template_list.append({
13
+ 'template_id': template_id,
14
+ 'template_name': template_name,
15
+ 'field_str': field_str
16
+ })
17
+ return export_template_list
@@ -0,0 +1,23 @@
1
+ from typing import Optional
2
+
3
+ from pydantic import BaseModel, Field, ConfigDict
4
+
5
+
6
+ class ExportPackageOrderModel(BaseModel):
7
+ template_id: str = Field(alias="templateId", description="模板ID")
8
+ package_ids: str = Field("", alias="packageIds", description="packageId使用,号连接")
9
+ export_keys: str = Field(alias="exportKeys", description="导出字段, 需要使用urllib.parse.quote编码")
10
+ order_field: str = Field('order_create_time', alias="orderField", description="固定值不用管")
11
+ state: str = Field("", alias="state", description="订单状态")
12
+ start_time: str = Field("", alias="startTime", description="开始时间")
13
+ end_time: str = Field("", alias="endTime", description="结束时间")
14
+ time_type: str = Field("", alias="timeType", description="时间类型 2(发货时间) 0(付款时间) 1(下单时间)")
15
+ export_style: str = Field("1", alias="exportStyle", description="按包裹导出(1) 按订单导出(0) 按产品导出(2)")
16
+ history: str = Field("", alias="history", description="120天订单('') 历史订单('all')")
17
+ is_voided: str = Field("-1", alias="isVoided")
18
+ rule_id: str = Field("-1", alias="ruleId")
19
+ sysrule: str = Field("", alias="sysrule")
20
+ request_location: str = Field('0', alias="requestLocation", description="页面上pageTag的值(一般不用管0)")
21
+ is_search: str = Field('1', alias="isSearch")
22
+
23
+ model_config = ConfigDict(populate_by_name=True)
@@ -4,7 +4,7 @@ import logging
4
4
  from typing import Callable
5
5
 
6
6
  import ddddocr
7
- from httpx import AsyncClient, ReadTimeout
7
+ from httpx import AsyncClient, ReadTimeout, Timeout
8
8
  from playwright.async_api import async_playwright, TimeoutError
9
9
 
10
10
  from ey_commerce_lib.four_seller.constant.response import ResponseCodeEnum
@@ -37,13 +37,14 @@ class FourSellerClient:
37
37
  self.__login_in_progress = None
38
38
  # ddddocr实例
39
39
  self.__ocr = ddddocr.DdddOcr()
40
+ timeout = Timeout(connect=60.0, read=60.0, write=60.0, pool=30.0)
40
41
  # 异步客户端
41
42
  self.__async_client = AsyncClient(base_url="https://www.4seller.com", cookies={"userToken": user_token},
42
43
  headers={
43
44
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
44
45
  "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 "
45
46
  "Safari/537.36"
46
- })
47
+ }, timeout=timeout)
47
48
 
48
49
  async def __auto_login_4seller(self) -> str:
49
50
  """
@@ -9,7 +9,9 @@ class TakeSendClient(object):
9
9
  timeout = Timeout(connect=60.0, read=60.0, write=60.0, pool=30.0)
10
10
  self.__async_client = AsyncClient(
11
11
  base_url="http://k5.takesend.com:8180",
12
- timeout=timeout)
12
+ timeout=timeout,
13
+ verify=False
14
+ )
13
15
  self.__username = username
14
16
  self.__password = password
15
17
 
@@ -18,9 +20,9 @@ class TakeSendClient(object):
18
20
  自动登录
19
21
  :return:
20
22
  """
21
- # 1. 先访问首页更新JESSIONID
23
+ # 访问首页
22
24
  await self.__async_client.get("/c_index.jsp")
23
- # 2.在登录
25
+ # 登录
24
26
  params = {
25
27
  'action': 'logon'
26
28
  }
@@ -28,9 +30,10 @@ class TakeSendClient(object):
28
30
  'userid': self.__username,
29
31
  'password': self.__password
30
32
  }
31
- await self.__async_client.post("//client/Logon", params=params, data=data, headers=LOGIN_HEADERS)
33
+ # 请求登录接口
34
+ await self.__async_client.post(".//client/Logon", params=params, data=data, headers=LOGIN_HEADERS)
32
35
 
33
- async def client_cc_order(self, excel_data: list):
36
+ async def client_cc_order(self, excel_data: list | str):
34
37
  """
35
38
  修改泰嘉产品上传重量数据
36
39
  :param excel_data:
@@ -43,7 +46,9 @@ class TakeSendClient(object):
43
46
  data = {
44
47
  'excel[]': excel_data,
45
48
  }
46
- return await self.__async_client.post("/Client/CCOrder", params=params, data=data, headers=EDIT_HEADERS)
49
+
50
+ response = await self.__async_client.post('/Client/CCOrder', params=params, data=data, headers=EDIT_HEADERS)
51
+ return response.json()
47
52
 
48
53
  async def __aenter__(self):
49
54
  return self
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ey-commerce-lib
3
- Version: 1.0.21
3
+ Version: 1.0.23
4
4
  Summary: eeyoung电商客户端调用封装
5
5
  Author-email: 饶奇奇 <1124393197@qq.com>
6
6
  Requires-Python: >=3.10
@@ -2,8 +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=SU1e5L_rPMbS9QZJmB8I-jirBr5_rWu3I2ZQ2vNuUz0,35274
6
- ey_commerce_lib/dxm/order.py,sha256=hMdNm9X5h9tbvMWFnyE5hcSF4butzn7m-akGqLQUD0k,35
5
+ ey_commerce_lib/dxm/main.py,sha256=M0HDl3pZDZRpNmHdN4AkyvbQ5DOpUXpIbsFBx7-ysIM,37258
7
6
  ey_commerce_lib/dxm/constant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
7
  ey_commerce_lib/dxm/constant/order.py,sha256=U-2NYnkIcqukzMtOFpfqvzIktu_t7jYEms_n9LgKMlY,2213
9
8
  ey_commerce_lib/dxm/exception/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -12,6 +11,7 @@ ey_commerce_lib/dxm/parser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
12
11
  ey_commerce_lib/dxm/parser/common.py,sha256=srzjwl7CviDgv0vizDC3RO2cbkQG9Pl-JpQpGAO5U14,3627
13
12
  ey_commerce_lib/dxm/parser/count.py,sha256=WOrGeA6DP6_IBtiF1TEZhW528f8kHxlT2cpmg_7FKPM,1561
14
13
  ey_commerce_lib/dxm/parser/ebay_product.py,sha256=Ub6of2YhFnXQwZiFBvZa6wnTIsGbsedAKHW92dbBHIY,589
14
+ ey_commerce_lib/dxm/parser/export_template.py,sha256=bzqBguzanQTNnea26MOLSl5iLUd-bvNnnGCxxvJp9kA,787
15
15
  ey_commerce_lib/dxm/parser/order.py,sha256=9At7M1mlTslGnCO-BfjAFXNT9SPabXtTG38dnShluKI,19448
16
16
  ey_commerce_lib/dxm/parser/purchase.py,sha256=lmcC41HtdUqCgGamFASPnzHatUziLFaenTJmazsiMm0,5750
17
17
  ey_commerce_lib/dxm/parser/tracking.py,sha256=ND7Xo31lMycmRLXIYtPAXqOh2W-tmeFE8t-f-sNDLLI,2629
@@ -20,6 +20,7 @@ ey_commerce_lib/dxm/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
20
20
  ey_commerce_lib/dxm/schemas/common.py,sha256=ihCeYrh4K_-m9_4rVzHm-o8rFNqzcD5XkO0JQd2023g,234
21
21
  ey_commerce_lib/dxm/schemas/dxm_commodity_product.py,sha256=9CiMTkRFk2McFL5jiHI35furvuxhJlqBr4AWOC3hlXw,30871
22
22
  ey_commerce_lib/dxm/schemas/ebay_product.py,sha256=k8LqBCz657vYRcLRjjyPJjQYjQOSwSGBivvp2LPWuYc,3696
23
+ ey_commerce_lib/dxm/schemas/export_package.py,sha256=azochz5FBwvCktXf78A2W46iFjwpkA54j06F9YLCCjY,1475
23
24
  ey_commerce_lib/dxm/schemas/order.py,sha256=6ps9aXFcEiRASLv1CH5uW7wnplaWzD_vTfyzvi5eLE0,7881
24
25
  ey_commerce_lib/dxm/schemas/tracking.py,sha256=ZysvY6zbgfwmeNCS-s21XugrKG5d0OPHMFTZfLYBDAc,3059
25
26
  ey_commerce_lib/dxm/schemas/warehouse.py,sha256=BT9r92DgkGKRI-HPqHPt5FKPdPJr2h-rxjfh25STR2E,5094
@@ -27,7 +28,7 @@ ey_commerce_lib/dxm/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
27
28
  ey_commerce_lib/dxm/utils/dxm_commodity_product.py,sha256=OkL9Ve0lnSA2l-3DMWXF2fSj-A0uV4ucrhfEWNL2Z-Y,5398
28
29
  ey_commerce_lib/dxm/utils/mark.py,sha256=rAmofi3JmdI8gdl3s-U0ZEKcA-cn6vtS3lsXDrVXRLc,4716
29
30
  ey_commerce_lib/four_seller/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- ey_commerce_lib/four_seller/main.py,sha256=cqO29DRRVzJHwo_005RFOO3vyGboQcuJUli783nyQjA,13131
31
+ ey_commerce_lib/four_seller/main.py,sha256=6f6gIpUeQZfETGeAbpM-Avyi7Mbmjj-05Qaa-RDh2pg,13232
31
32
  ey_commerce_lib/four_seller/constant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
33
  ey_commerce_lib/four_seller/constant/response.py,sha256=UqGeRCaAV6B_IyNfJR5oJvbKW4BUF5jQGhU5JYpYP1k,163
33
34
  ey_commerce_lib/four_seller/parser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -48,13 +49,13 @@ ey_commerce_lib/kogan/schemas/response/order.py,sha256=ATWks8Erv9HmW9t_UklYRMn4s
48
49
  ey_commerce_lib/kogan/schemas/response/product.py,sha256=IVC1QSHSYZyHa4lCYz20rTdtmPvpPoqJsQP88hu48S4,2773
49
50
  ey_commerce_lib/takesend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
51
  ey_commerce_lib/takesend/config.py,sha256=doR1mzVL3hrDY8luVT1_hRIGAc2_ZaTgYS8-SBU__Js,1260
51
- ey_commerce_lib/takesend/main.py,sha256=kYnRQxAgLWagyKr8ilLG7XrF2sG0ANoXoVm47fAANZ8,1568
52
+ ey_commerce_lib/takesend/main.py,sha256=x91ySyNfxUYQuuzKpA1hCW_IH7H9_Rxj-PTmYNwjs2g,1654
52
53
  ey_commerce_lib/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
54
  ey_commerce_lib/utils/close.py,sha256=-De_H1I-gryytKYhLMsC3HfW67W852XkP1ckK2gLsFs,141
54
55
  ey_commerce_lib/utils/dxm.py,sha256=jVNltK_Pm_yMzXReD0Aw5VW6kzIZ5Bn23RucS0DKBI0,1196
55
56
  ey_commerce_lib/utils/float.py,sha256=PiOMf9pRApc1DskKkhKx0LAWHAYTpAPT_G4QRZRd8ZU,905
56
57
  ey_commerce_lib/utils/list_util.py,sha256=R1w7B1m3sEXr38zSHWp-15C3xAs5ykYCCpvwmnRW4xs,545
57
58
  ey_commerce_lib/utils/str.py,sha256=939xE0y8U7KEWjwbEezMlaWJNBsfb2BSb-dBpYbOD8Q,138
58
- ey_commerce_lib-1.0.21.dist-info/METADATA,sha256=gy3nsyb6elHZ7EdZlmzSkyuphYwOpmK9u1OUoN1IF3k,391
59
- ey_commerce_lib-1.0.21.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
60
- ey_commerce_lib-1.0.21.dist-info/RECORD,,
59
+ ey_commerce_lib-1.0.23.dist-info/METADATA,sha256=SpR-HuS_lKn3GTuGWFvpa6fPyj7REejby7icmqLtQxc,391
60
+ ey_commerce_lib-1.0.23.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
61
+ ey_commerce_lib-1.0.23.dist-info/RECORD,,
@@ -1,2 +0,0 @@
1
- async def page_order():
2
- pass