demand: 销售提成计算销售顾问、销售经理、销售支持按比例分成

committer: heyu
This commit is contained in:
aike 2025-07-23 15:42:47 +08:00
parent 4f08854914
commit 1e21eea08a
3 changed files with 92 additions and 25 deletions

View File

@ -724,4 +724,9 @@ public class EmisWaybill extends BaseEntity
@DataAuditField(fieldComment = "箱量") @DataAuditField(fieldComment = "箱量")
private String boxQuantity; private String boxQuantity;
/* 销售支持 */
private String salesSupport;
/* 销售主管 */
private String salesExecutive;
} }

View File

@ -69,6 +69,9 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
@Autowired @Autowired
RedissonService redissonService; RedissonService redissonService;
@Autowired
private EmisSalesCommissionRatioMapper emisSalesCommissionRatioMapper;
/** /**
* 自动计算提成 * 自动计算提成
*/ */
@ -1340,31 +1343,66 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
} }
// 插入提成 // 插入提成
if(BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO)>0) { if (BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO) > 0) {
// 新增:按销售分成配置插入多岗位提成
EmisCommissionDtl emisCommissionDtl = new EmisCommissionDtl(); String salesSupport = waybill.getSalesSupport();
emisCommissionDtl.setBillCode(waybill.getBillCode()); String salesExecutive = waybill.getSalesExecutive();
emisCommissionDtl.setFeeType(quoteItem.getFeeType()); boolean hasRatioInsert = false;
if (StringUtils.isNotEmpty(salesmen) && StringUtils.isNotEmpty(salesSupport)
emisCommissionDtl.setBillType("1"); && StringUtils.isNotEmpty(salesExecutive)) {
EmisSalesCommissionRatio ratioQuery = new EmisSalesCommissionRatio();
emisCommissionDtl.setBillMonth(billMonth); ratioQuery.setSalesmen(salesmen);
emisCommissionDtl.setMoney(BigDecimal.valueOf(profitMoney)); ratioQuery.setSalesSupport(salesSupport);
ratioQuery.setSalesExecutive(salesExecutive);
emisCommissionDtl.setEmpName(salesmen); ratioQuery.setStatus("1");
List<EmisSalesCommissionRatio> ratioList = emisSalesCommissionRatioMapper
emisCommissionDtl.setCalcExpr(calcExprStr); .selectEmisSalesCommissionRatioList(ratioQuery);
emisCommissionDtl.setQuoteId(exprItem.getQuoteId()); if (!CollectionUtils.isEmpty(ratioList)) {
emisCommissionDtl.setQuoteName(quoteItem.getQuoteName()); EmisSalesCommissionRatio ratio = ratioList.get(0);
emisCommissionDtl.setExprId(exprItem.getId()); // 销售联系人
if (StringUtils.isNotEmpty(salesmen) && ratio.getSalesmenRatio() != null
emisCommissionDtl.setFeeRemark(calcExprStr); && ratio.getSalesmenRatio().compareTo(BigDecimal.ZERO) > 0) {
insertCommissionDtl(
emisCommissionDtlMapper.insertEmisCommissionDtl(emisCommissionDtl); waybill.getBillCode(), quoteItem.getFeeType(), "1", billMonth,
BigDecimal.valueOf(profitMoney).multiply(ratio.getSalesmenRatio())
// 单独根据人名称和月份汇总统计 .divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP),
// reCalcEmpProfitSumMoney(salesmen,billMonth); salesmen, calcExprStr, exprItem.getQuoteId(), quoteItem.getQuoteName(),
}else{ 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"); 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);
}
/** /**
* 计算中转操作提成 * 计算中转操作提成

View File

@ -233,6 +233,8 @@
<result property="virtualRemark" column="virtual_remark" /> <result property="virtualRemark" column="virtual_remark" />
<result property="transType" column="trans_type" /> <result property="transType" column="trans_type" />
<result property="salesSupport" column="sales_support" />
<result property="salesExecutive" column="sales_executive" />
</resultMap> </resultMap>
@ -435,6 +437,8 @@
a3.phone as customer_phone, a3.phone as customer_phone,
a3.nick_name as customer_nick_name, a3.nick_name as customer_nick_name,
a3.avatar as customer_avatar, 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, p.emp_name as dispatch_man_name,q.site_name as print_site_name,
r.emp_name as print_man_name, r.emp_name as print_man_name,