py_easy_chanjet
畅捷通 T+ Python SDK,提供简单易用的畅捷通 T+ 系统交互功能,支持中科华博等模块的操作。
功能特性
- 中科华博:支持验证支付金额是否足够覆盖指定日期范围内的费用
- SQL 语句生成:提供查询实际支付项目的 SQL 语句格式化功能
- WebService 交互:支持调用畅捷通 T+ 系统的 WebService 接口
- 同步/异步支持:同时支持同步和异步操作
- 灵活配置:支持通过参数自定义客户端行为
- 响应处理:提供 XML 与字典之间的转换功能
- 类型提示:完整的类型注解,提供良好的 IDE 支持
安装
使用 pip 安装
pip install py_easy_chanjet
从源码安装
git clone https://gitee.com/guolei19850528/py_easy_chanjet.git
cd py_easy_chanjet
pip install -e .
依赖
- arrow
- httpx
- xmltodict
- py_easy_httpx
快速开始
验证支付金额
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 查询语句
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 接口
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 接口的基础 URLclient_kwargs: 传递给 httpx.Client 的额外参数
方法
get_data_set(client=None, **kwargs): 同步调用 GetDataSet WebService 方法async_get_data_set(client=None, **kwargs): 异步调用 GetDataSet WebService 方法
高级用法
异步调用 WebService
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 # 测试文件
测试
运行测试:
# 运行测试
python test_tplus_zkhb.py
许可证
MIT License
贡献
欢迎提交 Issue 和 Pull Request!
联系方式
- 作者:guolei
- 邮箱:174000902@qq.com
- 项目地址:https://gitee.com/guolei19850528/py_easy_chanjet
致谢
- arrow - 强大的日期时间处理库
- httpx - 高性能的异步 HTTP 客户端库
- xmltodict - XML 与字典之间的转换库
- py_easy_httpx - 简化 HTTP 请求的工具包
Metadata
Release files for py-easy-chanjet 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_easy_chanjet-2.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Release files / py_easy_chanjet-2.0.2-py3-none-any.whl
| Download URL | py_easy_chanjet-2.0.2-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
947319e6f96962788e75e4e5fb37e575392ada55e1e45e7cdeb2245e0259373e
|
|
BLAKE2b-256 checksum How to use checksums |
14e8be033fb5d487c08e81eb76adde42b783bdcdc5adc6bdfeda222ffc4bf34f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Security for py-easy-chanjet 2.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.