AutoRpa/rpa_cart/README.md

78 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# rpa_cart
加购与支付回传。两个班次,同一个包。
| 班次 | 状态 |
| --- | --- |
| 加购 `operateType=1` | 未做。选品已落表 2 |
| 支付回传 `operateType=2` | **1 号药城已做落表**。不推接口 2 |
## 1 号药城支付落表
从买家中心导出已付订单,按导出行字段写入表 2 `operate_type=2`。不对加购行。购物车和支付单没有强关联,`oms_id` 表上 NOT NULL,先填 `0`,等人后选。
```bash
cd rpa_cart
uv sync --python 3.12
# 账号用 rpa_selection/.env 的 YAOEX_*,库用 RPA_ORACLE_*
uv run python main.py
uv run python main.py --dry-run --xls /tmp/yaoex_order_export/orders.xls
uv run python main.py --days 0 # 仅当天(默认)
uv run python main.py --day 2026-09-30 --days 0
```
过滤:只落 待发货 / 待收货 / 已完成。单价用折后单价,总价 `round(折后单价×数量, 4)`。`pay_order_no` 用商城订单号,`pay_order_dtl_id` 用详情接口 `orderDetailId`。
幂等:同一 `pay_order_no + pay_order_dtl_id` 不重复插入。细单号拉不到的留下,不猜。
```bash
uv run pytest -v
```
## Windows 真库
Mac 打不到 `192.168.12.244`,**插入表 2 在 Windows 上测**。导出/解析在 Mac 已经跑过,Win 上要测的是登录、详情、落表。
Python 3.12 + Instant Client(位数一致)+ Chrome。密码不要写进仓库。把本包和 `rpa_selection/.env` 一起带过去。
PowerShell:
```powershell
cd rpa_cart
uv sync --python 3.12
uv run playwright install chrome
$env:RPA_ORACLE_HOST = "192.168.12.244"
$env:RPA_ORACLE_PORT = "1521"
$env:RPA_ORACLE_SERVICE = "rpa"
$env:RPA_ORACLE_USER = "rpainit"
$env:RPA_ORACLE_PASSWORD = "这里填密码"
$env:RPA_ORACLE_THICK = "1"
$env:RPA_ORACLE_CLIENT_LIB = "C:\oracle\instantclient"
uv run pytest -v
# 国庆当天可能没单,用 9-30 有数
uv run python main.py --dry-run --day 2026-09-30 --days 0
uv run python main.py --day 2026-09-30 --days 0
```
看控制台 `inserted / unmatched`。细单号拉不到是 `NO_DTL_ID`。
查库:
```sql
SELECT operate_type, oms_id, platform_type, supplier_name, bar_code,
purchase_price, purchase_qty, purchase_total,
pay_order_no, pay_order_dtl_id, push_status
FROM rpa_cart_settlement_goods_data
WHERE operate_type = 2 AND platform_type = 66
ORDER BY fid DESC;
```
再跑一遍同一天,`skipped_dup` 应上升,行数不再增加。
不要在页面点「确认收货」。脚本自己导出,过滤待发货/待收货/已完成。
## 本期不做
真加购、清空购物车、药帮忙支付、接口 2 推送。