Merge pull request 'demand: tms-提成管理-运单提成明细-批量重算-按单号/按月份重算-计算员工提成按岗位生成 tms-提成管理-提成统计-查询支持按岗位查询' (#273) from develop into master

Reviewed-on: http://git.xdadan.loc/tanex/emis-service/pulls/273
This commit is contained in:
heyu 2025-12-18 16:25:11 +08:00
commit 80386d22a2
4 changed files with 109 additions and 33 deletions

View File

@ -80,4 +80,7 @@ public class EmisCommissionProfit extends BaseEntity
/* 结算类型 1-现金 2-月结 */
private String settleType;
/* 岗位类型 */
private String postType;
}

View File

@ -1,10 +1,10 @@
/**
/**
* @Project: emis
* @Title: EmisCommissionProfitMapper.java
* @author linfso
* @date 2024-10-24 01:46:35
* @Copyright: ShangHai Doitinfo 2022 All rights reserved.
* @version v1.0
* @version v1.0
* @Description: <p> 员工提成表 Mapper 接口 </p>
* <span style='color:red'> Warning : This file is generate by ai tools,don't edit!!! </span>
*/
@ -26,14 +26,14 @@ public interface EmisCommissionProfitMapper extends BaseMapper<EmisCommissionPro
/**
* 主键查询
* @param id
* @return
* @return
*/
public EmisCommissionProfit selectEmisCommissionProfitById(Long id);
/**
* 查询列表
*
* @param emisCommissionProfit
*
* @param emisCommissionProfit
* @return 集合
*/
public List<EmisCommissionProfit> selectEmisCommissionProfitList(EmisCommissionProfit emisCommissionProfit);
@ -44,26 +44,26 @@ public interface EmisCommissionProfitMapper extends BaseMapper<EmisCommissionPro
/**
* 检查是否重复
*
* @param emisCommissionProfit
*
* @param emisCommissionProfit
* @return 数量
*/
public int checkUnique(EmisCommissionProfit emisCommissionProfit);
/**
* 新增
*
* 新增
*
* @param emisCommissionProfit
* @return
* @return
*/
public int insertEmisCommissionProfit(EmisCommissionProfit emisCommissionProfit);
/**
* 修改
*
* @param emisCommissionProfit
* @return
*
* @param emisCommissionProfit
* @return
*/
public int updateEmisCommissionProfit(EmisCommissionProfit emisCommissionProfit);
@ -76,7 +76,7 @@ public interface EmisCommissionProfitMapper extends BaseMapper<EmisCommissionPro
/**
* 删除
*
*
* @param id 主键
* @return 结果
*/
@ -84,9 +84,11 @@ public interface EmisCommissionProfitMapper extends BaseMapper<EmisCommissionPro
/**
* 批量删除
*
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteEmisCommissionProfitByIds(Long[] ids);
void deleteEmpty();
}

View File

@ -459,7 +459,10 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
boolean found = false;
for(EmisCommissionProfit newProfit : listProfit) {
if(existingProfit.getEmpName().equals(newProfit.getEmpName())
&& existingProfit.getBillMonth().equals(newProfit.getBillMonth())) {
&& existingProfit.getBillMonth().equals(newProfit.getBillMonth())
&& StringUtils.equals(
StringUtils.isEmpty(existingProfit.getPostType()) ? "" : existingProfit.getPostType(),
StringUtils.isEmpty(newProfit.getPostType()) ? "" : newProfit.getPostType())) {
found = true;
break;
}
@ -469,6 +472,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
EmisCommissionProfit zeroProfit = new EmisCommissionProfit();
zeroProfit.setEmpName(existingProfit.getEmpName());
zeroProfit.setBillMonth(existingProfit.getBillMonth());
zeroProfit.setPostType(existingProfit.getPostType());
zeroProfit.setMoney(BigDecimal.ZERO);
zeroProfit.setMonthMoney(BigDecimal.ZERO);
listProfit.add(zeroProfit);
@ -487,6 +491,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
emisCommissionProfitMapper.insertEmisCommissionProfit(profitItem);
}
}
emisCommissionProfitMapper.deleteEmpty();
}catch (Exception ex){
redissonService.unlock(lockKey);
ex.printStackTrace();

View File

@ -24,25 +24,66 @@
<result property="confirmSiteManCode" column="confirm_site_man_code" />
<result property="confirmSiteNote" column="confirm_site_note" />
<result property="confirmSiteCode" column="confirm_site_code" />
<result property="postType" column="post_type" />
</resultMap>
<sql id="selectEmisCommissionProfitVo">
select id, profit_no, emp_code, emp_name, bill_month, money,month_money, real_money, payed_money, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_commission_profit
select id, profit_no, emp_code, emp_name, bill_month, money,month_money, real_money, payed_money, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, post_type, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_commission_profit
</sql>
<select id="selectProfitStatList" parameterType="String" resultMap="EmisCommissionProfitResult">
select emp_name ,bill_month,
sum(if(b.payment_type in(1,3,6),money,0) ) as money,
sum(if(b.payment_type in(2,4,5),money,0) ) as month_money
from emis_commission_dtl a,emis_waybill b
where a.del_flag='0' and a.bill_code=b.bill_code
<if test="empName != null and empName != ''">
and a.emp_name = #{empName}
</if>
<if test="billMonth != null and billMonth != ''">
and a.bill_month=#{billMonth}
</if>
group by a.emp_name,a.bill_month
select
t.emp_name,
t.bill_month,
sum(if(t.payment_type in(1,3,6),t.money,0)) as money,
sum(if(t.payment_type in(2,4,5),t.money,0)) as month_money,
t.post_type
from (
select
a.emp_name,
a.bill_month,
a.money,
b.payment_type,
CASE
WHEN c.post_type = '6' THEN
CASE
WHEN EXISTS (
SELECT 1 FROM emis_sales_commission_ratio r
WHERE r.del_flag='0'
AND r.salesmen = a.emp_name
AND r.status = '1'
LIMIT 1
) THEN '6'
WHEN EXISTS (
SELECT 1 FROM emis_sales_commission_ratio r
WHERE r.del_flag='0'
AND r.sales_executive = a.emp_name
AND r.status = '1'
LIMIT 1
) THEN '9'
WHEN EXISTS (
SELECT 1 FROM emis_sales_commission_ratio r
WHERE r.del_flag='0'
AND r.sales_support = a.emp_name
AND r.status = '1'
LIMIT 1
) THEN '10'
ELSE '6'
END
ELSE COALESCE(c.post_type, '6')
END as post_type
from emis_commission_dtl a
inner join emis_waybill b on a.bill_code = b.bill_code
left join emis_commission_quote c on a.quote_id = c.quote_id and c.del_flag='0'
where a.del_flag='0'
<if test="empName != null and empName != ''">
and a.emp_name = #{empName}
</if>
<if test="billMonth != null and billMonth != ''">
and a.bill_month=#{billMonth}
</if>
) t
group by t.emp_name, t.bill_month, t.post_type
</select>
@ -55,6 +96,7 @@
<if test="empCode != null and empCode != ''"> and emp_code like concat('%', #{empCode}, '%')</if>
<if test="empName != null and empName != ''"> and emp_name=#{empName}</if>
<if test="billMonth != null and billMonth != ''"> and bill_month=#{billMonth}</if>
<if test="postType != null and postType != ''"> and post_type=#{postType}</if>
<if test="money != null "> and money = #{money}</if>
<if test="realMoney != null "> and real_money = #{realMoney}</if>
<if test="payedMoney != null "> and payed_money = #{payedMoney}</if>
@ -85,11 +127,17 @@
where del_flag='0'
and emp_name = #{empName}
and bill_month = #{billMonth}
<if test="postType != null and postType != ''">
and post_type = #{postType}
</if>
<if test="postType == null or postType == ''">
and (post_type is null or post_type = '')
</if>
limit 1
</select>
<select id="selectEmisCommissionProfitById" parameterType="Long" resultMap="EmisCommissionProfitResult">
select id, profit_no, emp_code, emp_name, bill_month, money, monthMoney,real_money, payed_money, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
select id, profit_no, emp_code, emp_name, bill_month, money, month_money, real_money, payed_money, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, post_type, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_commission_profit a
where a.id = #{id}
</select>
@ -116,6 +164,7 @@
<if test="confirmSiteManCode != null and confirmSiteManCode != ''">confirm_site_man_code,</if>
<if test="confirmSiteNote != null and confirmSiteNote != ''">confirm_site_note,</if>
<if test="confirmSiteCode != null and confirmSiteCode != ''">confirm_site_code,</if>
<if test="postType != null and postType != ''">post_type,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
@ -145,6 +194,7 @@
<if test="confirmSiteManCode != null and confirmSiteManCode != ''">#{confirmSiteManCode},</if>
<if test="confirmSiteNote != null and confirmSiteNote != ''">#{confirmSiteNote},</if>
<if test="confirmSiteCode != null and confirmSiteCode != ''">#{confirmSiteCode},</if>
<if test="postType != null and postType != ''">#{postType},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
@ -176,6 +226,7 @@
<if test="confirmSiteManCode != null and confirmSiteManCode != ''">confirm_site_man_code = #{confirmSiteManCode},</if>
<if test="confirmSiteNote != null and confirmSiteNote != ''">confirm_site_note = #{confirmSiteNote},</if>
<if test="confirmSiteCode != null and confirmSiteCode != ''">confirm_site_code = #{confirmSiteCode},</if>
<if test="postType != null and postType != ''">post_type = #{postType},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
@ -189,7 +240,14 @@
</update>
<update id="updateProfitMoney" parameterType="EmisCommissionProfit">
update emis_commission_profit set money = #{money},month_money = #{monthMoney} where emp_name = #{empName} and bill_month = #{billMonth}
update emis_commission_profit set money = #{money},month_money = #{monthMoney}
where emp_name = #{empName} and bill_month = #{billMonth}
<if test="postType != null and postType != ''">
and post_type = #{postType}
</if>
<if test="postType == null or postType == ''">
and (post_type is null or post_type = '')
</if>
</update>
<delete id="deleteEmisCommissionProfitById" parameterType="Long">
@ -202,4 +260,12 @@
#{id}
</foreach>
</delete>
</mapper>
<delete id="deleteEmpty" parameterType="String">
update emis_commission_profit
set del_flag='1'
where money = 0
and month_money = 0
and del_flag = '0'
</delete>
</mapper>