fix 代理商提成APS特殊处理:1、代理商提成表内的Aps的channel存了2个数据(例如:ApsInStore,alipayCN。后面区分大陆钱包【alipayCN】或者海外钱包【alipayOS】)。2、

master
Todking 3 years ago
parent e5898e5ec6
commit 7de58bbeb2

@ -497,6 +497,124 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
}
}
PayChannel payChannel = PayChannel.fromChannelCode(channel);
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"));
}
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 {
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);
}
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);
}
}
} else {
for (JSONObject params : oneChannel.getValue()) {
if (payChannel == PayChannel.RPAY_CHANNEL_CARD) {
//rpaypmt_domestic_card
@ -583,7 +701,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
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,6 +803,204 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
} catch (Exception e) {
}
PayChannel payChannel = PayChannel.fromChannelCode(channel);
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"));
}
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);
}
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);
}
}
} 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")) {
@ -825,6 +1134,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
json.put("month", month);
amountByChannel.add(json);
}
}
return amountByChannel;
}

@ -15,6 +15,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by yixian on 2017-03-08.
@ -28,6 +29,7 @@ public class CityPartnerPrizeController {
/**
*
*
* @param param
*/
@PostMapping("/generate")
@ -79,6 +81,7 @@ public class CityPartnerPrizeController {
int type = 1;
ArrayList<JSONObject> objectAlipayPlus = new ArrayList<>();
ArrayList<Object> unGmos = new ArrayList<>();
ArrayList<JSONObject> aps = new ArrayList<>();
for (JSONObject jsonObject : entry.getValue()) {
grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount"));
totalCharge = totalCharge.add(jsonObject.getBigDecimal("total_charge"));
@ -94,6 +97,8 @@ public class CityPartnerPrizeController {
if (StringUtils.equalsAny(jsonObject.getString("channel"), "alipay_cn", "alipay_ac_sg", "alipay_ac_mo", "alipay_ac_hk", "alipay_ac_lu", "alipay_ac_gb", "alipay_ac_us", "paytm", "kakaopay", "truemoney", "ezlink", "gcash", "tng", "dana", "easy_paisa", "bkash", "lazada_wallet_my")) {
jsonObject.put("channel", AlipayPlusChannelEnum.statusOf(jsonObject.getString("channel")).description());
objectAlipayPlus.add(jsonObject);
} else if (StringUtils.equalsAny(jsonObject.getString("channel"), "ApsInStore,alipayCN", "ApsInStore,alipayOS", "ApsCashier,alipayCN", "ApsCashier,alipayOS")) {
aps.add(jsonObject);
} else {
unGmos.add(jsonObject);
}
@ -128,6 +133,12 @@ public class CityPartnerPrizeController {
totalAlipayPlus.put("AlipayPlus", objectAlipayPlus);
unGmos.add(totalAlipayPlus);
}
if(aps.size() != 0){
List<JSONObject> apsInfo = getApsInfo(aps, monthStr);
for (JSONObject jsonObject : apsInfo) {
unGmos.add(jsonObject);
}
}
sumResult.put("channel_detail", unGmos);
resultTotalCharge = resultTotalCharge.add(totalCharge);
resultRoyalpayCharge = resultRoyalpayCharge.add(royalpayCharge);
@ -150,6 +161,51 @@ public class CityPartnerPrizeController {
return result;
}
private List<JSONObject> getApsInfo(List<JSONObject> partnerPrizes, String monthStr) {
for (JSONObject prize : partnerPrizes) {
String[] channels = prize.getString("channel").split(",");
if (channels.length == 2) {
prize.put("channel", channels[0]);
prize.put("pay_type", channels[1]);
}
}
List<JSONObject> apsInfo = new ArrayList<>();
Map<String, List<JSONObject>> groupByChannel = partnerPrizes.stream().collect(Collectors.groupingBy(e -> e.getString("channel")));
for (Map.Entry<String, List<JSONObject>> channel : groupByChannel.entrySet()) {
if (channel.getKey().equals("ApsInStore") || channel.getKey().equals("ApsCashier")) {
JSONObject sumAps = new JSONObject();
sumAps.put("gross_amount", 0);
sumAps.put("total_charge", 0);
sumAps.put("royalpay_charge", 0);
sumAps.put("org_charge", 0);
sumAps.put("net_charge", 0);
sumAps.put("share_charge", 0);
for (JSONObject aps : channel.getValue()) {
plusKey(sumAps, aps, "gross_amount");
plusKey(sumAps, aps, "total_charge");
if (aps.get("parent_org_id") == null) {
aps.put("org_charge", aps.getBigDecimal("org_charge").add(aps.getBigDecimal("share_charge")));
}
plusKey(sumAps, aps, "royalpay_charge");
plusKey(sumAps, aps, "org_charge");
plusKey(sumAps, aps, "net_charge");
plusKey(sumAps, aps, "share_charge");
aps.put("monthstr", monthStr);
}
sumAps.put("org_rate", channel.getValue().get(0).getString("org_rate"));
sumAps.put("channel", channel.getKey());
sumAps.put("monthstr", monthStr);
sumAps.put("sunAps", channel.getValue());
apsInfo.add(sumAps);
}
}
return apsInfo;
}
private void plusKey(JSONObject sum, JSONObject prize, String key) {
sum.put(key, sum.getBigDecimal(key).add(prize.getBigDecimal(key)));
}
@ManagerMapping("/months/{monthStr}/orgs/{orgId}")
public JSONObject getCityPartnerPrizeDetail(@PathVariable String monthStr, @PathVariable String orgId) {
return cityPartnerPrizeService.getCityPartnerPrizeDetail(monthStr, orgId);
@ -262,8 +318,6 @@ public class CityPartnerPrizeController {
}
JSONObject result = new JSONObject();
List<JSONObject> partnerInfos = new ArrayList<>(partenerPrizeMap.size());
BigDecimal resultGrossAmount = BigDecimal.ZERO;

@ -178,6 +178,7 @@ define(['angular', '../../analysis/org/analysis-org'], function (angular) {
$scope.commissionTypeMap = commissionTypeMap
$scope.seniors = {}
$scope.isAlipayPlus = false
$scope.isAps = false
$scope.active = function (log) {
$http.get('/sys/citypartner_prizes/senior/' + log.org_id + '/details?monthStr=' + $scope.monthData.monthstr).then(function (resp) {
$scope.seniors = resp.data
@ -189,6 +190,10 @@ define(['angular', '../../analysis/org/analysis-org'], function (angular) {
})
$scope.isAlipayPlus = false
}
$scope.activeAps = function (apsInfo){
$scope.ctrl.apsInfo = apsInfo
$scope.isAps = true
}
$scope.activeAlipayPlus= function (detail){
$scope.isAlipayPlus = !$scope.isAlipayPlus
if($scope.isAlipayPlus){

@ -122,11 +122,16 @@
<td ng-bind="detail.org_charge"></td>
<td ng-bind="detail.share_charge"></td>
<td>
{{detail.channel}}
<span ng-if="detail.channel == 'ApsInStore'">A+(Retail)</span>
<span ng-if="detail.channel == 'ApsCashier'">A+(Online)</span>
<span ng-if="detail.channel != 'ApsCashier'&& detail.channel != 'ApsInStore'">{{detail.channel}}</span>
<a role="button" ng-if="detail.channel == 'alipayPlus'"
ng-click="activeAlipayPlus(detail)">
<i class="fa fa-list-ul"></i>
</a>
<a role="button" ng-if="detail.sunAps" ng-click="activeAps(detail.sunAps)">
<i class="fa fa-list-ul"></i>
</a>
</td>
</tr>
</tbody>
@ -198,6 +203,47 @@
</tr>
</tbody>
</table>
<table ng-if="isAps"
class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Keep Rate</th>
<th>Transaction Amount</th>
<th>Total Charge</th>
<th>RoyalPay Charge</th>
<th>Net Charge</th>
<th>City Partner Charge</th>
<th>Share Charge</th>
<th>channel</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="aps in ctrl.apsInfo">
<td ng-bind="aps.org_rate"></td>
<td ng-bind="aps.gross_amount"></td>
<td ng-bind="aps.total_charge"></td>
<td ng-bind="aps.royalpay_charge"></td>
<td ng-bind="aps.net_charge"></td>
<td ng-bind="aps.org_charge"></td>
<td ng-bind="aps.share_charge"></td>
<td ng-if="aps.pay_type == 'alipayCN'">AlipayCN
<!-- <a ng-if="!aps.parent_org_id" role="button"-->
<!-- ng-href="/sys/citypartners/client/extract/{{aps.org_id}}/excel?year={{aps.year}}&month={{aps.month}}&channel={{aps.channel}}"-->
<!-- target="_blank" title="Download Transactions">-->
<!-- <i class="fa fa-download"></i>-->
<!-- </a>-->
<!-- <a ng-if="aps.parent_org_id" role="button"-->
<!-- ng-href="/sys/citypartners/client/extract/{{aps.org_id}}/agent/excel?year={{aps.year}}&month={{aps.month}}&channel={{aps.channel}}"-->
<!-- target="_blank" title="Download Transactions">-->
<!-- <i class="fa fa-download"></i>-->
<!-- </a>-->
</td>
<td ng-if="aps.pay_type == 'alipayOS'">Other wallets</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>

Loading…
Cancel
Save