From e2f1ca5d7ce61e6836f6a7f1bc94c4b6adcc1618 Mon Sep 17 00:00:00 2001 From: Yixian Date: Mon, 7 Feb 2022 09:48:11 +0800 Subject: [PATCH] 2.4.5: hotfix-transaction fee config --- .../merchants/core/impls/ClientManagerImpl.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 63d66f9c3..ebe774bfc 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -2115,11 +2115,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid newConfig.put("rate_value", config.getBigDecimal(rateKey)); newConfig.put("rate_name", channel); newConfig.put("pay_type", config.getString("pay_type")); - BigDecimal transactionFeeDecimal = config.getBigDecimal("transaction_fee"); - TransactionFee transFee = Optional.ofNullable(paymentApi.channelCalculator(channel)) - .map(calculator -> calculator.convertTransactionFee(transactionFeeDecimal)) - .orElse(TransactionFee.ZERO); - newConfig.put("transaction_fee", transFee.storeValue()); if (!clientRateMapper.listClientRatesForSaving(clientId, config.getDate("active_time"), config.getDate("expiry_time"), config.getBigDecimal("rate_value"), config.getInteger("clean_days"), channel).isEmpty()) { return; } @@ -2149,10 +2144,18 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid clientRateMapper.saveRate(newConfig); } } else if ("ApsInStore".equalsIgnoreCase(channel)) { - newConfig.put("transaction_fee", newConfig.getFloatValue("retail_service_fee_value")); + BigDecimal transactionFeeDecimal = config.getBigDecimal("retail_service_fee_value"); + TransactionFee transFee = Optional.ofNullable(paymentApi.channelCalculator("ApsInStore")) + .map(calculator -> calculator.convertTransactionFee(transactionFeeDecimal)) + .orElse(TransactionFee.ZERO); + newConfig.put("transaction_fee", transFee.storeValue()); clientRateMapper.saveRate(newConfig); } else if ("ApsCashier".equalsIgnoreCase(channel)) { - newConfig.put("transaction_fee", newConfig.getFloatValue("online_service_fee_value")); + BigDecimal transactionFeeDecimal = config.getBigDecimal("online_service_fee_value"); + TransactionFee transFee = Optional.ofNullable(paymentApi.channelCalculator("ApsCashier")) + .map(calculator -> calculator.convertTransactionFee(transactionFeeDecimal)) + .orElse(TransactionFee.ZERO); + newConfig.put("transaction_fee", transFee.storeValue()); clientRateMapper.saveRate(newConfig); } else { clientRateMapper.saveRate(newConfig);