|
@@ -0,0 +1,249 @@
|
|
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
+<!DOCTYPE mapper
|
|
|
|
|
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
+<mapper namespace="com.ydtech.modules.admin.dao.UserReportMapper">
|
|
|
|
|
+ <select id="selectChannelPerson" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
|
|
|
|
|
+ select
|
|
|
|
|
+ d.name as "deptName",
|
|
|
|
|
+ u.name as "name",
|
|
|
|
|
+ d.id as "deptId",
|
|
|
|
|
+ u.id as "userId",
|
|
|
|
|
+ u.mobile as "mobile",
|
|
|
|
|
+ inf.url as "filePath",
|
|
|
|
|
+ sui.sex as "sex",
|
|
|
|
|
+ r.role_id AS roleId,
|
|
|
|
|
+ f.totalPremium as "totalPremium",
|
|
|
|
|
+ f.averagePremium as "averagePremium",
|
|
|
|
|
+ IFNULL(f.entranceAllFee,0) -IFNULL(f.exportAllFee,0) as "distributionAmount"
|
|
|
|
|
+ from sys_user u
|
|
|
|
|
+ left join sys_dept d on d.id = u.dept_id
|
|
|
|
|
+ left join sys_user_role r on u.id = r.user_id
|
|
|
|
|
+ LEFT JOIN ins_upload_files inf on u.head_sculpture =inf.id
|
|
|
|
|
+ LEFT JOIN sys_user_info sui on sui .id =u.id
|
|
|
|
|
+ left join (select (select user_id
|
|
|
|
|
+ from sys_user u
|
|
|
|
|
+ left join sys_user_role r on u.id = r.user_id
|
|
|
|
|
+ where u.dept_id = sd.id and r.role_id = 21 limit 1) as "userid",
|
|
|
|
|
+ sum(jqpremium + sypremium + jypremium) as "totalPremium",
|
|
|
|
|
+ ROUND(sum( jqpremium + sypremium + jypremium )/ count( iac.orderno ),2) AS "averagePremium",
|
|
|
|
|
+ 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_supervise_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as
|
|
|
|
|
+ "exportAllFee"
|
|
|
|
|
+ from ins_area_company iac
|
|
|
|
|
+ left join ins_orders io on iac.orderno = io.orderno
|
|
|
|
|
+ left join sys_dept sd on io.deptid = sd.id
|
|
|
|
|
+ LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
|
|
+ <where>
|
|
|
|
|
+ sd.management_source = '1'
|
|
|
|
|
+ and iac.orderstatus = '3'
|
|
|
|
|
+ <if test="vo.ids != null and vo.ids.size()>0 ">
|
|
|
|
|
+ AND io.userid IN
|
|
|
|
|
+ <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
|
|
|
|
|
+ AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ group by sd.id) as f on f.userid = u.id
|
|
|
|
|
+ <where>
|
|
|
|
|
+ d.management_source = '1'
|
|
|
|
|
+ and r.role_id = 21
|
|
|
|
|
+ and u.status = '1'
|
|
|
|
|
+ <if test="vo.provinceId != null and vo.provinceId != ''">
|
|
|
|
|
+ and d.id like concat('%',#{vo.provinceId},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.cityId != null and vo.cityId != ''">
|
|
|
|
|
+ and d.id like concat('%',#{vo.cityId},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.countyId != null and vo.countyId != ''">
|
|
|
|
|
+ and d.id like concat('%',#{vo.countyId},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.houseId != null and vo.houseId != ''">
|
|
|
|
|
+ and d.id like concat('%',#{vo.houseId},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.name != null and vo.name != ''">
|
|
|
|
|
+ and u.name =#{vo.name}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.userCode != null and vo.userCode != ''">
|
|
|
|
|
+ and u.id =#{vo.userCode}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.phoneNumber != null and vo.phoneNumber != ''">
|
|
|
|
|
+ and u.mobile =#{vo.phoneNumber}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.leaderId != null and vo.leaderId != ''">
|
|
|
|
|
+ and u.leader_id =#{vo.leaderId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.leaderName != null and vo.leaderName != ''">
|
|
|
|
|
+ and u.leader_name =#{vo.leaderName}
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
|
|
+ <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
|
|
+ AND d.id in
|
|
|
|
|
+ <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
|
|
+ <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
|
|
|
|
|
+ AND u.id in
|
|
|
|
|
+ <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ order by f.totalPremium desc
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectChannelPersonOld" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
|
|
|
|
|
+ select
|
|
|
|
|
+ d.name as "deptName",
|
|
|
|
|
+ u.name as "name",
|
|
|
|
|
+ d.id as "deptId",
|
|
|
|
|
+ u.id as "userId",
|
|
|
|
|
+ u.mobile as "mobile",
|
|
|
|
|
+ u.leader_name as "leaderName",
|
|
|
|
|
+ inf.url as "filePath",
|
|
|
|
|
+ sui.sex as "sex",
|
|
|
|
|
+ r.role_id AS roleId,
|
|
|
|
|
+ IFNULL(f.totalPremium,0) as "totalPremium",
|
|
|
|
|
+ IFNULL(f.averagePremium,0) as "averagePremium",
|
|
|
|
|
+ IFNULL(IFNULL(f.entranceAllFee,0) -IFNULL(f.exportAllFee,0),0) as "estimatedProfit"
|
|
|
|
|
+ from sys_user u
|
|
|
|
|
+ left join sys_dept d on d.id = u.dept_id
|
|
|
|
|
+ left join sys_user_role r on u.id = r.user_id
|
|
|
|
|
+ LEFT JOIN ins_upload_files inf on u.head_sculpture =inf.id
|
|
|
|
|
+ LEFT JOIN sys_user_info sui on sui .id =u.id
|
|
|
|
|
+ left join (select (select user_id
|
|
|
|
|
+ from sys_user u
|
|
|
|
|
+ left join sys_user_role r on u.id = r.user_id
|
|
|
|
|
+ where u.dept_id = sd.id and r.role_id = 21 limit 1) as "userid",
|
|
|
|
|
+ sum(jqpremium + sypremium + jypremium) as "totalPremium",
|
|
|
|
|
+ ROUND(sum( jqpremium + sypremium + jypremium )/ count( iac.orderno ),2) AS "averagePremium",
|
|
|
|
|
+ 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_supervise_costs_premiums,0)+IFNULL(no_export_supervise_costs_premiums,0) ),2) as
|
|
|
|
|
+ "exportAllFee"
|
|
|
|
|
+ from ins_area_company iac
|
|
|
|
|
+ left join ins_orders io on iac.orderno = io.orderno
|
|
|
|
|
+ left join sys_dept sd on io.deptid = sd.id
|
|
|
|
|
+ LEFT JOIN ins_fee_order_new ifon ON iac.id = ifon.ins_order_no
|
|
|
|
|
+ <where>
|
|
|
|
|
+ and iac.orderstatus = '3'
|
|
|
|
|
+ <if test="vo.managementSource != null and vo.managementSource!=''">
|
|
|
|
|
+ AND sd.management_source =#{vo.managementSource}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.ids != null and vo.ids.size()>0 ">
|
|
|
|
|
+ AND io.userid IN
|
|
|
|
|
+ <foreach item="item" collection="vo.ids" open="(" separator="," close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.createtimeStart != null and vo.createtimeStart!='' and vo.createtimeEnd != null and vo.createtimeEnd!=''">
|
|
|
|
|
+ AND iac.signing_time BETWEEN #{vo.createtimeStart} AND #{vo.createtimeEnd}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ group by sd.id) as f on f.userid = u.id
|
|
|
|
|
+ <where>
|
|
|
|
|
+ d.management_source = '1'
|
|
|
|
|
+ and r.role_id = 21
|
|
|
|
|
+ and u.status = '1'
|
|
|
|
|
+ <if test="vo.provinceId != null and vo.provinceId != ''">
|
|
|
|
|
+ and d.id like concat('%',#{vo.provinceId},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.cityId != null and vo.cityId != ''">
|
|
|
|
|
+ and d.id like concat('%',#{vo.cityId},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.countyId != null and vo.countyId != ''">
|
|
|
|
|
+ and d.id like concat('%',#{vo.countyId},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.houseId != null and vo.houseId != ''">
|
|
|
|
|
+ and d.id like concat('%',#{vo.houseId},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.name != null and vo.name != ''">
|
|
|
|
|
+ and u.name =#{vo.name}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.userCode != null and vo.userCode != ''">
|
|
|
|
|
+ and u.id =#{vo.userCode}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.phoneNumber != null and vo.phoneNumber != ''">
|
|
|
|
|
+ and u.mobile =#{vo.phoneNumber}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.leaderId != null and vo.leaderId != ''">
|
|
|
|
|
+ and u.leader_id =#{vo.leaderId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="vo.leaderName != null and vo.leaderName != ''">
|
|
|
|
|
+ and u.leader_name =#{vo.leaderName}
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
|
|
+ <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
|
|
|
|
|
+ AND d.id in
|
|
|
|
|
+ <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
|
|
+ <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
|
|
|
|
|
+ AND u.id in
|
|
|
|
|
+ <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
|
|
|
|
|
+ #{item}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ order by f.totalPremium desc
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectAgentPerson" resultType="com.ydtech.modules.admin.model.dto.QxFrontlineAgentDto">
|
|
|
|
|
+ select u.id,
|
|
|
|
|
+ u.name,
|
|
|
|
|
+ f.c,
|
|
|
|
|
+ (select count(*) from sys_user where dept_id = u.dept_id) as ucount,
|
|
|
|
|
+ (
|
|
|
|
|
+ select count(*) from
|
|
|
|
|
+ (select io1.userid, count(*) count1 from ins_area_company iac1
|
|
|
|
|
+ left join ins_orders io1 on iac1.orderno = io1.orderno
|
|
|
|
|
+ where iac1.orderstatus = '3' and io1.userid = u.id
|
|
|
|
|
+ group by io1.userid) as f1
|
|
|
|
|
+ where f1.count1 > 0
|
|
|
|
|
+ ) as count2
|
|
|
|
|
+
|
|
|
|
|
+ from sys_user u
|
|
|
|
|
+ left join sys_dept d on d.id = u.dept_id
|
|
|
|
|
+ left join sys_user_role r on u.id = r.user_id
|
|
|
|
|
+ left join (select (select user_id
|
|
|
|
|
+ from sys_user u
|
|
|
|
|
+ left join sys_user_role r on u.id = r.user_id
|
|
|
|
|
+ where u.dept_id = sd.id
|
|
|
|
|
+ and r.role_id = 21
|
|
|
|
|
+ limit 1) as userid,
|
|
|
|
|
+ (select u.name
|
|
|
|
|
+ from sys_user u
|
|
|
|
|
+ left join sys_user_role r on u.id = r.user_id
|
|
|
|
|
+ where u.dept_id = sd.id
|
|
|
|
|
+ and r.role_id = 21
|
|
|
|
|
+ limit 1) as username,
|
|
|
|
|
+ sd.id,
|
|
|
|
|
+ sum(jqpremium + sypremium + jypremium) c
|
|
|
|
|
+ from ins_area_company iac
|
|
|
|
|
+ left join ins_orders io on iac.orderno = io.orderno
|
|
|
|
|
+ left join sys_dept sd on io.deptid = sd.id
|
|
|
|
|
+ where sd.management_source = '2'
|
|
|
|
|
+ and iac.orderstatus = '3'
|
|
|
|
|
+ and iac.createtime between '2024-10-24 00:00:00' and '2024-10-25 00:00:00'
|
|
|
|
|
+ group by sd.id) as f on f.userid = u.id
|
|
|
|
|
+ where d.management_source = '2'
|
|
|
|
|
+ and r.role_id = 21
|
|
|
|
|
+ order by c desc;
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+</mapper>
|