224 lines
9.9 KiB
XML
224 lines
9.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.jjr.dao.JjrDataDao">
|
|
|
|
<select id="findPage" resultType="com.sqx.modules.bl.commission.jjr.entity.JjrData">
|
|
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 inner join artificer aa on a.user_id = aa.user_id where ac.bl_jjr_code = y.invitation_code,0) as artificerCount,
|
|
ifnull(t1.ordersCount,0) as ordersCount,
|
|
ifnull(t3.money,0) as money
|
|
from bl_jjr_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_jjr_code
|
|
from (
|
|
select o1.orders_id,a.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
|
|
left join artificer a on a.artificer_id=o1.artificer_id
|
|
where o1.old_orders_id is not null
|
|
and o1.status in (3,5)
|
|
union all
|
|
select o1.orders_id,a.user_id
|
|
from orders o1
|
|
left join artificer a on a.artificer_id=o1.artificer_id
|
|
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_jjr_code
|
|
) t1 on t1.bl_jjr_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
|
|
<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="invitationArtificerPage" resultType="com.sqx.modules.bl.commission.jjr.entity.JjrData">
|
|
select a.user_id,a.artificer_img as avatar,a.artificer_name as name,b.phone,b.invitation_code
|
|
from artificer a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
where b.bl_jjr_code= #{params.invitationCode}
|
|
<if test="params.name!=null and params.name!=''">
|
|
and a.artificer_name like concat('%',#{params.name},'%')
|
|
</if>
|
|
<if test="params.phone!=null and params.phone!=''">
|
|
and b.phone like concat('%',#{params.phone},'%')
|
|
</if>
|
|
order by a.user_id desc
|
|
</select>
|
|
|
|
<select id="artificerPage" resultType="com.sqx.modules.bl.commission.jjr.entity.JjrData">
|
|
select a.user_id,a.artificer_img as avatar,a.artificer_name as name,b.phone,b.invitation_code
|
|
from artificer a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
where ifnull(b.bl_jjr_code,'') = ''
|
|
<if test="params.name!=null and params.name!=''">
|
|
and a.artificer_name like concat('%',#{params.name},'%')
|
|
</if>
|
|
<if test="params.phone!=null and params.phone!=''">
|
|
and b.phone like concat('%',#{params.phone},'%')
|
|
</if>
|
|
order by a.user_id desc
|
|
</select>
|
|
|
|
<select id="findJjrPage" resultType="com.sqx.modules.bl.commission.jjr.entity.JjrData">
|
|
select a.id,a.user_id,b.avatar,b.user_name,a.name,a.phone,a.remarks,a.create_time,a.status,a.opinion,b.invitation_code,a.approve_time
|
|
from bl_jjr_apply a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
where a.status= 1
|
|
<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>
|
|
<if test="params.startTime!=null and params.startTime!=''">
|
|
and a.approve_time >= #{params.startTime}
|
|
</if>
|
|
<if test="params.endTime!=null and params.endTime!=''">
|
|
and a.approve_time <= #{params.endTime}
|
|
</if>
|
|
order by id desc
|
|
</select>
|
|
|
|
<update id="cancelInvitation" parameterType="com.sqx.modules.bl.commission.jjr.entity.JjrData">
|
|
update tb_user
|
|
set bl_jjr_code=null
|
|
where user_id=#{artificerUserId}
|
|
</update>
|
|
|
|
<select id="getByCode" resultType="com.sqx.modules.bl.commission.jjr.entity.JjrData">
|
|
select a.id,a.user_id,b.avatar,b.user_name,a.name,a.phone,a.remarks,a.create_time,a.status,a.opinion
|
|
from bl_jjr_apply a
|
|
inner join tb_user b on a.user_id = b.user_id
|
|
where b.invitation_code= #{invitationCode}
|
|
</select>
|
|
|
|
<update id="modifyJjr" parameterType="com.sqx.modules.bl.commission.jjr.entity.JjrData">
|
|
update tb_user
|
|
set bl_jjr_code=#{invitationCode}
|
|
where user_id=#{artificerUserId}
|
|
</update>
|
|
|
|
<select id="findJjr" resultType="com.sqx.modules.bl.commission.jjr.entity.JjrData">
|
|
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 inner join artificer aa on a.user_id = aa.user_id where ac.bl_jjr_code = y.invitation_code,0) as artificerCount,
|
|
ifnull(select count(*) from tb_user ac inner join artificer aa on a.user_id = aa.user_id
|
|
where ac.bl_jjr_code = y.invitation_code and date_format(aa.create_time, '%Y-%m-%d') = date_format(now(),'%Y-%m-%d'),0) as curArtificerCount,
|
|
ifnull(t1.ordersCount,0) as ordersCount,
|
|
ifnull(t2.ordersCount,0) as curOrdersCount,
|
|
ifnull(t3.money,0) as money
|
|
from bl_jjr_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_jjr_code
|
|
from (
|
|
select o1.orders_id,a.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
|
|
left join artificer a on a.artificer_id=o1.artificer_id
|
|
where o1.old_orders_id is not null
|
|
and o1.status in (3,5)
|
|
union all
|
|
select o1.orders_id,a.user_id
|
|
from orders o1
|
|
left join artificer a on a.artificer_id=o1.artificer_id
|
|
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_jjr_code
|
|
) t1 on t1.bl_jjr_code = y.invitation_code
|
|
left join (
|
|
select count(*) as ordersCount, aa.user_id, bb.bl_jjr_code
|
|
from (
|
|
select o1.orders_id,a.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
|
|
left join artificer a on a.artificer_id=o1.artificer_id
|
|
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,a.user_id
|
|
from orders o1
|
|
left join artificer a on a.artificer_id=o1.artificer_id
|
|
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_jjr_code
|
|
) t2 on t2.bl_jjr_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>
|
|
|
|
<select id="getByUserId" resultType="com.sqx.modules.bl.commission.jjr.entity.JjrData">
|
|
select user_id,avatar,user_name,phone,create_time,status,invitation_code
|
|
from tb_user
|
|
where user_id = #{userId}
|
|
</select>
|
|
|
|
</mapper> |