|
|
@@ -8,7 +8,7 @@
|
|
|
SELECT
|
|
|
a.userId as "userId",
|
|
|
su.name AS "userName",
|
|
|
- sd.id AS "deptId",
|
|
|
+ a.deptId AS "deptId",
|
|
|
su.leader_name AS "leaderName",
|
|
|
a.sumpremium,
|
|
|
a.jqpremium,
|
|
|
@@ -20,12 +20,14 @@
|
|
|
a.riskCodeJshang,
|
|
|
a.riskCodeDs,
|
|
|
a.riskCodeDsan,
|
|
|
- sd.management_source AS "managementSource",
|
|
|
+ a.managementSource AS "managementSource",
|
|
|
a.distributionAmount,
|
|
|
CASE WHEN a.sumpremium = 0 THEN 0 ELSE a.distributionAmount / a.sumpremium END AS "distributionAmountRate"
|
|
|
FROM (
|
|
|
SELECT
|
|
|
io.userid AS "userId",
|
|
|
+ sd.id as"deptId",
|
|
|
+ sd.management_source as"managementSource",
|
|
|
SUM(IFNULL(jqpremium, 0) + IFNULL(sypremium, 0) + IFNULL(jypremium, 0)) AS "sumpremium",
|
|
|
IFNULL(SUM(jqpremium), 0) AS "jqpremium",
|
|
|
IFNULL(SUM(sypremium), 0) AS "sypremium",
|
|
|
@@ -44,6 +46,8 @@
|
|
|
LEFT JOIN ins_orders io ON io.orderno = iac.orderno
|
|
|
LEFT JOIN sys_user su ON su.id = io.userid
|
|
|
LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
+ LEFT JOIN sys_dept sd ON sd.id = su.dept_id
|
|
|
+
|
|
|
WHERE
|
|
|
iac.orderstatus = '3'
|
|
|
AND (iac.del_flag = '1' OR io.del_flag IS NULL OR io.del_flag = 1)
|
|
|
@@ -63,11 +67,22 @@
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
+ <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
+ AND sd.id IN
|
|
|
+ <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
|
+ AND sd.management_source = #{vo.managementSource}
|
|
|
+ </if>
|
|
|
+ <if test="vo.deptId !=null and vo.deptId!=''">
|
|
|
+ AND sd.id LIKE CONCAT('%', #{vo.deptId}, '%')
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
- io.userid
|
|
|
+ io.userid ,sd.id,sd.management_source
|
|
|
) a
|
|
|
LEFT JOIN sys_user su ON a.userId = su.id
|
|
|
- LEFT JOIN sys_dept sd ON sd.id = su.dept_id
|
|
|
LEFT JOIN sys_user_role sur ON sur.user_id = su.id
|
|
|
WHERE
|
|
|
1 = 1
|
|
|
@@ -77,9 +92,6 @@
|
|
|
<if test="vo.userName !=null and vo.userName!=''">
|
|
|
AND su.name = #{vo.userName}
|
|
|
</if>
|
|
|
- <if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
|
- AND sd.management_source = #{vo.managementSource}
|
|
|
- </if>
|
|
|
<choose>
|
|
|
<when test='vo.managementSource == "2"'>
|
|
|
AND (sur.role_id = 20 OR sur.role_id = 21)
|
|
|
@@ -90,15 +102,6 @@
|
|
|
<otherwise>
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
- AND sd.id IN
|
|
|
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- <if test="vo.deptId !=null and vo.deptId!=''">
|
|
|
- AND sd.id LIKE CONCAT('%', #{vo.deptId}, '%')
|
|
|
- </if>
|
|
|
ORDER BY
|
|
|
a.sumpremium DESC,
|
|
|
a.userId
|
|
|
@@ -118,15 +121,29 @@
|
|
|
LEFT JOIN ins_orders io ON io.orderno = iac.orderno
|
|
|
LEFT JOIN sys_user su ON su.id = io.userid
|
|
|
LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
+ LEFT JOIN sys_dept sd ON sd.id = su.dept_id
|
|
|
+
|
|
|
WHERE
|
|
|
iac.orderstatus = '3'
|
|
|
AND (iac.del_flag = '1' OR io.del_flag IS NULL OR io.del_flag = 1)
|
|
|
<if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
|
|
|
</if>
|
|
|
+ <if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
|
+ AND sd.management_source = #{vo.managementSource}
|
|
|
+ </if>
|
|
|
<if test="vo.leaderName != null and vo.leaderName!='' ">
|
|
|
AND iac.leader_name = #{vo.leaderName}
|
|
|
</if>
|
|
|
+ <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
+ AND sd.id IN
|
|
|
+ <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="vo.deptId !=null and vo.deptId!=''">
|
|
|
+ AND sd.id LIKE CONCAT('%', #{vo.deptId}, '%')
|
|
|
+ </if>
|
|
|
<if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
|
|
|
</if>
|
|
|
@@ -137,10 +154,9 @@
|
|
|
</foreach>
|
|
|
</if>
|
|
|
GROUP BY
|
|
|
- io.userid
|
|
|
+ io.userid,sd.id,sd.management_source
|
|
|
) a
|
|
|
LEFT JOIN sys_user su ON a.userId = su.id
|
|
|
- LEFT JOIN sys_dept sd ON sd.id = su.dept_id
|
|
|
LEFT JOIN sys_user_role sur ON sur.user_id = su.id
|
|
|
WHERE
|
|
|
1 = 1
|
|
|
@@ -150,9 +166,7 @@
|
|
|
<if test="vo.userName !=null and vo.userName!=''">
|
|
|
AND su.name = #{vo.userName}
|
|
|
</if>
|
|
|
- <if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
|
- AND sd.management_source = #{vo.managementSource}
|
|
|
- </if>
|
|
|
+
|
|
|
<choose>
|
|
|
<when test='vo.managementSource == "2"'>
|
|
|
AND (sur.role_id = 20 OR sur.role_id = 21)
|
|
|
@@ -163,83 +177,96 @@
|
|
|
<otherwise>
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
+
|
|
|
+ ) a
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getBusinessAgentDataTotalAdd" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
|
|
|
+ SELECT
|
|
|
+ IFNULL(sum(sumpremium),0) as "sumpremium",
|
|
|
+ IFNULL(sum(a.jqpremium),0) as "jqpremium",
|
|
|
+ IFNULL(sum(a.sypremium),0) as "sypremium",
|
|
|
+ IFNULL(sum(a.taxamount),0) as "taxamount",
|
|
|
+ IFNULL(sum(a.jypremium),0) as "jypremium",
|
|
|
+ IFNULL(sum(a.exportAllFee),0) as "exportAllFee"
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ io.userid AS "userId",
|
|
|
+ sd.id as"deptId",
|
|
|
+ sd.management_source as"managementSource",
|
|
|
+ SUM(IFNULL(jqpremium, 0) + IFNULL(sypremium, 0) + IFNULL(jypremium, 0)) AS "sumpremium",
|
|
|
+ IFNULL(SUM(jqpremium), 0) AS "jqpremium",
|
|
|
+ IFNULL(SUM(sypremium), 0) AS "sypremium",
|
|
|
+ IFNULL(SUM(taxamount), 0) AS "taxamount",
|
|
|
+ IFNULL(SUM(jypremium), 0) AS "jypremium",
|
|
|
+ COUNT(CASE WHEN iac.product = '交三' THEN 1 END) AS "riskCodeJs",
|
|
|
+ COUNT(CASE WHEN iac.product = '单交' THEN 1 END) AS "riskCodeDj",
|
|
|
+ COUNT(CASE WHEN iac.product = '交商' THEN 1 END) AS "riskCodeJshang",
|
|
|
+ COUNT(CASE WHEN iac.product = '单商' THEN 1 END) AS "riskCodeDs",
|
|
|
+ COUNT(CASE WHEN iac.product = '单三' THEN 1 END) AS "riskCodeDsan",
|
|
|
+ ROUND(SUM(IFNULL(ifon.jq_costs_premiums, 0) + IFNULL(ifon.sy_costs_premiums, 0) + IFNULL(ifon.no_costs_premiums, 0)), 2) AS "entranceAllFee",
|
|
|
+ ROUND(SUM(IFNULL(jq_export_other_costs_premiums, 0) + IFNULL(jq_export_supervise_costs_premiums, 0) + IFNULL(sy_export_other_costs_premiums, 0) + IFNULL(sy_export_supervise_costs_premiums, 0) + IFNULL(no_export_other_costs_premiums, 0) + IFNULL(no_export_supervise_costs_premiums, 0)), 2) AS "exportAllFee"
|
|
|
+ FROM
|
|
|
+ ins_area_company iac
|
|
|
+ LEFT JOIN ins_orders io ON io.orderno = iac.orderno
|
|
|
+ LEFT JOIN sys_user su ON su.id = io.userid
|
|
|
+ LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
+ LEFT JOIN sys_dept sd ON sd.id = su.dept_id
|
|
|
+
|
|
|
+ WHERE
|
|
|
+ iac.orderstatus = '3'
|
|
|
+ AND (iac.del_flag = '1' OR io.del_flag IS NULL OR io.del_flag = 1)
|
|
|
+ <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
+ AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
|
|
|
+ </if>
|
|
|
+ <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
+ AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="vo.leaderName != null and vo.leaderName!='' ">
|
|
|
+ AND iac.leader_name = #{vo.leaderName}
|
|
|
+ </if>
|
|
|
+ <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
|
|
|
+ AND su.leader_id IN
|
|
|
+ <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
<if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
AND sd.id IN
|
|
|
<foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
+ <if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
|
+ AND sd.management_source = #{vo.managementSource}
|
|
|
+ </if>
|
|
|
<if test="vo.deptId !=null and vo.deptId!=''">
|
|
|
AND sd.id LIKE CONCAT('%', #{vo.deptId}, '%')
|
|
|
</if>
|
|
|
+ GROUP BY
|
|
|
+ io.userid ,sd.id,sd.management_source
|
|
|
) a
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="getBusinessAgentDataTotalAdd" resultType="com.ydtech.modules.admin.model.vo.BusinessAgentData">
|
|
|
- select
|
|
|
- sum(IFNULL(jqpremium, 0) + IFNULL(sypremium, 0)+ IFNULL(jypremium, 0)) as "sumpremium",
|
|
|
- IFNULL(sum(jqpremium),0) as "jqpremium",
|
|
|
- IFNULL(sum(sypremium),0) as "sypremium",
|
|
|
- IFNULL(sum(taxamount),0) as "taxamount",
|
|
|
- IFNULL(sum(jypremium),0) as "jypremium",
|
|
|
- ROUND(sum(IFNULL(ifon.jq_costs_premiums,0) + IFNULL(ifon.sy_costs_premiums,0) + IFNULL
|
|
|
- (ifon.no_costs_premiums,0)),2) as "entranceAllFee",
|
|
|
- ROUND(sum(IFNULL(jq_export_other_costs_premiums,0) + IFNULL(jq_export_supervise_costs_premiums,0)
|
|
|
- +IFNULL(sy_export_other_costs_premiums,0) +IFNULL(sy_export_supervise_costs_premiums,0)
|
|
|
- +IFNULL(no_export_other_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as "exportAllFee"
|
|
|
- from ins_area_company iac
|
|
|
- left join ins_orders io on io.orderno =iac.orderno
|
|
|
- left join sys_dept sd on sd.id =io.deptid
|
|
|
- LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
- <where>
|
|
|
- iac.orderstatus = '3'
|
|
|
- and (iac.del_flag = '1' )
|
|
|
- <if test="vo.signingTimeStart != null and vo.signingTimeStart!='' and vo.signingTimeEnd != null and vo.signingTimeEnd != ''">
|
|
|
- AND iac.signing_time BETWEEN #{vo.signingTimeStart} AND #{vo.signingTimeEnd}
|
|
|
- </if>
|
|
|
- <if test="vo.enterTimeStart != null and vo.enterTimeStart!='' and vo.enterTimeEnd != null and vo.enterTimeEnd != ''">
|
|
|
- AND iac.createtime BETWEEN #{vo.enterTimeStart} AND #{vo.enterTimeEnd}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="vo.days !=null and vo.days !='' and vo.days != 0 ">
|
|
|
- and iac.createtime >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
|
|
|
- </if>
|
|
|
- <if test="vo.leaderName != null and vo.leaderName!='' ">
|
|
|
- AND iac.leader_name = #{vo.leaderName}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="vo.userName !=null and vo.userName!=''">
|
|
|
- and io.userName=#{vo.userName}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="vo.userId !=null and vo.userId !=''">
|
|
|
- and io.userid=#{vo.userId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="vo.userIds !=null and vo.userIds!='' and vo.userIds.size()>0">
|
|
|
- and iac.leader_id in
|
|
|
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="vo.deptId !=null and vo.deptId!=''">
|
|
|
- and io.deptid like concat('%',#{vo.deptId},'%')
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
|
- and sd.management_source=#{vo.managementSource}
|
|
|
- </if>
|
|
|
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
- AND io.deptid in
|
|
|
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- <if test="vo.leaderName !=null and vo.leaderName!=''">
|
|
|
- and iac.leader_name=#{vo.leaderName}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
+ LEFT JOIN sys_user su ON a.userId = su.id
|
|
|
+ LEFT JOIN sys_user_role sur ON sur.user_id = su.id
|
|
|
+ WHERE
|
|
|
+ 1 = 1
|
|
|
+ <if test="vo.userId !=null and vo.userId!=''">
|
|
|
+ AND su.id = #{vo.userId}
|
|
|
+ </if>
|
|
|
+ <if test="vo.userName !=null and vo.userName!=''">
|
|
|
+ AND su.name = #{vo.userName}
|
|
|
+ </if>
|
|
|
+ <choose>
|
|
|
+ <when test='vo.managementSource == "2"'>
|
|
|
+ AND (sur.role_id = 20 OR sur.role_id = 21)
|
|
|
+ </when>
|
|
|
+ <when test='vo.managementSource == "1"'>
|
|
|
+ AND (sur.role_id = 19 OR sur.role_id = 21)
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
</select>
|
|
|
|
|
|
|
|
|
@@ -534,7 +561,8 @@
|
|
|
SELECT
|
|
|
a.userId as "userId",
|
|
|
su.name AS "userName",
|
|
|
- sd.id AS "deptId",
|
|
|
+ a.deptId AS "deptId",
|
|
|
+ a.managementSource AS "managementSource",
|
|
|
su.leader_name AS "leaderName",
|
|
|
a.sumpremium,
|
|
|
a.jqpremium,
|
|
|
@@ -546,12 +574,14 @@
|
|
|
a.riskCodeJshang,
|
|
|
a.riskCodeDs,
|
|
|
a.riskCodeDsan,
|
|
|
- sd.management_source AS "managementSource",
|
|
|
+ a.managementSource AS "managementSource",
|
|
|
a.distributionAmount,
|
|
|
CASE WHEN a.sumpremium = 0 THEN 0 ELSE a.distributionAmount / a.sumpremium END AS "distributionAmountRate"
|
|
|
FROM (
|
|
|
SELECT
|
|
|
io.userid AS "userId",
|
|
|
+ sd.management_source AS "managementSource",
|
|
|
+ sd.id as "deptId",
|
|
|
SUM(IFNULL(jqpremium, 0) + IFNULL(sypremium, 0) + IFNULL(jypremium, 0)) AS "sumpremium",
|
|
|
IFNULL(SUM(jqpremium), 0) AS "jqpremium",
|
|
|
IFNULL(SUM(sypremium), 0) AS "sypremium",
|
|
|
@@ -570,6 +600,7 @@
|
|
|
LEFT JOIN ins_orders io ON io.orderno = iac.orderno
|
|
|
LEFT JOIN sys_user su ON su.id = io.userid
|
|
|
LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
+ LEFT JOIN sys_dept sd ON sd.id = su.dept_id
|
|
|
WHERE
|
|
|
iac.orderstatus = '3'
|
|
|
AND (iac.del_flag = '1' OR io.del_flag IS NULL OR io.del_flag = 1)
|
|
|
@@ -589,11 +620,22 @@
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
+ <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
+ AND sd.id IN
|
|
|
+ <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="vo.deptId !=null and vo.deptId!=''">
|
|
|
+ AND sd.id LIKE CONCAT('%', #{vo.deptId}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
|
+ AND sd.management_source = #{vo.managementSource}
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
- io.userid
|
|
|
+ io.userid,sd.management_source ,sd.id
|
|
|
) a
|
|
|
LEFT JOIN sys_user su ON a.userId = su.id
|
|
|
- LEFT JOIN sys_dept sd ON sd.id = su.dept_id
|
|
|
LEFT JOIN sys_user_role sur ON sur.user_id = su.id
|
|
|
WHERE
|
|
|
1 = 1
|
|
|
@@ -603,9 +645,6 @@
|
|
|
<if test="vo.userName !=null and vo.userName!=''">
|
|
|
AND su.name = #{vo.userName}
|
|
|
</if>
|
|
|
- <if test="vo.managementSource !=null and vo.managementSource!=''">
|
|
|
- AND sd.management_source = #{vo.managementSource}
|
|
|
- </if>
|
|
|
<choose>
|
|
|
<when test='vo.managementSource == "2"'>
|
|
|
AND (sur.role_id = 20 OR sur.role_id = 21)
|
|
|
@@ -616,15 +655,6 @@
|
|
|
<otherwise>
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
- AND sd.id IN
|
|
|
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- <if test="vo.deptId !=null and vo.deptId!=''">
|
|
|
- AND sd.id LIKE CONCAT('%', #{vo.deptId}, '%')
|
|
|
- </if>
|
|
|
ORDER BY
|
|
|
a.sumpremium DESC,
|
|
|
a.userId
|