|
|
|
@ -429,7 +429,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
List<JSONObject> transactionDetail = transactionMapper.listTransactionForCityPartnerCommissionByDate(year, month);
|
|
|
|
|
Map<Integer, List<JSONObject>> groupByOrgMap = transactionDetail.stream().collect(Collectors.groupingBy(e -> e.getInteger("org_id")));
|
|
|
|
|
for (Map.Entry<Integer, List<JSONObject>> oneOrg : groupByOrgMap.entrySet()) {
|
|
|
|
|
|
|
|
|
|
int orgId = oneOrg.getKey();
|
|
|
|
|
JSONObject org = orgMapper.findOne(orgId);
|
|
|
|
|
if (org == null) {
|
|
|
|
@ -440,8 +439,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
generateold(monthStr);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<JSONObject> items = oneOrg.getValue();
|
|
|
|
|
Map<String, List<JSONObject>> groupByChannelMap = items.stream().collect(Collectors.groupingBy(e -> e.getString("channel")));
|
|
|
|
|
List<JSONObject> channelAmount = orgChannelAmount(org, groupByChannelMap, channelCharge);
|
|
|
|
@ -450,23 +447,18 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
channel.put("month", month);
|
|
|
|
|
channel.put("year", year);
|
|
|
|
|
channel.put("org_id", orgId);
|
|
|
|
|
|
|
|
|
|
financialPartnerCommissionMapper.save(channel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Map<Integer, List<JSONObject>> groupByClientMap = transactionDetail.stream().collect(Collectors.groupingBy(e -> e.getInteger("client_id")));
|
|
|
|
|
for (Map.Entry<Integer, List<JSONObject>> oneClient : groupByClientMap.entrySet()) {
|
|
|
|
|
|
|
|
|
|
JSONObject org = orgMapper.findOne(oneClient.getValue().get(0).getInteger("org_id"));
|
|
|
|
|
Map<String, List<JSONObject>> groupByChannel = oneClient.getValue().stream().collect(Collectors.groupingBy(e -> e.getString("channel")));
|
|
|
|
|
|
|
|
|
|
List<JSONObject> clientChannelAmount = clientChannelAmount(oneClient.getKey(), org, groupByChannel, channelCharge, year, month, 1);
|
|
|
|
|
for (JSONObject channel : clientChannelAmount) {
|
|
|
|
|
financialPartnerCommissionDetailMapper.save(channel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Runnable task = () -> {
|
|
|
|
|
generateAgent(monthStr, channelCharge);
|
|
|
|
|
generateReferrer(monthStr);
|
|
|
|
@ -479,7 +471,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
|
|
|
|
|
public List<JSONObject> orgChannelAmount(JSONObject orgInfo, Map<String, List<JSONObject>> channelMap, JSONObject channelCharge) {
|
|
|
|
|
List<JSONObject> amountByChannel = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, List<JSONObject>> oneChannel : channelMap.entrySet()) {
|
|
|
|
|
BigDecimal total = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal total_surage = BigDecimal.ZERO;
|
|
|
|
@ -487,7 +478,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
BigDecimal royalpay_surage = BigDecimal.ZERO;
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
String channel = oneChannel.getKey();
|
|
|
|
|
|
|
|
|
|
if ("hf".equals(oneChannel.getKey().toLowerCase()) || "yeepay".equals(oneChannel.getKey().toLowerCase()) || "lakalapay".equals(oneChannel.getKey().toLowerCase())) {
|
|
|
|
|
channel = "cb_bankpay";
|
|
|
|
|
if (orgInfo.get("cb_bankpay_rate_value") == null) {
|
|
|
|
@ -498,9 +488,8 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
throw new ServerErrorException(orgInfo.getString("name") + "组织下" + oneChannel.getKey() + "成本手续费未设置");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (JSONObject params : oneChannel.getValue()) {
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBigDecimal("clearing_amount");
|
|
|
|
|
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"));
|
|
|
|
|
//增加货币判断
|
|
|
|
@ -543,7 +532,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
channel = "cb_bankpay";
|
|
|
|
|
}
|
|
|
|
|
for (JSONObject params : oneChannel.getValue()) {
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBigDecimal("clearing_amount");
|
|
|
|
|
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"));
|
|
|
|
|
//增加货币判断
|
|
|
|
@ -578,7 +567,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
//type 1:一级代理 2:二级代理
|
|
|
|
|
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) {
|
|
|
|
@ -607,7 +595,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
}
|
|
|
|
|
for (JSONObject params : oneChannel.getValue()) {
|
|
|
|
|
BigDecimal tmpClearingAmount = params.getBigDecimal("clearing_amount");
|
|
|
|
|
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"));
|
|
|
|
|
//增加货币判断
|
|
|
|
|