| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <?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.DeptBalanceMapper">
- <select id="queryDeptLeaderStatistics" resultType="com.ydtech.modules.admin.model.dto.DeptBalanceDto">
- SELECT
- sd.id as "deptId",
- sd.name as "deptName",
- sd.address as "deptAddress",
- sa.user_name as "userName",
- sd.comlevel as "comLevel",
- IFNULL(b.sumPremium,0) as "deptManagementFee",
- IFNULL(b.sumPremium,0) * IFNULL((sa.proportional /100),0) as "totalIncome",
- IFNULL(b.sumPremium,0) * IFNULL((sa.proportional /100),0) -IFNULL(c.sumHistoryFee,0) as "notWithdrawn",
- IFNULL(c.sumHistoryFee,0) as "withdrawn"
- FROM
- sys_agency_leader sa
- LEFT JOIN sys_dept sd ON sd.id = sa.dept_id
- LEFT JOIN (
- SELECT
- io.userid AS "userId",
- sum( IFNULL( iac.jqpremium, 0 ) )+ sum(
- IFNULL( sypremium, 0 )) + sum(
- IFNULL( jypremium, 0 )) AS "sumPremium"
- FROM
- ins_orders io
- LEFT JOIN ins_area_company iac ON iac.orderno = io.orderno
- WHERE
- iac.orderstatus = '3'
- AND io.orderstatus = '3'
- GROUP BY
- io.userid
- ) b ON b.userId = sa.user_id
- LEFT JOIN (
- SELECT
- sum( safa.history_fee ) AS "sumHistoryFee",
- safa.user_id AS "userId"
- FROM
- sys_agency_fee_approval_record safa
- WHERE
- safa.`status` = '1'
- GROUP BY
- safa.user_id
- ) c ON c.userId = sa.user_id
- <where>
- 1=1
- <if test="vo.provinceId != null and vo.provinceId != ''">
- and sd.id like concat('%',#{vo.provinceId},'%')
- </if>
- <if test="vo.cityId != null and vo.cityId != ''">
- and sd.id like concat('%',#{vo.cityId},'%')
- </if>
- <if test="vo.countyId != null and vo.countyId != ''">
- and sd.id like concat('%',#{vo.countyId},'%')
- </if>
- <if test="vo.houseId != null and vo.houseId != ''">
- and sd.id like concat('%',#{vo.houseId},'%')
- </if>
- </where>
- </select>
- <select id="queryPartnerStatistics" resultType="com.ydtech.modules.admin.model.dto.SysPartnerConsoleDto">
- select
- sp.id as "id",
- sp.user_id as "userId",
- sp.user_name as "userName",
- sp.proportional as "proportional",
- sp.suggest_id as "suggestId",
- sp.suggest_name as "suggestName",
- sp.create_time as "createTime",
- sp.create_by as "createBy",
- sp.del_flag as "delFlag",
- sd.name as "deptName"
- from sys_partner sp
- left join sys_user su on su.id = sp.user_id
- left join sys_dept sd on sd.id= su.dept_id
- <where>
- sp.del_flag='0'
- <if test="vo.userId !=null and vo.userId!='' ">
- and sp.user_id =#{vo.userId}
- </if>
- <if test="vo.userIdList !=null and vo.userIdList!='' and vo.userIdList .size() >0">
- and a.user_id IN
- <foreach item="item" index="index" collection="userIdList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="getByDeptId" resultType="java.util.HashMap">
- SELECT
- sum(IFNULL(iac.jqpremium,0) + IFNULL(iac.sypremium,0) + IFNULL(iac.jypremium,0)) * (sal.proportional /100) as
- "totalIncome",
- sum(IFNULL(iac.jqpremium,0) + IFNULL(iac.sypremium,0) + IFNULL(iac.jypremium,0)) * (sal.proportional /100) as
- "deptManagementFee"
- FROM
- ins_orders io
- left join ins_area_company iac on iac.orderno =io.orderno
- left join sys_agency_leader sal on sal.dept_id = iac.deptid
- <where>
- io.orderstatus ='3'
- and iac.orderstatus ='3'
- and sal.del_flag ='1'
- <if test="deptId != null and deptId !=''">
- iac.deptid =#{deptId}
- </if>
- </where>
- </select>
- <select id="getWalletAgent" resultType="com.ydtech.modules.admin.model.dto.SysPartnerConsoleDto">
- select
- su.id as "userId",
- su.name as "userName",
- sd.id as "deptId",
- sd.name as "deptName",
- inf.file_path as "filePath",
- suif.sex as "sex"
- from sys_user su
- left join sys_dept sd on sd.id=su.dept_id
- LEFT JOIN ins_upload_files inf on su.head_sculpture =inf.id
- LEFT JOIN sys_user_info suif on suif.id =su.id
- <where>
- 1=1
- and su.id LIKE '%M%'
- <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>
- <if test="vo.phoneNumber !=null and vo.phoneNumber !=''">
- and su.mobile =#{vo.phoneNumber}
- </if>
- <if test="vo.name !=null and vo.name !=''">
- and su.name =#{vo.name}
- </if>
- <if test="vo.userCode !=null and vo.userCode !=''">
- and su.id= #{vo.userCode}
- </if>
- <if test="vo.days !=null and vo.days !='' ">
- and su.create_time >= DATE_SUB(NOW(), INTERVAL #{vo.days} DAY)
- </if>
- <if test="vo.beginDate !=null and vo.beginDate != '' and vo.endDate !=null and vo.endDate != ''">
- AND DATE_FORMAT( su.create_time, '%Y-%m-%d') BETWEEN #{vo.beginDate} AND #{vo.endDate}
- </if>
- </where>
- </select>
- <select id="getWalletAgentAmount" resultType="java.util.HashMap">
- SELECT
- sum(IFNULL(iac.jqpremium,0) + IFNULL(iac.sypremium,0) + IFNULL(iac.jypremium,0)) as "totalIncome"
- FROM
- ins_orders io
- left join ins_area_company iac on iac.orderno =io.orderno
- <where>
- io.orderstatus ='3'
- and iac.orderstatus ='3'
- <if test="userId != null and userId !=''">
- and io.userid =#{userId}
- </if>
- </where>
- </select>
- </mapper>
|