348 lines
15 KiB
XML
348 lines
15 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.fxy.dao.FxyDataDao">
|
|
|
|
<select id="findPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
|
|
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,
|
|
ifnull((select count(*) from tb_user ac where ac.bl_fxy_code = y.invitation_code and bl_is_fxy = 0),0) as userCount,
|
|
ifnull((select count(*) from tb_user ac where ac.bl_fxy_code = y.invitation_code and bl_is_fxy = 1),0) as fxtCount,
|
|
ifnull(t1.ordersCount,0)+ifnull(t2.ordersCount,0) as ordersCount,
|
|
ifnull(t3.money,0) as money
|
|
from bl_fxy_apply x
|
|
inner join tb_user y on x.user_id = y.user_id
|
|
left join (
|
|
select count(*) as ordersCount, aa.user_id, bb.bl_fxy_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_fxy_code
|
|
) t1 on t1.bl_fxy_code = y.invitation_code
|
|
left join (
|
|
select count(*) as ordersCount,cc.bl_fxy_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
|
|
inner join tb_user cc on cc.invitation_code = bb.bl_fxy_code
|
|
group by cc.bl_fxy_code
|
|
) t2 on t2.bl_fxy_code = y.invitation_code
|
|
left join (
|
|
select sum(money) money,user_id
|
|
from user_money_details
|
|
where state = 2
|
|
and type = 1
|
|
and bl_role = 5
|
|
group by user_id
|
|
) t3 on t3.user_id = x.user_id
|
|
where x.status= 1
|
|
<if test="params.name!=null and params.name!=''">
|
|
and x.name like concat('%',#{params.name},'%')
|
|
</if>
|
|
<if test="params.phone!=null and params.phone!=''">
|
|
and x.phone like concat('%',#{params.phone},'%')
|
|
</if>
|
|
<if test="params.startTime!=null and params.startTime!=''">
|
|
and x.approve_time >= #{params.startTime}
|
|
</if>
|
|
<if test="params.endTime!=null and params.endTime!=''">
|
|
and x.approve_time <= #{params.endTime}
|
|
</if>
|
|
order by x.id desc
|
|
</select>
|
|
|
|
<select id="invitationFxyPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
|
|
select a.id,a.user_id,b.avatar,b.user_name,a.name,a.phone,a.remarks,a.create_time
|
|
from bl_fxy_apply a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
where b.bl_fxy_code = #{params.invitationCode}
|
|
<if test="params.name!=null and params.name!=''">
|
|
and a.name like concat('%',#{params.name},'%')
|
|
</if>
|
|
<if test="params.phone!=null and params.phone!=''">
|
|
and a.phone like concat('%',#{params.phone},'%')
|
|
</if>
|
|
order by a.user_id desc
|
|
</select>
|
|
|
|
<select id="invitationUserPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
|
|
select b.user_id,b.avatar,b.user_name as name,b.phone
|
|
from tb_user b
|
|
where b.bl_fxy_code = #{params.invitationCode}
|
|
and b.bl_is_fxy = 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="oneFxyPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
|
|
select a.id,a.user_id,b.avatar,b.user_name,a.name,a.phone,a.remarks,a.create_time
|
|
from bl_fxy_apply a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
where ifnull(b.bl_fxy_code,'') != #{params.invitationCode}
|
|
and b.bl_fxy_level = 1
|
|
and b.user_id != #{params.userId}
|
|
<if test="params.name!=null and params.name!=''">
|
|
and a.name like concat('%',#{params.name},'%')
|
|
</if>
|
|
<if test="params.phone!=null and params.phone!=''">
|
|
and a.phone like concat('%',#{params.phone},'%')
|
|
</if>
|
|
order by a.user_id desc
|
|
</select>
|
|
|
|
<select id="userPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
|
|
select b.user_id,b.avatar,b.user_name as name,b.phone
|
|
from tb_user b
|
|
where ifnull(b.bl_fxy_code,'') != #{params.invitationCode}
|
|
and b.bl_is_fxy = 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="findOrderPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
|
|
select a.id,a.user_id,b.avatar,a.name,a.phone,c.trade_no,c.money,c.pay_time,b.bl_fxy_level
|
|
from bl_fxy_apply a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
inner join pay_details c on a.user_id = c.user_id
|
|
where c.state = 1
|
|
and c.type = 9
|
|
<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>
|
|
<if test="params.startTime!=null and params.startTime!=''">
|
|
and c.pay_time >= #{params.startTime}
|
|
</if>
|
|
<if test="params.endTime!=null and params.endTime!=''">
|
|
and c.pay_time <= #{params.endTime}
|
|
</if>
|
|
order by b.user_id desc
|
|
</select>
|
|
|
|
<select id="invitationDetailPage" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
|
|
select b.user_id,b.avatar,b.user_name,b.phone,
|
|
(case when b.bl_is_fxy = 0 then '用户' else '分销员' end) as type
|
|
from tb_user b
|
|
where b.bl_fxy_code= #{params.invitationCode}
|
|
<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>
|
|
<if test="params.blIsFxy!=null">
|
|
and b.bl_is_fxy = #{params.blIsFxy}
|
|
</if>
|
|
order by b.user_id desc
|
|
</select>
|
|
|
|
<select id="findFxy" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
|
|
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,
|
|
ifnull(select count(*) from tb_user ac where ac.bl_fxy_code = y.invitation_code,0) as userCount,
|
|
ifnull(select count(*)
|
|
from tb_user ac
|
|
where ac.bl_fxy_code = y.invitation_code
|
|
and date_format(aa.create_time, '%Y-%m-%d') = date_format(now(),'%Y-%m-%d'),0
|
|
) as curUserCount,
|
|
ifnull(t1.ordersCount,0)+ifnull(t2.ordersCount,0) as ordersCount,
|
|
ifnull(t4.ordersCount,0)+ifnull(t5.ordersCount,0) as curOrdersCount,
|
|
ifnull(t3.money,0) as money
|
|
from bl_fxy_apply x
|
|
inner join tb_user y on x.user_id = y.user_id
|
|
left join (
|
|
select count(*) as ordersCount, aa.user_id, bb.bl_fxy_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_fxy_code
|
|
) t1 on t1.bl_fxy_code = y.invitation_code
|
|
left join (
|
|
select count(*) as ordersCount,cc.bl_fxy_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
|
|
inner join tb_user cc on cc.invitation_code = bb.bl_fxy_code
|
|
group by cc.bl_fxy_code
|
|
) t2 on t2.bl_fxy_code = y.invitation_code
|
|
left join (
|
|
select count(*) as ordersCount, aa.user_id, bb.bl_fxy_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)
|
|
and date_format(o1.serve_time, '%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
|
|
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)
|
|
and date_format(o1.serve_time, '%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
|
|
) aa inner join tb_user bb on aa.user_id = bb.user_id
|
|
group by aa.user_id, bb.bl_fxy_code
|
|
) t4 on t4.bl_fxy_code = y.invitation_code
|
|
left join (
|
|
select count(*) as ordersCount,cc.bl_fxy_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)
|
|
and date_format(o1.serve_time, '%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
|
|
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)
|
|
and date_format(o1.serve_time, '%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
|
|
) aa inner join tb_user bb on aa.user_id = bb.user_id
|
|
inner join tb_user cc on cc.invitation_code = bb.bl_fxy_code
|
|
group by cc.bl_fxy_code
|
|
) t5 on t5.bl_fxy_code = y.invitation_code
|
|
left join (
|
|
select sum(money) money,user_id
|
|
from user_money_details
|
|
where state = 2
|
|
and type = 1
|
|
group by user_id
|
|
) t3 on t3.user_id = x.user_id
|
|
where x.status= 1
|
|
and x.user_id = #{userId}
|
|
</select>
|
|
|
|
<update id="invitationUser" parameterType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
|
|
update tb_user
|
|
set bl_fxy_code=#{invitationCode}
|
|
where user_id=#{userId}
|
|
</update>
|
|
|
|
<select id="getByUserId" resultType="com.sqx.modules.bl.commission.fxy.entity.FxyData">
|
|
select user_id,avatar,user_name,phone,create_time,status,invitation_code
|
|
from tb_user
|
|
where user_id = #{userId}
|
|
</select>
|
|
|
|
</mapper> |