Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.egzosn.pay.common.util;

import com.egzosn.pay.common.bean.result.PayException;
import com.egzosn.pay.common.exception.PayErrorException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.Collection;
import java.util.Map;

Expand Down Expand Up @@ -590,7 +593,11 @@ public static byte[] subByte(byte[] input, int startIndex, int length) {
* @return 分的金额
*/
public static int conversionCentAmount(BigDecimal amount) {
return amount.multiply(HUNDRED).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
final BigDecimal decimal = amount.multiply(HUNDRED).setScale(0, RoundingMode.HALF_UP);
if (decimal.longValue() > (long) Integer.MAX_VALUE) {
throw new PayErrorException(new PayException("illegal parameter", "订单金额过大"));
}
return decimal.intValue();
}

/**
Expand All @@ -613,4 +620,4 @@ public static <V> boolean isEmpty(Collection<V> collection) {
}


}
}