ey-commerce-lib 1.0.2__tar.gz → 1.0.4__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.2 → ey_commerce_lib-1.0.4}/PKG-INFO +1 -1
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/pyproject.toml +1 -1
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/main.py +152 -4
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/parser/common.py +21 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/parser/order.py +2 -2
- ey_commerce_lib-1.0.4/src/ey_commerce_lib/dxm/parser/purchase.py +122 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/schemas/warehouse.py +6 -2
- ey_commerce_lib-1.0.4/tests/dxm/test_purchase.py +0 -0
- ey_commerce_lib-1.0.2/src/ey_commerce_lib/dxm/parser/purchase.py +0 -40
- ey_commerce_lib-1.0.2/tests/dxm/test_order.py +0 -55
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/.gitignore +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/.python-version +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/README.md +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/pytest.ini +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/__init__.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/__init__.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/constant/__init__.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/constant/order.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/exception/__init__.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/exception/common.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/order.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/parser/__init__.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/parser/warehouse.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/schemas/__init__.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/schemas/common.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/schemas/order.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/py.typed +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/utils/__init__.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/utils/dxm.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/utils/list_util.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/utils/str.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/tests/__init__.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/tests/dxm/__init__.py +0 -0
- {ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/uv.lock +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
|
|
3
3
|
from ey_commerce_lib.dxm.constant.order import DxmOrderRuleType
|
|
4
|
-
from ey_commerce_lib.dxm.parser.common import get_page_info
|
|
4
|
+
from ey_commerce_lib.dxm.parser.common import get_page_info, get_purchase_pagination_info
|
|
5
5
|
from ey_commerce_lib.dxm.parser.order import list_order_base_by_html, list_order_rule, get_rule_detail, \
|
|
6
6
|
get_order_detail_by_html
|
|
7
|
-
from ey_commerce_lib.dxm.parser.purchase import list_purchasing_all
|
|
7
|
+
from ey_commerce_lib.dxm.parser.purchase import list_purchasing_all, list_1688_purchase_order_number, \
|
|
8
|
+
list_wait_pay_page_purchase_order_number
|
|
8
9
|
from ey_commerce_lib.dxm.parser.warehouse import list_warehouse_product
|
|
9
10
|
from ey_commerce_lib.dxm.schemas.common import Page
|
|
10
11
|
from ey_commerce_lib.dxm.schemas.order import DxmOrderSearchForm, DxmJsonResponse, DxmCheckProcessResponse, DxmOrderRule
|
|
@@ -380,14 +381,161 @@ class DxmClient:
|
|
|
380
381
|
|
|
381
382
|
async def page_purchasing_all(self, query: PurchasingAllQuery):
|
|
382
383
|
"""
|
|
383
|
-
|
|
384
|
+
分页查询采购单全部
|
|
384
385
|
:return:
|
|
385
386
|
"""
|
|
386
387
|
async with self.__sem:
|
|
387
388
|
page_purchasing_all_pageList_res = await self.__async_client.post(
|
|
388
389
|
"/dxmPurchasingNote/purchasingAllPageList.htm",
|
|
389
390
|
data=query.model_dump(by_alias=True))
|
|
390
|
-
|
|
391
|
+
page_info = get_purchase_pagination_info(page_purchasing_all_pageList_res.text)
|
|
392
|
+
return {
|
|
393
|
+
**page_info,
|
|
394
|
+
'data': list_purchasing_all(page_purchasing_all_pageList_res.text)
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
async def list_purchasing_all(self, query: PurchasingAllQuery):
|
|
398
|
+
"""
|
|
399
|
+
查询采购单全部列表
|
|
400
|
+
:param query:
|
|
401
|
+
:return:
|
|
402
|
+
"""
|
|
403
|
+
query.page_no = 1
|
|
404
|
+
data = await self.page_purchasing_all(query)
|
|
405
|
+
total_page = data['total_page']
|
|
406
|
+
result = data['data']
|
|
407
|
+
for page_number in range(2, total_page + 1):
|
|
408
|
+
query.page_no = page_number
|
|
409
|
+
data = await self.page_purchasing_all(query)
|
|
410
|
+
result.extend(data['data'])
|
|
411
|
+
return result
|
|
412
|
+
|
|
413
|
+
async def wait_pay_page_list(self, data: dict):
|
|
414
|
+
"""
|
|
415
|
+
采购分页
|
|
416
|
+
:return:
|
|
417
|
+
"""
|
|
418
|
+
async with self.__sem:
|
|
419
|
+
page_purchasing_all_pageList_res = await self.__async_client.post(
|
|
420
|
+
"/dxmPurchasingNote/waitPayPageList.htm",
|
|
421
|
+
data=data)
|
|
422
|
+
page_info = get_page_info(page_purchasing_all_pageList_res.text)
|
|
423
|
+
purchase_order_number_list = list_wait_pay_page_purchase_order_number(page_purchasing_all_pageList_res.text)
|
|
424
|
+
# 200个200个一批进行处理
|
|
425
|
+
page_data = list()
|
|
426
|
+
for i in range(0, len(purchase_order_number_list), 200):
|
|
427
|
+
search_value = ','.join(purchase_order_number_list[i:i + 200])
|
|
428
|
+
data = await self.list_purchasing_all(PurchasingAllQuery(search_value=search_value
|
|
429
|
+
, search_type=0))
|
|
430
|
+
page_data.extend(data)
|
|
431
|
+
return {
|
|
432
|
+
**page_info,
|
|
433
|
+
'data': page_data
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
async def wait_pay_list(self, data: dict):
|
|
437
|
+
"""
|
|
438
|
+
采购订单其它查询列表
|
|
439
|
+
:param data:
|
|
440
|
+
:return:
|
|
441
|
+
"""
|
|
442
|
+
async with self.__sem:
|
|
443
|
+
data['pageNo'] = 1
|
|
444
|
+
wait_pay_page_list_res = await self.wait_pay_page_list(data)
|
|
445
|
+
total_page = wait_pay_page_list_res['total_page']
|
|
446
|
+
result = wait_pay_page_list_res['data']
|
|
447
|
+
for page_number in range(2, total_page + 1):
|
|
448
|
+
data['pageNo'] = page_number
|
|
449
|
+
wait_pay_page_list_res = await self.wait_pay_page_list(data)
|
|
450
|
+
result.extend(wait_pay_page_list_res['data'])
|
|
451
|
+
return result
|
|
452
|
+
|
|
453
|
+
async def wait_pay_alibaba_page_list(self, data: dict):
|
|
454
|
+
"""
|
|
455
|
+
采购订单1688采购分页
|
|
456
|
+
:return:
|
|
457
|
+
"""
|
|
458
|
+
wait_pay_alibaba_page_list_res = await self.__async_client.post('/dxmPurchasingNote/waitPayAliBabaPageList.htm',
|
|
459
|
+
data=data)
|
|
460
|
+
page_info = get_page_info(wait_pay_alibaba_page_list_res.text)
|
|
461
|
+
purchase_order_number_list = list_1688_purchase_order_number(wait_pay_alibaba_page_list_res.text)
|
|
462
|
+
# 分页数据
|
|
463
|
+
page_data = list()
|
|
464
|
+
# 200个一批进行搜索
|
|
465
|
+
for i in range(0, len(purchase_order_number_list), 200):
|
|
466
|
+
search_value = ','.join(purchase_order_number_list[i:i + 200])
|
|
467
|
+
data = await self.list_purchasing_all(PurchasingAllQuery(search_value=search_value
|
|
468
|
+
, search_type=0))
|
|
469
|
+
page_data.extend(data)
|
|
470
|
+
return {
|
|
471
|
+
**page_info,
|
|
472
|
+
'data': page_data
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
async def wait_pay_alibaba_list(self, data: dict):
|
|
476
|
+
"""
|
|
477
|
+
采购订单1688采购列表
|
|
478
|
+
:param data:
|
|
479
|
+
:return:
|
|
480
|
+
"""
|
|
481
|
+
data['pageNo'] = 1
|
|
482
|
+
wait_pay_alibaba_page_list_res = await self.wait_pay_alibaba_page_list(data)
|
|
483
|
+
total_page = wait_pay_alibaba_page_list_res['total_page']
|
|
484
|
+
result = wait_pay_alibaba_page_list_res['data']
|
|
485
|
+
for page_number in range(2, total_page + 1):
|
|
486
|
+
data['pageNo'] = page_number
|
|
487
|
+
wait_pay_alibaba_page_list_res = await self.wait_pay_alibaba_page_list(data)
|
|
488
|
+
result.extend(wait_pay_alibaba_page_list_res['data'])
|
|
489
|
+
return result
|
|
490
|
+
|
|
491
|
+
async def __sync_alibaba_order(self):
|
|
492
|
+
"""
|
|
493
|
+
采购全部同步订单
|
|
494
|
+
:return:
|
|
495
|
+
"""
|
|
496
|
+
async with self.__sem:
|
|
497
|
+
sync_alibaba_order_response = await self.__async_client.post("/dxmPurchasingNote/syncAliBabaOrder.json")
|
|
498
|
+
return sync_alibaba_order_response.json()
|
|
499
|
+
|
|
500
|
+
async def sync_alibaba_order(self):
|
|
501
|
+
"""
|
|
502
|
+
同步采购全部订单
|
|
503
|
+
:return:
|
|
504
|
+
"""
|
|
505
|
+
sync_alibaba_order_data = await self.__sync_alibaba_order()
|
|
506
|
+
process_uuid = sync_alibaba_order_data.get('uuid')
|
|
507
|
+
while True:
|
|
508
|
+
# 查询同步进度
|
|
509
|
+
check_process_res = await self.__check_process(process_uuid)
|
|
510
|
+
process_code = check_process_res.get('processMsg').get('code')
|
|
511
|
+
if process_code:
|
|
512
|
+
# 同步完成结束监测
|
|
513
|
+
break
|
|
514
|
+
await asyncio.sleep(1)
|
|
515
|
+
|
|
516
|
+
async def validate_price(self, ids: str):
|
|
517
|
+
"""
|
|
518
|
+
采购单提交审核
|
|
519
|
+
:param ids: purchase_id 多个,分隔
|
|
520
|
+
:return:
|
|
521
|
+
"""
|
|
522
|
+
validate_price_res = await self.__async_client.post("/dxmPurchasingNote/validatePrice.json", data={
|
|
523
|
+
'ids': ids
|
|
524
|
+
})
|
|
525
|
+
return validate_price_res
|
|
526
|
+
|
|
527
|
+
async def wait_pay_pay_money(self, purchase_id: str):
|
|
528
|
+
"""
|
|
529
|
+
采购订单支付(通过审核)
|
|
530
|
+
:param purchase_id:
|
|
531
|
+
:return:
|
|
532
|
+
"""
|
|
533
|
+
async with self.__sem:
|
|
534
|
+
wait_pay_pay_money_res = await self.__async_client.post("/dxmPurchasingNote/waitPayPayMoney.json", data={
|
|
535
|
+
'id': purchase_id,
|
|
536
|
+
'auditResult': '1',
|
|
537
|
+
})
|
|
538
|
+
return wait_pay_pay_money_res.json()
|
|
391
539
|
|
|
392
540
|
async def __aenter__(self):
|
|
393
541
|
return self
|
|
@@ -52,6 +52,27 @@ def __parse_js_vals(js_snippet: str) -> dict[str, int]:
|
|
|
52
52
|
return {key: int(value) for key, value in matches}
|
|
53
53
|
|
|
54
54
|
|
|
55
|
+
def get_purchase_pagination_info(script: str) -> dict:
|
|
56
|
+
# 定义要提取的字段及其对应的 key 名
|
|
57
|
+
field_map = {
|
|
58
|
+
'pageNo': 'page_number',
|
|
59
|
+
'pageSize': 'page_size',
|
|
60
|
+
'totalSize': 'total_size',
|
|
61
|
+
'totalPage': 'total_page',
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
result = {}
|
|
65
|
+
|
|
66
|
+
for field, key in field_map.items():
|
|
67
|
+
pattern = rf"\$\('#{field}'\)\.val\('(\d+)'\);"
|
|
68
|
+
match = re.search(pattern, script)
|
|
69
|
+
if not match:
|
|
70
|
+
raise ValueError(f"无法从字符串中提取字段:{field}")
|
|
71
|
+
result[key] = int(match.group(1))
|
|
72
|
+
|
|
73
|
+
return result
|
|
74
|
+
|
|
75
|
+
|
|
55
76
|
def get_purchasing_page_info(html_str: str):
|
|
56
77
|
"""
|
|
57
78
|
获取分页信息和分页数据(店小秘->采购部分)
|
|
@@ -165,9 +165,9 @@ def list_order_base_by_html(html_str: str) -> list[dict]:
|
|
|
165
165
|
logistics_info['logistics'] = logistics
|
|
166
166
|
# 状态
|
|
167
167
|
if has_logistics:
|
|
168
|
-
status = order_first_element.xpath('.//td[7]/text()')
|
|
168
|
+
status = get_str_list_first_not_blank_or_none(order_first_element.xpath('.//td[7]/text()'))
|
|
169
169
|
else:
|
|
170
|
-
status = order_first_element.xpath('.//td[6]/text()')
|
|
170
|
+
status = get_str_list_first_not_blank_or_none(order_first_element.xpath('.//td[6]/text()'))
|
|
171
171
|
# 整理订单
|
|
172
172
|
if len(order_element_list) > 1:
|
|
173
173
|
# 合并单
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import lxml.html
|
|
2
|
+
from lxml import html
|
|
3
|
+
|
|
4
|
+
from ey_commerce_lib.utils.list_util import get_str_list_first_not_blank_or_none
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def list_1688_purchase_order_number(html_str: str) -> list[str]:
|
|
8
|
+
"""
|
|
9
|
+
根据1688采购页面html获取1688采购页面采购单号列表
|
|
10
|
+
:param html_str:
|
|
11
|
+
:return:
|
|
12
|
+
"""
|
|
13
|
+
tree = html.fromstring(html_str)
|
|
14
|
+
good_element_list: list[html.HtmlElement] = tree.xpath('//tr[contains(@class, "goodsId")]')
|
|
15
|
+
purchase_order_number_list = list()
|
|
16
|
+
for good_element in good_element_list:
|
|
17
|
+
purchase_order_number_list.append(get_str_list_first_not_blank_or_none(
|
|
18
|
+
good_element.xpath('.//span[@class="limingcentUrlpic"]/text()')))
|
|
19
|
+
return purchase_order_number_list
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def list_wait_pay_page_purchase_order_number(html_str: str) -> list[str]:
|
|
23
|
+
"""
|
|
24
|
+
根据采购wait_pay_pag这个请求返回html代码获取采购单号列表
|
|
25
|
+
:param html_str:
|
|
26
|
+
:return:
|
|
27
|
+
"""
|
|
28
|
+
tree = html.fromstring(html_str)
|
|
29
|
+
good_element_list: list[html.HtmlElement] = tree.xpath('//tr[contains(@class, "goodsId")]')
|
|
30
|
+
purchase_order_number_list = list()
|
|
31
|
+
for good_element in good_element_list:
|
|
32
|
+
purchase_order_number = get_str_list_first_not_blank_or_none(
|
|
33
|
+
good_element.xpath('.//a[@class="limingcentUrlpic"]/text()'))
|
|
34
|
+
purchase_order_number_list.append(purchase_order_number)
|
|
35
|
+
return purchase_order_number_list
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def list_purchasing_all(html_str: str) -> list[dict]:
|
|
39
|
+
"""
|
|
40
|
+
根据采购全部页面html,获取采购页面详细数据列表
|
|
41
|
+
:param html_str:
|
|
42
|
+
:return:
|
|
43
|
+
"""
|
|
44
|
+
tree = html.fromstring(html_str)
|
|
45
|
+
good_element_list: list[html.HtmlElement] = tree.xpath('//tr[contains(@class, "goodsId")]')
|
|
46
|
+
purchase_result = list()
|
|
47
|
+
for good_element in good_element_list:
|
|
48
|
+
purchase_id = get_str_list_first_not_blank_or_none(good_element.xpath('@id'))
|
|
49
|
+
purchase_order_number = get_str_list_first_not_blank_or_none(
|
|
50
|
+
good_element.xpath('.//a[@class="limingcentUrlpic"]/text()'))
|
|
51
|
+
ghs_id = get_str_list_first_not_blank_or_none(
|
|
52
|
+
good_element.xpath('.//span[contains(@class, "ghsHoverPrompt")]/@data-ghsid'))
|
|
53
|
+
ghs_name = get_str_list_first_not_blank_or_none(
|
|
54
|
+
good_element.xpath('.//span[contains(@class, "ghsHoverPrompt")]/span/text()'))
|
|
55
|
+
warehouse_name, purchase_info = good_element.xpath('.//td[4]/span/text()')[0].strip().split('|')
|
|
56
|
+
agent_name = purchase_info.split(':')[1]
|
|
57
|
+
# 获取兄弟元素
|
|
58
|
+
content_element = good_element.getnext()
|
|
59
|
+
# 获取商品信息
|
|
60
|
+
img = get_str_list_first_not_blank_or_none(content_element.xpath('.//img/@data-original'))
|
|
61
|
+
content_number_info = content_element.xpath('./td[2]/text()')
|
|
62
|
+
product_zl_number = None
|
|
63
|
+
purchase_number = None
|
|
64
|
+
for content_number in content_number_info:
|
|
65
|
+
content_number = content_number.strip()
|
|
66
|
+
if content_number.split(':')[0] == '商品种类':
|
|
67
|
+
product_zl_number = content_number.split(':')[1].strip()
|
|
68
|
+
elif content_number.split(':')[0] == '采购数量':
|
|
69
|
+
purchase_number = content_number.split(':')[1].strip()
|
|
70
|
+
# 解析出货款
|
|
71
|
+
total_amount = get_str_list_first_not_blank_or_none(content_element.xpath('./td[3]//input/@data-totalamount'))
|
|
72
|
+
# 运费
|
|
73
|
+
shipping_amount = get_str_list_first_not_blank_or_none(content_element.xpath('./td[3]//input/@value'))
|
|
74
|
+
source = None
|
|
75
|
+
source_list = content_element.xpath('./td[4]/span[1]')
|
|
76
|
+
if len(source_list) == 0:
|
|
77
|
+
# 说明不是淘供销
|
|
78
|
+
source_list = content_element.xpath('./td[4]/div[1]')
|
|
79
|
+
|
|
80
|
+
if len(source_list) > 0:
|
|
81
|
+
try:
|
|
82
|
+
source = source_list[0].text_content()
|
|
83
|
+
source = source.strip()
|
|
84
|
+
platform, source_str = source.split(":")
|
|
85
|
+
source = platform.strip() + ":" + source_str.strip()
|
|
86
|
+
except:
|
|
87
|
+
source = None
|
|
88
|
+
# 获取物流信息
|
|
89
|
+
track_element_list = content_element.xpath('./td[4]//a[@class="getLogisticsMsgBox"]')
|
|
90
|
+
track_list = list()
|
|
91
|
+
for track_element in track_element_list:
|
|
92
|
+
tracking_id = get_str_list_first_not_blank_or_none(track_element.xpath("@trackingid"))
|
|
93
|
+
tracking_number = get_str_list_first_not_blank_or_none(track_element.xpath("@data-trackingnumber"))
|
|
94
|
+
tracking_code = get_str_list_first_not_blank_or_none(track_element.xpath("@data-trackingcode"))
|
|
95
|
+
track_status = get_str_list_first_not_blank_or_none(
|
|
96
|
+
track_element.xpath('./span[contains(@class, "iconfont")]/@data-original-title'))
|
|
97
|
+
track_list.append({
|
|
98
|
+
"tracking_id": tracking_id,
|
|
99
|
+
"tracking_number": tracking_number,
|
|
100
|
+
"tracking_code": tracking_code,
|
|
101
|
+
"track_status": track_status
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
# 状态
|
|
105
|
+
status = get_str_list_first_not_blank_or_none(content_element.xpath('./td[6]/div[@class="mBottom3"]/text()'))
|
|
106
|
+
purchase_result.append({
|
|
107
|
+
"purchase_id": purchase_id,
|
|
108
|
+
"purchase_order_number": purchase_order_number,
|
|
109
|
+
"ghs_id": ghs_id,
|
|
110
|
+
"ghs_name": ghs_name,
|
|
111
|
+
"agent_name": agent_name,
|
|
112
|
+
"img": img,
|
|
113
|
+
"product_zl_number": product_zl_number,
|
|
114
|
+
"purchase_number": purchase_number,
|
|
115
|
+
"total_amount": total_amount,
|
|
116
|
+
"shipping_amount": shipping_amount,
|
|
117
|
+
"source": source,
|
|
118
|
+
"status": status,
|
|
119
|
+
'track_list': track_list
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
return purchase_result
|
{ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/schemas/warehouse.py
RENAMED
|
@@ -105,6 +105,7 @@ class PurchasingAllQuery(BaseModel):
|
|
|
105
105
|
comment_colors: str = ''
|
|
106
106
|
# 仓库id
|
|
107
107
|
warehouse_id: str = ''
|
|
108
|
+
|
|
108
109
|
# 店铺id(或者1688账号)
|
|
109
110
|
authorization_id: str = ''
|
|
110
111
|
# 排序方式: 1(按创建时间) 2(按更新时间) 4(按照采购单号)5(按照供货商名)
|
|
@@ -157,5 +158,8 @@ class PurchasingAllQuery(BaseModel):
|
|
|
157
158
|
|
|
158
159
|
model_config = ConfigDict(
|
|
159
160
|
alias_generator=to_camel,
|
|
160
|
-
populate_by_name=True
|
|
161
|
-
)
|
|
161
|
+
populate_by_name=True
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
File without changes
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
from lxml import html
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def list_purchasing_all(html_str: str):
|
|
5
|
-
tree = html.fromstring(html_str)
|
|
6
|
-
good_element_list: list[html.HtmlElement] = tree.xpath('//tr[contains(@class, "goodsId")]')
|
|
7
|
-
for good_element in good_element_list:
|
|
8
|
-
purchase_id = good_element.xpath('@id')[0]
|
|
9
|
-
purchase_order_number = good_element.xpath('.//a[@class="limingcentUrlpic"]/text()')[0]
|
|
10
|
-
ghs_id = good_element.xpath('.//span[contains(@class, "ghsHoverPrompt")]/@data-ghsid')[0]
|
|
11
|
-
ghs_name = good_element.xpath('.//span[contains(@class, "ghsHoverPrompt")]/span/text()')[0].strip()
|
|
12
|
-
warehouse_name, purchase_info = good_element.xpath('.//td[4]/span/text()')[0].strip().split('|')
|
|
13
|
-
# 采购员
|
|
14
|
-
agent_name = purchase_info.split(':')[1]
|
|
15
|
-
#print(purchase_order_number, ghs_id, ghs_name, warehouse_name, agent_name)
|
|
16
|
-
# 获取兄弟元素
|
|
17
|
-
content_element = good_element.getnext()
|
|
18
|
-
# 获取商品信息
|
|
19
|
-
img = content_element.xpath('.//img/@data-original')[0]
|
|
20
|
-
content_number_info = content_element.xpath('./td[2]/text()')
|
|
21
|
-
product_zl_number = None
|
|
22
|
-
purchase_number = None
|
|
23
|
-
for content_number in content_number_info:
|
|
24
|
-
content_number = content_number.strip()
|
|
25
|
-
if content_number.split(':')[0] == '商品种类':
|
|
26
|
-
product_zl_number = content_number.split(':')[1].strip()
|
|
27
|
-
elif content_number.split(':')[0] == '采购数量':
|
|
28
|
-
purchase_number = content_number.split(':')[1].strip()
|
|
29
|
-
# 解析出货款
|
|
30
|
-
total_amount = content_element.xpath('./td[3]//input/@data-totalamount')[0]
|
|
31
|
-
# 运费
|
|
32
|
-
shipping_amount = content_element.xpath('./td[3]//input/@value')[0]
|
|
33
|
-
platform_list = content_element.xpath('./td[4]/div/span')
|
|
34
|
-
if len(platform_list) > 0:
|
|
35
|
-
source = platform_list[0].text.strip()
|
|
36
|
-
else:
|
|
37
|
-
source = content_element.xpath('./td[4]/span/span/text()')[0].strip()
|
|
38
|
-
source2 = content_element.xpath('./td[4]/span/span[@class="alibabaPurchaseOrder"]/text()')[0].strip()
|
|
39
|
-
source = source + source2
|
|
40
|
-
print(source)
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
from ey_commerce_lib.dxm.constant.order import ORDER_SEARCH_APPROVAL_BASE_FORM, \
|
|
6
|
-
ORDER_SEARCH_PENDING_PROCESSING_BASE_FORM, ORDER_SEARCH_SELF_WAREHOUSE_BASE_FORM, \
|
|
7
|
-
ORDER_SEARCH_OVERSEA_WAREHOUSE_BASE_FORM, ORDER_SEARCH_HAVE_GOODS_BASE_FORM, ORDER_SEARCH_OUT_OF_STOCK_BASE_FORM, \
|
|
8
|
-
ORDER_SEARCH_DELIVERY_FAILURE_BASE_FORM, ORDER_SEARCH_DELIVERY_SUCCESS_BASE_FORM, DxmOrderRuleType
|
|
9
|
-
from ey_commerce_lib.dxm.main import DxmClient
|
|
10
|
-
from ey_commerce_lib.dxm.schemas.order import DxmOrderSearchForm
|
|
11
|
-
from ey_commerce_lib.dxm.schemas.warehouse import WarehouseProductQuery, PurchasingAllQuery
|
|
12
|
-
|
|
13
|
-
cookies = {
|
|
14
|
-
'dxm_i': 'MTAyNzg5NiFhVDB4TURJM09EazIhZjc5ZTMxMjZmN2Q3NTk5OGZlMDg4YjQzNzNlNzlmOWY',
|
|
15
|
-
'dxm_t': 'MTcxNDk2NDU4MiFkRDB4TnpFME9UWTBOVGd5IWIzZWRjYTc3YTdjYWE0MmIxMWYwNjFhOTlmMDgxZjY5',
|
|
16
|
-
'dxm_c': 'TWVOMVpiclYhWXoxTlpVNHhXbUp5VmchNmM5MmM5ODc1MDBkODVjOWJmOTFlMzdhNGJiNWI3Njk',
|
|
17
|
-
'dxm_w': 'ZDc3NWVhOTdkOTEyNGE4ZmRkODBmYzc2YmFlOGVjZjEhZHoxa056YzFaV0U1TjJRNU1USTBZVGhtWkdRNE1HWmpOelppWVdVNFpXTm1NUSFmZWZiZGZiMTEwMzhlN2M4M2MzYjZmYjAxYTcxMjViMw',
|
|
18
|
-
'dxm_s': 'aMHO7LWKAQe6NzFrV3O4cceXkBriLGNmwondOR7INWs',
|
|
19
|
-
'MYJ_MKTG_fapsc5t4tc': 'JTdCJTdE',
|
|
20
|
-
'MYJ_fapsc5t4tc': 'JTdCJTIyZGV2aWNlSWQlMjIlM0ElMjJkMGRlYzNkYi00MTNlLTQyZjktOWIxNC0xYzBhZTY4MTk4ZmIlMjIlMkMlMjJ1c2VySWQlMjIlM0ElMjIxMDI3ODk2JTIyJTJDJTIycGFyZW50SWQlMjIlM0ElMjIyNTg2MzQlMjIlMkMlMjJzZXNzaW9uSWQlMjIlM0ExNzMxMDU5MDc1MjU0JTJDJTIyb3B0T3V0JTIyJTNBZmFsc2UlMkMlMjJsYXN0RXZlbnRUaW1lJTIyJTNBMTczMTA1OTA3NTQyNCUyQyUyMmxhc3RFdmVudElkJTIyJTNBMTE2JTdE',
|
|
21
|
-
'MYJ_fapsc5t4tc': 'JTdCJTIyZGV2aWNlSWQlMjIlM0ElMjJkMGRlYzNkYi00MTNlLTQyZjktOWIxNC0xYzBhZTY4MTk4ZmIlMjIlMkMlMjJ1c2VySWQlMjIlM0ElMjIxMDI3ODk2JTIyJTJDJTIycGFyZW50SWQlMjIlM0ElMjIyNTg2MzQlMjIlMkMlMjJzZXNzaW9uSWQlMjIlM0ExNzMxMDU5MDc1MTEwJTJDJTIyb3B0T3V0JTIyJTNBZmFsc2UlMkMlMjJsYXN0RXZlbnRUaW1lJTIyJTNBMTczMTA1OTA3NTk5NiUyQyUyMmxhc3RFdmVudElkJTIyJTNBMTE2JTdE',
|
|
22
|
-
'_dxm_ad_client_id': '7AEFA0B78CE1B35075D391C5226612CED',
|
|
23
|
-
'Hm_lvt_f8001a3f3d9bf5923f780580eb550c0b': '1731459796,1731547149,1731590878,1731893161',
|
|
24
|
-
'HMACCOUNT': 'F266E8F609D8D8B1',
|
|
25
|
-
'MYJ_fapsc5t4tc': 'JTdCJTIyZGV2aWNlSWQlMjIlM0ElMjJkMGRlYzNkYi00MTNlLTQyZjktOWIxNC0xYzBhZTY4MTk4ZmIlMjIlMkMlMjJ1c2VySWQlMjIlM0ElMjIxMDI3ODk2JTIyJTJDJTIycGFyZW50SWQlMjIlM0ElMjIyNTg2MzQlMjIlMkMlMjJzZXNzaW9uSWQlMjIlM0ExNzMxOTAxNDMzMTk3JTJDJTIyb3B0T3V0JTIyJTNBZmFsc2UlMkMlMjJsYXN0RXZlbnRJZCUyMiUzQTExNiU3RA==',
|
|
26
|
-
'Hm_lpvt_f8001a3f3d9bf5923f780580eb550c0b': '1731901433',
|
|
27
|
-
'JSESSIONID': 'CD9C8372185D453012E5EEFBA64E2C9C',
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
headers = {
|
|
31
|
-
'accept': 'text/html, */*; q=0.01',
|
|
32
|
-
'accept-language': 'zh-CN,zh;q=0.9',
|
|
33
|
-
'cache-control': 'no-cache',
|
|
34
|
-
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
35
|
-
'origin': 'https://www.dianxiaomi.com',
|
|
36
|
-
'pragma': 'no-cache',
|
|
37
|
-
'priority': 'u=1, i',
|
|
38
|
-
'referer': 'https://www.dianxiaomi.com/sys/index.htm?go=m420',
|
|
39
|
-
'sec-ch-ua': '"Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
|
|
40
|
-
'sec-ch-ua-mobile': '?0',
|
|
41
|
-
'sec-ch-ua-platform': '"Windows"',
|
|
42
|
-
'sec-fetch-dest': 'empty',
|
|
43
|
-
'sec-fetch-mode': 'cors',
|
|
44
|
-
'sec-fetch-site': 'same-origin',
|
|
45
|
-
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
|
|
46
|
-
'x-requested-with': 'XMLHttpRequest',
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# XM7WJA451012,XM7WJA451092,XM7WJA451089
|
|
51
|
-
@pytest.mark.asyncio
|
|
52
|
-
async def test_order():
|
|
53
|
-
async with DxmClient(cookies=cookies, headers=headers) as dxm:
|
|
54
|
-
print(await dxm.list_rule(DxmOrderRuleType.LOGISTICS))
|
|
55
|
-
# print(await dxm.get_warehouse_dict())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/constant/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{ey_commerce_lib-1.0.2 → ey_commerce_lib-1.0.4}/src/ey_commerce_lib/dxm/exception/__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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|