Merge branch 'new_bd_commissions' into develop

master
eason 6 years ago
commit e4eac97729

@ -611,4 +611,8 @@ CREATE TABLE `pre_apply_handle_log` (
ALTER TABLE `sys_client_pre_apply`
ADD COLUMN `status` tinyint(2) NULL DEFAULT 0 COMMENT '0:未处理1处理中2处理完成';
alter table sys_clients add column hfindustry varchar(10) DEFAULT NULL COMMENT 'HF行业';
alter table sys_clients add column hfindustry varchar(10) DEFAULT NULL COMMENT 'HF行业';
alter table financial_bd_prize_rate_config add column `kpi_range` smallint(6) NOT NULL;
alter table financial_bd_config add column `kpi_amount` decimal(15,2) DEFAULT NULL;
alter table financial_bd_prize_log add column `kpi_amount` decimal(15,2) DEFAULT NULL;

@ -12,7 +12,7 @@ import com.alibaba.fastjson.JSONObject;
* Created by yixian on 2017-02-07.
*/
public interface BDPrizeService {
void generateRecord();
void generateRecord(String month);
@Transactional
void recordGenerateProcess(Calendar now);
@ -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;
}

@ -78,10 +78,10 @@ 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() {
public void generateRecord(String month) {
if (backupSystem) {
throw new ServerErrorException("Updating System,wait for a moment");
}
@ -89,9 +89,15 @@ public class BDPrizeServiceImpl implements BDPrizeService {
throw new ServerErrorException("Processing task, wait for a moment");
}
try {
final Calendar now = Calendar.getInstance();
DateUtils.truncate(now, Calendar.MONTH);
now.add(Calendar.MONTH, -1);
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM");
Date date = null;
try {
date = sdf.parse(month);
} catch (ParseException e) {
e.printStackTrace();
}
Calendar now = Calendar.getInstance();
now.setTime(date);
recordGenerateProcess(now);
} finally {
@ -133,10 +139,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 = 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) {
groupPrize = groupAmount.multiply(new BigDecimal(rateJson.getString("commission_rate")).divide(percent)).setScale(2, BigDecimal.ROUND_DOWN);
@ -212,28 +222,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 +269,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;
}
@ -418,5 +456,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);
}
}
}

@ -46,16 +46,16 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
public BDPrizeCalculatorDefaultImpl rateConfig(List<JSONObject> rateConfig) {
for (JSONObject rateCfgItem : rateConfig) {
int level = rateCfgItem.getIntValue("bd_level");
int monthLevel = rateCfgItem.getIntValue("time_range");
int kpiRange = rateCfgItem.getIntValue("kpi_range");
Map<Integer, List<JSONObject>> rates = rateConfigMap.get(level);
if (rates == null) {
rates = new HashMap<>();
rateConfigMap.put(level, rates);
}
List<JSONObject> rate = rates.get(monthLevel);
List<JSONObject> rate = rates.get(kpiRange);
if (rate == null) {
rate = new ArrayList<>();
rates.put(monthLevel, rate);
rates.put(kpiRange, rate);
}
rate.add(rateCfgItem);
}
@ -81,18 +81,28 @@ 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);
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 bdRate = getRate(bdLevel, months, detailItem.getIntValue("client_source"), detailItem.getBigDecimal("rate_value"));
// int months = detailItem.getIntValue("client_create_months");
BigDecimal totalTransaction = detailItem.getBigDecimal("total_transaction");
BigDecimal coefficient = detailItem.getBigDecimal("coefficient");
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;
if (clientsWithBDAwayDeterminor.clientWithBDAway(clientId, month)) {
@ -208,4 +218,42 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
}
throw new ServerErrorException("Prize Rate Config has no equalize:bdLevel=" + bdLevel + ",months=" + months + ",clientRate=" + clientRate.doubleValue());
}
private BigDecimal getNewRate(int bdLevel, int kpiRange, int clientSource, BigDecimal clientRate) {
BigDecimal prizeRate = BigDecimal.ZERO;
Map<Integer, List<JSONObject>> rates = rateConfigMap.get(bdLevel);
List<JSONObject> rate = rates.get(kpiRange);
for (JSONObject rateCfg : rate) {
if (rateCfg.getBigDecimal("rate_from").compareTo(clientRate) <= 0 && rateCfg.getBigDecimal("rate_to").compareTo(clientRate) >= 0) {
prizeRate= rateCfg.getBigDecimal("prize_rate");
continue;
}
}
if (clientSource == 1) {
return prizeRate;
} else {
return prizeRate.divide(BigDecimal.valueOf(2),3,BigDecimal.ROUND_HALF_DOWN);
}
}
private int getKpiPrizeLevel(BigDecimal transactionAmount,BigDecimal kpiAmount){
if (kpiAmount.compareTo(BigDecimal.ZERO)==0){//未设置kpi金额的按照最小完成度来计算
return 1;
}
BigDecimal rate = transactionAmount.divide(kpiAmount,2,BigDecimal.ROUND_HALF_DOWN);
if (rate.compareTo(BigDecimal.valueOf(0.5))<0){
return 1;
}
if (rate.compareTo(BigDecimal.valueOf(0.8))<0){
return 2;
}
if (rate.compareTo(BigDecimal.valueOf(1))<0){
return 3;
}
if (rate.compareTo(BigDecimal.valueOf(1.2))<0){
return 4;
}
return 5;
}
}

@ -29,9 +29,9 @@ public class BDPrizeController {
@Resource
private BDPrizeService bdPrizeService;
@ManagerMapping(value = "/generate_record", method = RequestMethod.POST, role = {ManagerRole.FINANCIAL_STAFF, ManagerRole.ADMIN})
public void generateRecord() {
bdPrizeService.generateRecord();
@ManagerMapping(value = "/generate_record/{month}", method = RequestMethod.POST, role = {ManagerRole.FINANCIAL_STAFF, ManagerRole.ADMIN})
public void generateRecord(@PathVariable String month) {
bdPrizeService.generateRecord(month);
}
@ManagerMapping(value = "/records", method = RequestMethod.GET, role = {ManagerRole.FINANCIAL_STAFF, ManagerRole.BD_USER})
@ -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);
}
}

@ -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 " +

@ -94,6 +94,8 @@ public interface TransactionMapper {
List<JSONObject> listTransactionsForBDPrize(@Param("year") int year, @Param("month") int month, @Param("channel") String channel);
BigDecimal TotalAmountForBDLeaderPrize(@Param("year") int year, @Param("month") int month, @Param("bd_group") String bd_group);
BigDecimal TotalAmountForSydneyGMPrize(@Param("year") int year, @Param("month") int month);
List<JSONObject> listTransactionsForCityPartnerCommission(@Param("year") int year, @Param("month") int month);

@ -9,7 +9,8 @@
c.bd_level,
c.city,
c.get_prize,
c.bd_group
c.bd_group,
c.kpi_amount
FROM sys_managers m
LEFT JOIN financial_bd_config c ON c.manager_id = m.manager_id
WHERE m.role & 4 > 0 AND m.is_valid = 1 AND (m.org_id = 1 OR m.org_id IS NULL)

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

@ -495,10 +495,7 @@
INNER JOIN pmt_orders o ON o.order_id = t.order_id
INNER JOIN sys_clients c ON c.client_id = o.client_id AND c.org_id = 1
WHERE year(o.create_time) = #{year} AND month(o.create_time) = #{month} AND t.channel != 'Settlement'
<if test="channel=='Wechat'">
and t.channel not in ('Alipay','Bestpay')
</if>
<if test="channel!='Wechat'">
<if test="channel!=null">
and t.channel = #{channel}
</if>
GROUP BY o.client_id, trade_date
@ -507,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
@ -528,6 +525,30 @@
where b.is_valid=1 and b.start_date&lt;=now() and (b.end_date is null or b.end_date &gt;= now())
AND c.bd_group=#{bd_group} or c.manager_id=#{bd_group})
</select>
<select id="TotalAmountForSydneyGMPrize" resultType="java.math.BigDecimal">
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))
total
FROM pmt_transactions t
INNER JOIN pmt_orders o ON o.order_id = t.order_id
INNER JOIN sys_clients c ON c.client_id = o.client_id AND c.org_id = 1
WHERE year(o.create_time) = #{year} AND month(o.create_time) = #{month}
AND(
t.transaction_type = 'Credit'
OR t.refund_id IS NOT NULL
)
AND(
o. STATUS =5
OR o. STATUS =6
OR o. STATUS =7
)
and t.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
where b.is_valid=1 and b.start_date&lt;=now() and (b.end_date is null or b.end_date &gt;= now())
AND c.city='Sydney')
</select>
<select id="listTransactionsForCityPartnerCommission" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT

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

@ -39,9 +39,12 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
})
}]);
app.controller('bdPrizeRootCtrl', ['$scope', '$http', '$uibModal', 'commonDialog', function ($scope, $http, $uibModal, commonDialog) {
app.controller('bdPrizeRootCtrl', ['$scope', '$http', '$uibModal', 'commonDialog','$filter', function ($scope, $http, $uibModal, commonDialog,$filter) {
$scope.params = {year: new Date().getFullYear()};
$scope.generate = {};
$scope.availableYears = [new Date().getFullYear() - 1, new Date().getFullYear()];
$scope.kpiRanges = [{value: 1, label: '0-50%'}, {value: 2, label: '50%~80%'}, {value: 3, label: '80%~100%'},
{value: 4, label: '100%-120%'}, {value: 5, label: '>=120%'}];
$scope.initMonth = function (year) {
$scope.params.year = year;
$scope.months = [];
@ -72,27 +75,37 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
};
$scope.getYearReports(new Date().getFullYear());
$scope.generateReport = function () {
if (!$scope.generate.month) {
commonDialog.alert({
type: 'error', title: 'Error', content: 'Select a month first!'
});
return;
}
commonDialog.confirm({
title: 'Warning',
content: 'This operation will clear the result of last month generated before. Are you sure?'
}).then(function () {
$http.post('/sys/bd_prize/generate_record', null, {timeout: 60000}).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 (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;
})
})
};
$scope.loadRateConfigs = function () {
$http.get('/sys/bd_prize/config/rates').then(function (resp) {
$scope.bd_rate_configs = resp.data;
$scope.bd_rate_ranges = [];
var rangeStart = [];
$scope.kpi_ranges = [];
var kpiStart = [];
angular.forEach($scope.bd_rate_configs, function (cfg) {
if (rangeStart.indexOf(cfg.rate_from) < 0) {
rangeStart.push(cfg.rate_from);
$scope.bd_rate_ranges.push(cfg);
if (kpiStart.indexOf(cfg.kpi_range) < 0) {
kpiStart.push(cfg.kpi_range);
$scope.kpi_ranges.push(cfg);
}
})
})
@ -136,7 +149,10 @@ 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: '0-50%'}, {value: 2, label: '50%~80%'}, {value: 3, label: '80%~100%'},
{value: 4, label: '100%-120%'}, {value: 5, label: '>=120%'}];
$scope.clientRate = [{value: 0.6, label: '0.6-0.79'}, {value: 0.8, label: '0.8-2.0'}];
$scope.filter = {bd_level: 1,rate_from:0.6};
$scope.rates = rates;
$scope.submitRates = function () {
var validation = null;
@ -191,7 +207,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: 'BD Manager'}, {id: 2, label: 'KA 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 +225,34 @@ 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.chooseLastConfig = function (mon) {
var index = $scope.months.indexOf(mon);
if(index == 0){
var year = new Date().getFullYear();
year--;
mon = year + '-12';
}else {
mon = $scope.months[index-1];
}
$http.get('/sys/bd_prize/commission/le_ma/' + mon).then(function (resp) {
$scope.bdlm = [];
angular.forEach(resp.data,function (e) {
var bdC = {};
bdC.commission_start_amount = e.commission_start_amount;
bdC.commission_end_amount = e.commission_end_amount;
bdC.bd_commission_rate = e.bd_commission_rate;
bdC.bd_type = e.bd_type;
$scope.bdlm.push(bdC);
});
$scope.listConfig = true;
})
};
$scope.listCurrentMonBDCommission = function (mon) {
$http.get('/sys/bd_prize/commission/le_ma/' + mon).then(function (resp) {
$scope.bdlm = resp.data;
@ -266,6 +310,24 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
})
}
}
$scope.submitBdCommmissionConfig = function (mon, bds) {
$scope.check = true;
$scope.errmsg = null;
angular.forEach(bds, function (data, index) {
if(data.get_prize){
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,54 +1,154 @@
<style>
.intro_color{
color:#7a869d ;
}
</style>
<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>
<table class="table table-hover">
<thead>
<tr>
<th>Commission Amount</th>
<th>Commission Rate</th>
<th>BD Type</th>
<th>
<span class="fa fa-plus" style="color: #0bb20c" ng-click="bdlm.push({})"></span>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="bd in bdlm">
<td class="col-sm-5">
<div class="input-group">
<input class="form-control" id="re-from-input" type="number"
ng-model="bd.commission_start_amount"
placeholder="Start Amount">
<span class="input-group-addon">~</span>
<input class="form-control" id="re-to-input" type="number"
ng-model="bd.commission_end_amount"
placeholder="End Amount">
</div>
</td>
<td class="col-sm-3">
<div class="input-group">
<input placeholder="rate" class="form-control" type="number" step="0.01"
ng-model="bd.bd_commission_rate">
<span class="input-group-addon">%</span>
</div>
</td>
<td>
<select class="form-control" ng-model="bd.bd_type" ng-options="bdtype.id as bdtype.label for bdtype in bdtypes"></select>
</td>
<td>
<span class="fa fa-close" style="color: #b92c28" ng-click="deleteCommission(bd.bc_config_id)"></span>
</td>
</tr>
</tbody>
</table>
<div class="alert alert-danger" ng-if="errmsg" ng-bind="errmsg"></div>
<div class="modal-footer" ng-if="listConfig">
<button class="btn btn-success" type="button" ng-click="submitCommmissionConfig(bdmon,bdlm)">Submit</button>
<button class="btn btn-danger" ng-click="$dismiss()">Cancel</button>
</div>
</div>
<button class="btn btn-primary" ng-bind="bdmon" style="margin-bottom: 10px"></button>
<uib-tabset>
<uib-tab heading="Leader">
<div class="box margin-top" >
<div class="box-body no-padding table-responsive">
<div class="table-responsive margin-top">
<table class="table table-hover">
<thead>
<tr>
<th>Commission Amount</th>
<th>Commission Rate</th>
<th>BD Type</th>
<th>
<button class="btn btn-primary" ng-click="chooseLastConfig(bdmon)" ng-if="bdlm.length<=0">启用上月设置</button>
<span class="fa fa-plus" style="color: #0bb20c" ng-click="bdlm.push({})"></span>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="bd in bdlm">
<td class="col-sm-5">
<div class="input-group">
<input class="form-control" id="re-from-input" type="number"
ng-model="bd.commission_start_amount"
placeholder="Start Amount">
<span class="input-group-addon">~</span>
<input class="form-control" id="re-to-input" type="number"
ng-model="bd.commission_end_amount"
placeholder="End Amount">
</div>
</td>
<td class="col-sm-3">
<div class="input-group">
<input placeholder="rate" class="form-control" type="number" step="0.01"
ng-model="bd.bd_commission_rate">
<span class="input-group-addon">%</span>
</div>
</td>
<td>
<select class="form-control" ng-model="bd.bd_type" ng-options="bdtype.id as bdtype.label for bdtype in bdtypes"></select>
</td>
<td>
<span class="fa fa-close" style="color: #b92c28" ng-click="deleteCommission(bd.bc_config_id)"></span>
</td>
</tr>
</tbody>
</table>
<div class="alert alert-danger" ng-if="errmsg" ng-bind="errmsg"></div>
<div class="modal-footer" ng-if="listConfig">
<button class="btn btn-success" type="button" ng-click="submitCommmissionConfig(bdmon,bdlm)">Submit</button>
<button class="btn btn-danger" ng-click="$dismiss()">Cancel</button>
</div>
</div>
</div>
<div class="box intro_color">
<div class="box-header with-border">
<h5 class="intro_color" >跨境事业部总监提成制度</h5>
</div>
<div class="box-body">
<ul class="small">
<li>享受墨尔本和悉尼两地部门流水总和提成</li>
<li>完成当月指标低于 51%,提成按照 0.005%提取</li>
<li>完成当月指标高于 80%,提成按照 0.008%提取</li>
<li>完成当月指标 100%,提成按照 0.01%</li>
<li>连续六个月未完成指标,撤职处理或回归原有职位</li>
<li>销售总监任职后需将自己手头客户按照公司规定公平分配给客户专员,本人可挂靠 50%,每个商户享受 50%的流水提成</li>
</ul>
</div>
<div class="box-header with-border">
<h5 class="intro_color">大客户部门 Manager 提成考核指标</h5>
</div>
<div class="box-body">
<ul class="small">
<li>完成月度指标,当月部门提成为该部门总流水的 0.01%</li>
<li>未完成月度指标,当月部门提成为该部门总流水的 0.005%</li>
</ul>
</div>
<div class="box-header with-border">
<h6 class="intro_color">悉尼分公司总经理</h6>
</div>
<div class="box-body">
<ul>
<li>完成月度指标,当月提成为该分公司总流水的 0.005%</li>
<li>未完成月度指标,当月提成为该分公司总流水的 0.0025%</li>
</ul>
</div>
<div class="box-header with-border">
<h5 class="intro_color">南京分公司技术部提成</h5>
</div>
<div class="box-body">
<ul class="small">
<li>完成月度指标,当月提成为公司总流水的 0.01%</li>
<li>未完成月度指标,当月提成为公司总流水的 0.005%</li>
<li>【发放原则:季度一发放;分配原则由总经理 Leo Huang 制定。】</li>
</ul>
</div>
<div class="box-header with-border">
<h5 class="intro_color">COO考核及提成政策</h5>
</div>
<div class="box-body">
<ul class="small">
<li>需完成董事会下达的指标任务</li>
<li>按照公司总流水进行提取(包含合伙人)</li>
<li>每月商户数量递增不得少于 100 家</li>
<li>需带领团队按时保质完成每月 KPI 任务</li>
<li>需带领团队配合公司的每一个活动执行;</li>
<li>及时做好培训、后台管理</li>
<li>完成 KPI 按照 0.03%提取;未完成 KPI 按照 0.02%提取</li>
</ul>
</div>
</div>
</div>
</uib-tab>
<uib-tab heading="BD">
<div class="box margin-top">
<div class="box-body no-padding table-responsive">
<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|filter:{get_prize:true}">
<td ng-bind="bd.display_name"></td>
<td>
<input type="number" ng-model="bd.kpi_amount" min="0">
</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>
</div>
</div>
</uib-tab>
</uib-tabset>
</div>

@ -41,9 +41,9 @@
<img uib-tooltip="Wechat" src="/static/images/wechatpay_sign_lg.png">
</div>
<div class="info-box-content">
<h5>BD Taotal Commission: ${{report.WechatReport.total_prize}}</h5>
<h5>BD Taotal Send: ${{report.WechatReport.total_send_prize}}</h5>
<h5>BD Taotal Fund: ${{report.WechatReport.total_donation}}</h5>
<h5>BD Total Commission: ${{report.WechatReport.total_prize}}</h5>
<h5>BD Total Send: ${{report.WechatReport.total_send_prize}}</h5>
<h5>BD Total Fund: ${{report.WechatReport.total_donation}}</h5>
</div>
</div>
</div>
@ -54,7 +54,7 @@
</div>
<div class="info-box-content">
<h5>BD Total Commission: ${{report.AlipayReport.total_prize}}</h5>
<h5>BD Taotal Send: ${{report.AlipayReport.total_send_prize}}</h5>
<h5>BD Total Send: ${{report.AlipayReport.total_send_prize}}</h5>
<h5>BD Total Fund: ${{report.AlipayReport.total_donation}}</h5>
</div>
</div>
@ -65,9 +65,9 @@
<img uib-tooltip="Bestpay" src="/static/images/bestpay_sign_lg.png">
</div>
<div class="info-box-content">
<h5>BD Taotal Commission: ${{report.BestpayReport.total_prize}}</h5>
<h5>BD Taotal Send: ${{report.BestpayReport.total_send_prize}}</h5>
<h5>BD Taotal Fund: ${{report.BestpayReport.total_donation}}</h5>
<h5>BD Total Commission: ${{report.BestpayReport.total_prize}}</h5>
<h5>BD Total Send: ${{report.BestpayReport.total_send_prize}}</h5>
<h5>BD Total Fund: ${{report.BestpayReport.total_donation}}</h5>
</div>
</div>
</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>
@ -91,8 +92,12 @@
<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==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 ng-bind="log.total_amount|currency:'AUD '"></td>
<td>{{log.total_amount|currency:'AUD '}}</td>
<td ng-bind="log.total_prize|currency:'AUD '"></td>
<td ng-bind="log.send_prize|currency:'AUD '"></td>
<td>
@ -110,7 +115,7 @@
</div>
</div>
<div class="box box-default">
<div class="box-header">BD Manager Commission</div>
<div class="box-header">Manager Commission</div>
<div class="box-body table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
@ -152,18 +157,44 @@
</div>
</div>-->
<div class="box box-success">
<div class="box-header">Director Commission</div>
<div class="box-body">
<div class="row">
<div class="col-xs-6 col-sm-6">
Transaction Amount: <span ng-bind="report.directPrizeLogs.total_amount|currency:'AUD '"></span>
</div>
<div class="col-xs-6 col-sm-6">
Total Commission: <span ng-bind="report.directPrizeLogs.total_prize|currency:'AUD '"></span>
</div>
<div class="box-header">Sydney GM Commission</div>
<div class="box-body">
<div class="row">
<div class="col-xs-6 col-sm-6">
Transaction Amount: <span ng-bind="report.sydneyPrizeLog.total_amount|currency:'AUD '"></span>
</div>
<div class="col-xs-6 col-sm-6">
Total Commission: <span ng-bind="report.sydneyPrizeLog.total_prize|currency:'AUD '"></span>
</div>
</div>
</div>
</div>
<div class="box box-success">
<div class="box-header">NJ Department Commission</div>
<div class="box-body">
<div class="row">
<div class="col-xs-6 col-sm-6">
Transaction Amount: <span ng-bind="report.ngDepartmentPrizeLog.total_amount|currency:'AUD '"></span>
</div>
<div class="col-xs-6 col-sm-6">
Total Commission: <span ng-bind="report.ngDepartmentPrizeLog.total_prize|currency:'AUD '"></span>
</div>
</div>
</div>
</div>
<div class="box box-success">
<div class="box-header">COO Commission</div>
<div class="box-body">
<div class="row">
<div class="col-xs-6 col-sm-6">
Transaction Amount: <span ng-bind="report.directPrizeLogs.total_amount|currency:'AUD '"></span>
</div>
<div class="col-xs-6 col-sm-6">
Total Commission: <span ng-bind="report.directPrizeLogs.total_prize|currency:'AUD '"></span>
</div>
</div>
</div>
</div>
<!--<div class="box-header">Manager Commission</div>-->
<!--<div class="box-body table-responsive">-->
<!--<table class="table table-bordered table-hover table-striped">-->

@ -9,9 +9,25 @@
<section class="content">
<div class="box box-danger" ng-if="'1000'|withRole">
<div class="box-body">
<button class="btn btn-danger" ng-click="generateReport()">Generate Report</button>
<button class="btn btn-primary" ng-click="editRateConfig()"><i class="fa fa-cog"></i> Edit Rate Config</button>
<button class="btn btn-primary" ng-click="editBDLevels()"><i class="fa fa-user"></i> Edit BD Level</button>
<div class="box box-default">
<div class="box-body">
<div class="form-inline">
<div class="form-group">
<input type="text" class="form-control" uib-datepicker-popup="yyyy-MM" ng-model="generate.month"
is-open="ctrl.genmonth" datepicker-options="{minMode: 'month'}"
ng-click="ctrl.genmonth=true" placeholder="Select Month"/>
</div>
<button class="btn btn-primary" ng-click="generateReport()" ng-disabled="!generate.month">
Generate Report
</button>
<button class="btn btn-primary" ng-click="editRateConfig()"><i class="fa fa-cog"></i> Edit Rate Config</button>
<button class="btn btn-primary" ng-click="editBDLevels()"><i class="fa fa-user"></i> Edit BD Level</button>
<loadingbar ng-if="generate.status"></loadingbar>
</div>
</div>
</div>
<!--<button class="btn btn-danger" ng-click="generateReport()">Generate Report</button>-->
<!--<button class="btn btn-primary" ng-click="editCommissionConfig()"><i class="fa fa-user"></i> Edit Commission Config</button>-->
</div>
</div>
@ -36,15 +52,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>
@ -59,49 +75,48 @@
<thead>
<tr>
<th>BD Level</th>
<th rowspan="2">费率</th>
<th rowspan="2">费率</th>
<th colspan="3">Junior BD</th>
<th colspan="3">Intermediate BD</th>
<th colspan="3">Senior BD</th>
<th rowspan="2">KPI完成度</th>
<th colspan="2">Junior BD</th>
<th colspan="2">Intermediate BD</th>
<th colspan="2">Senior BD</th>
</tr>
<tr>
<th>商户开通时长</th>
<th>1-3个月</th>
<th>4-6个月</th>
<th>&gt;=7个月</th>
<th>1-3个月</th>
<th>4-6个月</th>
<th>&gt;=7个月</th>
<th>1-3个月</th>
<th>4-6个月</th>
<th>&gt;=7个月</th>
<th>费率</th>
<th>0.6-0.79</th>
<th>0.8-2.0</th>
<th>0.6-0.79</th>
<th>0.8-2.0</th>
<th>0.6-0.79</th>
<th>0.8-2.0</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="range in bd_rate_ranges">
<tr ng-repeat="range in kpi_ranges">
<td ng-bind="'#'+($index+1)"></td>
<td ng-bind="range.rate_from"></td>
<td ng-bind="range.rate_to"></td>
<td ng-bind="(kpiRanges|filter:{value:range.kpi_range})[0].label"></td>
<td ng-repeat-start="level in [1,2,3] track by $index"
ng-bind="(bd_rate_configs|filter:{rate_from:range.rate_from,bd_level:level,time_range:1})[0].prize_rate+'%'"></td>
<td ng-bind="(bd_rate_configs|filter:{rate_from:range.rate_from,bd_level:level,time_range:2})[0].prize_rate+'%'"></td>
ng-bind="(bd_rate_configs|filter:{kpi_range:range.kpi_range,bd_level:level,rate_from:0.6})[0].prize_rate+'%'"></td>
<td ng-repeat-end
ng-bind="(bd_rate_configs|filter:{rate_from:range.rate_from,bd_level:level,time_range:3})[0].prize_rate+'%'"></td>
ng-bind="(bd_rate_configs|filter:{kpi_range:range.kpi_range,bd_level:level,rate_from:0.8})[0].prize_rate+'%'"></td>
</tr>
</tbody>
</table>
</div>
<h4>补充说明</h4>
<ul>
<li>商户费率变更,提成比随之变更</li>
<li>商户开通时长从商户开通时间起算</li>
<li>后台系统自主申请商户提成按照前三个月0.05%后期0.01%发放自主申请商户在详情列表中的Client Source标注为Apply</li>
<li>调岗人员移交的商户移交后6个月内移交人员和接收人员平分提成应在商户BD配置里进行设置分配比例请关注详情列表中的Coefficient正常情况下应当为1</li>
<li>离职人员移交的商户接收人员享受一半提成另一半作为BD福利基金离职转交商户在详情列表中用红色标注</li>
<li>BD提成按月发放</li>
<li>每月发放总额的80%剩余20%于每年年底即12月25日圣诞节前发放</li>
<li>按月度发放</li>
<li>每月发放总提成额度的 80%,剩余 20%按照“年度考评分数比例”于每年年底即 12 月 25 日圣诞前发放</li>
<li>提前离职者20%提成不予发放</li>
<li>年度考评(根据销管中心每月考评表打分制进行统计)按照考评分数对应比例发放 20%的占比部分,扣下部分如果第二年考评超出一定评分 110%可以补发;同样,如果年度考评分数超过 100 分按照同比例发放</li>
<li>商户开通后连续 1 个月未产生流水的,上交主管,由主管重新分配</li>
<li>连续 2 个月不产生流水的商户,由销管部统一收回,重新分配</li>
<li>分配后的商户流水客户专员只能占一半</li>
<li>离职及调岗人员商户统一上交销管中心,由销管中心 leader 及跨境事业部总监相互协商及相互监督,按照公平公正的原则, 做出分配方案,并由总监确认后统一分配。调岗人员移交的商户,在移交后 1 个月内移交人员和接收人员平分该商家产生的提成,移交人员需配合接收人员做好商户对接和短期内的商户维护;
离职人员交接的商户提成,接收人员享受一半的提成,另一半作为跨境客服专员福利会基金</li>
<li>被客户投诉情况严重者,此商户由销管中心无条件收回重新分配</li>
<li>活动执行未传达到位且出现舞弊、徇私、懒惰等行为的,商户上交由销管中心统一分配</li>
<li>后期维护不及时,连续一个月不跟踪者,此商户上交销管中心,统一重新分配</li>
<li>以上分配,销管中心 leader 和跨境支付事业部商量好之后需做好方案后经 COO 审批方可执行</li>
</ul>
</div>
</div>

@ -9,23 +9,29 @@
<select ng-model="filter.bd_level" class="form-control" ng-options="lv.value as lv.label for lv in bdLevels"
id="levelFilter"></select>
</div>
<div class="form-group">
<!-- <div class="form-group">
<label class="control-label" for="monthFilter">Months</label>
<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="rateFilter">Client Rate</label>
<select ng-model="filter.rate_from" class="form-control" ng-options="rate.value as rate.label for rate in clientRate"
id="rateFilter"></select>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Client Rate</th>
<th>KPI完成度</th>
<th>BD Rate</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="rate in rates|filter:{bd_level:filter.bd_level,time_range:filter.months}">
<td>{{rate.rate_from}}-{{rate.rate_to}}</td>
<tr ng-repeat="rate in rates|filter:{bd_level:filter.bd_level,rate_from:filter.rate_from}">
<td ng-bind="(kpiRanges|filter:{value:rate.kpi_range})[0].label"></td>
<td>
<div class="input-group">
<input placeholder="bd rate" class="form-control" type="number" step="0.01" ng-model="rate.prize_rate">

Loading…
Cancel
Save