demand: 提成统计相关需求

This commit is contained in:
aike 2026-04-09 14:24:03 +08:00
parent 9fa9315169
commit 8f8ae2a54c
3 changed files with 42 additions and 13 deletions

View File

@ -83,4 +83,7 @@ public class EmisCommissionProfit extends BaseEntity
/* 岗位类型 */
private String postType;
/* 销售联系人 */
private String salesmen;
}

View File

@ -463,7 +463,10 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
&& existingProfit.getBillMonth().equals(newProfit.getBillMonth())
&& StringUtils.equals(
StringUtils.isEmpty(existingProfit.getPostType()) ? "" : existingProfit.getPostType(),
StringUtils.isEmpty(newProfit.getPostType()) ? "" : newProfit.getPostType())) {
StringUtils.isEmpty(newProfit.getPostType()) ? "" : newProfit.getPostType())
&& StringUtils.equals(
StringUtils.isEmpty(existingProfit.getSalesmen()) ? "" : existingProfit.getSalesmen(),
StringUtils.isEmpty(newProfit.getSalesmen()) ? "" : newProfit.getSalesmen())) {
found = true;
break;
}
@ -474,6 +477,7 @@ public class EmisCommissionProfitServiceImpl extends EmisBaseService implements
zeroProfit.setEmpName(existingProfit.getEmpName());
zeroProfit.setBillMonth(existingProfit.getBillMonth());
zeroProfit.setPostType(existingProfit.getPostType());
zeroProfit.setSalesmen(existingProfit.getSalesmen());
zeroProfit.setMoney(BigDecimal.ZERO);
zeroProfit.setMonthMoney(BigDecimal.ZERO);
listProfit.add(zeroProfit);

View File

@ -25,10 +25,11 @@
<result property="confirmSiteNote" column="confirm_site_note" />
<result property="confirmSiteCode" column="confirm_site_code" />
<result property="postType" column="post_type" />
<result property="salesmen" column="salesmen" />
</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, post_type, 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, salesmen, 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">
@ -37,7 +38,8 @@
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
t.post_type,
t.salesmen
from (
select
a.emp_name,
@ -47,13 +49,6 @@
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'
@ -61,6 +56,13 @@
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.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'
@ -71,7 +73,11 @@
ELSE '6'
END
ELSE COALESCE(c.post_type, '6')
END as post_type
END as post_type,
CASE
WHEN c.post_type = '6' THEN IFNULL(NULLIF(b.salesmen, ''), a.emp_name)
ELSE NULL
END as salesmen
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'
@ -83,7 +89,7 @@
and a.bill_month=#{billMonth}
</if>
) t
group by t.emp_name, t.bill_month, t.post_type
group by t.emp_name, t.bill_month, t.post_type, t.salesmen
</select>
@ -97,6 +103,7 @@
<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="salesmen != null and salesmen != ''"> and salesmen=#{salesmen}</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>
@ -132,12 +139,18 @@
</if>
<if test="postType == null or postType == ''">
and (post_type is null or post_type = '')
</if>
<if test="salesmen != null and salesmen != ''">
and salesmen = #{salesmen}
</if>
<if test="salesmen == null or salesmen == ''">
and (salesmen is null or salesmen = '')
</if>
limit 1
</select>
<select id="selectEmisCommissionProfitById" parameterType="Long" resultMap="EmisCommissionProfitResult">
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
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, salesmen, 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>
@ -165,6 +178,7 @@
<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="salesmen != null and salesmen != ''">salesmen,</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>
@ -195,6 +209,7 @@
<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="salesmen != null and salesmen != ''">#{salesmen},</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>
@ -227,6 +242,7 @@
<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="salesmen != null and salesmen != ''">salesmen = #{salesmen},</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>
@ -248,6 +264,12 @@
<if test="postType == null or postType == ''">
and (post_type is null or post_type = '')
</if>
<if test="salesmen != null and salesmen != ''">
and salesmen = #{salesmen}
</if>
<if test="salesmen == null or salesmen == ''">
and (salesmen is null or salesmen = '')
</if>
</update>
<delete id="deleteEmisCommissionProfitById" parameterType="Long">