◐ Shell
clean mode source ↗

修复 WxMaExpressOrderCargo 字段类型以支持小数值 by Copilot · Pull Request #3802 · binarywang/WxJava

微信官方 API 文档规定 cargo 对象中的 weightspace_xspace_yspace_z 字段类型为 number,支持小数值(如 1.2kg、20.0cm)。但原实现使用 Integer 类型,导致无法处理小数。

变更内容

  • WxMaExpressOrderCargo.java: 将以下字段类型从 Integer 改为 Double

    • weight - 货物总重量(单位:kg)
    • spaceLength (space_x) - 货物长度(单位:cm)
    • spaceWidth (space_y) - 货物宽度(单位:cm)
    • spaceHeight (space_z) - 货物高度(单位:cm)
  • WxMaExpressServiceImplTest.java: 更新测试用例使用小数值

示例

WxMaExpressOrderCargo cargo = new WxMaExpressOrderCargo();
cargo.setWeight(1.2);        // 支持小数,符合官方文档示例
cargo.setSpaceLength(20.0);
cargo.setSpaceWidth(15.0);
cargo.setSpaceHeight(10.0);

兼容性

向后兼容。整数值自动装箱为 Double(55.0),现有代码无需修改。

Original prompt

This section details on the original issue you should resolve

<issue_title>WxMaExpressOrderCargo 类中变量类型问题</issue_title>
<issue_description>WxMaExpressOrderCargo类中的weight,spaceLength,,spaceWidth 不支持小数

Image</issue_description>

Comments on the Issue (you are @copilot in this section)

@binarywang 原始问题来自:https://gitee.com/binary/weixin-java-tools/issues/IDBUKJ

Custom agent used: 全部用中文
需要用中文,包括PR标题和分析总结过程


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.