|
|
|
@ -443,36 +443,40 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
}
|
|
|
|
|
for (JSONObject params : oneChannel.getValue()) {
|
|
|
|
|
if(StringUtils.equals("rpaypmt_card",channel.toLowerCase())){
|
|
|
|
|
covertOrgChangeAmount(params,orgInfo,"rpaypmt_domestic_card",total,total_surage,royalpay_surage,net_surage,transaction_fee);
|
|
|
|
|
covertOrgChangeAmount(params,orgInfo,"rpaypmt_overseas_card",total,total_surage,royalpay_surage,net_surage,transaction_fee);
|
|
|
|
|
}else{
|
|
|
|
|
covertOrgChangeAmount(params,orgInfo,channel,total,total_surage,royalpay_surage,net_surage,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);
|
|
|
|
|
json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
json.put("royalpay_charge", royalpay_surage);
|
|
|
|
|
json.put("org_charge", org_charge);
|
|
|
|
|
json.put("commission_type", "1");
|
|
|
|
|
json.put("create_time", new Date());
|
|
|
|
|
amountByChannel.add(json);
|
|
|
|
|
//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"));
|
|
|
|
|
|
|
|
|
|
return amountByChannel;
|
|
|
|
|
//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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void covertOrgChangeAmount(JSONObject params ,JSONObject orgInfo,String channel,
|
|
|
|
|
BigDecimal total,
|
|
|
|
|
BigDecimal total_surage,
|
|
|
|
|
BigDecimal royalpay_surage,
|
|
|
|
|
BigDecimal net_surage,
|
|
|
|
|
BigDecimal transaction_fee){
|
|
|
|
|
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异常
|
|
|
|
@ -490,6 +494,24 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
// 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);
|
|
|
|
|
json.put("org_rate", orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
json.put("royalpay_charge", royalpay_surage);
|
|
|
|
|
json.put("org_charge", org_charge);
|
|
|
|
|
json.put("commission_type", "1");
|
|
|
|
|
json.put("create_time", new Date());
|
|
|
|
|
amountByChannel.add(json);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return amountByChannel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<JSONObject> parentOrgChannelAmount(JSONObject orgInfo, JSONObject parentOrgInfo, Map<String, List<JSONObject>> channelMap, JSONObject channelCharge) {
|
|
|
|
@ -574,16 +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");
|
|
|
|
|
if(orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value") == null){
|
|
|
|
|
System.out.println("Rate_value======================="+orgInfo.getBigDecimal(channel.toLowerCase() + "_rate_value"));
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.equals(channel.toLowerCase() + "_rate_value","rpaypmt_card_rate_value")){
|
|
|
|
|
convertChildOrgChannelAmount(params,orgInfo,"rpaypmt_domestic_card",total,total_surage,royalpay_surage,net_surage,transaction_fee,datefrom,dateto,tmpClearingAmount);
|
|
|
|
|
convertChildOrgChannelAmount(params,orgInfo,"rpaypmt_overseas_card",total,total_surage,royalpay_surage,net_surage,transaction_fee,datefrom,dateto,tmpClearingAmount);
|
|
|
|
|
//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 (total.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
datefrom = params.getDate("transaction_time");
|
|
|
|
|
dateto = params.getDate("transaction_time");
|
|
|
|
|
} else {
|
|
|
|
|
convertChildOrgChannelAmount(params,orgInfo,channel,total,total_surage,royalpay_surage,net_surage,transaction_fee,datefrom,dateto,tmpClearingAmount);
|
|
|
|
|
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 = 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")) {
|
|
|
|
@ -622,42 +711,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
return amountByChannel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void convertChildOrgChannelAmount(JSONObject params ,JSONObject orgInfo,String channel,
|
|
|
|
|
BigDecimal total,
|
|
|
|
|
BigDecimal total_surage,
|
|
|
|
|
BigDecimal royalpay_surage,
|
|
|
|
|
BigDecimal net_surage,
|
|
|
|
|
BigDecimal transaction_fee,
|
|
|
|
|
Date datefrom, Date dateto,
|
|
|
|
|
BigDecimal tmpClearingAmount ){
|
|
|
|
|
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"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int currencyScale(String currency) {
|
|
|
|
|
int i = 0;
|
|
|
|
|
switch (currency) {
|
|
|
|
|