Metadata-Version: 2.4
Name: py-easy-chanjet
Version: 2.0.1
Summary: 畅捷通 T+ Python SDK，提供简单易用的畅捷通 T+ 系统交互功能，支持中科华博等模块的操作。
Home-page: https://gitee.com/guolei19850528/py_easy_chanjet
Author: guolei
Author-email: 174000902@qq.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx
Requires-Dist: xmltodict
Requires-Dist: arrow
Requires-Dist: jsonschema
Requires-Dist: jsonpath-ng
Requires-Dist: py-easy-httpx
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# py_easy_chanjet

畅捷通 T+ Python SDK，提供简单易用的畅捷通 T+ 系统交互功能，支持中科华博等模块的操作。

## 功能特性

- **中科华博**：支持验证支付金额是否足够覆盖指定日期范围内的费用
- **SQL 语句生成**：提供查询实际支付项目的 SQL 语句格式化功能
- **WebService 交互**：支持调用畅捷通 T+ 系统的 WebService 接口
- **同步/异步支持**：同时支持同步和异步操作
- **灵活配置**：支持通过参数自定义客户端行为
- **响应处理**：提供 XML 与字典之间的转换功能
- **类型提示**：完整的类型注解，提供良好的 IDE 支持

## 安装

### 使用 pip 安装

```bash
pip install py_easy_chanjet
```

### 从源码安装

```bash
git clone https://gitee.com/guolei19850528/py_easy_chanjet.git
cd py_easy_chanjet
pip install -e .
```

## 依赖

- arrow
- httpx
- xmltodict
- py_easy_httpx

## 快速开始

### 验证支付金额

```python
from py_easy_chanjet.tplus.zkhb import payment_date_range_validator

# 验证支付金额是否足够
is_valid = payment_date_range_validator(
    payment_daily_fee=100,  # 每日费用
    payment_total_amount=700,  # 实际支付金额
    payment_date_start="2024-01-01",  # 开始日期
    payment_date_end="2024-01-07"  # 结束日期
)
print(f"支付金额是否足够: {is_valid}")
```

### 生成 SQL 查询语句

```python
from py_easy_chanjet.tplus.zkhb import query_actual_payment_items_sql_formatter

# 生成查询实际支付项目的 SQL 语句
sql = query_actual_payment_items_sql_formatter(
    conditions=" and cml.EstateID = '123'",  # 查询条件
    order_by="order by cml.ChargeTime desc"  # 排序方式
)
print(f"生成的 SQL 语句: {sql}")
```

### 调用 WebService 接口

```python
from py_easy_chanjet.tplus.zkhb import WebService

# 初始化 WebService 客户端
web_service = WebService(base_url="http://example.com")

# 调用 GetDataSet 方法获取数据
data = {
    "sql": "select * from ChargeMasterList where ChargeMListID = '123'",
    "estateID": "123"
}
response = web_service.get_data_set(data=data)
print(f"WebService 响应: {response}")
```

## API 文档

### 函数

#### `payment_date_range_validator(payment_daily_fee, payment_total_amount, payment_date_start, payment_date_start_tz, payment_date_end, payment_date_end_tz)`
验证支付金额是否足够覆盖指定日期范围内的费用

- **参数**:
  - `payment_daily_fee`: 每日费用金额
  - `payment_total_amount`: 实际支付的总金额
  - `payment_date_start`: 开始日期字符串
  - `payment_date_start_tz`: 开始日期的时区，默认为 "Asia/Shanghai"
  - `payment_date_end`: 结束日期字符串
  - `payment_date_end_tz`: 结束日期的时区，默认为 "Asia/Shanghai"
- **返回**:
  - `bool`: 如果支付金额足够返回 True，否则返回 False

#### `query_actual_payment_items_sql_formatter(columns, conditions, order_by)`
格式化查询实际支付项目的 SQL 语句

- **参数**:
  - `columns`: 额外的查询列，默认为空字符串
  - `conditions`: 查询条件，默认为空字符串
  - `order_by`: 排序方式，默认为 "order by cfi.ChargeFeeItemID desc"
- **返回**:
  - `str`: 完整的 SQL 查询语句

### WebService 类

#### 初始化参数
- `base_url`: WebService 接口的基础 URL
- `client_kwargs`: 传递给 httpx.Client 的额外参数

#### 方法
- `get_data_set(client=None, **kwargs)`: 同步调用 GetDataSet WebService 方法
- `async_get_data_set(client=None, **kwargs)`: 异步调用 GetDataSet WebService 方法

## 高级用法

### 异步调用 WebService

```python
import asyncio
from py_easy_chanjet.tplus.zkhb import WebService

async def main():
    # 初始化 WebService 客户端
    web_service = WebService(base_url="http://example.com")
    
    # 异步调用 GetDataSet 方法获取数据
    data = {
        "sql": "select * from ChargeMasterList where ChargeMListID = '123'",
        "estateID": "123"
    }
    response = await web_service.async_get_data_set(data=data)
    print(f"WebService 响应: {response}")

asyncio.run(main())
```

## 项目结构

```
py_easy_chanjet/
├── py_easy_chanjet/              # 主包目录
│   ├── __init__.py            # 包初始化文件
│   └── tplus/                 # T+ 模块
│       ├── __init__.py        # T+ 模块初始化文件
│       └── zkhb.py            # 中科华博模块
├── README.md                  # 项目文档
├── setup.py                   # 安装配置
├── requirements.txt           # 依赖列表
├── LICENSE                    # 许可证文件
├── deploy.sh                  # 部署脚本
├── .gitignore                 # Git 忽略文件
└── test_tplus_zkhb.py         # 测试文件
```

## 测试

运行测试：

```bash
# 运行测试
python test_tplus_zkhb.py
```

## 许可证

MIT License

## 贡献

欢迎提交 Issue 和 Pull Request！

## 联系方式

- 作者：guolei
- 邮箱：174000902@qq.com
- 项目地址：https://gitee.com/guolei19850528/py_easy_chanjet

## 致谢

- [arrow](https://arrow.readthedocs.io/) - 强大的日期时间处理库
- [httpx](https://www.python-httpx.org/) - 高性能的异步 HTTP 客户端库
- [xmltodict](https://github.com/martinblech/xmltodict) - XML 与字典之间的转换库
- [py_easy_httpx](https://gitee.com/guolei19850528/py_easy_httpx) - 简化 HTTP 请求的工具包
