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.

117 lines
5.2 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.consumeTime != null and beanConsumeLive.consumeTime != null">
AND consumeTime BETWEEN #{beanConsumeLive.startTime} AND #{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>
</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="selectConsumeGoldsBy" resultType="com.example.demo.domain.vo.bean.BeanConsumeGold">
</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.consumeTime != null and beanConsumeLive.consumeTime != null">
AND consumeTime BETWEEN #{beanConsumeLive.startTime} AND #{beanConsumeLive.endTime}
</if>
</where>
) AS t
</select>
</mapper>