diff --git a/pom.xml b/pom.xml index 9cd5a1ab9..822e1873a 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 2.3.50 + 2.3.55 UTF-8 2.4.0 diff --git a/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java index 062fdb8aa..581cce80b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java @@ -344,10 +344,10 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { int year = monthCal.get(Calendar.YEAR); int month = monthCal.get(Calendar.MONTH) + 1; - List list = financialPartnerCommissionMapper.list(year, month); - if (list != null && !list.isEmpty()) { - throw new ServerErrorException("请不要重复生成合伙人记录"); - } +// List list = financialPartnerCommissionMapper.list(year, month); +// if (list != null && !list.isEmpty()) { +// throw new ServerErrorException("请不要重复生成合伙人记录"); +// } financialPartnerCommissionDetailMapper.clearData(year, month, 1); financialPartnerCommissionMapper.clearData(year, month, 1); @@ -429,26 +429,73 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { JSONObject json = new JSONObject(); String channel = oneChannel.getKey(); if (orgInfo.get(channel.toLowerCase() + "_rate_value") == null) { - throw new ServerErrorException(orgInfo.getString("name") + "组织下" + oneChannel.getKey() + "成本手续费未设置"); + if(StringUtils.equals(channel.toLowerCase() + "_rate_value","rpaypmt_card_rate_value")){ + if(orgInfo.get("rpaypmt_domestic_card_rate_value")==null){ + throw new ServerErrorException(orgInfo.getString("name") + "组织下domestic_card成本手续费未设置"); + } + if(orgInfo.get("rpaypmt_overseas_card_rate_value")==null){ + throw new ServerErrorException(orgInfo.getString("name") + "组织下overseas_card成本手续费未设置"); + } + }else{ + throw new ServerErrorException(orgInfo.getString("name") + "组织下" + oneChannel.getKey() + "成本手续费未设置"); + + } } for (JSONObject params : oneChannel.getValue()) { - 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(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); + if(StringUtils.equals("rpaypmt_card",channel.toLowerCase())){ + //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")); + 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")); + + //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 = 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 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()); @@ -458,7 +505,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { json.put("net_charge", net_surage); json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value")); json.put("royalpay_charge", royalpay_surage); - json.put("org_charge", org_charge); + 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); @@ -549,32 +596,83 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { } for (JSONObject params : oneChannel.getValue()) { 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(channel.toLowerCase() + "_rate_value").divide(CommonConsts.HUNDRED, 4, RoundingMode.DOWN)); - BigDecimal tmpTotalSurcharge = params.getBigDecimal("total_surcharge").subtract(params.getBigDecimal("surcharge_cashback")); - //增加货币判断 - //增加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)) { + 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")); + 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"); + } + } + + 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")); + + //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(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(params.getBigDecimal("channel_surcharge")); + transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee")); + }else{ + BigDecimal 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")); + //增加货币判断 + //增加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)) { + 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")); } + } BigDecimal org_charge = total_surage.subtract(royalpay_surage); if (channel.toLowerCase().equals("alipay_direct")) { @@ -599,7 +697,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { if (type == 2) { json.put("org_net_charge", net_surage); } - json.put("org_charge", org_charge); + 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()); diff --git a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java index c8e9ddb51..29d5b3331 100644 --- a/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/riskbusiness/core/impl/RiskBusinessServiceImpl.java @@ -626,6 +626,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo sendAppRiskMessage(event); } } catch (Exception e) { + logger.error("Risk Email sending failed", e); throw new EmailException("Email Sending Failed", e); } });