|
|
|
@ -78,7 +78,7 @@ public class BDPrizeServiceImpl implements BDPrizeService {
|
|
|
|
|
|
|
|
|
|
private static BigDecimal percent = new BigDecimal(100);
|
|
|
|
|
|
|
|
|
|
private static String[] channels = new String[]{"Wechat", "Alipay", "Bestpay", "jd", "AlipayOnline"};
|
|
|
|
|
private static String[] channels = new String[]{"Wechat", "Alipay", "Bestpay", "jd", "AlipayOnline","hf"};
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void generateRecord() {
|
|
|
|
@ -133,10 +133,14 @@ public class BDPrizeServiceImpl implements BDPrizeService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//BD Leader Prize
|
|
|
|
|
//bd_type:1 销售总监 2 大客户经理 3悉尼分公司经理 4 COO 5 NGDepartment
|
|
|
|
|
//todo 10月开始悉尼分公司经理不享受悉尼销售组提成
|
|
|
|
|
List<JSONObject> bdLeaders = managerMapper.listByRole(1, ManagerRole.BD_LEADER.getMask());
|
|
|
|
|
for (JSONObject leader : bdLeaders) {
|
|
|
|
|
BigDecimal groupAmount = transactionMapper.TotalAmountForBDLeaderPrize(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1,leader.getString("manager_id"));
|
|
|
|
|
JSONObject rateJson = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, groupAmount.toString(), 1);
|
|
|
|
|
JSONObject bdConfig = financialBDConfigMapper.getBdConfig(leader.getString("manager_id"));
|
|
|
|
|
int bd_type = ("Sydney").equals(bdConfig.getString("city"))?2:1;//sydney leader 即悉尼大客户经理
|
|
|
|
|
JSONObject rateJson = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, groupAmount.toString(), bd_type);
|
|
|
|
|
BigDecimal groupPrize = new BigDecimal(0);
|
|
|
|
|
if (rateJson != null) {
|
|
|
|
|
groupPrize = groupAmount.multiply(new BigDecimal(rateJson.getString("commission_rate")).divide(percent)).setScale(2, BigDecimal.ROUND_DOWN);
|
|
|
|
@ -212,28 +216,44 @@ public class BDPrizeServiceImpl implements BDPrizeService {
|
|
|
|
|
|
|
|
|
|
DateTime monthDate = new DateTime(month);
|
|
|
|
|
//bd manager commission
|
|
|
|
|
JSONObject cityPrizeLog = new JSONObject();
|
|
|
|
|
cityPrizeLog.put("total_amount", cplTotalprize);
|
|
|
|
|
JSONObject cplRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, cplTotalprize.toString(), 2);
|
|
|
|
|
if (cplRate == null) {
|
|
|
|
|
cityPrizeLog.put("total_prize", 0.00);
|
|
|
|
|
// JSONObject cityPrizeLog = new JSONObject();
|
|
|
|
|
// cityPrizeLog.put("total_amount", cplTotalprize);
|
|
|
|
|
// JSONObject cplRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, cplTotalprize.toString(), 2);
|
|
|
|
|
// if (cplRate == null) {
|
|
|
|
|
// cityPrizeLog.put("total_prize", 0.00);
|
|
|
|
|
// } else {
|
|
|
|
|
// BigDecimal _commission_rate = new BigDecimal(cplRate.getString("commission_rate"));
|
|
|
|
|
// BigDecimal _total_amount = new BigDecimal(cityPrizeLog.getString("total_amount"));
|
|
|
|
|
// BigDecimal total_prize = _total_amount.multiply(_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN);
|
|
|
|
|
// cityPrizeLog.put("total_prize", total_prize);
|
|
|
|
|
// }
|
|
|
|
|
// report.put("cityPrizeLogs", cityPrizeLog);
|
|
|
|
|
|
|
|
|
|
//bd_type=3 悉尼分公司经理 悉尼销售组和大客户组流水提成
|
|
|
|
|
|
|
|
|
|
JSONObject sydneyPrizeLog = new JSONObject();
|
|
|
|
|
BigDecimal sydneyAmount = transactionMapper.TotalAmountForSydneyGMPrize(monthDate.getYear(), monthDate.getMonthOfYear());
|
|
|
|
|
sydneyPrizeLog.put("total_amount",sydneyAmount);
|
|
|
|
|
JSONObject sydneyGMRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, sydneyAmount.toString(), 3);
|
|
|
|
|
if (sydneyGMRate == null) {
|
|
|
|
|
sydneyPrizeLog.put("total_prize", 0.00);
|
|
|
|
|
} else {
|
|
|
|
|
BigDecimal _commission_rate = new BigDecimal(cplRate.getString("commission_rate"));
|
|
|
|
|
BigDecimal _total_amount = new BigDecimal(cityPrizeLog.getString("total_amount"));
|
|
|
|
|
BigDecimal total_prize = _total_amount.multiply(_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN);
|
|
|
|
|
cityPrizeLog.put("total_prize", total_prize);
|
|
|
|
|
BigDecimal sydney_commission_rate = new BigDecimal(sydneyGMRate.getString("commission_rate"));
|
|
|
|
|
BigDecimal total_prize = sydneyAmount.multiply(sydney_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN);
|
|
|
|
|
sydneyPrizeLog.put("total_prize", total_prize);
|
|
|
|
|
}
|
|
|
|
|
report.put("cityPrizeLogs", cityPrizeLog);
|
|
|
|
|
report.put("sydneyPrizeLog", sydneyPrizeLog);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Director commission
|
|
|
|
|
JSONObject directPrizeLogs = new JSONObject();
|
|
|
|
|
//COO & NJ commission
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
|
params.put("begin", TimeZoneUtils.beginDate(TimeZoneUtils.getFirstDay(monthDate.toString())));
|
|
|
|
|
params.put("end", TimeZoneUtils.getPerFirstDayOfMonth(TimeZoneUtils.getLastDay(monthDate.toString())));
|
|
|
|
|
BigDecimal totalprize = transactionAnalysisMapper.analysisTotalAmount(params);
|
|
|
|
|
|
|
|
|
|
JSONObject directPrizeLogs = new JSONObject();
|
|
|
|
|
directPrizeLogs.put("total_amount", totalprize);
|
|
|
|
|
JSONObject rate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, totalprize.toString(), 3);
|
|
|
|
|
JSONObject rate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, totalprize.toString(), 4);
|
|
|
|
|
if (rate == null) {
|
|
|
|
|
directPrizeLogs.put("total_prize", 0.00);
|
|
|
|
|
} else {
|
|
|
|
@ -243,6 +263,18 @@ public class BDPrizeServiceImpl implements BDPrizeService {
|
|
|
|
|
directPrizeLogs.put("total_prize", total_prize);
|
|
|
|
|
}
|
|
|
|
|
report.put("directPrizeLogs", directPrizeLogs);
|
|
|
|
|
|
|
|
|
|
JSONObject ngDepartmentPrizeLog = new JSONObject();
|
|
|
|
|
ngDepartmentPrizeLog.put("total_amount", totalprize);
|
|
|
|
|
JSONObject ngRate = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, totalprize.toString(), 5);
|
|
|
|
|
if (ngRate == null) {
|
|
|
|
|
ngDepartmentPrizeLog.put("total_prize", 0.00);
|
|
|
|
|
} else {
|
|
|
|
|
BigDecimal ng_commission_rate = new BigDecimal(ngRate.getString("commission_rate"));
|
|
|
|
|
BigDecimal ng_total_prize = totalprize.multiply(ng_commission_rate.divide(percent)).setScale(2, BigDecimal.ROUND_DOWN);
|
|
|
|
|
ngDepartmentPrizeLog.put("total_prize", ng_total_prize);
|
|
|
|
|
}
|
|
|
|
|
report.put("ngDepartmentPrizeLog", ngDepartmentPrizeLog);
|
|
|
|
|
return report;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|