| @@ -125,7 +125,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| // 4. 扣减计算 | |||
| Double paymentD = 1.0 * cardInfo.getSaleAmount() * record.getDeductionAmount() / cardInfo.getAmount(); | |||
| Integer payment = paymentD.intValue(); | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate()); | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate(), false); | |||
| Integer real_payment = payment - iChargeFee; | |||
| Integer remain_real_pament = cardInfo.getRemainingShareFeeAmount() - real_payment; | |||
| Integer remaingAmount = cardInfo.getRemainingAmount()-record.getDeductionAmount(); | |||
| @@ -200,7 +200,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| logger.info("补贴额: " + subsidyFee); | |||
| if(subsidyFee > 0) { | |||
| // 有补贴时入库 | |||
| int iSubChargeFee = PayUtils.getPayRate(subsidyFee, payAccount.getRate()); | |||
| int iSubChargeFee = PayUtils.getPayRate(subsidyFee, payAccount.getRate(), false); | |||
| Integer realSubsidyFee = subsidyFee - iSubChargeFee; | |||
| WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy(); | |||
| merchantSubsidy.setId(idWorker.nextId()); | |||
| @@ -599,7 +599,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| // 4. 扣减计算 | |||
| Double paymentD = 1.0 * cardInfo.getSaleAmount() * record.getDeductionAmount() / cardInfo.getAmount(); | |||
| Integer payment = paymentD.intValue(); | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate()); | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate(), false); | |||
| Integer real_payment = payment - iChargeFee; | |||
| Integer remain_real_pament = cardInfo.getRemainingShareFeeAmount() - real_payment; | |||
| Integer remaingAmount = cardInfo.getRemainingAmount()-record.getDeductionAmount(); | |||
| @@ -680,7 +680,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| // 4. 增加计算 | |||
| Double paymentD = 1.0 * cardInfo.getSaleAmount() * record.getDeductionAmount() / cardInfo.getAmount(); | |||
| Integer payment = paymentD.intValue(); | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate()); | |||
| int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate(), false); | |||
| Integer real_payment = payment - iChargeFee; | |||
| Integer remain_real_pament = cardInfo.getRemainingShareFeeAmount() + real_payment; | |||
| Integer remaingAmount = cardInfo.getRemainingAmount()+record.getDeductionAmount(); | |||
| @@ -772,7 +772,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| logger.info("补贴额: " + subsidyFee); | |||
| if(subsidyFee > 0) { | |||
| // 有补贴时入库 | |||
| int iSubChargeFee = PayUtils.getPayRate(subsidyFee, payAccount.getRate()); | |||
| int iSubChargeFee = PayUtils.getPayRate(subsidyFee, payAccount.getRate(), false); | |||
| Integer realSubsidyFee = subsidyFee - iSubChargeFee; | |||
| WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy(); | |||
| merchantSubsidy.setId(idWorker.nextId()); | |||
| @@ -509,10 +509,10 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| if (subsidyNum != null && subsidyNum.intValue() > 0) { | |||
| // 有补贴时入库 | |||
| int iSubChargeFee = PayUtils.getPayRate(subsidyNum, payAccount.getRate()); | |||
| int iSubChargeFee = PayUtils.getPayRate(subsidyNum, payAccount.getRate(), false); | |||
| Integer realSubsidyFee = subsidyNum - iSubChargeFee; | |||
| int iPriceChargeFee = PayUtils.getPayRate(coupon.getSalePrice(), payAccount.getRate()); | |||
| int iPriceChargeFee = PayUtils.getPayRate(coupon.getSalePrice(), payAccount.getRate(), false); | |||
| Integer realPayment = coupon.getSalePrice() - iPriceChargeFee; | |||
| WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy(); | |||
| @@ -228,11 +228,11 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| record.setShare(isShare.getCode()); | |||
| if (isShare == EnumPayShare.YES) { | |||
| // 分账金额 | |||
| int iChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRate()); | |||
| int iChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRate(), false); | |||
| Integer share_amount = record.getPayAmount() - iChargeFee; | |||
| record.setShareAmount(share_amount); | |||
| if(payAccount.getRealRate() != null) { | |||
| int iRealChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRealRate()); | |||
| int iRealChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRealRate(), true); | |||
| if(iChargeFee > iRealChargeFee) { | |||
| record.setRateAmount(iChargeFee - iRealChargeFee); | |||
| } | |||
| @@ -459,11 +459,11 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| record.setShare(isShare.getCode()); | |||
| if (isShare == EnumPayShare.YES) { | |||
| // 分账金额 | |||
| int iChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRate()); | |||
| int iChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRate(), false); | |||
| Integer share_amount = record.getPayAmount() - iChargeFee; | |||
| record.setShareAmount(share_amount); | |||
| if(payAccount.getRealRate() != null) { | |||
| int iRealChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRealRate()); | |||
| int iRealChargeFee = PayUtils.getPayRate(record.getPayAmount(), payAccount.getRealRate(), true); | |||
| record.setRateAmount(iRealChargeFee); | |||
| } | |||
| if (share_amount <= 0) { | |||
| @@ -114,7 +114,7 @@ public class WxSubsidyServiceImpl implements WxSubsidyService { | |||
| record.setPayTimeEnd(curDate); | |||
| record.setAmount(totalFee); | |||
| // 分账金额 | |||
| int iChargeFee = PayUtils.getPayRate(record.getAmount(), payAccount.getRate()); | |||
| int iChargeFee = PayUtils.getPayRate(record.getAmount(), payAccount.getRate(), false); | |||
| Integer share_amount = record.getAmount() - iChargeFee; | |||
| record.setShareAmount(share_amount); | |||
| record.setShareRemainAmount(share_amount); | |||
| @@ -15,10 +15,16 @@ public class PayUtils { | |||
| * @param rate 万分之几 | |||
| * @return | |||
| */ | |||
| public static int getPayRate(int payAmount, int rate) { | |||
| public static int getPayRate(int payAmount, int rate, boolean isReal) { | |||
| Double dBaseAmount = 5.0D * 1000 / rate; | |||
| // 基础分 千分之6 83分 | |||
| if(payAmount > dBaseAmount.intValue()) { | |||
| 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(); | |||
| @@ -30,21 +36,14 @@ public class PayUtils { | |||
| } | |||
| } | |||
| /* | |||
| public static void main(String[] args) { | |||
| int iValue = getPayRate(100, 60); | |||
| System.out.println(iValue); | |||
| iValue = getPayRate(200, 60); | |||
| System.out.println(iValue); | |||
| iValue = getPayRate(82, 60); | |||
| System.out.println(iValue); | |||
| iValue = getPayRate(83, 60); | |||
| int iValue = getPayRate(600, 60, false); | |||
| System.out.println(iValue); | |||
| iValue = getPayRate(84, 60); | |||
| iValue = getPayRate(600, 20, true); | |||
| System.out.println(iValue); | |||
| } | |||
| */ | |||
| } | |||