|
|
|
@ -497,93 +497,211 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PayChannel payChannel = PayChannel.fromChannelCode(channel);
|
|
|
|
|
for (JSONObject params : oneChannel.getValue()) {
|
|
|
|
|
if (payChannel == PayChannel.RPAY_CHANNEL_CARD) {
|
|
|
|
|
//rpaypmt_domestic_card
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount");
|
|
|
|
|
BigDecimal channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("rpaypmt_domestic_card" + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
//增加transaction_fee为null异常
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
|
|
|
|
|
//rpaypmt_overseas_card
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("rpaypmt_overseas_card" + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
//增加transaction_fee为null异常
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|
total = total.add(tmpClearingAmount);
|
|
|
|
|
total_surage = total_surage.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
} else {
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount");
|
|
|
|
|
BigDecimal channelRate = null;
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("aliapy_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE || payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
Map<Boolean, List<JSONObject>> groupByPayType = oneChannel.getValue().stream().collect(Collectors.groupingBy(e -> e.getString("pay_type").equals("alipay_cn")));
|
|
|
|
|
for (Map.Entry<Boolean, List<JSONObject>> payType : groupByPayType.entrySet()) {
|
|
|
|
|
BigDecimal totalAps = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal total_surageAps = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal net_surageAps = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal royalpay_surageAps = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal transaction_feeAps = BigDecimal.ZERO;
|
|
|
|
|
JSONObject jsonAps = new JSONObject();
|
|
|
|
|
if (payType.getKey()) {
|
|
|
|
|
for (JSONObject params : payType.getValue()) {
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount");
|
|
|
|
|
BigDecimal channelRate = null;
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("aliapy_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//增加transaction_fee为null异常
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
totalAps = totalAps.add(tmpClearingAmount);
|
|
|
|
|
total_surageAps = total_surageAps.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surageAps = royalpay_surageAps.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
// net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
|
|
|
|
|
net_surageAps = net_surageAps.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
transaction_feeAps = transaction_feeAps.add(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
}
|
|
|
|
|
} else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
BigDecimal org_charge = total_surageAps.subtract(royalpay_surageAps);
|
|
|
|
|
jsonAps.put("channel", oneChannel.getKey() + ",alipayCN");
|
|
|
|
|
jsonAps.put("gross_amount", totalAps);
|
|
|
|
|
jsonAps.put("total_charge", total_surageAps);
|
|
|
|
|
jsonAps.put("transaction_fee", transaction_feeAps);
|
|
|
|
|
jsonAps.put("net_charge", net_surageAps);
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
jsonAps.put("org_rate", (orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))));
|
|
|
|
|
} else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
jsonAps.put("org_rate", (orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
jsonAps.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
jsonAps.put("royalpay_charge", royalpay_surageAps);
|
|
|
|
|
jsonAps.put("org_charge", org_charge.signum() < 0 ? new BigDecimal(0) : org_charge);
|
|
|
|
|
jsonAps.put("commission_type", "1");
|
|
|
|
|
jsonAps.put("create_time", new Date());
|
|
|
|
|
amountByChannel.add(jsonAps);
|
|
|
|
|
}
|
|
|
|
|
//增加transaction_fee为null异常
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
if (!payType.getKey()) {
|
|
|
|
|
for (JSONObject params : payType.getValue()) {
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount");
|
|
|
|
|
BigDecimal channelRate = null;
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("aliapy_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//增加transaction_fee为null异常
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
totalAps = totalAps.add(tmpClearingAmount);
|
|
|
|
|
total_surageAps = total_surageAps.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surageAps = royalpay_surageAps.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
// net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
|
|
|
|
|
net_surageAps = net_surageAps.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
transaction_feeAps = transaction_feeAps.add(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
}
|
|
|
|
|
BigDecimal org_charge = total_surageAps.subtract(royalpay_surageAps);
|
|
|
|
|
jsonAps.put("channel", oneChannel.getKey() + ",alipayOS");
|
|
|
|
|
jsonAps.put("gross_amount", totalAps);
|
|
|
|
|
jsonAps.put("total_charge", total_surageAps);
|
|
|
|
|
jsonAps.put("transaction_fee", transaction_feeAps);
|
|
|
|
|
jsonAps.put("net_charge", net_surageAps);
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
jsonAps.put("org_rate", (orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))));
|
|
|
|
|
} else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
jsonAps.put("org_rate", (orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))));
|
|
|
|
|
} else {
|
|
|
|
|
jsonAps.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
}
|
|
|
|
|
jsonAps.put("royalpay_charge", royalpay_surageAps);
|
|
|
|
|
jsonAps.put("org_charge", org_charge.signum() < 0 ? new BigDecimal(0) : org_charge);
|
|
|
|
|
jsonAps.put("commission_type", "1");
|
|
|
|
|
jsonAps.put("create_time", new Date());
|
|
|
|
|
amountByChannel.add(jsonAps);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
total = total.add(tmpClearingAmount);
|
|
|
|
|
total_surage = total_surage.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
// net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
|
|
|
|
|
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BigDecimal org_charge = total_surage.subtract(royalpay_surage);
|
|
|
|
|
json.put("channel", oneChannel.getKey());
|
|
|
|
|
json.put("gross_amount", total);
|
|
|
|
|
json.put("total_charge", total_surage);
|
|
|
|
|
json.put("transaction_fee", transaction_fee);
|
|
|
|
|
json.put("net_charge", net_surage);
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
json.put("org_rate", (orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))));
|
|
|
|
|
} else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
json.put("org_rate", (orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))));
|
|
|
|
|
} else {
|
|
|
|
|
json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
for (JSONObject params : oneChannel.getValue()) {
|
|
|
|
|
if (payChannel == PayChannel.RPAY_CHANNEL_CARD) {
|
|
|
|
|
//rpaypmt_domestic_card
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount");
|
|
|
|
|
BigDecimal channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("rpaypmt_domestic_card" + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
//增加transaction_fee为null异常
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
|
|
|
|
|
//rpaypmt_overseas_card
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("rpaypmt_overseas_card" + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
//增加transaction_fee为null异常
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|
total = total.add(tmpClearingAmount);
|
|
|
|
|
total_surage = total_surage.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
} else {
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount");
|
|
|
|
|
BigDecimal channelRate = null;
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("aliapy_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
} else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
//增加transaction_fee为null异常
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
total = total.add(tmpClearingAmount);
|
|
|
|
|
total_surage = total_surage.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
// net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
|
|
|
|
|
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BigDecimal org_charge = total_surage.subtract(royalpay_surage);
|
|
|
|
|
json.put("channel", oneChannel.getKey());
|
|
|
|
|
json.put("gross_amount", total);
|
|
|
|
|
json.put("total_charge", total_surage);
|
|
|
|
|
json.put("transaction_fee", transaction_fee);
|
|
|
|
|
json.put("net_charge", net_surage);
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
json.put("org_rate", (orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))));
|
|
|
|
|
} else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
json.put("org_rate", (orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))));
|
|
|
|
|
} else {
|
|
|
|
|
json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
}
|
|
|
|
|
json.put("royalpay_charge", royalpay_surage);
|
|
|
|
|
json.put("org_charge", org_charge.signum() < 0 ? new BigDecimal(0) : org_charge);
|
|
|
|
|
json.put("commission_type", "1");
|
|
|
|
|
json.put("create_time", new Date());
|
|
|
|
|
amountByChannel.add(json);
|
|
|
|
|
}
|
|
|
|
|
json.put("royalpay_charge", royalpay_surage);
|
|
|
|
|
json.put("org_charge", org_charge.signum() < 0 ? new BigDecimal(0) : org_charge);
|
|
|
|
|
json.put("commission_type", "1");
|
|
|
|
|
json.put("create_time", new Date());
|
|
|
|
|
amountByChannel.add(json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return amountByChannel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -662,13 +780,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
public List<JSONObject> clientChannelAmount(int clientId, JSONObject orgInfo, Map<String, List<JSONObject>> channelMap, JSONObject channelCharge, int year, int month, int type) {
|
|
|
|
|
List<JSONObject> amountByChannel = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, List<JSONObject>> oneChannel : channelMap.entrySet()) {
|
|
|
|
|
String recordId = "";
|
|
|
|
|
if (type == 1) {
|
|
|
|
|
recordId = financialPartnerCommissionMapper.getRecordId(orgInfo.getInteger("org_id"), year, month, oneChannel.getKey());
|
|
|
|
|
}
|
|
|
|
|
if (type == 2) {
|
|
|
|
|
recordId = financialAgentCommissionMapper.getRecordId(orgInfo.getInteger("org_id"), year, month, oneChannel.getKey());
|
|
|
|
|
}
|
|
|
|
|
BigDecimal total = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal total_surage = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal net_surage = BigDecimal.ZERO;
|
|
|
|
@ -692,138 +803,337 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
}
|
|
|
|
|
PayChannel payChannel = PayChannel.fromChannelCode(channel);
|
|
|
|
|
for (JSONObject params : oneChannel.getValue()) {
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount");
|
|
|
|
|
if (StringUtils.equals(channel.toLowerCase() + "_rate_value", "rpaypmt_card_rate_value")) {
|
|
|
|
|
//rpaypmt_domestic_card
|
|
|
|
|
BigDecimal channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("rpaypmt_domestic_card_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
if (total.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
dateto = params.getDate("transaction_time");
|
|
|
|
|
} else {
|
|
|
|
|
if (params.getDate("transaction_time").before(datefrom)) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE || payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
Map<Boolean, List<JSONObject>> groupByPayType = oneChannel.getValue().stream().collect(Collectors.groupingBy(e -> e.getString("pay_type").equals("alipay_cn")));
|
|
|
|
|
for (Map.Entry<Boolean, List<JSONObject>> payType : groupByPayType.entrySet()) {
|
|
|
|
|
if (payType.getKey()) {
|
|
|
|
|
String recordId = financialPartnerCommissionMapper.getRecordId(orgInfo.getInteger("org_id"), year, month, oneChannel.getKey() + ",alipayCN");
|
|
|
|
|
BigDecimal total_aps = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal total_surage_aps = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal net_surage_aps = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal royalpay_surage_aps = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal transaction_fee_aps = BigDecimal.ZERO;
|
|
|
|
|
Date datefrom_aps = new Date();
|
|
|
|
|
Date dateto_aps = new Date();
|
|
|
|
|
JSONObject json_aps = new JSONObject();
|
|
|
|
|
for (JSONObject params : payType.getValue()) {
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount");
|
|
|
|
|
BigDecimal channelRate = BigDecimal.ZERO;
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("aliapy_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|
//增加transaction_fee为null异常
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
if (total_aps.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
datefrom_aps = params.getDate("transaction_time");
|
|
|
|
|
dateto_aps = params.getDate("transaction_time");
|
|
|
|
|
} else {
|
|
|
|
|
if (params.getDate("transaction_time").before(datefrom)) {
|
|
|
|
|
datefrom_aps = params.getDate("transaction_time");
|
|
|
|
|
}
|
|
|
|
|
if (params.getDate("transaction_time").after(dateto)) {
|
|
|
|
|
dateto_aps = params.getDate("transaction_time");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
total_aps = total_aps.add(tmpClearingAmount);
|
|
|
|
|
total_surage_aps = total_surage_aps.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surage_aps = royalpay_surage_aps.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
//net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
|
|
|
|
|
net_surage_aps = net_surage_aps.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
transaction_fee_aps = transaction_fee_aps.add(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
}
|
|
|
|
|
if (params.getDate("transaction_time").after(dateto)) {
|
|
|
|
|
dateto = params.getDate("transaction_time");
|
|
|
|
|
BigDecimal org_charge = total_surage_aps.subtract(royalpay_surage_aps);
|
|
|
|
|
if (channel.toLowerCase().equals("alipay_direct")) {
|
|
|
|
|
channel = channel.replace("_", "");
|
|
|
|
|
}
|
|
|
|
|
json_aps.put("channel", oneChannel.getKey() + ",alipayCN");
|
|
|
|
|
json_aps.put("record_id", recordId);
|
|
|
|
|
json_aps.put("client_id", clientId);
|
|
|
|
|
if (clientRate != null) {
|
|
|
|
|
json_aps.put("client_rate", clientRate.getBigDecimal("rate_value"));
|
|
|
|
|
} else {
|
|
|
|
|
json_aps.put("client_rate", oneChannel.getValue().get(0).getBigDecimal("surcharge_rate").multiply(CommonConsts.HUNDRED));
|
|
|
|
|
}
|
|
|
|
|
json_aps.put("gross_amount", total);
|
|
|
|
|
json_aps.put("total_charge", total_surage);
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
json_aps.put("org_rate", (orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))));
|
|
|
|
|
} else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
json_aps.put("org_rate", (orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))));
|
|
|
|
|
} else {
|
|
|
|
|
json_aps.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
}
|
|
|
|
|
json_aps.put("royalpay_charge", royalpay_surage_aps);
|
|
|
|
|
if (type == 1) {
|
|
|
|
|
json_aps.put("net_charge", net_surage_aps);
|
|
|
|
|
}
|
|
|
|
|
if (type == 2) {
|
|
|
|
|
json_aps.put("org_net_charge", net_surage_aps);
|
|
|
|
|
}
|
|
|
|
|
json_aps.put("org_charge", org_charge.signum() < 0 ? new BigDecimal(0) : org_charge);
|
|
|
|
|
json_aps.put("transaction_fee", transaction_fee_aps);
|
|
|
|
|
json_aps.put("commission_type", "1");
|
|
|
|
|
json_aps.put("create_time", new Date());
|
|
|
|
|
json_aps.put("date_from", DateFormatUtils.format(datefrom_aps, "yyyy-MM-dd"));
|
|
|
|
|
json_aps.put("date_to", DateFormatUtils.format(dateto_aps, "yyyy-MM-dd"));
|
|
|
|
|
json_aps.put("year", year);
|
|
|
|
|
json_aps.put("month", month);
|
|
|
|
|
amountByChannel.add(json_aps);
|
|
|
|
|
}
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
//rpaypmt_overseas_card
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("rpaypmt_overseas_card_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
tmpTotalSurcharge = params.getBigDecimal("total_surcharge").subtract(params.getBigDecimal("surcharge_cashback"));
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
if (!payType.getKey()) {
|
|
|
|
|
String recordId = financialPartnerCommissionMapper.getRecordId(orgInfo.getInteger("org_id"), year, month, oneChannel.getKey() + ",alipayOS");
|
|
|
|
|
BigDecimal total_aps = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal total_surage_aps = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal net_surage_aps = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal royalpay_surage_aps = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal transaction_fee_aps = BigDecimal.ZERO;
|
|
|
|
|
Date datefrom_aps = new Date();
|
|
|
|
|
Date dateto_aps = new Date();
|
|
|
|
|
JSONObject json_aps = new JSONObject();
|
|
|
|
|
for (JSONObject params : payType.getValue()) {
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount");
|
|
|
|
|
BigDecimal channelRate = BigDecimal.ZERO;
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("aliapy_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|
//增加transaction_fee为null异常
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
if (total_aps.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
datefrom_aps = params.getDate("transaction_time");
|
|
|
|
|
dateto_aps = params.getDate("transaction_time");
|
|
|
|
|
} else {
|
|
|
|
|
if (params.getDate("transaction_time").before(datefrom)) {
|
|
|
|
|
datefrom_aps = params.getDate("transaction_time");
|
|
|
|
|
}
|
|
|
|
|
if (params.getDate("transaction_time").after(dateto)) {
|
|
|
|
|
dateto_aps = params.getDate("transaction_time");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
total_aps = total_aps.add(tmpClearingAmount);
|
|
|
|
|
total_surage_aps = total_surage_aps.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surage_aps = royalpay_surage_aps.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
//net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
|
|
|
|
|
net_surage_aps = net_surage_aps.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
transaction_fee_aps = transaction_fee_aps.add(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
}
|
|
|
|
|
BigDecimal org_charge = total_surage_aps.subtract(royalpay_surage_aps);
|
|
|
|
|
if (channel.toLowerCase().equals("alipay_direct")) {
|
|
|
|
|
channel = channel.replace("_", "");
|
|
|
|
|
}
|
|
|
|
|
json_aps.put("channel", oneChannel.getKey() + ",alipayOS");
|
|
|
|
|
json_aps.put("record_id", recordId);
|
|
|
|
|
json_aps.put("client_id", clientId);
|
|
|
|
|
if (clientRate != null) {
|
|
|
|
|
json_aps.put("client_rate", clientRate.getBigDecimal("rate_value"));
|
|
|
|
|
} else {
|
|
|
|
|
json_aps.put("client_rate", oneChannel.getValue().get(0).getBigDecimal("surcharge_rate").multiply(CommonConsts.HUNDRED));
|
|
|
|
|
}
|
|
|
|
|
json_aps.put("gross_amount", total);
|
|
|
|
|
json_aps.put("total_charge", total_surage);
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
json_aps.put("org_rate", (orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))));
|
|
|
|
|
} else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
json_aps.put("org_rate", (orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))));
|
|
|
|
|
} else {
|
|
|
|
|
json_aps.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
}
|
|
|
|
|
json_aps.put("royalpay_charge", royalpay_surage_aps);
|
|
|
|
|
if (type == 1) {
|
|
|
|
|
json_aps.put("net_charge", net_surage_aps);
|
|
|
|
|
}
|
|
|
|
|
if (type == 2) {
|
|
|
|
|
json_aps.put("org_net_charge", net_surage_aps);
|
|
|
|
|
}
|
|
|
|
|
json_aps.put("org_charge", org_charge.signum() < 0 ? new BigDecimal(0) : org_charge);
|
|
|
|
|
json_aps.put("transaction_fee", transaction_fee_aps);
|
|
|
|
|
json_aps.put("commission_type", "1");
|
|
|
|
|
json_aps.put("create_time", new Date());
|
|
|
|
|
json_aps.put("date_from", DateFormatUtils.format(datefrom_aps, "yyyy-MM-dd"));
|
|
|
|
|
json_aps.put("date_to", DateFormatUtils.format(dateto_aps, "yyyy-MM-dd"));
|
|
|
|
|
json_aps.put("year", year);
|
|
|
|
|
json_aps.put("month", month);
|
|
|
|
|
amountByChannel.add(json_aps);
|
|
|
|
|
}
|
|
|
|
|
if (total.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
dateto = params.getDate("transaction_time");
|
|
|
|
|
} else {
|
|
|
|
|
if (params.getDate("transaction_time").before(datefrom)) {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
String recordId = "";
|
|
|
|
|
if (type == 1) {
|
|
|
|
|
recordId = financialPartnerCommissionMapper.getRecordId(orgInfo.getInteger("org_id"), year, month, oneChannel.getKey());
|
|
|
|
|
}
|
|
|
|
|
if (type == 2) {
|
|
|
|
|
recordId = financialAgentCommissionMapper.getRecordId(orgInfo.getInteger("org_id"), year, month, oneChannel.getKey());
|
|
|
|
|
}
|
|
|
|
|
for (JSONObject params : oneChannel.getValue()) {
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBooleanValue("customer_surcharge") ? params.getBigDecimal("settle_amount") : params.getBigDecimal("clearing_amount");
|
|
|
|
|
if (StringUtils.equals(channel.toLowerCase() + "_rate_value", "rpaypmt_card_rate_value")) {
|
|
|
|
|
//rpaypmt_domestic_card
|
|
|
|
|
BigDecimal channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("rpaypmt_domestic_card_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
if (total.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
dateto = params.getDate("transaction_time");
|
|
|
|
|
} else {
|
|
|
|
|
if (params.getDate("transaction_time").before(datefrom)) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
}
|
|
|
|
|
if (params.getDate("transaction_time").after(dateto)) {
|
|
|
|
|
dateto = params.getDate("transaction_time");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
//rpaypmt_overseas_card
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("rpaypmt_overseas_card_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
tmpTotalSurcharge = params.getBigDecimal("total_surcharge").subtract(params.getBigDecimal("surcharge_cashback"));
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
if (params.getDate("transaction_time").after(dateto)) {
|
|
|
|
|
if (total.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
dateto = params.getDate("transaction_time");
|
|
|
|
|
} else {
|
|
|
|
|
if (params.getDate("transaction_time").before(datefrom)) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
}
|
|
|
|
|
if (params.getDate("transaction_time").after(dateto)) {
|
|
|
|
|
dateto = params.getDate("transaction_time");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
total = total.add(tmpClearingAmount);
|
|
|
|
|
total_surage = total_surage.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
} else {
|
|
|
|
|
BigDecimal channelRate;
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("aliapy_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
total = total.add(tmpClearingAmount);
|
|
|
|
|
total_surage = total_surage.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
} else {
|
|
|
|
|
BigDecimal channelRate;
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("aliapy_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
} else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
} else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
if ("alipay_cn".equalsIgnoreCase(params.getString("pay_type"))) {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : ((orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))).divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|
//增加transaction_fee为null异常
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
channelRate = params.get("org_rate") != null ? params.getBigDecimal("org_rate") : (orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN));
|
|
|
|
|
}
|
|
|
|
|
BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge")
|
|
|
|
|
.subtract(params.getBigDecimal("surcharge_cashback"))
|
|
|
|
|
.subtract(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|
//增加transaction_fee为null异常
|
|
|
|
|
if (!params.containsKey("transaction_fee") || StringUtils.isEmpty(params.getString("transaction_fee"))) {
|
|
|
|
|
params.put("transaction_fee", BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
if (total.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
dateto = params.getDate("transaction_time");
|
|
|
|
|
} else {
|
|
|
|
|
if (params.getDate("transaction_time").before(datefrom)) {
|
|
|
|
|
int i = currencyScale(params.getString("clearing_currency"));
|
|
|
|
|
if (total.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
}
|
|
|
|
|
if (params.getDate("transaction_time").after(dateto)) {
|
|
|
|
|
dateto = params.getDate("transaction_time");
|
|
|
|
|
} else {
|
|
|
|
|
if (params.getDate("transaction_time").before(datefrom)) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
}
|
|
|
|
|
if (params.getDate("transaction_time").after(dateto)) {
|
|
|
|
|
dateto = params.getDate("transaction_time");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
total = total.add(tmpClearingAmount);
|
|
|
|
|
total_surage = total_surage.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
//net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
|
|
|
|
|
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
total = total.add(tmpClearingAmount);
|
|
|
|
|
total_surage = total_surage.add(tmpTotalSurcharge).setScale(i, RoundingMode.HALF_UP);
|
|
|
|
|
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
|
|
|
|
|
//net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
|
|
|
|
|
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
|
|
|
|
|
transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee"));
|
|
|
|
|
}
|
|
|
|
|
BigDecimal org_charge = total_surage.subtract(royalpay_surage);
|
|
|
|
|
if (channel.toLowerCase().equals("alipay_direct")) {
|
|
|
|
|
channel = channel.replace("_", "");
|
|
|
|
|
}
|
|
|
|
|
json.put("channel", oneChannel.getKey());
|
|
|
|
|
|
|
|
|
|
json.put("record_id", recordId);
|
|
|
|
|
json.put("client_id", clientId);
|
|
|
|
|
if (clientRate != null) {
|
|
|
|
|
json.put("client_rate", clientRate.getBigDecimal("rate_value"));
|
|
|
|
|
} else {
|
|
|
|
|
json.put("client_rate", oneChannel.getValue().get(0).getBigDecimal("surcharge_rate").multiply(CommonConsts.HUNDRED));
|
|
|
|
|
}
|
|
|
|
|
json.put("gross_amount", total);
|
|
|
|
|
json.put("total_charge", total_surage);
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
json.put("org_rate", (orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))));
|
|
|
|
|
} else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
json.put("org_rate", (orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))));
|
|
|
|
|
} else {
|
|
|
|
|
json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
}
|
|
|
|
|
json.put("royalpay_charge", royalpay_surage);
|
|
|
|
|
if (type == 1) {
|
|
|
|
|
json.put("net_charge", net_surage);
|
|
|
|
|
}
|
|
|
|
|
if (type == 2) {
|
|
|
|
|
json.put("org_net_charge", net_surage);
|
|
|
|
|
}
|
|
|
|
|
json.put("org_charge", org_charge.signum() < 0 ? new BigDecimal(0) : org_charge);
|
|
|
|
|
json.put("transaction_fee", transaction_fee);
|
|
|
|
|
json.put("commission_type", "1");
|
|
|
|
|
json.put("create_time", new Date());
|
|
|
|
|
json.put("date_from", DateFormatUtils.format(datefrom, "yyyy-MM-dd"));
|
|
|
|
|
json.put("date_to", DateFormatUtils.format(dateto, "yyyy-MM-dd"));
|
|
|
|
|
json.put("year", year);
|
|
|
|
|
json.put("month", month);
|
|
|
|
|
amountByChannel.add(json);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal org_charge = total_surage.subtract(royalpay_surage);
|
|
|
|
|
if (channel.toLowerCase().equals("alipay_direct")) {
|
|
|
|
|
channel = channel.replace("_", "");
|
|
|
|
|
}
|
|
|
|
|
json.put("channel", oneChannel.getKey());
|
|
|
|
|
|
|
|
|
|
json.put("record_id", recordId);
|
|
|
|
|
json.put("client_id", clientId);
|
|
|
|
|
if (clientRate != null) {
|
|
|
|
|
json.put("client_rate", clientRate.getBigDecimal("rate_value"));
|
|
|
|
|
} else {
|
|
|
|
|
json.put("client_rate", oneChannel.getValue().get(0).getBigDecimal("surcharge_rate").multiply(CommonConsts.HUNDRED));
|
|
|
|
|
}
|
|
|
|
|
json.put("gross_amount", total);
|
|
|
|
|
json.put("total_charge", total_surage);
|
|
|
|
|
if (payChannel == PayChannel.ALIPAY_APS_IN_STORE) {
|
|
|
|
|
json.put("org_rate", (orgInfo.getBigDecimal("retail_interchange_fee_value").add(orgInfo.getBigDecimal("retail_service_fee_value"))));
|
|
|
|
|
} else if (payChannel == PayChannel.ALIPAY_APS_CASHIER) {
|
|
|
|
|
json.put("org_rate", (orgInfo.getBigDecimal("online_interchange_fee_value").add(orgInfo.getBigDecimal("online_service_fee_value"))));
|
|
|
|
|
} else {
|
|
|
|
|
json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
}
|
|
|
|
|
json.put("royalpay_charge", royalpay_surage);
|
|
|
|
|
if (type == 1) {
|
|
|
|
|
json.put("net_charge", net_surage);
|
|
|
|
|
}
|
|
|
|
|
if (type == 2) {
|
|
|
|
|
json.put("org_net_charge", net_surage);
|
|
|
|
|
}
|
|
|
|
|
json.put("org_charge", org_charge.signum() < 0 ? new BigDecimal(0) : org_charge);
|
|
|
|
|
json.put("transaction_fee", transaction_fee);
|
|
|
|
|
json.put("commission_type", "1");
|
|
|
|
|
json.put("create_time", new Date());
|
|
|
|
|
json.put("date_from", DateFormatUtils.format(datefrom, "yyyy-MM-dd"));
|
|
|
|
|
json.put("date_to", DateFormatUtils.format(dateto, "yyyy-MM-dd"));
|
|
|
|
|
json.put("year", year);
|
|
|
|
|
json.put("month", month);
|
|
|
|
|
amountByChannel.add(json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return amountByChannel;
|
|
|
|
|