demand: 销售提成计算销售顾问、销售经理、销售支持按比例分成
committer: heyu
This commit is contained in:
parent
4f08854914
commit
1e21eea08a
@ -724,4 +724,9 @@ public class EmisWaybill extends BaseEntity
|
||||
@DataAuditField(fieldComment = "箱量")
|
||||
private String boxQuantity;
|
||||
|
||||
/* 销售支持 */
|
||||
private String salesSupport;
|
||||
/* 销售主管 */
|
||||
private String salesExecutive;
|
||||
|
||||
}
|
||||
|
||||
@ -69,6 +69,9 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
||||
@Autowired
|
||||
RedissonService redissonService;
|
||||
|
||||
@Autowired
|
||||
private EmisSalesCommissionRatioMapper emisSalesCommissionRatioMapper;
|
||||
|
||||
/**
|
||||
* 自动计算提成
|
||||
*/
|
||||
@ -1340,31 +1343,66 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
||||
}
|
||||
|
||||
// 插入提成
|
||||
if(BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO)>0) {
|
||||
|
||||
EmisCommissionDtl emisCommissionDtl = new EmisCommissionDtl();
|
||||
emisCommissionDtl.setBillCode(waybill.getBillCode());
|
||||
emisCommissionDtl.setFeeType(quoteItem.getFeeType());
|
||||
|
||||
emisCommissionDtl.setBillType("1");
|
||||
|
||||
emisCommissionDtl.setBillMonth(billMonth);
|
||||
emisCommissionDtl.setMoney(BigDecimal.valueOf(profitMoney));
|
||||
|
||||
emisCommissionDtl.setEmpName(salesmen);
|
||||
|
||||
emisCommissionDtl.setCalcExpr(calcExprStr);
|
||||
emisCommissionDtl.setQuoteId(exprItem.getQuoteId());
|
||||
emisCommissionDtl.setQuoteName(quoteItem.getQuoteName());
|
||||
emisCommissionDtl.setExprId(exprItem.getId());
|
||||
|
||||
emisCommissionDtl.setFeeRemark(calcExprStr);
|
||||
|
||||
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
|
||||
|
||||
// 单独根据人名称和月份汇总统计
|
||||
// reCalcEmpProfitSumMoney(salesmen,billMonth);
|
||||
}else{
|
||||
if (BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 新增:按销售分成配置插入多岗位提成
|
||||
String salesSupport = waybill.getSalesSupport();
|
||||
String salesExecutive = waybill.getSalesExecutive();
|
||||
boolean hasRatioInsert = false;
|
||||
if (StringUtils.isNotEmpty(salesmen) && StringUtils.isNotEmpty(salesSupport)
|
||||
&& StringUtils.isNotEmpty(salesExecutive)) {
|
||||
EmisSalesCommissionRatio ratioQuery = new EmisSalesCommissionRatio();
|
||||
ratioQuery.setSalesmen(salesmen);
|
||||
ratioQuery.setSalesSupport(salesSupport);
|
||||
ratioQuery.setSalesExecutive(salesExecutive);
|
||||
ratioQuery.setStatus("1");
|
||||
List<EmisSalesCommissionRatio> ratioList = emisSalesCommissionRatioMapper
|
||||
.selectEmisSalesCommissionRatioList(ratioQuery);
|
||||
if (!CollectionUtils.isEmpty(ratioList)) {
|
||||
EmisSalesCommissionRatio ratio = ratioList.get(0);
|
||||
// 销售联系人
|
||||
if (StringUtils.isNotEmpty(salesmen) && ratio.getSalesmenRatio() != null
|
||||
&& ratio.getSalesmenRatio().compareTo(BigDecimal.ZERO) > 0) {
|
||||
insertCommissionDtl(
|
||||
waybill.getBillCode(), quoteItem.getFeeType(), "1", billMonth,
|
||||
BigDecimal.valueOf(profitMoney).multiply(ratio.getSalesmenRatio())
|
||||
.divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP),
|
||||
salesmen, calcExprStr, exprItem.getQuoteId(), quoteItem.getQuoteName(),
|
||||
exprItem.getId(), calcExprStr);
|
||||
hasRatioInsert = true;
|
||||
}
|
||||
// 销售支持
|
||||
if (StringUtils.isNotEmpty(salesSupport) && ratio.getSalesSupportRatio() != null
|
||||
&& ratio.getSalesSupportRatio().compareTo(BigDecimal.ZERO) > 0) {
|
||||
insertCommissionDtl(
|
||||
waybill.getBillCode(), quoteItem.getFeeType(), "1", billMonth,
|
||||
BigDecimal.valueOf(profitMoney).multiply(ratio.getSalesSupportRatio())
|
||||
.divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP),
|
||||
salesSupport, calcExprStr, exprItem.getQuoteId(),
|
||||
quoteItem.getQuoteName(), exprItem.getId(), calcExprStr);
|
||||
hasRatioInsert = true;
|
||||
}
|
||||
// 销售主管
|
||||
if (StringUtils.isNotEmpty(salesExecutive) && ratio.getSalesExecutiveRatio() != null
|
||||
&& ratio.getSalesExecutiveRatio().compareTo(BigDecimal.ZERO) > 0) {
|
||||
insertCommissionDtl(
|
||||
waybill.getBillCode(), quoteItem.getFeeType(), "1", billMonth,
|
||||
BigDecimal.valueOf(profitMoney).multiply(ratio.getSalesExecutiveRatio())
|
||||
.divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP),
|
||||
salesExecutive, calcExprStr, exprItem.getQuoteId(),
|
||||
quoteItem.getQuoteName(), exprItem.getId(), calcExprStr);
|
||||
hasRatioInsert = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 若未查到分成配置或无有效分成,则按原逻辑插入销售员
|
||||
if (!hasRatioInsert) {
|
||||
insertCommissionDtl(
|
||||
waybill.getBillCode(), quoteItem.getFeeType(), "1", billMonth,
|
||||
BigDecimal.valueOf(profitMoney),
|
||||
salesmen, calcExprStr, exprItem.getQuoteId(), quoteItem.getQuoteName(),
|
||||
exprItem.getId(), calcExprStr);
|
||||
}
|
||||
} else {
|
||||
log.error("计算提成费用为0");
|
||||
}
|
||||
|
||||
@ -1379,6 +1417,26 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提成明细插入工具方法,支持金额自定义
|
||||
*/
|
||||
private void insertCommissionDtl(
|
||||
String billCode, String feeType, String billType, String billMonth, BigDecimal money,
|
||||
String empName, String calcExpr, Long quoteId, String quoteName, Long exprId, String feeRemark) {
|
||||
EmisCommissionDtl emisCommissionDtl = new EmisCommissionDtl();
|
||||
emisCommissionDtl.setBillCode(billCode);
|
||||
emisCommissionDtl.setFeeType(feeType);
|
||||
emisCommissionDtl.setBillType(billType);
|
||||
emisCommissionDtl.setBillMonth(billMonth);
|
||||
emisCommissionDtl.setMoney(money);
|
||||
emisCommissionDtl.setEmpName(empName);
|
||||
emisCommissionDtl.setCalcExpr(calcExpr);
|
||||
emisCommissionDtl.setQuoteId(quoteId);
|
||||
emisCommissionDtl.setQuoteName(quoteName);
|
||||
emisCommissionDtl.setExprId(exprId);
|
||||
emisCommissionDtl.setFeeRemark(feeRemark);
|
||||
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算中转操作提成
|
||||
|
||||
@ -233,6 +233,8 @@
|
||||
<result property="virtualRemark" column="virtual_remark" />
|
||||
|
||||
<result property="transType" column="trans_type" />
|
||||
<result property="salesSupport" column="sales_support" />
|
||||
<result property="salesExecutive" column="sales_executive" />
|
||||
|
||||
|
||||
</resultMap>
|
||||
@ -435,6 +437,8 @@
|
||||
a3.phone as customer_phone,
|
||||
a3.nick_name as customer_nick_name,
|
||||
a3.avatar as customer_avatar,
|
||||
a3.sales_support ,
|
||||
a3.sales_executive ,
|
||||
|
||||
p.emp_name as dispatch_man_name,q.site_name as print_site_name,
|
||||
r.emp_name as print_man_name,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user