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 390f4f386..843565a9d 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 @@ -102,6 +102,7 @@ import au.com.royalpay.payment.tools.locale.LocaleSupport; import au.com.royalpay.payment.tools.lock.Locker; import au.com.royalpay.payment.tools.mail.SendMail; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; +import au.com.royalpay.payment.tools.merchants.beans.TransactionFee; import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; import au.com.royalpay.payment.tools.merchants.core.MerchantChannelPermissionResolver; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; @@ -400,7 +401,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } @Override - @Cacheable(value = ":app_client_info_moniker:", key = "#clientMoniker",unless="#result == null") + @Cacheable(value = ":app_client_info_moniker:", key = "#clientMoniker", unless = "#result == null") public JSONObject getClientInfoByMoniker(String clientMoniker) { return clientMapper.findClientByMonikerAll(clientMoniker); } @@ -624,7 +625,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid assert client != null; JSONObject clientConfig = clientConfigService.find(clientId); - if(clientConfig !=null) { + if (clientConfig != null) { client.putAll(clientConfig); } return client; @@ -1990,6 +1991,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid convertExtRateValueDataVersion(rate, extRates, "overseas_rate_value"); rate.put("ext_rates", extRates); } + TransactionFee transFee = paymentApi.channelCalculator(rate.getString("rate_name")).convertTransactionFee(rate.getBigDecimal("transaction_fee")); + rate.put("transaction_fee", transFee.displayValue()); } } catch (Exception ignore) { } @@ -2035,6 +2038,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid configJson.put("manager_name", manager.getString("display_name")); configJson.put("create_time", new Date()); configJson.put("update_time", new Date()); + BigDecimal transactionFeeDecimal = config.getTransactionFee(); + TransactionFee transFee = paymentApi.channelCalculator(config.getRateName()).convertTransactionFee(transactionFeeDecimal); + configJson.put("transaction_fee", transFee.storeValue()); clientRateMapper.saveRate(configJson); // clientMapper.updateCleanDays(clientId, config.getCleanDays()); } @@ -2059,7 +2065,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid config.put("update_time", new Date()); config.put("active_time", DateFormatUtils.format(config.getDate("active_time"), "yyyy-MM-dd")); config.put("expiry_time", DateFormatUtils.format(config.getDate("expiry_time"), "yyyy-MM-dd")); - if (isAddCardPaymentRate(config, clientId)) { return; } @@ -2107,6 +2112,9 @@ 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 = paymentApi.channelCalculator(channel).convertTransactionFee(transactionFeeDecimal); + 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; } @@ -2164,6 +2172,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } checkOrgPermission(manager, client); JSONObject configJson = config.toJSON(); + BigDecimal transactionFeeDecimal = config.getTransactionFee(); + TransactionFee transFee = paymentApi.channelCalculator(config.getRateName()).convertTransactionFee(transactionFeeDecimal); + configJson.put("transaction_fee", transFee.storeValue()); JSONObject org = orgMapper.findOne(client.getIntValue("org_id")); checkModifyRate(org, configJson, "Wechat", "min_wechat_rate"); checkModifyRate(org, configJson, "Alipay", "min_alipay_rate"); @@ -2186,7 +2197,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid int clientId = client.getIntValue("client_id"); JSONObject changeRate = merchantInfoProvider.clientCurrentRate(clientId, new Date(), "Wechat"); int cleanDays = changeRate.getIntValue("clean_days"); - if (cleanDays != client.getIntValue("clean_days") && StringUtils.equalsIgnoreCase("Wechat", config.getRateName())) { + if (cleanDays != client.getIntValue("clean_days")) { clientModifySupport.processClientConfigModify(new ClearDaysModify(manager, clientMoniker, cleanDays)); } } @@ -3085,13 +3096,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } JSONObject alipayApsCashierRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), PayChannel.ALIPAY_APS_CASHIER.getChannelCode()); if (alipayApsCashierRate != null) { - client.put("aps_cashier_rate", alipayApsCashierRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)+"%"); - client.put("aps_cashier_service_rate", alipayApsCashierRate.getBigDecimal("transaction_fee").setScale(2, RoundingMode.DOWN)+"%"); + client.put("aps_cashier_rate", alipayApsCashierRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN) + "%"); + client.put("aps_cashier_service_rate", alipayApsCashierRate.getBigDecimal("transaction_fee").setScale(2, RoundingMode.DOWN) + "%"); } JSONObject alipayApsInstoreRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), PayChannel.ALIPAY_APS_IN_STORE.getChannelCode()); if (alipayApsInstoreRate != null) { - client.put("aps_instore_rate", alipayApsInstoreRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN)+"%"); - client.put("aps_instore_service_rate", alipayApsInstoreRate.getBigDecimal("transaction_fee").setScale(2, RoundingMode.DOWN)+"%"); + client.put("aps_instore_rate", alipayApsInstoreRate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN) + "%"); + client.put("aps_instore_service_rate", alipayApsInstoreRate.getBigDecimal("transaction_fee").setScale(2, RoundingMode.DOWN) + "%"); client.put("alipayplus_clean", alipayApsInstoreRate.getString("clean_days")); } } catch (Exception ignored) { @@ -6841,7 +6852,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid partner.put("lessComplianceFiles", signInAccountService.checkAuthFileStatus(partner.getJSONObject("client")).getBoolean("client_less_file")); } JSONObject clientConfig = clientConfigMapper.find(client.getIntValue("client_id")); - if(clientConfig !=null) { + if (clientConfig != null) { partner.put("geek_shop_status", clientConfig.getBooleanValue("geek_shop_status")); } return partner;