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 deleteCommConfig(String config_id);
void updateBdKpiConfig(List<JSONObject> configs, JSONObject manager)throws ParseException;
}

@ -418,5 +418,12 @@ public class BDPrizeServiceImpl implements BDPrizeService {
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());
int bdLevel = bd.getIntValue("bd_level");
log.put("bd_level", bdLevel);
log.put("kpi_amount", bd.getBigDecimal("kpi_amount"));
log.put("bd_name", bd.getString("bd_name"));
log.put("total_amount", 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 {
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 id="getReport" resultType="com.alibaba.fastjson.JSONObject">
SELECT
r.*,
r.*,l.kpi_amount,
sum(total_prize) total_prize,
sum(send_prize) total_send_prize,
sum(total_donation) total_donation

@ -20,7 +20,8 @@
SELECT
b.*,
c.bd_level,
c.get_prize
c.get_prize,
c.kpi_amount
FROM sys_client_bd b
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

@ -106,7 +106,8 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
rates: function () {
return angular.copy($scope.bd_rate_configs);
}
}
},
size:'lg'
}).result.then(function () {
$scope.loadRateConfigs();
})
@ -136,7 +137,9 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
value: 3,
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.submitRates = function () {
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) {
$scope.monModal = monModal;
$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.newSwitch;
$scope.initMonth = function (year) {
@ -209,6 +212,12 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
var end = $filter('date')(new Date(), 'yyyy-MM');
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) {
$http.get('/sys/bd_prize/commission/le_ma/' + mon).then(function (resp) {
$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) {
$scope.report = report.data;

@ -1,10 +1,12 @@
<div class="modal-header">
<h4>Leader Commission Config</h4>
<h4>Commission Config</h4>
</div>
<div class="modal-body">
<!--<div class="alert alert-danger" ng-bind="errmsg" ng-if="errmsg"></div>-->
<div class="table-responsive">
<button class="btn btn-primary" ng-bind="bdmon"></button>
<button class="btn btn-primary" ng-bind="bdmon" style="margin-bottom: 10px"></button>
<uib-tabset>
<uib-tab heading="Leader">
<div class="table-responsive margin-top">
<table class="table table-hover">
<thead>
<tr>
@ -51,4 +53,30 @@
<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>

@ -79,6 +79,7 @@
<thead>
<tr>
<th>BD Name</th>
<th>KPI</th>
<th>BD Level</th>
<th>Transaction Amount</th>
<th>Total Commission</th>
@ -90,9 +91,10 @@
<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 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.send_prize|currency:'AUD '"></td>
<td>

@ -36,15 +36,15 @@
<div class="col-xs-2" ng-repeat="mon in months">
<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>
<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 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>
<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 ng-if="!hasReport(mon)">
<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>
</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"
id="monthFilter"></select>
</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 class="table-responsive">
<table class="table table-hover">
@ -24,7 +30,7 @@
</tr>
</thead>
<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>
<div class="input-group">

Loading…
Cancel
Save