You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
6.6 KiB
148 lines
6.6 KiB
<?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.example.demo.mapper.bean.BeanConsumeMapper">
|
|
|
|
<!--获取消费用户分部-->
|
|
<select id="getDept" resultType="java.lang.String">
|
|
select distinct fm.dept
|
|
from fx_member fm
|
|
inner join fx_yaoqing_records fyr on fyr.uid = fm.id
|
|
where fm.dept is not null and fm.dept != ''
|
|
</select>
|
|
<!--筛选查询直播消费-->
|
|
<select id="selectLiveBy" resultType="com.example.demo.domain.vo.bean.BeanConsumeLive">
|
|
SELECT *
|
|
FROM (
|
|
SELECT fm.nickname AS name,
|
|
fm.jwcode,
|
|
fm.dept,
|
|
fyr.source_type AS type,
|
|
CASE
|
|
WHEN LOCATE('直播间', content) > 0 AND LOCATE('送礼物', content) > 0
|
|
THEN SUBSTRING(content, LOCATE('送礼物', content) + CHAR_LENGTH('送礼物'))
|
|
ELSE NULL
|
|
END AS gift,
|
|
fyr.money AS beanNum,
|
|
CASE
|
|
WHEN LOCATE('直播间', content) > 0 AND LOCATE('送礼物', content) > 0
|
|
THEN SUBSTRING_INDEX(SUBSTRING(content, LOCATE('直播间', content) + CHAR_LENGTH('直播间')), '送礼物', 1)
|
|
ELSE NULL
|
|
END AS channel,
|
|
fyr.source_name AS liveName,
|
|
FROM_UNIXTIME(fyr.time, '%Y-%m-%d %H:%i:%s') AS consumeTime,
|
|
fyr.pay_type AS payType
|
|
FROM fx_member fm
|
|
INNER JOIN fx_yaoqing_records fyr ON fyr.uid = fm.id
|
|
<where>
|
|
fyr.pay_type IN (1,2,3,4,5)
|
|
<if test="beanConsumeLive.jwcode != null and beanConsumeLive.jwcode != ''">
|
|
AND fm.jwcode = #{beanConsumeLive.jwcode}
|
|
</if>
|
|
<if test="beanConsumeLive.dept != null and beanConsumeLive.dept != ''">
|
|
AND fm.dept = #{beanConsumeLive.dept}
|
|
</if>
|
|
<if test="beanConsumeLive.type != null and beanConsumeLive.type != ''">
|
|
AND fyr.source_type = #{beanConsumeLive.type}
|
|
</if>
|
|
<if test="beanConsumeLive.startTime != null and beanConsumeLive.endTime != null">
|
|
AND fyr.time BETWEEN UNIX_TIMESTAMP(#{beanConsumeLive.startTime})
|
|
AND UNIX_TIMESTAMP(#{beanConsumeLive.endTime})
|
|
</if>
|
|
</where>
|
|
) AS t
|
|
<where>
|
|
<if test="beanConsumeLive.gift != null and beanConsumeLive.gift != ''">
|
|
AND t.gift = #{beanConsumeLive.gift}
|
|
</if>
|
|
<if test="beanConsumeLive.channel != null and beanConsumeLive.channel != ''">
|
|
AND t.channel= #{beanConsumeLive.channel}
|
|
</if>
|
|
<if test="beanConsumeLive.liveName != null and beanConsumeLive.liveName != ''">
|
|
AND t.liveName LIKE CONCAT('%', #{beanConsumeLive.liveName}, '%')
|
|
</if>
|
|
|
|
</where>
|
|
|
|
<choose>
|
|
<when test="beanConsumeLive.sortField != null and beanConsumeLive.sortField != '' and beanConsumeLive.sortOrder != null and beanConsumeLive.sortOrder != ''">
|
|
ORDER BY t.${beanConsumeLive.sortField} ${beanConsumeLive.sortOrder}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY t.consumeTime DESC
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
<!--查询消费直播合计数-->
|
|
<select id="selectSumLiveBy" resultType="com.example.demo.domain.vo.bean.BeanConsumeGold">
|
|
SELECT
|
|
IFNULL(SUM(t.money_buy), 0) AS permanentBean,
|
|
IFNULL(SUM(t.money_free), 0) AS freeBean,
|
|
COUNT(*) AS totalNum
|
|
FROM (
|
|
SELECT
|
|
fyr.money_buy,
|
|
fyr.money_free,
|
|
fyr.time
|
|
FROM fx_member fm
|
|
INNER JOIN fx_yaoqing_records fyr ON fyr.uid = fm.id
|
|
<where>
|
|
fyr.pay_type IN (1,2,3,4,5)
|
|
|
|
<if test="beanConsumeLive.jwcode != null and beanConsumeLive.jwcode != ''">
|
|
AND fm.jwcode = #{beanConsumeLive.jwcode}
|
|
</if>
|
|
<if test="beanConsumeLive.dept != null and beanConsumeLive.dept != ''">
|
|
AND fm.dept = #{beanConsumeLive.dept}
|
|
</if>
|
|
<if test="beanConsumeLive.type != null and beanConsumeLive.type != ''">
|
|
AND fyr.source_type = #{beanConsumeLive.type}
|
|
</if>
|
|
<if test="beanConsumeLive.gift != null and beanConsumeLive.gift != ''">
|
|
AND CASE
|
|
WHEN LOCATE('直播间', fyr.content) > 0 AND LOCATE('送礼物', fyr.content) > 0
|
|
THEN SUBSTRING(fyr.content, LOCATE('送礼物', fyr.content) + CHAR_LENGTH('送礼物'))
|
|
ELSE NULL
|
|
END = #{beanConsumeLive.gift}
|
|
</if>
|
|
<if test="beanConsumeLive.channel != null and beanConsumeLive.channel != ''">
|
|
AND CASE
|
|
WHEN LOCATE('直播间', fyr.content) > 0 AND LOCATE('送礼物', fyr.content) > 0
|
|
THEN SUBSTRING_INDEX(SUBSTRING(fyr.content, LOCATE('直播间', fyr.content) + CHAR_LENGTH('直播间')), '送礼物', 1)
|
|
ELSE NULL
|
|
END = #{beanConsumeLive.channel}
|
|
</if>
|
|
<if test="beanConsumeLive.startTime != null and beanConsumeLive.endTime != null">
|
|
AND fyr.time BETWEEN UNIX_TIMESTAMP(#{beanConsumeLive.startTime})
|
|
AND UNIX_TIMESTAMP(#{beanConsumeLive.endTime})
|
|
</if>
|
|
<if test="beanConsumeLive.liveName != null and beanConsumeLive.liveName != ''">
|
|
AND fyr.source_name LIKE CONCAT('%', #{beanConsumeLive.liveName}, '%')
|
|
</if>
|
|
</where>
|
|
) AS t
|
|
</select>
|
|
<select id="getLiveGift" resultType="java.lang.String">
|
|
SELECT DISTINCT
|
|
CASE
|
|
WHEN LOCATE('直播间', content) > 0 AND LOCATE('送礼物', content) > 0
|
|
THEN SUBSTRING(content, LOCATE('送礼物', content) + CHAR_LENGTH('送礼物'))
|
|
ELSE NULL
|
|
END AS gift
|
|
FROM fx_yaoqing_records
|
|
WHERE LOCATE('直播间', content) > 0 AND LOCATE('送礼物', content) > 0
|
|
AND content IS NOT NULL AND source_type=1
|
|
</select>
|
|
<select id="getLiveChannel" resultType="java.lang.String">
|
|
SELECT DISTINCT
|
|
CASE
|
|
WHEN LOCATE('直播间', content) > 0 AND LOCATE('送礼物', content) > 0
|
|
THEN SUBSTRING_INDEX(SUBSTRING(content, LOCATE('直播间', content) + CHAR_LENGTH('直播间')), '送礼物', 1)
|
|
ELSE NULL
|
|
END AS channel
|
|
FROM fx_yaoqing_records
|
|
WHERE LOCATE('直播间', content) > 0 AND LOCATE('送礼物', content) > 0
|
|
AND content IS NOT NULL AND pay_type in (1,2,3,4,5)
|
|
</select>
|
|
|
|
</mapper>
|