SELECT
COUNT(DISTINCT g.send_uid) AS countUsers,
COUNT(DISTINCT g.send_uid,
if(
u2.create_time >= #{beginTime}
AND
u2.create_time <= #{endTime}
, TRUE, NULL)
) AS countNewUsers,
g.uid as uid ,
SUM(g.sum_gold) as totalGoldNum,
u.erban_no as erbanNo,
u.nick as nick,
u.phone as phone,
u.alipay_account as alipayAccount,
u.alipay_account_name as alipayAccountName,
r.room_id AS roomId,
r.room_tag as roomTag,
r.is_permit_room as isPermitRoom,
ifnull(r.reward_money,0) AS bounsPersent,
if(uc.occupation_ratio is null,0,ROUND(uc.occupation_ratio*SUM(g.sum_gold)/100,2)) as occupation,
uc.bank_card as bankCard,
uc.cardholder as cardholder
FROM one_day_room_send_sum g
INNER JOIN users u ON g.uid = u.uid
INNER JOIN room r ON r.uid = g.uid
LEFT JOIN user_configure uc ON g.uid = uc.uid
LEFT JOIN users u2 ON g.send_uid = u2.uid
GROUP BY g.uid
order by totalGoldNum desc
1=1
AND u.erban_no=#{erbanNo}
AND g.create_time >= #{beginTime}
AND g.create_time <= #{endTime}
AND r.is_permit_room=#{roomType}
AND r.tag_id=#{roomTag}
select ifnull(sum(bgd.gift_num * g.gold_price),0)
from bill_gift_draw bgd
inner join gift g on bgd.gift_id = g.gift_id
where bgd.uid = #{uid}
SELECT SUM(g.sum_gold) as totalGoldNum,
ifnull(r.reward_money,0) AS bounsPersent
FROM one_day_room_send_sum g
INNER JOIN users u ON g.uid = u.uid
INNER JOIN room r ON r.uid = g.uid
SELECT
DATE_FORMAT(odr.create_time, '%Y%m%d') period,
DATE_FORMAT(odr.create_time, '%Y%u') period,
DATE_FORMAT(odr.create_time, '%Y%m') period,
DATE_FORMAT(odr.create_time, '%Y') period,
SUM(odr.sum_gold) totalGold,
odr.uid as uid,
u.nick,
u.erban_no as erbanNo
FROM
one_day_room_recv_sum odr
LEFT JOIN users u ON odr.uid = u.uid
AND DATE(odr.create_time) >= #{beginDate}
AND DATE(odr.create_time) <= #{endDate}
AND odr.uid = #{uid}
AND odr.uid IN
#{item}
GROUP BY
period, odr.uid
HAVING totalGold >= #{minNum}
ORDER BY period ASC, odr.uid ASC