|
- package com.iformall.utils;
-
- /**
- * 分账手续费
- *
- * @author stormeye.wu
- * @email wuguoqiang@iformall.com
- * @date 2019年1月5月
- */
- public class PayUtils {
-
- /**
- * getPayRate
- * @param payAmount 支付总钱数(分)
- * @param rate 万分之几
- * @return
- */
- public static int getPayRate(int payAmount, int rate, boolean isReal) {
- Double dBaseAmount = 5.0D * 1000 / rate;
- // 基础分 千分之6 83分
- if (isReal) {
- // 小于基础分,四舍五入
- Double dPayRate = 1.0D * payAmount * rate / 10000;
- long dChargeFee = Math.round(dPayRate);
- return Long.valueOf(dChargeFee).intValue();
- }else if(payAmount > dBaseAmount.intValue()) {
- // 大于基础分,不小于他的最小整数
- Double dChargeFee = Math.ceil(payAmount * 1.0D * rate / 10000);
- return dChargeFee.intValue();
- } else {
- // 小于基础分,四舍五入
- Double dPayRate = 1.0D * payAmount * rate / 10000;
- long dChargeFee = Math.round(dPayRate);
- return Long.valueOf(dChargeFee).intValue();
- }
- }
-
- public static void main(String[] args) {
- System.out.println(getPayRate(990, 7001, true));
- }
-
- /*
- public static void main(String[] args) {
- int iValue = getPayRate(600, 60, false);
- System.out.println(iValue);
-
- iValue = getPayRate(600, 20, true);
- System.out.println(iValue);
- }
- */
-
- }
|