122 lines
4.9 KiB
XML
122 lines
4.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.ext.dao.ExtSysDao">
|
|
|
|
<select id="findInviteFriendList" resultType="com.sqx.modules.ext.dto.InviteFriendDTO">
|
|
select
|
|
t1.user_id as userId,
|
|
t1.user_name as userName,
|
|
t1.phone,
|
|
t1.avatar,
|
|
ifnull(t2.signInNum,0) as signInNum,
|
|
ifnull(t2.awardAmount,0) as awardAmount
|
|
from v_tb_user t1
|
|
left JOIN (select user_id,sum(money) as awardAmount,sum(case when title = '签到奖励' then 1 else 0 end) as signInNum from v_user_money_details where classify = 6 group by user_id) t2 on t1.user_id = t2.user_id
|
|
<where>
|
|
<if test="keywords != null and keywords != ''">
|
|
and (t1.user_name like concat('%',${keywords},'%') or t1.phone like concat('%',${keywords},'%'))
|
|
</if>
|
|
</where>
|
|
ORDER BY t2.signInNum desc,t1.user_id asc
|
|
</select>
|
|
<select id="findInviteSignInList" resultType="com.sqx.modules.ext.dto.SignInNumDTO">
|
|
select
|
|
t1.by_user_id as userId,
|
|
t1.createTime,
|
|
t2.user_name as userName,
|
|
t2.phone,
|
|
t3.cert_name as realName,
|
|
t3.cert_no as idCardNo,
|
|
t3.bank_name as bankName,
|
|
t3.account_no as bankCardNo,
|
|
t3.mobile,
|
|
t3.province,
|
|
t3.city,
|
|
t3.bank_branch as bankBranch
|
|
from (
|
|
SELECT
|
|
t.by_user_id,
|
|
MIN( t.create_time ) as createTime
|
|
FROM
|
|
v_user_money_details t
|
|
WHERE 1=1
|
|
AND t.user_id = ${userId}
|
|
AND t.classify = 6
|
|
AND t.title = '签到奖励'
|
|
GROUP BY t.by_user_id
|
|
) t1
|
|
LEFT JOIN v_tb_user t2 on t1.by_user_id = t2.user_id
|
|
LEFT JOIN v_user_info t3 on t1.by_user_id = t3.user_id
|
|
order by t1.createTime desc,t1.by_user_id asc
|
|
</select>
|
|
<select id="findInviteAwardDetailList" resultType="com.sqx.modules.ext.dto.InviteAwardDTO">
|
|
SELECT
|
|
t1.by_user_id AS userId,
|
|
t1.money as amount,
|
|
t2.phone as userPhone,
|
|
t1.create_time as createTime
|
|
FROM
|
|
v_user_money_details t1
|
|
LEFT JOIN v_tb_user t2 on t1.by_user_id = t2.user_id
|
|
WHERE
|
|
t1.user_id = ${userId}
|
|
AND t1.classify = '6'
|
|
and t1.by_user_id is not null
|
|
and t2.user_id is not null
|
|
order by t1.create_time desc,t1.by_user_id asc
|
|
</select>
|
|
<select id="findLotteryCountList" resultType="com.sqx.modules.ext.dto.LotteryCountQueryDTO">
|
|
SELECT
|
|
t1.user_id as userId,
|
|
t1.avatar,
|
|
t1.user_name as userName,
|
|
t1.phone,
|
|
ifnull( t2.unlocked, 0 ) AS unlocked,
|
|
ifnull( t2.todayUnlocked, 0 ) AS todayUnlocked,
|
|
ifnull( t3.totalDrawCount, 0 ) AS totalDrawCount,
|
|
ifnull( t3.residueDrawCount, 0 ) AS residueDrawCount,
|
|
ifnull( t3.todayDrawCount, 0 ) AS todayDrawCount
|
|
FROM
|
|
v_tb_user t1
|
|
LEFT JOIN (
|
|
SELECT
|
|
user_id,
|
|
count( 1 ) AS unlocked,
|
|
sum(CASE WHEN pay_time >= DATE_FORMAT(CURDATE(), '%Y-%m-%d 00:00:00') and pay_time <= DATE_FORMAT(CURDATE(), '%Y-%m-%d 23:59:59') then 1 else 0 end) as todayUnlocked
|
|
FROM
|
|
v_orders
|
|
WHERE STATUS = 1 AND pay_way = 9
|
|
GROUP BY user_id
|
|
) t2 on t1.user_id = t2.user_id
|
|
LEFT JOIN (
|
|
SELECT
|
|
x.user_id,
|
|
count(x.orders_id) as totalDrawCount,
|
|
sum(case when y.source_id is null then 1 else 0 end) as residueDrawCount,
|
|
sum(case when y.source_id is not null and DATE_FORMAT(y.create_time,'%Y-%m-%d') = CURDATE() then 1 else 0 end) as todayDrawCount
|
|
FROM v_orders x
|
|
LEFT JOIN v_disc_spinning_record y ON x.orders_id = y.source_id
|
|
AND y.source = 'order'
|
|
WHERE 1 = 1
|
|
AND x.status = 1
|
|
AND x.pay_way = 9
|
|
group by x.user_id
|
|
) t3 on t1.user_id = t3.user_id
|
|
<where>
|
|
<if test="keywords != null and keywords != ''">
|
|
and (t1.user_name like concat('%',${keywords},'%') or t1.phone like concat('%',${keywords},'%'))
|
|
</if>
|
|
</where>
|
|
order by t2.unlocked desc,t1.user_id asc
|
|
</select>
|
|
<select id="findLotteryDetailPage" resultType="com.sqx.modules.ext.dto.LotteryDetailDTO">
|
|
select
|
|
t1.id,
|
|
t1.name,
|
|
t1.number,
|
|
t1.create_time
|
|
from v_disc_spinning_record t1
|
|
where t1.user_id = ${userId}
|
|
order by t1.id asc
|
|
</select>
|
|
</mapper> |