fix BD Commissions

master
yuan 6 years ago
parent 9d39e2cad6
commit 0a13bcd876

@ -145,7 +145,7 @@ public class BDPrizeServiceImpl implements BDPrizeService {
for (JSONObject leader : bdLeaders) {
BigDecimal groupAmount = transactionMapper.TotalAmountForBDLeaderPrize(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1,leader.getString("manager_id"));
JSONObject bdConfig = financialBDConfigMapper.getBdConfig(leader.getString("manager_id"));
int bd_type = ("Sydney").equals(bdConfig.getString("city"))?2:1;//sydney leader 即悉尼大客户经理
int bd_type = bdConfig ==null?2:("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) {

@ -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);

@ -19,7 +19,7 @@ public interface FinancialBDPrizeLogMapper {
@AutoSql(type = SqlType.INSERT)
void save(JSONObject log);
@Select("SELECT fbpl.prize_log_id,fbpl.record_id,fbpl.manager_id,fbpl.bd_name,fbpl.bd_level,SUM(fbpl.total_amount) total_amount, " +
@Select("SELECT fbpl.prize_log_id,fbpl.record_id,fbpl.manager_id,fbpl.bd_name,fbpl.kpi_amount,fbpl.bd_level,SUM(fbpl.total_amount) total_amount, " +
"SUM(fbpl.total_prize) total_prize,SUM(fbpl.total_donation) total_donation, SUM(fbpl.send_prize) send_prize, " +
"SUM(fbpl.hold_prize) hold_prize,fbpl.last_punish,fbpl.prize_type,sysm.is_valid FROM financial_bd_prize_log fbpl, " +
"sys_managers sysm " +

@ -504,7 +504,7 @@
<select id="TotalAmountForBDLeaderPrize" resultType="java.math.BigDecimal">
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))
ifnull(sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)),0)
total
FROM pmt_transactions t
INNER JOIN pmt_orders o ON o.order_id = t.order_id

@ -75,7 +75,6 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
};
$scope.getYearReports(new Date().getFullYear());
$scope.generateReport = function () {
$scope.generate.status = {};
if (!$scope.generate.month) {
commonDialog.alert({
type: 'error', title: 'Error', content: 'Select a month first!'
@ -86,13 +85,15 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
title: 'Warning',
content: 'This operation will clear the result of last month generated before. Are you sure?'
}).then(function () {
$scope.generate.status = {};
var params = {month: $filter('date')($scope.generate.month, 'yyyy-MM')};
$http.post('/sys/bd_prize/generate_record/'+params.month, null, {timeout: 60000}).then(function () {
$http.post('/sys/bd_prize/generate_record/'+params.month, null, {timeout: 60000}).then(function (resp) {
$scope.generate.status = null;
commonDialog.alert({title: 'Success', content: 'Generate Finished', type: 'success'});
$scope.getYearReports($scope.params.year);
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
$scope.generate.status = null;
})
})
};

@ -91,8 +91,11 @@
<tbody>
<tr ng-repeat="log in report.logs|prizeLogsFilter:0">
<td ng-if="log.is_valid==1">{{log.bd_name}}</td>
<td>{{log.kpi_amount}}</td>
<td ng-if="log.is_valid==0"><s>{{log.bd_name}}</s><span style="color: red"> (Left Company)</span></td>
<td>
<span ng-if="log.kpi_amount">{{log.kpi_amount}}</span>
<span ng-if="!log.kpi_amount">0.00</span>
</td>
<td ng-bind="log.bd_level|financialBdLevel"></td>
<td>{{log.total_amount|currency:'AUD '}}</td>
<td ng-bind="log.total_prize|currency:'AUD '"></td>

Loading…
Cancel
Save