Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题与验收标准
关联 Issue:无(源码静态审查发现,已确认
dev分支当前仍存在)。现象 / 预期:
AbstractCtrl里三个"元转分"的入参换算方法把不足 1 分的部分静默截断了:BigDecimal#longValue()是向零截断(truncate),不是四舍五入。前端只要传入超过两位小数的金额,就会直接掉分:1.0051001010.09999910-1.005-100-101并且截断方向是"向零",正数少收、负数少扣,退款 / 转账这类场景下误差方向还不一致。
受影响入口:这三个方法是
getRequiredAmountL/getAmountL/handleParamAmount,仓库内的调用点(grep结果)为:jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/order/PayOrderController.java(商户端订单金额入参)jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/transfer/MchTransferController.java(商户提现 / 转账金额)jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/ctrl/paytest/PaytestController.java(支付测试金额)jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/ctrl/order/PayOrderController.java(运营端订单)jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/qr/QrCashierController.java(收银台金额)金额最终单位是"分"(整型),所以这里少 1 分就是实收实付少 1 分。
修改内容
jeepay-core/src/main/java/com/jeequan/jeepay/core/ctrls/AbstractCtrl.java的三处换算统一加上显式舍入。取整到"分"在本仓库里已有约定就是ROUND_HALF_UP(见AmountUtil.java:134的calPercentageFee(amount, rate, BigDecimal.ROUND_HALF_UP)与AmountUtil.java:149的setScale(0, mode);另外convertCent2Dollar用的是setScale(2, BigDecimal.ROUND_HALF_UP)),因此这里按同一规则补齐:行为兼容性:两位小数及以内的常规入参(也就是前端正常输入的格式)结果完全不变,本次只影响超过两位小数的入参——原实现会静默丢掉这部分,现在按四舍五入计入。没有改动方法签名、返回类型或任何配置项。
验证
新增
jeepay-core/src/test/java/com/jeequan/jeepay/core/ctrls/AbstractCtrlAmountTest.java,用一个只覆写getReqParamJSON()的测试子类驱动三个方法,不依赖 Servlet 上下文、数据库或网络。改动前(
dev@ 最新提交):改动后,同一个类:
整个
jeepay-core模块(含模块内既有测试,无回归):Prepared with an AI coding agent.