|
|
|
@ -10,9 +10,11 @@ import au.com.royalpay.payment.manage.mappers.financial.FinancialPartnerCommissi
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialPartnerCommissionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialPartnerCommissionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialReferrerCommissionDetailMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialReferrerCommissionDetailMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialReferrerCommissionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialReferrerCommissionMapper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialSeniorPartnerCommissionDetailMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialSeniorPartnerCommissionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialSeniorPartnerCommissionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.CommonConsts;
|
|
|
|
import au.com.royalpay.payment.tools.env.SysConfigManager;
|
|
|
|
import au.com.royalpay.payment.tools.env.SysConfigManager;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
@ -30,6 +32,7 @@ import java.text.ParseException;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.HashSet;
|
|
|
|
@ -64,6 +67,8 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
private SysConfigManager sysConfigManager;
|
|
|
|
private SysConfigManager sysConfigManager;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private FinancialSeniorPartnerCommissionMapper financialSeniorPartnerCommissionMapper;
|
|
|
|
private FinancialSeniorPartnerCommissionMapper financialSeniorPartnerCommissionMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private FinancialSeniorPartnerCommissionDetailMapper financialSeniorPartnerCommissionDetailMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<JSONObject> listAvailableMonths(String year) {
|
|
|
|
public List<JSONObject> listAvailableMonths(String year) {
|
|
|
|
@ -239,7 +244,14 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
result.put("total_charge", resultTotalCharge);
|
|
|
|
result.put("total_charge", resultTotalCharge);
|
|
|
|
result.put("royalPay_charge", resultRoyalpayCharge);
|
|
|
|
result.put("royalPay_charge", resultRoyalpayCharge);
|
|
|
|
result.put("net_charge", resultNetCharge);
|
|
|
|
result.put("net_charge", resultNetCharge);
|
|
|
|
|
|
|
|
result.put("own_charge", resultOrgCharge);
|
|
|
|
|
|
|
|
JSONObject senior = financialSeniorPartnerCommissionMapper.find(year, month, orgId);
|
|
|
|
|
|
|
|
if (senior != null) {
|
|
|
|
|
|
|
|
result.put("senior_partner_charge", senior.getBigDecimal("gross_amount"));
|
|
|
|
|
|
|
|
result.put("city_partner_charge", resultOrgCharge.add(senior.getBigDecimal("gross_amount")));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
result.put("city_partner_charge", resultOrgCharge);
|
|
|
|
result.put("city_partner_charge", resultOrgCharge);
|
|
|
|
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -252,7 +264,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
int year = monthCal.get(Calendar.YEAR);
|
|
|
|
int year = monthCal.get(Calendar.YEAR);
|
|
|
|
int month = monthCal.get(Calendar.MONTH) + 1;
|
|
|
|
int month = monthCal.get(Calendar.MONTH) + 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
BigDecimal alipayChargeRate = new BigDecimal("0.6");
|
|
|
|
BigDecimal alipayChargeRate = new BigDecimal("0.6");
|
|
|
|
BigDecimal wechatChargeRate = new BigDecimal("0.6");
|
|
|
|
BigDecimal wechatChargeRate = new BigDecimal("0.6");
|
|
|
|
@ -292,7 +303,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
financialPartnerCommissionDetailMapper.clearData(year, month, org.getIntValue("commission_type"));
|
|
|
|
financialPartnerCommissionDetailMapper.clearData(year, month, org.getIntValue("commission_type"));
|
|
|
|
financialPartnerCommissionMapper.clearData(year, month, org.getIntValue("commission_type"));
|
|
|
|
financialPartnerCommissionMapper.clearData(year, month, org.getIntValue("commission_type"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String key = analysisDay.getString("channel");
|
|
|
|
String key = analysisDay.getString("channel");
|
|
|
|
String channel = analysisDay.getString("channel");
|
|
|
|
String channel = analysisDay.getString("channel");
|
|
|
|
if (!channelMap.containsKey(key)) {
|
|
|
|
if (!channelMap.containsKey(key)) {
|
|
|
|
@ -322,6 +332,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
generateAgent(monthStr, p);
|
|
|
|
generateAgent(monthStr, p);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
generateReferrer(monthStr);
|
|
|
|
generateReferrer(monthStr);
|
|
|
|
|
|
|
|
generateSenior(monthStr);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
new Thread(task).start();
|
|
|
|
new Thread(task).start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -704,6 +715,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
public void generateSenior(String monthStr) {
|
|
|
|
public void generateSenior(String monthStr) {
|
|
|
|
List<String> seniorOrgs = orgMapper.listSeniorOrgId(0);
|
|
|
|
List<String> seniorOrgs = orgMapper.listSeniorOrgId(0);
|
|
|
|
if (CollectionUtils.isEmpty(seniorOrgs)) {
|
|
|
|
if (CollectionUtils.isEmpty(seniorOrgs)) {
|
|
|
|
@ -715,24 +727,32 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
int year = monthCal.get(Calendar.YEAR);
|
|
|
|
int year = monthCal.get(Calendar.YEAR);
|
|
|
|
int month = monthCal.get(Calendar.MONTH) + 1;
|
|
|
|
int month = monthCal.get(Calendar.MONTH) + 1;
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
BigDecimal rate = sysConfig.getBigDecimal("senior_charge_rate");
|
|
|
|
BigDecimal rate = sysConfig.getBigDecimal("senior_charge_rate").divide(CommonConsts.HUNDRED);
|
|
|
|
if (rate == null) {
|
|
|
|
if (rate == null) {
|
|
|
|
rate = new BigDecimal("0.0006");
|
|
|
|
rate = new BigDecimal("0.0006");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
Date now = new Date();
|
|
|
|
List<JSONObject> seniorOrgAnalysis = financialPartnerCommissionMapper.analysisSenior(year,month,seniorOrgs);
|
|
|
|
financialSeniorPartnerCommissionMapper.clearData(year, month);
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal finalRate = rate;
|
|
|
|
BigDecimal finalRate = rate;
|
|
|
|
seniorOrgAnalysis.parallelStream().forEach(p->{
|
|
|
|
seniorOrgs.parallelStream().forEach(p -> {
|
|
|
|
|
|
|
|
List<String> seniorSubOrgs = orgMapper.listSeniorOrgId(Integer.parseInt(p));
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(seniorSubOrgs)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject seniorOrgAnalysis = financialPartnerCommissionMapper.analysisSeniorForGenerate(year, month, seniorSubOrgs);
|
|
|
|
JSONObject record = new JSONObject();
|
|
|
|
JSONObject record = new JSONObject();
|
|
|
|
record.put("org_id",p.getString("org_id"));
|
|
|
|
record.put("org_id", p);
|
|
|
|
record.put("year", year);
|
|
|
|
record.put("year", year);
|
|
|
|
record.put("month", month);
|
|
|
|
record.put("month", month);
|
|
|
|
record.put("create_time", now);
|
|
|
|
record.put("create_time", now);
|
|
|
|
record.put("org_rate", finalRate);
|
|
|
|
record.put("org_rate", finalRate.multiply(CommonConsts.HUNDRED));
|
|
|
|
record.put("gross_amount",p.getBigDecimal("gross_amount"));
|
|
|
|
record.put("gross_amount", seniorOrgAnalysis.getBigDecimal("gross_amount"));
|
|
|
|
|
|
|
|
record.put("net_charge", seniorOrgAnalysis.getBigDecimal("gross_amount").multiply(finalRate));
|
|
|
|
financialSeniorPartnerCommissionMapper.save(record);
|
|
|
|
financialSeniorPartnerCommissionMapper.save(record);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@ -743,9 +763,19 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
|
|
|
|
int year = monthCal.get(Calendar.YEAR);
|
|
|
|
int year = monthCal.get(Calendar.YEAR);
|
|
|
|
int month = monthCal.get(Calendar.MONTH) + 1;
|
|
|
|
int month = monthCal.get(Calendar.MONTH) + 1;
|
|
|
|
List<String> orgs = orgMapper.listSeniorOrgId(param.getIntValue("org_id"));
|
|
|
|
List<String> orgs = orgMapper.listSeniorOrgId(param.getIntValue("org_id"));
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(orgs)) {
|
|
|
|
|
|
|
|
return Collections.EMPTY_LIST;
|
|
|
|
|
|
|
|
}
|
|
|
|
List<JSONObject> result = financialPartnerCommissionMapper.analysisSenior(year, month, orgs);
|
|
|
|
List<JSONObject> result = financialPartnerCommissionMapper.analysisSenior(year, month, orgs);
|
|
|
|
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
|
|
|
|
BigDecimal rate = sysConfig.getBigDecimal("senior_charge_rate").divide(CommonConsts.HUNDRED);
|
|
|
|
|
|
|
|
if (rate == null) {
|
|
|
|
|
|
|
|
rate = new BigDecimal("0.0006");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BigDecimal finalRate = rate;
|
|
|
|
result.parallelStream().forEach(p -> {
|
|
|
|
result.parallelStream().forEach(p -> {
|
|
|
|
p.put("gross_amount",p.getBigDecimal("gross_amount").multiply(new BigDecimal("0.0005")).setScale(2, BigDecimal.ROUND_HALF_DOWN));
|
|
|
|
p.put("net_charge", p.getBigDecimal("gross_amount").multiply(finalRate).setScale(2, BigDecimal.ROUND_HALF_DOWN));
|
|
|
|
|
|
|
|
p.put("org_rate", finalRate.multiply(CommonConsts.HUNDRED));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|