ey-commerce-lib 1.0.23__tar.gz → 1.0.25__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.
Potentially problematic release.
This version of ey-commerce-lib might be problematic. Click here for more details.
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/PKG-INFO +1 -1
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/pyproject.toml +1 -1
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/main.py +72 -39
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/common.py +6 -12
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/order.py +2 -82
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/takesend/config.py +14 -1
- ey_commerce_lib-1.0.25/src/ey_commerce_lib/takesend/main.py +117 -0
- ey_commerce_lib-1.0.25/src/ey_commerce_lib/takesend/parser/order.py +20 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/tests/dxm/test_purchase.py +25 -28
- ey_commerce_lib-1.0.25/tests/kogan/__init__.py +0 -0
- ey_commerce_lib-1.0.23/src/ey_commerce_lib/takesend/main.py +0 -57
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/.gitignore +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/.python-version +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/README.md +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/pytest.ini +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/constant/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/constant/order.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/exception/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/exception/common.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/count.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/ebay_product.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/export_template.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/purchase.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/tracking.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/warehouse.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/common.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/dxm_commodity_product.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/ebay_product.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/export_package.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/order.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/tracking.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/warehouse.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/utils/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/utils/dxm_commodity_product.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/utils/mark.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/constant/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/constant/response.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/main.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/parser/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/parser/order.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/schemas/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/schemas/query/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/schemas/query/order.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/schemas/vo/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/schemas/vo/order.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/kogan/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/kogan/main.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/kogan/schemas/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/kogan/schemas/query/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/kogan/schemas/query/order.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/kogan/schemas/query/product.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/kogan/schemas/response/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/kogan/schemas/response/order.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/kogan/schemas/response/product.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/model.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/py.typed +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/takesend/__init__.py +0 -0
- {ey_commerce_lib-1.0.23/src/ey_commerce_lib/utils → ey_commerce_lib-1.0.25/src/ey_commerce_lib/takesend/parser}/__init__.py +0 -0
- {ey_commerce_lib-1.0.23/tests → ey_commerce_lib-1.0.25/src/ey_commerce_lib/utils}/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/utils/close.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/utils/dxm.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/utils/float.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/utils/list_util.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/utils/str.py +0 -0
- {ey_commerce_lib-1.0.23/tests/dxm → ey_commerce_lib-1.0.25/tests}/__init__.py +0 -0
- {ey_commerce_lib-1.0.23/tests/kogan → ey_commerce_lib-1.0.25/tests/dxm}/__init__.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/tests/kogan/test_client.py +0 -0
- {ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/uv.lock +0 -0
|
@@ -8,8 +8,8 @@ from ey_commerce_lib.dxm.constant.order import DxmOrderRuleType
|
|
|
8
8
|
from ey_commerce_lib.dxm.parser.common import get_page_info, get_purchase_pagination_info, get_tracking_page_info
|
|
9
9
|
from ey_commerce_lib.dxm.parser.count import parse_count
|
|
10
10
|
from ey_commerce_lib.dxm.parser.export_template import parse_list_export_template
|
|
11
|
-
from ey_commerce_lib.dxm.parser.order import
|
|
12
|
-
|
|
11
|
+
from ey_commerce_lib.dxm.parser.order import list_order_rule, get_rule_detail, \
|
|
12
|
+
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, \
|
|
14
14
|
list_wait_pay_page_purchase_order_number
|
|
15
15
|
from ey_commerce_lib.dxm.parser.tracking import parse_tracking_page
|
|
@@ -34,78 +34,111 @@ class DxmClient:
|
|
|
34
34
|
self.__async_client = AsyncClient(base_url=self.__base_url, cookies=cookies, headers=headers,
|
|
35
35
|
timeout=timeout)
|
|
36
36
|
|
|
37
|
-
async def
|
|
37
|
+
async def package_advanced_search_api(self, query: DxmOrderSearchForm):
|
|
38
38
|
"""
|
|
39
|
-
|
|
39
|
+
条件店小秘订单高级搜索api
|
|
40
40
|
:param query:
|
|
41
41
|
:return:
|
|
42
42
|
"""
|
|
43
43
|
# 查询分页数据
|
|
44
|
-
|
|
44
|
+
package_advanced_search_res = await self.__async_client.post("/api/package/advancedSearch.json",
|
|
45
|
+
data=query.model_dump(by_alias=True))
|
|
46
|
+
package_advanced_search_data = package_advanced_search_res.json()
|
|
47
|
+
if package_advanced_search_data.get('code') != 0:
|
|
48
|
+
raise Exception('店小秘订单高级查询接口失败')
|
|
45
49
|
# 获取分页信息
|
|
46
|
-
|
|
47
|
-
data = list_order_base_by_html(data.text)
|
|
48
|
-
return {
|
|
49
|
-
**page_info,
|
|
50
|
-
'data': data
|
|
51
|
-
}
|
|
50
|
+
return package_advanced_search_data
|
|
52
51
|
|
|
53
|
-
async def
|
|
52
|
+
async def package_advanced_search_list(self, query: DxmOrderSearchForm):
|
|
54
53
|
"""
|
|
55
|
-
|
|
54
|
+
条件店小秘订单高级搜索分页数据列表(根据条件将page中的list进行汇总)
|
|
56
55
|
:return:
|
|
57
56
|
"""
|
|
58
57
|
query.page_no = 1
|
|
59
|
-
|
|
60
|
-
total_page = data
|
|
61
|
-
|
|
58
|
+
package_advanced_search_data = await self.package_advanced_search_api(query)
|
|
59
|
+
total_page = package_advanced_search_data.get('data', {}).get('page', {}).get('totalPage')
|
|
60
|
+
package_advanced_search_data_list = package_advanced_search_data.get('data', {}).get('page', {}).get('list', [])
|
|
62
61
|
for page_number in range(2, total_page + 1):
|
|
62
|
+
# 更改条件查询的页码
|
|
63
63
|
query.page_no = page_number
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
# 调用api获取分页数据
|
|
65
|
+
page_package_advanced_search_data = await self.package_advanced_search_api(query)
|
|
66
|
+
# 获取每一页的数据,没有获取到则为空数组
|
|
67
|
+
page_package_advanced_search_data_list = (page_package_advanced_search_data.get('data', {})
|
|
68
|
+
.get('page', {}).get('list', []))
|
|
69
|
+
# 合并每一页的数据
|
|
70
|
+
package_advanced_search_data_list.extend(page_package_advanced_search_data_list)
|
|
71
|
+
return package_advanced_search_data_list
|
|
72
|
+
|
|
73
|
+
async def package_advanced_search_with_detail(self, query: DxmOrderSearchForm):
|
|
74
|
+
"""
|
|
75
|
+
条件店小秘订单高级搜索分页数据(带详情)
|
|
76
|
+
:param query:
|
|
77
|
+
:return:
|
|
78
|
+
"""
|
|
67
79
|
|
|
68
|
-
|
|
69
|
-
async def set_detail(order_base: dict):
|
|
80
|
+
async def set_detail(pkg: dict):
|
|
70
81
|
"""
|
|
71
|
-
|
|
72
|
-
:param
|
|
82
|
+
将包裹详情数据注入到订单高级查询数据中
|
|
83
|
+
:param pkg:每一条包裹
|
|
73
84
|
:return:
|
|
74
85
|
"""
|
|
75
|
-
|
|
86
|
+
pkg['withDetail'] = await self.package_detail_json_api(pkg.get('id'))
|
|
76
87
|
|
|
77
88
|
# 获取基本分页数据信息
|
|
78
|
-
|
|
89
|
+
package_advanced_search_data = await self.package_advanced_search_api(query)
|
|
79
90
|
# 获取并设置详情信息
|
|
80
91
|
await asyncio.gather(*[
|
|
81
|
-
set_detail(
|
|
82
|
-
for
|
|
92
|
+
set_detail(pkg)
|
|
93
|
+
for pkg in package_advanced_search_data.get('data', {}).get('page', {}).get('list', [])])
|
|
83
94
|
|
|
84
|
-
return
|
|
95
|
+
return package_advanced_search_data
|
|
85
96
|
|
|
86
|
-
async def
|
|
97
|
+
async def package_advanced_search_with_detail_list(self, query: DxmOrderSearchForm):
|
|
98
|
+
"""
|
|
99
|
+
条件店小秘订单高级搜索分页数据(带详情)
|
|
100
|
+
:param query:
|
|
101
|
+
:return:
|
|
102
|
+
"""
|
|
103
|
+
# 默认从第一页开始
|
|
87
104
|
query.page_no = 1
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
105
|
+
# 获取第一页数据
|
|
106
|
+
package_advanced_search_with_detail_data = await self.package_advanced_search_with_detail(query)
|
|
107
|
+
# 获取总页数
|
|
108
|
+
total_page = package_advanced_search_with_detail_data.get('data', {}).get('page', {}).get('totalPage', 0)
|
|
109
|
+
# 获取第一页数据列表
|
|
110
|
+
package_advanced_search_with_detail_list = package_advanced_search_with_detail_data.get('data', {}).get('page',
|
|
111
|
+
{}).get(
|
|
112
|
+
'list', [])
|
|
113
|
+
# 循环获取每一页数据
|
|
91
114
|
for page_number in range(2, total_page + 1):
|
|
115
|
+
# 变更页码
|
|
92
116
|
query.page_no = page_number
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
117
|
+
# 获取每一页数据
|
|
118
|
+
page_package_advanced_search_with_detail_data = await self.package_advanced_search_with_detail(query)
|
|
119
|
+
# 获取每一页数据列表
|
|
120
|
+
page_package_advanced_search_with_detail_data_list = page_package_advanced_search_with_detail_data.get(
|
|
121
|
+
'data', {}).get('page', {}).get('list', [])
|
|
122
|
+
# 合并
|
|
123
|
+
package_advanced_search_with_detail_list.extend(page_package_advanced_search_with_detail_data_list)
|
|
124
|
+
# 返回合并后的数据
|
|
125
|
+
return package_advanced_search_with_detail_list
|
|
126
|
+
|
|
127
|
+
async def package_detail_json_api(self, package_id: str):
|
|
98
128
|
"""
|
|
99
129
|
获取包裹的详情数据
|
|
100
130
|
:param package_id:
|
|
101
131
|
:return:
|
|
102
132
|
"""
|
|
103
133
|
async with self.__sem:
|
|
104
|
-
package_detail_res = await self.__async_client.post('/package/detail.
|
|
134
|
+
package_detail_res = await self.__async_client.post('/api/package/detail.json', data={
|
|
105
135
|
'packageId': package_id,
|
|
106
136
|
'history': ''
|
|
107
137
|
})
|
|
108
|
-
|
|
138
|
+
package_detail_json = package_detail_res.json()
|
|
139
|
+
if package_detail_json.get('code') != 0:
|
|
140
|
+
raise Exception(f'店小秘获取订单详情失败,失败原因是{traceback.format_exc()}')
|
|
141
|
+
return package_detail_json
|
|
109
142
|
|
|
110
143
|
async def move_process(self, package_id: str) -> DxmJsonResponse:
|
|
111
144
|
"""
|
|
@@ -14,23 +14,17 @@ class PageInfo(TypedDict):
|
|
|
14
14
|
page_number: int
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
def get_page_info(
|
|
17
|
+
def get_page_info(page_order_data: dict) -> PageInfo:
|
|
18
18
|
"""
|
|
19
19
|
获取分页信息和分页数据
|
|
20
20
|
:return:
|
|
21
21
|
"""
|
|
22
|
-
|
|
23
|
-
page_size_list = tree.xpath('//input[@id="pageSize"]/@value')
|
|
24
|
-
total_page_list = tree.xpath('//input[@id="totalPage"]/@value')
|
|
25
|
-
total_size_list = tree.xpath('//input[@id="totalSize"]/@value')
|
|
26
|
-
page_number_list = tree.xpath('//input[@id="pageNo"]/@value')
|
|
27
|
-
if len(page_size_list) == 0 or len(total_page_list) == 0:
|
|
28
|
-
raise PageInfoNotFoundException("分页信息获取失败")
|
|
22
|
+
page_info = page_order_data.get('data').get('page')
|
|
29
23
|
return {
|
|
30
|
-
'page_size':
|
|
31
|
-
'total_page':
|
|
32
|
-
'total_size':
|
|
33
|
-
'page_number':
|
|
24
|
+
'page_size': page_info.get('pageSize'),
|
|
25
|
+
'total_page':page_info.get('totalPage'),
|
|
26
|
+
'total_size': page_info.get('totalSize'),
|
|
27
|
+
'page_number': page_info.get('pageNo')
|
|
34
28
|
}
|
|
35
29
|
|
|
36
30
|
|
|
@@ -136,88 +136,8 @@ def get_order_buyer_select_provider(good_element: html.HtmlElement):
|
|
|
136
136
|
return buyer_select_provider
|
|
137
137
|
|
|
138
138
|
|
|
139
|
-
def list_order_base_by_html(
|
|
140
|
-
|
|
141
|
-
获取基本的订单分页信息
|
|
142
|
-
有三种情况:
|
|
143
|
-
1. 合并单
|
|
144
|
-
2. 一单多件
|
|
145
|
-
3. 普通一单一件
|
|
146
|
-
:param html_str:
|
|
147
|
-
:return:
|
|
148
|
-
"""
|
|
149
|
-
tree = html.fromstring(html_str)
|
|
150
|
-
good_element_list = tree.xpath('//tbody[@class="xianshishujudate"]/tr[@class="goodsId"]')
|
|
151
|
-
order_list = list()
|
|
152
|
-
table_columns = tree.xpath('//table[@id="orderListTable"]/thead/tr/th/text()')
|
|
153
|
-
# 是否又物流方式
|
|
154
|
-
has_logistics = True if '物流方式' in table_columns else False
|
|
155
|
-
for good_element in good_element_list:
|
|
156
|
-
# 包裹号
|
|
157
|
-
package_number = good_element.xpath('.//a[@class="limingcentUrlpic"]/text()')[0]
|
|
158
|
-
# 包裹id
|
|
159
|
-
package_id = good_element.xpath('.//input[@class="input1"]/@value')[0]
|
|
160
|
-
# authid 物流方式的id
|
|
161
|
-
auth_id = good_element.xpath(f'.//input[@id="dxmAuthId{package_id}"]/@value')[0]
|
|
162
|
-
# data-custom-mark标记
|
|
163
|
-
data_custom_mark = get_str_list_first_not_blank_or_none(good_element.xpath('@data-custom-mark'))
|
|
164
|
-
buyer_select_provider = get_order_buyer_select_provider(good_element)
|
|
165
|
-
order_form_source = good_element.xpath('.//span[contains(@class, "order-form-source")]/text()')[0]
|
|
166
|
-
platform, shop = order_form_source.replace('「', '').replace('」', '').split(':')
|
|
167
|
-
order_class = f"orderId_{package_id}"
|
|
168
|
-
order_element_list = tree.xpath(f'//tr[@class="{order_class}"]')
|
|
169
|
-
order_first_element = order_element_list[0]
|
|
170
|
-
# 订单备注
|
|
171
|
-
hover_prompt_content_list = good_element.xpath('.//span[contains(@class, "hoverPrompt")]/@data-content')
|
|
172
|
-
# 物流方式, 要先检查是否包含物流方式这一列
|
|
173
|
-
logistics_info = None
|
|
174
|
-
if has_logistics:
|
|
175
|
-
# 物流方式
|
|
176
|
-
logistics_list = order_first_element.xpath('.//td[6]/span/a/text()')
|
|
177
|
-
# 可能又不存在的物流方式情况发生
|
|
178
|
-
if len(logistics_list) > 0:
|
|
179
|
-
logistics_info = dict()
|
|
180
|
-
logistics = logistics_list[0].strip()
|
|
181
|
-
# 物流单号
|
|
182
|
-
logistics_info['track_number'] = get_str_list_first_not_blank_or_none(
|
|
183
|
-
order_first_element.xpath('.//td[6]//span[contains(@class, "limingcentUrlpicson")]/a/text()'))
|
|
184
|
-
logistics_info['logistics'] = logistics
|
|
185
|
-
# 称重重量
|
|
186
|
-
weight_element_list = order_first_element.xpath('.//td[6]//span[@class="gray-c"]/text()')
|
|
187
|
-
weight = None
|
|
188
|
-
for weight_element in weight_element_list:
|
|
189
|
-
if '称重重量' in weight_element:
|
|
190
|
-
# 如果包含了称重重量的话,获取完整的数字部分
|
|
191
|
-
weight = float(re.search(r'\d+(?:\.\d+)?', weight_element).group())
|
|
192
|
-
# 设置重量部分
|
|
193
|
-
logistics_info['weight'] = weight
|
|
194
|
-
|
|
195
|
-
# 状态
|
|
196
|
-
if has_logistics:
|
|
197
|
-
status = get_str_list_first_not_blank_or_none(order_first_element.xpath('.//td[7]/text()'))
|
|
198
|
-
else:
|
|
199
|
-
status = get_str_list_first_not_blank_or_none(order_first_element.xpath('.//td[6]/text()'))
|
|
200
|
-
# 整理订单
|
|
201
|
-
if len(order_element_list) > 1:
|
|
202
|
-
# 合并单
|
|
203
|
-
order_item_list = get_merge_order_item_list(order_element_list)
|
|
204
|
-
else:
|
|
205
|
-
# 普通单
|
|
206
|
-
order_item_list = get_single_order_item_list(order_element_list[0])
|
|
207
|
-
order_list.append({
|
|
208
|
-
'package_id': package_id,
|
|
209
|
-
'auth_id': auth_id,
|
|
210
|
-
'package_number': package_number,
|
|
211
|
-
'data_custom_mark': data_custom_mark,
|
|
212
|
-
'buyer_select_provider': buyer_select_provider,
|
|
213
|
-
'platform': platform,
|
|
214
|
-
'shop': shop,
|
|
215
|
-
'hover_prompt_content_list': hover_prompt_content_list,
|
|
216
|
-
'logistics_info': logistics_info,
|
|
217
|
-
'status': status,
|
|
218
|
-
'order_item_list': order_item_list
|
|
219
|
-
})
|
|
220
|
-
return order_list
|
|
139
|
+
def list_order_base_by_html(page_order_data: dict) -> list[dict]:
|
|
140
|
+
return page_order_data.get('data').get('page').get('list')
|
|
221
141
|
|
|
222
142
|
|
|
223
143
|
def list_order_rule(html_str: str):
|
|
@@ -23,4 +23,17 @@ EDIT_HEADERS = {
|
|
|
23
23
|
'Referer': 'http://k5.takesend.com:8180/client/Logon?action=initMenu',
|
|
24
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
25
|
'X-Requested-With': 'XMLHttpRequest',
|
|
26
|
-
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
LIST_HEADS = {
|
|
29
|
+
'Accept': '*/*',
|
|
30
|
+
'Accept-Language': 'zh-CN,zh;q=0.9',
|
|
31
|
+
'Cache-Control': 'no-cache',
|
|
32
|
+
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
33
|
+
'Origin': 'http://k5.takesend.com:8180',
|
|
34
|
+
'Pragma': 'no-cache',
|
|
35
|
+
'Proxy-Connection': 'keep-alive',
|
|
36
|
+
'Referer': 'http://k5.takesend.com:8180/client/Logon?action=initMenu',
|
|
37
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36',
|
|
38
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
39
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
from httpx import AsyncClient, Timeout
|
|
2
|
+
|
|
3
|
+
from ey_commerce_lib.takesend.config import LOGIN_HEADERS, EDIT_HEADERS, LIST_HEADS
|
|
4
|
+
from ey_commerce_lib.takesend.parser.order import get_order_page, get_order_track_number_list
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TakeSendClient(object):
|
|
8
|
+
|
|
9
|
+
def __init__(self, username: str, password: str):
|
|
10
|
+
timeout = Timeout(connect=60.0, read=60.0, write=60.0, pool=30.0)
|
|
11
|
+
self.__async_client = AsyncClient(
|
|
12
|
+
base_url="http://k5.takesend.com:8180",
|
|
13
|
+
timeout=timeout,
|
|
14
|
+
verify=False
|
|
15
|
+
)
|
|
16
|
+
self.__username = username
|
|
17
|
+
self.__password = password
|
|
18
|
+
|
|
19
|
+
async def login(self):
|
|
20
|
+
"""
|
|
21
|
+
自动登录
|
|
22
|
+
:return:
|
|
23
|
+
"""
|
|
24
|
+
# 访问首页
|
|
25
|
+
await self.__async_client.get("/c_index.jsp")
|
|
26
|
+
# 登录
|
|
27
|
+
params = {
|
|
28
|
+
'action': 'logon'
|
|
29
|
+
}
|
|
30
|
+
data = {
|
|
31
|
+
'userid': self.__username,
|
|
32
|
+
'password': self.__password
|
|
33
|
+
}
|
|
34
|
+
# 请求登录接口
|
|
35
|
+
await self.__async_client.post(".//client/Logon", params=params, data=data, headers=LOGIN_HEADERS)
|
|
36
|
+
|
|
37
|
+
async def client_cc_order(self, excel_data: list | str):
|
|
38
|
+
"""
|
|
39
|
+
修改泰嘉产品上传重量数据
|
|
40
|
+
:param excel_data:
|
|
41
|
+
:return:
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
params = {
|
|
45
|
+
'action': 'updateDweight',
|
|
46
|
+
}
|
|
47
|
+
data = {
|
|
48
|
+
'excel[]': excel_data,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
response = await self.__async_client.post('/Client/CCOrder', params=params, data=data, headers=EDIT_HEADERS)
|
|
52
|
+
return response.json()
|
|
53
|
+
|
|
54
|
+
async def client_cc_order_list_by_pre_date(self, pageNum: int, pageSize: int, begeditdate: str, endeditdate: str):
|
|
55
|
+
"""
|
|
56
|
+
泰嘉已预报根据制单日期查询全部订单
|
|
57
|
+
:param pageNum:
|
|
58
|
+
:param pageSize:
|
|
59
|
+
:param begeditdate: 制单日期开始
|
|
60
|
+
:param endeditdate: 制单日期结束
|
|
61
|
+
:return:
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
# 访问首页刷新token
|
|
65
|
+
await self.__async_client.get('/client/Logon?action=initMenu')
|
|
66
|
+
params = {
|
|
67
|
+
'action': 'list',
|
|
68
|
+
}
|
|
69
|
+
data = {
|
|
70
|
+
'flag': '3',
|
|
71
|
+
'pageNum1': '1',
|
|
72
|
+
'numPerPage': '200',
|
|
73
|
+
'orderField': '1',
|
|
74
|
+
'orderDirection': 'asc',
|
|
75
|
+
'corpbillid': '',
|
|
76
|
+
'channelid': '',
|
|
77
|
+
'orgLookup.country': '',
|
|
78
|
+
'orgLookup.chinese': '',
|
|
79
|
+
'printnum': '',
|
|
80
|
+
'ordertype': 'CORDER',
|
|
81
|
+
'buyerid': '',
|
|
82
|
+
'mbflag': '',
|
|
83
|
+
'houseid': '',
|
|
84
|
+
'begeditdate': '2025-10-24 00:00:00',
|
|
85
|
+
'endeditdate': '2025-10-24 23:50:50',
|
|
86
|
+
}
|
|
87
|
+
response = await self.__async_client.post('/Client/CCOrder', params=params, data=data)
|
|
88
|
+
return response.text
|
|
89
|
+
|
|
90
|
+
async def list_track_number_client_cc_order_list_by_pre_date(self, begeditdate: str, endeditdate: str):
|
|
91
|
+
"""
|
|
92
|
+
泰嘉已预报根据制单日期查询全部订单
|
|
93
|
+
:param begeditdate:
|
|
94
|
+
:param endeditdate:
|
|
95
|
+
:return:
|
|
96
|
+
"""
|
|
97
|
+
# 遍历页码
|
|
98
|
+
page_info = get_order_page(
|
|
99
|
+
await self.client_cc_order_list_by_pre_date(pageNum=1, pageSize=200, begeditdate=begeditdate,
|
|
100
|
+
endeditdate=endeditdate))
|
|
101
|
+
total = page_info['total']
|
|
102
|
+
# 计算总页数
|
|
103
|
+
total_page = total // 200 + 1
|
|
104
|
+
track_number_list = []
|
|
105
|
+
for page in range(1, total_page + 1):
|
|
106
|
+
# 获取订单列表
|
|
107
|
+
page_html = await self.client_cc_order_list_by_pre_date(pageNum=page, pageSize=200, begeditdate=begeditdate,
|
|
108
|
+
endeditdate=endeditdate)
|
|
109
|
+
# 解析
|
|
110
|
+
track_number_list.extend(get_order_track_number_list(page_html))
|
|
111
|
+
return track_number_list
|
|
112
|
+
|
|
113
|
+
async def __aenter__(self):
|
|
114
|
+
return self
|
|
115
|
+
|
|
116
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
117
|
+
await self.__async_client.aclose()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from lxml import html
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def get_order_track_number_list(html_str: str):
|
|
5
|
+
tree = html.fromstring(html_str)
|
|
6
|
+
track_number_element_list = tree.xpath('//div[@class="pageContent"]//tbody/tr[@target="sid_serialid"]/td[4]/text()')
|
|
7
|
+
track_number_list = []
|
|
8
|
+
for track_number_element in track_number_element_list:
|
|
9
|
+
track_number = track_number_element.strip()
|
|
10
|
+
if track_number:
|
|
11
|
+
track_number_list.append(track_number)
|
|
12
|
+
return track_number_list
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_order_page(html_str: str):
|
|
16
|
+
tree = html.fromstring(html_str)
|
|
17
|
+
return {
|
|
18
|
+
'total': int(tree.xpath('//div[@class="pagination"]/@totalcount')[0]),
|
|
19
|
+
'page_size': int(tree.xpath('//div[@class="pagination"]/@numperpage')[0])
|
|
20
|
+
}
|
|
@@ -17,6 +17,7 @@ from ey_commerce_lib.four_seller.main import FourSellerClient
|
|
|
17
17
|
from ey_commerce_lib.four_seller.schemas.query.order import FourSellerOrderQueryModel
|
|
18
18
|
from ey_commerce_lib.takesend.main import TakeSendClient
|
|
19
19
|
import ey_commerce_lib.dxm.utils.dxm_commodity_product as dxm_commodity_product_util
|
|
20
|
+
from ey_commerce_lib.takesend.parser.order import get_order_track_number_list
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
async def login_success(user_token: str):
|
|
@@ -27,12 +28,7 @@ async def login_success(user_token: str):
|
|
|
27
28
|
@pytest.mark.asyncio
|
|
28
29
|
async def test_auto_login_4seller():
|
|
29
30
|
# print(user_token)
|
|
30
|
-
|
|
31
|
-
user_name="xxxxx",
|
|
32
|
-
password="xxxxxx",
|
|
33
|
-
login_success_call_back=login_success,
|
|
34
|
-
user_token="xxxxxx") as four_seller_client:
|
|
35
|
-
await four_seller_client.list_history_order(FourSellerOrderQueryModel())
|
|
31
|
+
pass
|
|
36
32
|
|
|
37
33
|
|
|
38
34
|
cookies = {
|
|
@@ -47,33 +43,34 @@ headers = {
|
|
|
47
43
|
@pytest.mark.asyncio
|
|
48
44
|
async def test_dxm_api():
|
|
49
45
|
async with (DxmClient(headers=headers, cookies=cookies) as dxm_client):
|
|
50
|
-
|
|
46
|
+
data = await dxm_client.package_advanced_search_with_detail(query=ORDER_SEARCH_APPROVAL_BASE_FORM)
|
|
47
|
+
print(data.get('code'))
|
|
51
48
|
# for order in data:
|
|
52
49
|
# for pair_info in order.get('detail').get('pair_info_list'):
|
|
53
50
|
# print(pair_info.get('proid'))
|
|
54
51
|
# data = await dxm_client.update_dxm_commodity_front_sku('17773195771232287', 'fuck112')
|
|
55
52
|
# data = await dxm_client.get_authid_like_keyword('泰嘉')
|
|
56
|
-
data = await dxm_client.list_export_template()
|
|
57
|
-
for item in data:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
53
|
+
# data = await dxm_client.list_export_template()
|
|
54
|
+
# for item in data:
|
|
55
|
+
# if item.get('template_name') == '周报订单导出模板':
|
|
56
|
+
# template_json = await dxm_client.export_template_get_by_id_json(id_str=item.get('template_id'))
|
|
57
|
+
# template_id = template_json.get('template').get('id')
|
|
58
|
+
# template_field = template_json.get('template').get('templateField')
|
|
59
|
+
# url = await dxm_client.export_package_order(ExportPackageOrderModel(
|
|
60
|
+
# # 模板id
|
|
61
|
+
# template_id=f'{template_id}',
|
|
62
|
+
# # 导出字段
|
|
63
|
+
# export_keys=urllib.parse.quote(template_field),
|
|
64
|
+
# # 按包裹导出
|
|
65
|
+
# export_type='1',
|
|
66
|
+
# # 发货时间
|
|
67
|
+
# time_type='2',
|
|
68
|
+
# # 已发货
|
|
69
|
+
# state='shipped',
|
|
70
|
+
# start_time='2025-08-06 00:00:00',
|
|
71
|
+
# end_time='2025-08-12 23:59:59'
|
|
72
|
+
# ))
|
|
73
|
+
# print(f'导出成功,url={url}')
|
|
77
74
|
|
|
78
75
|
|
|
79
76
|
@pytest.mark.asyncio
|
|
File without changes
|
|
@@ -1,57 +0,0 @@
|
|
|
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=60.0, read=60.0, write=60.0, pool=30.0)
|
|
10
|
-
self.__async_client = AsyncClient(
|
|
11
|
-
base_url="http://k5.takesend.com:8180",
|
|
12
|
-
timeout=timeout,
|
|
13
|
-
verify=False
|
|
14
|
-
)
|
|
15
|
-
self.__username = username
|
|
16
|
-
self.__password = password
|
|
17
|
-
|
|
18
|
-
async def login(self):
|
|
19
|
-
"""
|
|
20
|
-
自动登录
|
|
21
|
-
:return:
|
|
22
|
-
"""
|
|
23
|
-
# 访问首页
|
|
24
|
-
await self.__async_client.get("/c_index.jsp")
|
|
25
|
-
# 登录
|
|
26
|
-
params = {
|
|
27
|
-
'action': 'logon'
|
|
28
|
-
}
|
|
29
|
-
data = {
|
|
30
|
-
'userid': self.__username,
|
|
31
|
-
'password': self.__password
|
|
32
|
-
}
|
|
33
|
-
# 请求登录接口
|
|
34
|
-
await self.__async_client.post(".//client/Logon", params=params, data=data, headers=LOGIN_HEADERS)
|
|
35
|
-
|
|
36
|
-
async def client_cc_order(self, excel_data: list | str):
|
|
37
|
-
"""
|
|
38
|
-
修改泰嘉产品上传重量数据
|
|
39
|
-
:param excel_data:
|
|
40
|
-
:return:
|
|
41
|
-
"""
|
|
42
|
-
|
|
43
|
-
params = {
|
|
44
|
-
'action': 'updateDweight',
|
|
45
|
-
}
|
|
46
|
-
data = {
|
|
47
|
-
'excel[]': excel_data,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
response = await self.__async_client.post('/Client/CCOrder', params=params, data=data, headers=EDIT_HEADERS)
|
|
51
|
-
return response.json()
|
|
52
|
-
|
|
53
|
-
async def __aenter__(self):
|
|
54
|
-
return self
|
|
55
|
-
|
|
56
|
-
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
57
|
-
await self.__async_client.aclose()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/constant/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/exception/__init__.py
RENAMED
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/exception/common.py
RENAMED
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/ebay_product.py
RENAMED
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/export_template.py
RENAMED
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/purchase.py
RENAMED
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/tracking.py
RENAMED
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/parser/warehouse.py
RENAMED
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/ebay_product.py
RENAMED
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/export_package.py
RENAMED
|
File without changes
|
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/tracking.py
RENAMED
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/dxm/schemas/warehouse.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/parser/__init__.py
RENAMED
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/four_seller/parser/order.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/kogan/schemas/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/kogan/schemas/query/order.py
RENAMED
|
File without changes
|
{ey_commerce_lib-1.0.23 → ey_commerce_lib-1.0.25}/src/ey_commerce_lib/kogan/schemas/query/product.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ey_commerce_lib-1.0.23/tests → ey_commerce_lib-1.0.25/src/ey_commerce_lib/utils}/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|