|
|
|
@ -86,15 +86,22 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
|
|
|
|
|
log.put("total_amount", 0);
|
|
|
|
|
log.put("total_prize", 0);
|
|
|
|
|
log.put("total_donation", 0);
|
|
|
|
|
BigDecimal totalAmount = log.getBigDecimal("total_amount");
|
|
|
|
|
List<JSONObject> details = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, JSONObject> detail : resultItem.getValue().entrySet()) {
|
|
|
|
|
JSONObject detailItem = detail.getValue();
|
|
|
|
|
BigDecimal totalTransaction = detailItem.getBigDecimal("total_transaction");
|
|
|
|
|
BigDecimal coefficient = detailItem.getBigDecimal("coefficient");
|
|
|
|
|
BigDecimal realTransaction = totalTransaction.multiply(coefficient).setScale(2,BigDecimal.ROUND_DOWN);
|
|
|
|
|
totalAmount = totalAmount.add(realTransaction);
|
|
|
|
|
}
|
|
|
|
|
for (Map.Entry<String, JSONObject> detail : resultItem.getValue().entrySet()) {
|
|
|
|
|
JSONObject detailItem = detail.getValue();
|
|
|
|
|
int clientId = detailItem.getIntValue("client_id");
|
|
|
|
|
// int months = detailItem.getIntValue("client_create_months");
|
|
|
|
|
BigDecimal totalTransaction = detailItem.getBigDecimal("total_transaction");
|
|
|
|
|
BigDecimal coefficient = detailItem.getBigDecimal("coefficient");
|
|
|
|
|
BigDecimal realTransaction = totalTransaction.multiply(coefficient).setScale(2,BigDecimal.ROUND_DOWN);
|
|
|
|
|
int prizeLevel = getKpiPrizeLevel(realTransaction,log.getBigDecimal("kpi_amount"));
|
|
|
|
|
int prizeLevel = getKpiPrizeLevel(totalAmount,log.getBigDecimal("kpi_amount"));
|
|
|
|
|
BigDecimal bdRate = getNewRate(bdLevel, prizeLevel, detailItem.getIntValue("client_source"), detailItem.getBigDecimal("rate_value"));
|
|
|
|
|
BigDecimal prizeValue = totalTransaction.multiply(coefficient).multiply(bdRate).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_DOWN);
|
|
|
|
|
BigDecimal donation = BigDecimal.ZERO;
|
|
|
|
@ -231,7 +238,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int getKpiPrizeLevel(BigDecimal transactionAmount,BigDecimal kpiAmount){
|
|
|
|
|
if (kpiAmount.equals(BigDecimal.ZERO)){//未设置kpi金额的按照最小完成度来计算
|
|
|
|
|
if (kpiAmount.compareTo(BigDecimal.ZERO)==0){//未设置kpi金额的按照最小完成度来计算
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
BigDecimal rate = transactionAmount.divide(kpiAmount,2,BigDecimal.ROUND_HALF_DOWN);
|
|
|
|
|