sadjv3_java/src/main/resources/mapper/bl/commission/qds/QdsDataDao.xml

88 lines
3.9 KiB
XML

<?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.sqx.modules.bl.commission.qds.dao.QdsDataDao">
<select id="findPage" resultType="com.sqx.modules.bl.commission.qds.entity.QdsData">
select bqc.id,bqc.name as qdmName,bqc.code as qdsCode,bqc.lm,y.user_name as userName,x.name as qdsName,bqc.rate,
bqc.start_date as startTime,bqc.end_date as endTime,bqc.create_time as createTime,
ifnull((select count(*) from tb_user ac where ac.bl_qds_code = bqc.code and ifnull(bl_is_qds,0) = 0),0) as smCount,
ifnull(t1.ordersCount,0) as ordersCount,
ifnull(t3.money,0) as money
from bl_qds_code bqc
inner join bl_qds_apply x on bqc.user_id = x.user_id and x.status = 1
inner join tb_user y on x.user_id = y.user_id
left join (
select count(*) as ordersCount, aa.user_id, bb.bl_qds_code
from (
select o1.orders_id,o1.user_id
from orders o1
left join orders o2 on o1.old_orders_id = o2.orders_id and o2.status != 4
left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4
where o1.old_orders_id is not null
and o1.status in (3,5)
union all
select o1.orders_id,o1.user_id
from orders o1
where o1.parent_id = 0
and o1.old_orders_id is null
and o1.orders_id not in (
select orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.orders_id not in (
select old_orders_id from orders
where old_orders_id is not null
and status != 4
)
and o1.status in (3,5)
) aa inner join tb_user bb on aa.user_id = bb.user_id
group by aa.user_id, bb.bl_qds_code
) t1 on t1.bl_qds_code = bqc.code
left join (
select sum(ifnull(qds_code_money,0)) money,user_id
from orders
where status in (3,5,15)
group by user_id
) t3 on t3.user_id = x.user_id
where x.status= 1
<if test="params.qdmName!=null and params.qdmName!=''">
and bqc.name like concat('%',#{params.qdmName},'%')
</if>
<if test="params.qdsCode!=null and params.qdsCode!=''">
and bqc.code like concat('%',#{params.qdsCode},'%')
</if>
<if test="params.qdsName!=null and params.qdsName!=''">
and x.name like concat('%',#{params.qdsName},'%')
</if>
<if test="params.lm!=null and params.lm!=''">
and bqc.lm = #{params.lm}
</if>
order by x.id desc
</select>
<select id="invitationUserPage" resultType="com.sqx.modules.bl.commission.qds.entity.QdsData">
select b.user_id,b.avatar,b.user_name as name,b.phone
from tb_user b
where b.bl_qds_code = #{params.qdsCode}
and ifnull(b.bl_is_qds,0) = 0
<if test="params.name!=null and params.name!=''">
and b.user_name like concat('%',#{params.name},'%')
</if>
<if test="params.phone!=null and params.phone!=''">
and b.phone like concat('%',#{params.phone},'%')
</if>
order by b.user_id desc
</select>
<select id="findQds" resultType="com.sqx.modules.bl.commission.qds.entity.QdsData">
select
x.id,x.user_id,y.avatar,y.user_name,x.name,x.phone,x.remarks,x.create_time,x.status,x.opinion,y.invitation_code,x.approve_time
from bl_qds_apply x
inner join tb_user y on x.user_id = y.user_id
where x.status= 1
and x.user_id = #{userId}
</select>
</mapper>