rate config

master
yixian 5 years ago
parent c6c4c0eedf
commit 371a17632a

@ -793,7 +793,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
newConfig.put("rate_value", config.getBigDecimal(rateKey)); newConfig.put("rate_value", config.getBigDecimal(rateKey));
newConfig.put("rate_name", channel); newConfig.put("rate_name", channel);
if (!clientRateMapper.listClientRatesForSaving(clientId, config.getDate("active_time"), config.getDate("expiry_time"), if (!clientRateMapper.listClientRatesForSaving(clientId, config.getDate("active_time"), config.getDate("expiry_time"),
config.getDoubleValue("rate_value"), config.getInteger("clean_days"), channel).isEmpty()) { config.getBigDecimal("rate_value"), config.getInteger("clean_days"), channel).isEmpty()) {
return; return;
} }
List<JSONObject> existRate = clientRateMapper.listCurrentClientRates(clientId, config.getDate("active_time"), channel); List<JSONObject> existRate = clientRateMapper.listCurrentClientRates(clientId, config.getDate("active_time"), channel);

@ -1,12 +1,13 @@
package au.com.royalpay.payment.manage.mappers.system; package au.com.royalpay.payment.manage.mappers.system;
import com.alibaba.fastjson.JSONObject;
import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper; import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper;
import com.yixsoft.support.mybatis.autosql.annotations.AutoSql; import com.yixsoft.support.mybatis.autosql.annotations.AutoSql;
import com.yixsoft.support.mybatis.autosql.annotations.SqlType; import com.yixsoft.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator; import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -38,7 +39,7 @@ public interface ClientRateMapper {
@AutoSql(SqlType.SELECT) @AutoSql(SqlType.SELECT)
List<JSONObject> listClientRatesForSaving(@Param("client_id") int clientId, @Param("active_time") Date activeTime, List<JSONObject> listClientRatesForSaving(@Param("client_id") int clientId, @Param("active_time") Date activeTime,
@Param("expiry_time") Date expiryTime, @Param("rate_value") Double rateValue, @Param("expiry_time") Date expiryTime, @Param("rate_value") BigDecimal rateValue,
@Param("clean_days") Integer cleanDays, @Param("rate_name") String rateName); @Param("clean_days") Integer cleanDays, @Param("rate_name") String rateName);

@ -7,6 +7,7 @@ import org.apache.commons.lang3.time.DateUtils;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@ -21,11 +22,11 @@ public class ClientRateConfig {
@JSONField(name = "rate_value") @JSONField(name = "rate_value")
@NotNull(message = "error.payment.valid.param_missing") @NotNull(message = "error.payment.valid.param_missing")
private Double rateValue; private BigDecimal rateValue;
@JSONField(name = "transaction_fee") @JSONField(name = "transaction_fee")
@NotNull(message = "error.payment.valid.param_missing") @NotNull(message = "error.payment.valid.param_missing")
private Double transactionFee = 0.00; private BigDecimal transactionFee = BigDecimal.ZERO;
@JSONField(name = "active_time") @JSONField(name = "active_time")
@NotNull(message = "error.payment.valid.param_missing") @NotNull(message = "error.payment.valid.param_missing")
@ -53,7 +54,7 @@ public class ClientRateConfig {
this.rateName = rateName; this.rateName = rateName;
} }
public void setRateValue(Double rateValue) { public void setRateValue(BigDecimal rateValue) {
this.rateValue = rateValue; this.rateValue = rateValue;
} }
@ -69,7 +70,7 @@ public class ClientRateConfig {
return rateName; return rateName;
} }
public Double getRateValue() { public BigDecimal getRateValue() {
return rateValue; return rateValue;
} }
@ -97,11 +98,11 @@ public class ClientRateConfig {
this.remark = remark; this.remark = remark;
} }
public Double getTransactionFee() { public BigDecimal getTransactionFee() {
return transactionFee; return transactionFee;
} }
public void setTransactionFee(Double transactionFee) { public void setTransactionFee(BigDecimal transactionFee) {
this.transactionFee = transactionFee; this.transactionFee = transactionFee;
} }

@ -1951,7 +1951,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
newConfig.putAll(config); newConfig.putAll(config);
newConfig.put("rate_value", config.getBigDecimal(rateKey)); newConfig.put("rate_value", config.getBigDecimal(rateKey));
newConfig.put("rate_name", channel); 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.getBigDecimal("rate_value"), config.getInteger("clean_days"), channel).isEmpty()) {
return; return;
} }
List<JSONObject> existRate = clientRateMapper.listCurrentClientRates(clientId, config.getDate("active_time"), channel); List<JSONObject> existRate = clientRateMapper.listCurrentClientRates(clientId, config.getDate("active_time"), channel);
@ -2005,7 +2005,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
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");
JSONObject domesticRate = subRateObject(new BigDecimal(config.getRateValue()), config.getCleanDays()); JSONObject domesticRate = subRateObject(config.getRateValue(), config.getCleanDays());
extParams.put("domestic_rate_value", domesticRate); extParams.put("domestic_rate_value", domesticRate);
configJson.put("ext_rates", extParams.toJSONString()); configJson.put("ext_rates", extParams.toJSONString());
} }

@ -5,16 +5,14 @@ import au.com.royalpay.payment.manage.merchants.core.ClientConfigService;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.merchants.events.ClientSignEvent; import au.com.royalpay.payment.manage.merchants.events.ClientSignEvent;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Date;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
/** /**
* Created by yixian on 2017-04-11. * Created by yixian on 2017-04-11.
@ -41,7 +39,7 @@ public class NewRateEventListener implements ApplicationListener<ClientSignEvent
rate.setActiveTime(new DateTime(2017, 5, 1, 0, 0, 0, 0).toDate()); rate.setActiveTime(new DateTime(2017, 5, 1, 0, 0, 0, 0).toDate());
rate.setExpiryTime(new DateTime(2018, 5, 1, 0, 0, 0, 0).toDate()); rate.setExpiryTime(new DateTime(2018, 5, 1, 0, 0, 0, 0).toDate());
rate.setCleanDays(currentRate.getInteger("clean_days") == null ? clientConfig.getIntValue("clean_days") : currentRate.getIntValue("clean_days")); rate.setCleanDays(currentRate.getInteger("clean_days") == null ? clientConfig.getIntValue("clean_days") : currentRate.getIntValue("clean_days"));
rate.setRateValue(Math.min(1.4, currentRate.getDoubleValue("rate_value"))); rate.setRateValue(BigDecimal.valueOf(1.4).min(currentRate.getBigDecimal("rate_value")));
JSONObject mockManager = new JSONObject(); JSONObject mockManager = new JSONObject();
mockManager.put("manager_id", 0); mockManager.put("manager_id", 0);
mockManager.put("display_name", "System"); mockManager.put("display_name", "System");

Loading…
Cancel
Save