demand: TMS系统 - 提成管理 - 销售计提比例配置 - 销售顾问与销售主管 关系逻辑调整

committer: heyu
This commit is contained in:
aike 2025-11-28 11:19:24 +08:00
parent 1302743659
commit e7bd820e8c
4 changed files with 139 additions and 18 deletions

View File

@ -80,4 +80,28 @@ public interface EmisSalesCommissionRatioMapper extends BaseMapper<EmisSalesComm
* @return 重复数量
*/
int checkUnique(EmisSalesCommissionRatio emisSalesCommissionRatio);
/**
* 检查一个销售联系人是否已经对应了其他销售主管
*
* @param emisSalesCommissionRatio
* @return 冲突数量
*/
int countBySalesmenAndDifferentExecutive(EmisSalesCommissionRatio emisSalesCommissionRatio);
/**
* 检查一个销售支持是否已经对应了其他销售联系人
*
* @param emisSalesCommissionRatio
* @return 冲突数量
*/
int countBySalesSupportAndDifferentSalesmen(EmisSalesCommissionRatio emisSalesCommissionRatio);
/**
* 检查一个销售支持是否已经对应了其他销售主管
*
* @param emisSalesCommissionRatio
* @return 冲突数量
*/
int countBySalesSupportAndDifferentExecutive(EmisSalesCommissionRatio emisSalesCommissionRatio);
}

View File

@ -1,10 +1,10 @@
/**
/**
* @Project: emis
* @Title: EmisCommissionProfitServiceImpl.java
* @author linfso
* @date 2024-10-24 01:46:36
* @Copyright: ShangHai Duta 2022 All rights reserved.
* @version v1.0
* @version v1.0
* @Description: <p> 员工提成表 实体类 </p>
*/
@ -28,6 +28,7 @@ import com.xdadan.erp.emis.domain.enumtype.ProfitPostType;
import com.xdadan.erp.emis.mapper.*;
import com.xdadan.erp.emis.service.EmisBaseService;
import com.xdadan.erp.emis.utils.WaybillHelper;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
@ -39,7 +40,7 @@ import org.springframework.util.CollectionUtils;
/**
* 员工提成表Service业务层处理
*
*
* @author linfso
* @date 2024-10-24 01:46:36
*/
@ -1346,14 +1347,14 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
if (BigDecimal.valueOf(profitMoney).compareTo(BigDecimal.ZERO) > 0) {
// 新增:按销售分成配置插入多岗位提成
String salesSupport = waybill.getSalesSupport();
String salesExecutive = waybill.getSalesExecutive();
// String salesExecutive = waybill.getSalesExecutive();
boolean hasRatioInsert = false;
if (StringUtils.isNotEmpty(salesmen) && StringUtils.isNotEmpty(salesSupport)
&& StringUtils.isNotEmpty(salesExecutive)) {
if (StringUtils.isNotEmpty(salesmen)) {
EmisSalesCommissionRatio ratioQuery = new EmisSalesCommissionRatio();
ratioQuery.setSalesmen(salesmen);
ratioQuery.setSalesSupport(salesSupport);
ratioQuery.setSalesExecutive(salesExecutive);
if(StringUtil.isNotEmpty(salesSupport)){
ratioQuery.setSalesSupport(salesSupport);
}
ratioQuery.setStatus("1");
// 添加运单寄件日期条件,查询运单寄件日期在计提表有效期内的比例配置
if (waybill.getSendDate() != null) {
@ -1386,13 +1387,13 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
hasRatioInsert = true;
}
// 销售主管
if (StringUtils.isNotEmpty(salesExecutive) && ratio.getSalesExecutiveRatio() != null
if (StringUtils.isNotEmpty(ratio.getSalesExecutive()) && 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(),
ratio.getSalesExecutive(), calcExprStr, exprItem.getQuoteId(),
quoteItem.getQuoteName(), exprItem.getId(), calcExprStr);
hasRatioInsert = true;
}
@ -1726,7 +1727,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
/**
* 查询员工提成表
*
*
* @param id 员工提成表主键
* @return 员工提成表
*/
@ -1739,7 +1740,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
/**
* 查询员工提成表列表
*
*
* @param emisCommissionProfit 员工提成表
* @return 员工提成表
*/
@ -1751,8 +1752,8 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
/**
* 检查是否重复
*
* @param emisCommissionProfit
*
* @param emisCommissionProfit
* @return 数量
*/
@Override
@ -1763,7 +1764,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
/**
* 新增员工提成表
*
*
* @param emisCommissionProfit 员工提成表
* @return 结果
*/
@ -1775,7 +1776,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
/**
* 修改员工提成表
*
*
* @param emisCommissionProfit 员工提成表
* @return 结果
*/
@ -1787,7 +1788,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
/**
* 批量删除员工提成表
*
*
* @param ids 需要删除的员工提成表主键
* @return 结果
*/
@ -1799,7 +1800,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
/**
* 删除员工提成表信息
*
*
* @param id 员工提成表主键
* @return 结果
*/

View File

@ -58,6 +58,10 @@ public class EmisSalesCommissionRatioServiceImpl implements IEmisSalesCommission
if (!checkRatioValid(entity)) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "占比总和必须小于等于100%");
}
// 验证一个销售联系人只能对应一个销售主管
validateSalesmenToExecutive(entity);
// 验证一个销售支持只能对应一个销售联系人、只能对应一个销售主管
validateSalesSupport(entity);
return emisSalesCommissionRatioMapper.insertEmisSalesCommissionRatio(entity);
}
@ -76,6 +80,10 @@ public class EmisSalesCommissionRatioServiceImpl implements IEmisSalesCommission
if (!checkRatioValid(entity)) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "占比总和必须小于等于100%");
}
// 验证一个销售联系人只能对应一个销售主管
validateSalesmenToExecutive(entity);
// 验证一个销售支持只能对应一个销售联系人、只能对应一个销售主管
validateSalesSupport(entity);
return emisSalesCommissionRatioMapper.updateEmisSalesCommissionRatio(entity);
}
@ -122,4 +130,44 @@ public class EmisSalesCommissionRatioServiceImpl implements IEmisSalesCommission
BigDecimal sum = executiveRatio.add(salesmenRatio).add(supportRatio);
return sum.compareTo(new BigDecimal("100.00")) <= 0;
}
/**
* 验证一个销售联系人只能对应一个销售主管
*
* @param entity 配置实体
* @throws EmisBizError 如果销售联系人已经对应了其他销售主管
*/
private void validateSalesmenToExecutive(EmisSalesCommissionRatio entity) throws EmisBizError {
if (entity.getSalesmen() != null && !entity.getSalesmen().trim().isEmpty()
&& entity.getSalesExecutive() != null && !entity.getSalesExecutive().trim().isEmpty()) {
int count = emisSalesCommissionRatioMapper.countBySalesmenAndDifferentExecutive(entity);
if (count > 0) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR,
"销售联系人[" + entity.getSalesmen() + "]已经对应了其他销售主管,一个销售联系人只能对应一个销售主管");
}
}
}
/**
* 验证一个销售支持只能对应一个销售联系人、只能对应一个销售主管
*
* @param entity 配置实体
* @throws EmisBizError 如果销售支持已经对应了其他销售联系人或销售主管
*/
private void validateSalesSupport(EmisSalesCommissionRatio entity) throws EmisBizError {
if (entity.getSalesSupport() != null && !entity.getSalesSupport().trim().isEmpty()) {
// 检查销售支持是否已经对应了其他销售联系人
int countSalesmen = emisSalesCommissionRatioMapper.countBySalesSupportAndDifferentSalesmen(entity);
if (countSalesmen > 0) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR,
"销售支持[" + entity.getSalesSupport() + "]已经对应了其他销售联系人,一个销售支持只能对应一个销售联系人");
}
// 检查销售支持是否已经对应了其他销售主管
int countExecutive = emisSalesCommissionRatioMapper.countBySalesSupportAndDifferentExecutive(entity);
if (countExecutive > 0) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR,
"销售支持[" + entity.getSalesSupport() + "]已经对应了其他销售主管,一个销售支持只能对应一个销售主管");
}
}
}
}

View File

@ -156,4 +156,52 @@
<if test="id != null">AND id != #{id}</if>
</select>
<!-- 检查一个销售联系人是否已经对应了其他销售主管 -->
<select id="countBySalesmenAndDifferentExecutive" parameterType="com.xdadan.erp.emis.domain.EmisSalesCommissionRatio" resultType="int">
SELECT COUNT(1)
FROM emis_sales_commission_ratio
WHERE salesmen = #{salesmen}
AND salesmen IS NOT NULL
AND salesmen != ''
AND sales_executive IS NOT NULL
AND sales_executive != ''
<if test="salesExecutive != null and salesExecutive != ''">
AND sales_executive != #{salesExecutive}
</if>
AND del_flag = '0'
<if test="id != null">AND id != #{id}</if>
</select>
<!-- 检查一个销售支持是否已经对应了其他销售联系人 -->
<select id="countBySalesSupportAndDifferentSalesmen" parameterType="com.xdadan.erp.emis.domain.EmisSalesCommissionRatio" resultType="int">
SELECT COUNT(1)
FROM emis_sales_commission_ratio
WHERE sales_support = #{salesSupport}
AND sales_support IS NOT NULL
AND sales_support != ''
AND salesmen IS NOT NULL
AND salesmen != ''
<if test="salesmen != null and salesmen != ''">
AND salesmen != #{salesmen}
</if>
AND del_flag = '0'
<if test="id != null">AND id != #{id}</if>
</select>
<!-- 检查一个销售支持是否已经对应了其他销售主管 -->
<select id="countBySalesSupportAndDifferentExecutive" parameterType="com.xdadan.erp.emis.domain.EmisSalesCommissionRatio" resultType="int">
SELECT COUNT(1)
FROM emis_sales_commission_ratio
WHERE sales_support = #{salesSupport}
AND sales_support IS NOT NULL
AND sales_support != ''
AND sales_executive IS NOT NULL
AND sales_executive != ''
<if test="salesExecutive != null and salesExecutive != ''">
AND sales_executive != #{salesExecutive}
</if>
AND del_flag = '0'
<if test="id != null">AND id != #{id}</if>
</select>
</mapper>