后台服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

  1. package com.iformall.utils;
  2. /**
  3. * 分账手续费
  4. *
  5. * @author stormeye.wu
  6. * @email wuguoqiang@iformall.com
  7. * @date 2019年1月5月
  8. */
  9. public class PayUtils {
  10. /**
  11. * getPayRate
  12. * @param payAmount 支付总钱数(分)
  13. * @param rate 万分之几
  14. * @return
  15. */
  16. public static int getPayRate(int payAmount, int rate, boolean isReal) {
  17. Double dBaseAmount = 5.0D * 1000 / rate;
  18. // 基础分 千分之6 83分
  19. if (isReal) {
  20. // 小于基础分,四舍五入
  21. Double dPayRate = 1.0D * payAmount * rate / 10000;
  22. long dChargeFee = Math.round(dPayRate);
  23. return Long.valueOf(dChargeFee).intValue();
  24. }else if(payAmount > dBaseAmount.intValue()) {
  25. // 大于基础分,不小于他的最小整数
  26. Double dChargeFee = Math.ceil(payAmount * 1.0D * rate / 10000);
  27. return dChargeFee.intValue();
  28. } else {
  29. // 小于基础分,四舍五入
  30. Double dPayRate = 1.0D * payAmount * rate / 10000;
  31. long dChargeFee = Math.round(dPayRate);
  32. return Long.valueOf(dChargeFee).intValue();
  33. }
  34. }
  35. public static void main(String[] args) {
  36. System.out.println(getPayRate(990, 7001, true));
  37. }
  38. /*
  39. public static void main(String[] args) {
  40. int iValue = getPayRate(600, 60, false);
  41. System.out.println(iValue);
  42. iValue = getPayRate(600, 20, true);
  43. System.out.println(iValue);
  44. }
  45. */
  46. }