fix BD Commissions

master
yuan 6 years ago
parent 57efcab231
commit 9b031f73bb

@ -38,4 +38,6 @@ public interface BDPrizeService {
void insertOrUpdateCommissionConfig(String month, List<JSONObject> config, JSONObject manager) throws ParseException; void insertOrUpdateCommissionConfig(String month, List<JSONObject> config, JSONObject manager) throws ParseException;
void deleteCommConfig(String config_id); void deleteCommConfig(String config_id);
void updateBdKpiConfig(List<JSONObject> configs, JSONObject manager)throws ParseException;
} }

@ -418,5 +418,12 @@ public class BDPrizeServiceImpl implements BDPrizeService {
return firLasDay; return firLasDay;
} }
@Override
public void updateBdKpiConfig(List<JSONObject> configs, JSONObject manager) throws ParseException {
for (JSONObject config : configs){
config.put("LAST_UPDATE_DATE", new Date());
config.put("LAST_UPDATE_BY", manager.getString("display_name"));
financialBDConfigMapper.updateBDConfig(config);
}
}
} }

@ -81,6 +81,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
JSONObject bd = bdMap.get(resultItem.getKey()); JSONObject bd = bdMap.get(resultItem.getKey());
int bdLevel = bd.getIntValue("bd_level"); int bdLevel = bd.getIntValue("bd_level");
log.put("bd_level", bdLevel); log.put("bd_level", bdLevel);
log.put("kpi_amount", bd.getBigDecimal("kpi_amount"));
log.put("bd_name", bd.getString("bd_name")); log.put("bd_name", bd.getString("bd_name"));
log.put("total_amount", 0); log.put("total_amount", 0);
log.put("total_prize", 0); log.put("total_prize", 0);

@ -92,4 +92,9 @@ public class BDPrizeController {
public List<JSONObject> newCommissionConfig(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) throws ParseException { public List<JSONObject> newCommissionConfig(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) throws ParseException {
return bdPrizeService.listNeedConfigCommission(); return bdPrizeService.listNeedConfigCommission();
} }
@ManagerMapping(value = "/commission/kpi/update/{month}",method = RequestMethod.POST, role = {ManagerRole.FINANCIAL_STAFF, ManagerRole.ADMIN})
public void updatKpiConfig(@PathVariable String month , @RequestBody List<JSONObject> info , @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) throws ParseException {
bdPrizeService.updateBdKpiConfig(info,manager);
}
} }

@ -8,7 +8,7 @@
</select> </select>
<select id="getReport" resultType="com.alibaba.fastjson.JSONObject"> <select id="getReport" resultType="com.alibaba.fastjson.JSONObject">
SELECT SELECT
r.*, r.*,l.kpi_amount,
sum(total_prize) total_prize, sum(total_prize) total_prize,
sum(send_prize) total_send_prize, sum(send_prize) total_send_prize,
sum(total_donation) total_donation sum(total_donation) total_donation

@ -20,7 +20,8 @@
SELECT SELECT
b.*, b.*,
c.bd_level, c.bd_level,
c.get_prize c.get_prize,
c.kpi_amount
FROM sys_client_bd b FROM sys_client_bd b
LEFT JOIN financial_bd_config c ON c.manager_id = b.bd_id LEFT JOIN financial_bd_config c ON c.manager_id = b.bd_id
WHERE client_id = #{client_id} AND start_date <= #{date} AND (end_date > #{date} OR end_date IS NULL) AND WHERE client_id = #{client_id} AND start_date <= #{date} AND (end_date > #{date} OR end_date IS NULL) AND

@ -106,7 +106,8 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
rates: function () { rates: function () {
return angular.copy($scope.bd_rate_configs); return angular.copy($scope.bd_rate_configs);
} }
} },
size:'lg'
}).result.then(function () { }).result.then(function () {
$scope.loadRateConfigs(); $scope.loadRateConfigs();
}) })
@ -136,7 +137,9 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
value: 3, value: 3,
label: '>=7 Months' label: '>=7 Months'
}]; }];
$scope.filter = {bd_level: 1, months: 1}; $scope.kpiRanges = [{value: 1, label: '<50%'}, {value: 2, label: '50%<=kpi<80%'}, {value: 3, label: '80%<=kpi<100%'},
{value: 4, label: '100%<=kpi<120%'}, {value: 5, label: '>=120%'}];
$scope.filter = {bd_level: 1, months: 1,kpi_range:1};
$scope.rates = rates; $scope.rates = rates;
$scope.submitRates = function () { $scope.submitRates = function () {
var validation = null; var validation = null;
@ -191,7 +194,7 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
app.controller('bdCommissionConfigCtrl', ['$scope', '$state', '$http', '$filter', 'monModal', function ($scope, $state, $http, $filter, monModal) { app.controller('bdCommissionConfigCtrl', ['$scope', '$state', '$http', '$filter', 'monModal', function ($scope, $state, $http, $filter, monModal) {
$scope.monModal = monModal; $scope.monModal = monModal;
$scope.params = {year: new Date().getFullYear()}; $scope.params = {year: new Date().getFullYear()};
$scope.bdtypes = [{id: 1, label: 'Leader'}, {id: 2, label: 'Manager'}, {id: 3, label: 'Director'}]; $scope.bdtypes = [{id: 1, label: 'Director'}, {id: 2, label: 'Manager'}, {id: 3, label: 'Sydney GM'},{id: 4, label: 'COO'},{id: 5, label: 'NJ Department'}];
// $scope.bdmon; // $scope.bdmon;
// $scope.newSwitch; // $scope.newSwitch;
$scope.initMonth = function (year) { $scope.initMonth = function (year) {
@ -209,6 +212,12 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
var end = $filter('date')(new Date(), 'yyyy-MM'); var end = $filter('date')(new Date(), 'yyyy-MM');
return start <= mon && end >= mon return start <= mon && end >= mon
}; };
$scope.getBDLevels = function () {
$http.get('/sys/bd_prize/config/bd_levels').then(function (resp) {
$scope.bds = resp.data;
})
};
$scope.getBDLevels();
$scope.listCurrentMonBDCommission = function (mon) { $scope.listCurrentMonBDCommission = function (mon) {
$http.get('/sys/bd_prize/commission/le_ma/' + mon).then(function (resp) { $http.get('/sys/bd_prize/commission/le_ma/' + mon).then(function (resp) {
$scope.bdlm = resp.data; $scope.bdlm = resp.data;
@ -266,6 +275,22 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
}) })
} }
} }
$scope.submitBdCommmissionConfig = function (mon, bds) {
$scope.check = true;
angular.forEach(bds, function (data, index) {
$scope.errmsg = null;
if (!data.kpi_amount) {
$scope.errmsg = "BD kpi Amount not be null";
$scope.check = false;
return;
}
});
if ($scope.check) {
$http.post('/sys/bd_prize/commission/kpi/update/' + mon, bds).then(function (resp) {
$scope.$close();
})
}
}
}]); }]);
app.controller('bdPrizeMonthReportCtrl', ['$scope', '$http', 'report', function ($scope, $http, report) { app.controller('bdPrizeMonthReportCtrl', ['$scope', '$http', 'report', function ($scope, $http, report) {
$scope.report = report.data; $scope.report = report.data;

@ -1,54 +1,82 @@
<div class="modal-header"> <div class="modal-header">
<h4>Leader Commission Config</h4> <h4>Commission Config</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<!--<div class="alert alert-danger" ng-bind="errmsg" ng-if="errmsg"></div>--> <!--<div class="alert alert-danger" ng-bind="errmsg" ng-if="errmsg"></div>-->
<div class="table-responsive"> <button class="btn btn-primary" ng-bind="bdmon" style="margin-bottom: 10px"></button>
<button class="btn btn-primary" ng-bind="bdmon"></button> <uib-tabset>
<table class="table table-hover"> <uib-tab heading="Leader">
<thead> <div class="table-responsive margin-top">
<tr> <table class="table table-hover">
<th>Commission Amount</th> <thead>
<th>Commission Rate</th> <tr>
<th>BD Type</th> <th>Commission Amount</th>
<th> <th>Commission Rate</th>
<span class="fa fa-plus" style="color: #0bb20c" ng-click="bdlm.push({})"></span> <th>BD Type</th>
</th> <th>
</tr> <span class="fa fa-plus" style="color: #0bb20c" ng-click="bdlm.push({})"></span>
</thead> </th>
<tbody> </tr>
<tr ng-repeat="bd in bdlm"> </thead>
<td class="col-sm-5"> <tbody>
<div class="input-group"> <tr ng-repeat="bd in bdlm">
<input class="form-control" id="re-from-input" type="number" <td class="col-sm-5">
ng-model="bd.commission_start_amount" <div class="input-group">
placeholder="Start Amount"> <input class="form-control" id="re-from-input" type="number"
<span class="input-group-addon">~</span> ng-model="bd.commission_start_amount"
<input class="form-control" id="re-to-input" type="number" placeholder="Start Amount">
ng-model="bd.commission_end_amount" <span class="input-group-addon">~</span>
placeholder="End Amount"> <input class="form-control" id="re-to-input" type="number"
</div> ng-model="bd.commission_end_amount"
</td> placeholder="End Amount">
<td class="col-sm-3"> </div>
<div class="input-group"> </td>
<input placeholder="rate" class="form-control" type="number" step="0.01" <td class="col-sm-3">
ng-model="bd.bd_commission_rate"> <div class="input-group">
<span class="input-group-addon">%</span> <input placeholder="rate" class="form-control" type="number" step="0.01"
</div> ng-model="bd.bd_commission_rate">
</td> <span class="input-group-addon">%</span>
<td> </div>
<select class="form-control" ng-model="bd.bd_type" ng-options="bdtype.id as bdtype.label for bdtype in bdtypes"></select> </td>
</td> <td>
<td> <select class="form-control" ng-model="bd.bd_type" ng-options="bdtype.id as bdtype.label for bdtype in bdtypes"></select>
<span class="fa fa-close" style="color: #b92c28" ng-click="deleteCommission(bd.bc_config_id)"></span> </td>
</td> <td>
</tr> <span class="fa fa-close" style="color: #b92c28" ng-click="deleteCommission(bd.bc_config_id)"></span>
</tbody> </td>
</table> </tr>
<div class="alert alert-danger" ng-if="errmsg" ng-bind="errmsg"></div> </tbody>
<div class="modal-footer" ng-if="listConfig"> </table>
<button class="btn btn-success" type="button" ng-click="submitCommmissionConfig(bdmon,bdlm)">Submit</button> <div class="alert alert-danger" ng-if="errmsg" ng-bind="errmsg"></div>
<button class="btn btn-danger" ng-click="$dismiss()">Cancel</button> <div class="modal-footer" ng-if="listConfig">
</div> <button class="btn btn-success" type="button" ng-click="submitCommmissionConfig(bdmon,bdlm)">Submit</button>
</div> <button class="btn btn-danger" ng-click="$dismiss()">Cancel</button>
</div>
</div>
</uib-tab>
<uib-tab heading="BD">
<table class="table table-hover" style="text-align: center">
<thead>
<tr>
<th style="text-align: center;">BD Name</th>
<th style="text-align: center;">KPI Amount</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="bd in bds">
<td ng-bind="bd.display_name"></td>
<td>
<input ng-model="bd.kpi_amount">
</td>
</tr>
</tbody>
</table>
<div class="alert alert-danger" ng-if="errmsg" ng-bind="errmsg"></div>
<div class="modal-footer">
<button class="btn btn-success" type="button" ng-click="submitBdCommmissionConfig(bdmon,bds)">Submit</button>
<button class="btn btn-danger" ng-click="$dismiss()">Cancel</button>
</div>
</uib-tab>
</uib-tabset>
</div> </div>

@ -79,6 +79,7 @@
<thead> <thead>
<tr> <tr>
<th>BD Name</th> <th>BD Name</th>
<th>KPI</th>
<th>BD Level</th> <th>BD Level</th>
<th>Transaction Amount</th> <th>Transaction Amount</th>
<th>Total Commission</th> <th>Total Commission</th>
@ -90,9 +91,10 @@
<tbody> <tbody>
<tr ng-repeat="log in report.logs|prizeLogsFilter:0"> <tr ng-repeat="log in report.logs|prizeLogsFilter:0">
<td ng-if="log.is_valid==1">{{log.bd_name}}</td> <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 ng-if="log.is_valid==0"><s>{{log.bd_name}}</s><span style="color: red"> (Left Company)</span></td>
<td ng-bind="log.bd_level|financialBdLevel"></td> <td ng-bind="log.bd_level|financialBdLevel"></td>
<td ng-bind="log.total_amount|currency:'AUD '"></td> <td>{{log.total_amount|currency:'AUD '}} (({{log.total_amount}}/{{log.kpi_amount}})|percentage)</td>
<td ng-bind="log.total_prize|currency:'AUD '"></td> <td ng-bind="log.total_prize|currency:'AUD '"></td>
<td ng-bind="log.send_prize|currency:'AUD '"></td> <td ng-bind="log.send_prize|currency:'AUD '"></td>
<td> <td>

@ -36,15 +36,15 @@
<div class="col-xs-2" ng-repeat="mon in months"> <div class="col-xs-2" ng-repeat="mon in months">
<a ng-if="hasReport(mon) && ('1000'|withRole)"> <a ng-if="hasReport(mon) && ('1000'|withRole)">
<h2 ROLE="button" class="text-success" ui-sref=".month_report({month:mon})" ng-bind="mon.substring(5,7)"></h2> <h2 ROLE="button" class="text-success" ui-sref=".month_report({month:mon})" ng-bind="mon.substring(5,7)"></h2>
<span class="fa fa-edit btn" ng-click="editCommissionConfig(mon)">Leader Commission</span> <span class="fa fa-edit btn" ng-click="editCommissionConfig(mon)">Commission</span>
</a> </a>
<a ng-if="hasReport(mon) && ('100'|withRole) && (!('1000'|withRole))"> <a ng-if="hasReport(mon) && ('100'|withRole) && (!('1000'|withRole))">
<h2 ROLE="button" class="text-success" ui-sref=".bd_detail({month:mon})" ng-bind="mon.substring(5,7)"></h2> <h2 ROLE="button" class="text-success" ui-sref=".bd_detail({month:mon})" ng-bind="mon.substring(5,7)"></h2>
<span class="fa fa-edit btn" ng-click="editCommissionConfig(mon)">Leader Commission</span> <span class="fa fa-edit btn" ng-click="editCommissionConfig(mon)">Commission</span>
</a> </a>
<a ng-if="!hasReport(mon)"> <a ng-if="!hasReport(mon)">
<h2 ROLE="button" class="text-gray" ng-bind="mon.substring(5,7)"></h2> <h2 ROLE="button" class="text-gray" ng-bind="mon.substring(5,7)"></h2>
<span class="fa fa-edit btn" ng-click="editCommissionConfig(mon)">Leader Commission</span> <span class="fa fa-edit btn" ng-click="editCommissionConfig(mon)">Commission</span>
</a> </a>
</div> </div>
</div> </div>

@ -14,6 +14,12 @@
<select ng-model="filter.months" class="form-control" ng-options="mon.value as mon.label for mon in months" <select ng-model="filter.months" class="form-control" ng-options="mon.value as mon.label for mon in months"
id="monthFilter"></select> id="monthFilter"></select>
</div> </div>
<div class="form-group">
<label class="control-label" for="monthFilter">KPI Range</label>
<select ng-model="filter.kpi_range" class="form-control" ng-options="ran.value as ran.label for ran in kpiRanges"
id="kpiFilter"></select>
</div>
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover"> <table class="table table-hover">
@ -24,7 +30,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="rate in rates|filter:{bd_level:filter.bd_level,time_range:filter.months}"> <tr ng-repeat="rate in rates|filter:{bd_level:filter.bd_level,time_range:filter.months,kpi_range:filter.kpi_range}">
<td>{{rate.rate_from}}-{{rate.rate_to}}</td> <td>{{rate.rate_from}}-{{rate.rate_to}}</td>
<td> <td>
<div class="input-group"> <div class="input-group">

Loading…
Cancel
Save