Skip to main content

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

Project description

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 接口的基础 URL
  • client_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!

联系方式

致谢

  • arrow - 强大的日期时间处理库
  • httpx - 高性能的异步 HTTP 客户端库
  • xmltodict - XML 与字典之间的转换库
  • py_easy_httpx - 简化 HTTP 请求的工具包

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_easy_chanjet-2.0.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file py_easy_chanjet-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for py_easy_chanjet-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0ab979da54ebbc565cdc253ec8d86c7c2d10c468a899678a4bf8ca135eabdca6
MD5 60d795fc62642807122f31ab998c4c49
BLAKE2b-256 b7ce8d29071cd5b754e4e814931963f708472e55aabfbb61d2d6cb3d8823936f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page