0
点赞
收藏
分享

微信扫一扫

微信支付金额为0.01分报错,和少一分钱的解决办法

一天清晨 2022-02-24 阅读 72

微信支付失败,返回invalid total_fee,金额不能出现小数点
所以我们系统如果是以元为单位要处理下金额,即先乘以100,再去小数点

"result": {
		"return_msg": "invalid total_fee",
		"return_code": "FAIL"
	},

(Math.Round((decimal)order.Amount * 100, 0)).ToString()

如果金额为少一分钱

例:

//这样会少一分钱
 public static void main(String [] str){
        String a = "18.90";
        Double  d = Double.parseDouble(a);
        d = d * 100;
        Long totalL = d.longValue();
        System.out.println(totalL);
    }

在这里插入图片描述

//完美解决
 public static void main(String [] str){
        String a = "18.90";
        Double  d = Double.parseDouble(a);
        d = d * 1000 / 10;
        Long totalL = d.longValue();
        System.out.println(totalL);
    }

在这里插入图片描述

举报

相关推荐

0 条评论