diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java index 8d77c97db..755076ee1 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java @@ -270,7 +270,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider List cleanDaysDetails = logDetails.stream() .filter(detail -> detail.getIntValue("clear_days") == cleanDays) .collect(Collectors.toList()); - data.put("clean_days", cleanDays); + data.put("clean_days", "T+" + cleanDays); data.put("total_settle", cleanDaysDetails.stream() .map(detail -> detail.getBigDecimal("clearing_amount")) .reduce(BigDecimal::add) @@ -298,7 +298,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider JSONObject cleanDaysReport = new JSONObject(); cleanDaysReport.put("clean_days", "T+" + cleanDays); cleanDaysReport.put("clients", logs.stream().mapToInt(log -> log.getJSONObject("clean_days").getJSONObject("T+" + cleanDays).getIntValue("clients")).sum()); - cleanDaysReport.put("amount", logs.stream().map(log -> log.getJSONObject("clean_days").getJSONObject("T+" + cleanDays).getBigDecimal("total_settle")).reduce(BigDecimal::add).orElse(BigDecimal.ZERO)); + cleanDaysReport.put("total_settle", logs.stream().map(log -> log.getJSONObject("clean_days").getJSONObject("T+" + cleanDays).getBigDecimal("total_settle")).reduce(BigDecimal::add).orElse(BigDecimal.ZERO)); return cleanDaysReport; }).collect(HashMap::new, (map, report) -> map.put(report.getString("clean_days"), report), Map::putAll); total.put("logs", logs); 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 1698bd2dc..04620f581 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 @@ -1854,7 +1854,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid rate.put("clean_days", clientConfig.getIntValue("clean_days")); } if (StringUtils.equalsIgnoreCase("rpaypmt_card", rate.getString("rate_name"))) { - rate.put("ext_rates", JSONObject.parseObject(rate.getString("ext_rates"))); + JSONObject extRates = JSONObject.parseObject(rate.getString("ext_rates")); + convertExtRateValueDataVersion(rate, extRates, "domestic_rate_value"); + convertExtRateValueDataVersion(rate, extRates, "overseas_rate_value"); + rate.put("ext_rates", extRates); } } } catch (Exception ignore) { @@ -1863,6 +1866,16 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid return rates; } + public void convertExtRateValueDataVersion(JSONObject rate, JSONObject extRates, String subRateKey) { + if (!(extRates.get(subRateKey) instanceof JSON)) { + BigDecimal domesticRate = extRates.getBigDecimal(subRateKey); + JSONObject subRateConfig = new JSONObject(); + subRateConfig.put("rate", domesticRate); + subRateConfig.put("clean_days", rate.getIntValue("clean_days")); + extRates.put(subRateKey, subRateConfig); + } + } + @Override public void configSettleHour(JSONObject manager, String clientMoniker, Integer hour) { JSONObject client = getClientInfoByMoniker(clientMoniker); @@ -1948,18 +1961,26 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } if (StringUtils.equalsIgnoreCase("rpaypmt_card", config.getString("type"))) { JSONObject extRateParams = new JSONObject() {{ - put("domestic_rate_value", config.getBigDecimal("rate_value")); - put("overseas_rate_value", config.getJSONObject("ext_rates").getBigDecimal("international_rate_value")); + put("domestic_rate_value", subRateObject(config.getBigDecimal("rate_value"), config.getIntValue("clean_days"))); + JSONObject extRates = config.getJSONObject("ext_rates"); + put("overseas_rate_value", subRateObject(extRates.getBigDecimal("international_rate_value"), config.getIntValue("clean_days") + 1)); }}; newConfig.put("ext_rates", extRateParams.toJSONString()); } - if(newConfig.getBigDecimal("cb_bankpay_rate_value") != null){ + if (newConfig.getBigDecimal("cb_bankpay_rate_value") != null) { clientRateMapper.saveRate(newConfig); } logger.info(clientId + "的" + channel + "费率设置成功"); } } + private JSONObject subRateObject(BigDecimal rate, int cleanDays) { + JSONObject subRate = new JSONObject(); + subRate.put("rate", rate); + subRate.put("clean_days", cleanDays); + return subRate; + } + @Override @Transactional public void modifyRateConfig(JSONObject manager, String clientMoniker, int rateId, ClientRateConfig config) { @@ -1979,7 +2000,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid configJson.put("update_time", new Date()); if (StringUtils.equalsIgnoreCase("rpaypmt_card", config.getRateName())) { JSONObject extParams = configJson.getJSONObject("ext_rates"); - extParams.put("domestic_rate_value", config.getRateValue()); + + JSONObject domesticRate = subRateObject(new BigDecimal(config.getRateValue()), config.getCleanDays()); + extParams.put("domestic_rate_value", domesticRate); configJson.put("ext_rates", extParams.toJSONString()); } clientRateMapper.updateConfig(configJson); diff --git a/src/main/ui/static/analysis/settle_tools.js b/src/main/ui/static/analysis/settle_tools.js new file mode 100644 index 000000000..7c9376ee5 --- /dev/null +++ b/src/main/ui/static/analysis/settle_tools.js @@ -0,0 +1,8 @@ +define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) { + 'use strict'; + let app = angular.module('settleTools', ['ui.bootstrap', 'ui.router']); + + app.config(['$stateProvider', function ($stateProvider) { + $stateProvider.state('') + }]) +}) \ No newline at end of file diff --git a/src/main/ui/static/commons/templates/danger_confirm.html b/src/main/ui/static/commons/templates/danger_confirm.html index 7185a0697..f89800583 100644 --- a/src/main/ui/static/commons/templates/danger_confirm.html +++ b/src/main/ui/static/commons/templates/danger_confirm.html @@ -13,7 +13,7 @@ +
+ +
+
+ T+ + +
+
+
diff --git a/src/test/java/au/com/royalpay/payment/manage/merchants/beans/ClientRateConfigTest.java b/src/test/java/au/com/royalpay/payment/manage/merchants/beans/ClientRateConfigTest.java new file mode 100644 index 000000000..4e95d2c51 --- /dev/null +++ b/src/test/java/au/com/royalpay/payment/manage/merchants/beans/ClientRateConfigTest.java @@ -0,0 +1,29 @@ +package au.com.royalpay.payment.manage.merchants.beans; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.time.DateUtils; +import org.junit.Test; + +import java.util.Date; + +import static org.junit.Assert.assertNotNull; + +public class ClientRateConfigTest { + + @Test + public void testSerialize() { + ClientRateConfig rate = new ClientRateConfig(); + rate.setCleanDays(1); + rate.setRateName("rpaypmt_card"); + rate.setActiveTime(new Date()); + rate.setExpiryTime(DateUtils.addYears(new Date(), 1)); + rate.setRateValue(1.2); + rate.setTransactionFee(0.3); + rate.setExtRates("{\"international_rate\":3.5}"); + + JSONObject rateJson = rate.toJSON(); + JSONObject extRates = rateJson.getJSONObject("ext_rates"); + assertNotNull(extRates); + } + +} \ No newline at end of file