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 15667f54d..2e0bce146 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 @@ -1935,8 +1935,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid newConfig.putAll(config); newConfig.put("rate_value", config.getBigDecimal(rateKey)); newConfig.put("rate_name", channel); - if (!clientRateMapper.listClientRatesForSaving(clientId, config.getDate("active_time"), config.getDate("expiry_time"), - config.getDoubleValue("rate_value"), config.getInteger("clean_days"), channel).isEmpty()) { + if (!clientRateMapper.listClientRatesForSaving(clientId, config.getDate("active_time"), config.getDate("expiry_time"), config.getDoubleValue("rate_value"), config.getInteger("clean_days"), channel).isEmpty()) { return; } if (StringUtils.equalsIgnoreCase("rpaypmt_card", config.getString("type"))) { @@ -1946,11 +1945,26 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid }}; newConfig.put("ext_rates", extRateParams.toJSONString()); } + pastRate(clientId,channel); clientRateMapper.saveRate(newConfig); logger.info(clientId + "的" + channel + "费率设置成功"); } } + private void pastRate(int clientId,String rateName){ + List rates = clientRateMapper.listClientRates(clientId, rateName); + if (!rates.isEmpty()) { + Date today = DateUtils.truncate(new Date(), Calendar.DATE); + for (JSONObject rateItem : rates) { + if (rateItem.getDate("expiry_time").before(today) || rateItem.getDate("active_time").after(today)) { + continue; + } + rateItem.put("expiry_time",DateUtils.addDays(new Date(), -1)); + clientRateMapper.updateConfig(rateItem); + } + } + } + @Override @Transactional public void modifyRateConfig(JSONObject manager, String clientMoniker, int rateId, ClientRateConfig config) {