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 bd519bf5c..d4bfadbc0 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 @@ -2013,14 +2013,33 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid configNewClientRate(config, clientId, "AlipayOnline", "alipayonline_rate_value", org, "min_alipayonline_rate"); configNewClientRate(config, clientId, "Rpay", "Rpay_rate_value", org, "min_Rpay_rate"); configNewClientRate(config, clientId, "CB_BankPay", "cb_bankpay_rate_value", org, "min_cb_bankpay_rate"); + addAlipayPlusRateConfig(config,clientId,PayChannel.ALIPAY_PLUS.getChannelCode()); } + private void addAlipayPlusRateConfig(JSONObject config,int clientId, String channel){ + if (config.getString("alipay_cn_retail") != null){ + config.put("pay_type","alipay_cn_retail"); + configNewClientRate(config, clientId, channel, "alipay_cn_retail", null, null); + } + if (config.getString("alipay_cn_online")!= null){ + config.put("pay_type","alipay_cn_online"); + configNewClientRate(config, clientId, channel, "alipay_cn_online", null,null); + } + if (config.getString("alipay_other")!= null){ + config.put("pay_type","alipay_other"); + configNewClientRate(config, clientId, channel, "alipay_other", null,null); + } + config.remove("pay_type"); + } + + private void configNewClientRate(JSONObject config, int clientId, String channel, String rateKey, JSONObject org, String rateValueKey) { if (config.containsKey(rateKey)) { JSONObject newConfig = new JSONObject(); newConfig.putAll(config); newConfig.put("rate_value", config.getBigDecimal(rateKey)); newConfig.put("rate_name", channel); + newConfig.put("pay_type",config.getString("pay_type")); if (!clientRateMapper.listClientRatesForSaving(clientId, config.getDate("active_time"), config.getDate("expiry_time"), config.getBigDecimal("rate_value"), config.getInteger("clean_days"), channel).isEmpty()) { return; } @@ -2033,10 +2052,17 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid newConfig.put("ext_rates", extRateParams.toJSONString()); } else { List existRate = clientRateMapper.listCurrentClientRates(clientId, config.getDate("active_time"), channel); - for (JSONObject rateLog : existRate) { - rateLog.put("expiry_time", DateUtils.addDays(config.getDate("active_time"), -1)); - clientRateMapper.updateConfig(rateLog); - } + existRate.stream().filter(existConfig->{ + if(existConfig.getDate("active_time").equals(config.getDate("active_time")) && existConfig.getDate("expiry_time").equals(config.getDate("expiry_time")) ){ + return false; + } + return true; + } + ) + .forEach((rateLog)->{ + rateLog.put("expiry_time", DateUtils.addDays(config.getDate("active_time"), -1)); + clientRateMapper.updateConfig(rateLog); + }); } if ("cb_bankpay".equalsIgnoreCase(channel)) { if (newConfig.getBigDecimal("cb_bankpay_rate_value") != null) {