Merge branch 'develop'

master
yixian 4 years ago
commit 7da9d3a0ea

@ -270,7 +270,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
List<JSONObject> cleanDaysDetails = logDetails.stream() List<JSONObject> cleanDaysDetails = logDetails.stream()
.filter(detail -> detail.getIntValue("clear_days") == cleanDays) .filter(detail -> detail.getIntValue("clear_days") == cleanDays)
.collect(Collectors.toList()); .collect(Collectors.toList());
data.put("clean_days", cleanDays); data.put("clean_days", "T+" + cleanDays);
data.put("total_settle", cleanDaysDetails.stream() data.put("total_settle", cleanDaysDetails.stream()
.map(detail -> detail.getBigDecimal("clearing_amount")) .map(detail -> detail.getBigDecimal("clearing_amount"))
.reduce(BigDecimal::add) .reduce(BigDecimal::add)
@ -298,7 +298,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
JSONObject cleanDaysReport = new JSONObject(); JSONObject cleanDaysReport = new JSONObject();
cleanDaysReport.put("clean_days", "T+" + cleanDays); 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("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; return cleanDaysReport;
}).collect(HashMap::new, (map, report) -> map.put(report.getString("clean_days"), report), Map::putAll); }).collect(HashMap::new, (map, report) -> map.put(report.getString("clean_days"), report), Map::putAll);
total.put("logs", logs); total.put("logs", logs);

@ -1854,7 +1854,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
rate.put("clean_days", clientConfig.getIntValue("clean_days")); rate.put("clean_days", clientConfig.getIntValue("clean_days"));
} }
if (StringUtils.equalsIgnoreCase("rpaypmt_card", rate.getString("rate_name"))) { 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) { } catch (Exception ignore) {
@ -1863,6 +1866,16 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
return rates; 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 @Override
public void configSettleHour(JSONObject manager, String clientMoniker, Integer hour) { public void configSettleHour(JSONObject manager, String clientMoniker, Integer hour) {
JSONObject client = getClientInfoByMoniker(clientMoniker); JSONObject client = getClientInfoByMoniker(clientMoniker);
@ -1948,18 +1961,26 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
if (StringUtils.equalsIgnoreCase("rpaypmt_card", config.getString("type"))) { if (StringUtils.equalsIgnoreCase("rpaypmt_card", config.getString("type"))) {
JSONObject extRateParams = new JSONObject() {{ JSONObject extRateParams = new JSONObject() {{
put("domestic_rate_value", config.getBigDecimal("rate_value")); put("domestic_rate_value", subRateObject(config.getBigDecimal("rate_value"), config.getIntValue("clean_days")));
put("overseas_rate_value", config.getJSONObject("ext_rates").getBigDecimal("international_rate_value")); 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()); 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); clientRateMapper.saveRate(newConfig);
} }
logger.info(clientId + "的" + channel + "费率设置成功"); 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 @Override
@Transactional @Transactional
public void modifyRateConfig(JSONObject manager, String clientMoniker, int rateId, ClientRateConfig config) { 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()); configJson.put("update_time", new Date());
if (StringUtils.equalsIgnoreCase("rpaypmt_card", config.getRateName())) { if (StringUtils.equalsIgnoreCase("rpaypmt_card", config.getRateName())) {
JSONObject extParams = configJson.getJSONObject("ext_rates"); 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()); configJson.put("ext_rates", extParams.toJSONString());
} }
clientRateMapper.updateConfig(configJson); clientRateMapper.updateConfig(configJson);

@ -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('')
}])
})

@ -13,7 +13,7 @@
<div class="modal-footer"> <div class="modal-footer">
<div class="pull-right"> <div class="pull-right">
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-danger" ng-disabled="data.text===content" ng-click="submit()"><i <button class="btn btn-danger" ng-disabled="data.text!==content" ng-click="submit()"><i
class="glyphicon glyphicon-ok"></i> OK class="glyphicon glyphicon-ok"></i> OK
</button> </button>
</div> </div>

@ -39,7 +39,8 @@
<label class="control-label col-sm-4" for="international_rate_value_input">International Rate Value</label> <label class="control-label col-sm-4" for="international_rate_value_input">International Rate Value</label>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="input-group"> <div class="input-group">
<input type="number" name="international_rate_value" stringToNumber2 class="form-control" ng-model="rate.ext_rates.overseas_rate_value" <input type="number" name="international_rate_value" stringToNumber2 class="form-control"
ng-model="rate.ext_rates.overseas_rate_value.rate"
min="0" max="5" step="0.1" id="international_rate_value_input" required> min="0" max="5" step="0.1" id="international_rate_value_input" required>
<div class="input-group-addon">%</div> <div class="input-group-addon">%</div>
</div> </div>
@ -108,6 +109,18 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form-group" ng-if="rate.rate_name=='rpaypmt_card'">
<label class="control-label col-sm-4" for="international_clean_days_input">International Clean
Days</label>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon">T+</span>
<input class="form-control" type="number"
ng-model="rate.ext_rates.overseas_rate_value.clean_days"
id="international_clean_days_input">
</div>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-4" for="remark_text">Remark</label> <label class="control-label col-sm-4" for="remark_text">Remark</label>
<div class="col-sm-6"> <div class="col-sm-6">

@ -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);
}
}
Loading…
Cancel
Save