<?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="cn.stylefeng.guns.modular.business.mapper.TotalReportMapper">
|
|
<select id="courseTotalData" resultType="java.util.Map" parameterType="cn.stylefeng.guns.modular.business.dto.request.TotalRequest">
|
SELECT DATE_FORMAT( tco.create_time, #{dateFormat} ) time,IFNULL(SUM(tco.pay_amount),0) data,count(1) number FROM t_course_order tco
|
WHERE
|
tco.status_flag IN (1,2)
|
<if test="userId != null">
|
AND ( tco.course_user_id = #{userId} OR tco.tutoring_user_id = #{userId} )
|
</if>
|
<if test="beginTime != null and beginTime != ''">
|
AND tco.create_time <![CDATA[ >= ]]> #{beginTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
AND tco.create_time <![CDATA[ <= ]]> #{endTime}
|
</if>
|
GROUP BY time
|
</select>
|
|
<select id="mentalTestTotalData" resultType="java.util.Map" parameterType="cn.stylefeng.guns.modular.business.dto.request.TotalRequest">
|
SELECT DATE_FORMAT( o.create_time, #{dateFormat} ) time,IFNULL(SUM(o.pay_amount),0) data,count(1) number FROM
|
t_order_mental_test o
|
WHERE
|
o.status_flag = 1
|
<if test="beginTime != null and beginTime != ''">
|
AND o.create_time <![CDATA[ >= ]]> #{beginTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
AND o.create_time <![CDATA[ <= ]]> #{endTime}
|
</if>
|
GROUP BY time
|
</select>
|
|
<select id="orderConsultOneTotalData" resultType="java.util.Map" parameterType="cn.stylefeng.guns.modular.business.dto.request.TotalRequest">
|
SELECT DATE_FORMAT( o.create_time, #{dateFormat} ) time,IFNULL(SUM(o.pay_amount),0) data,count(1) number FROM
|
t_order_consult_one o
|
WHERE
|
o.status_flag = 1
|
<if test="userId != null">
|
AND ( o.goods_id = #{userId} )
|
</if>
|
<if test="beginTime != null and beginTime != ''">
|
AND o.create_time <![CDATA[ >= ]]> #{beginTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
AND o.create_time <![CDATA[ <= ]]> #{endTime}
|
</if>
|
GROUP BY time
|
</select>
|
|
<select id="counsellingTotalData" resultType="java.util.Map"
|
parameterType="cn.stylefeng.guns.modular.business.dto.request.TotalRequest">
|
SELECT DATE_FORMAT( tco.create_time, #{dateFormat} ) time,IFNULL(SUM(tco.pay_amount),0) data,count(1) number FROM t_counselling_order tco
|
INNER JOIN t_counselling_info tci ON tci.id = tco.counselling_info_id
|
WHERE
|
tco.status_flag IN (1,2)
|
<if test="userId != null">
|
AND (tci.user_id = #{userId} OR tco.companion_user_id = #{userId} OR tco.consultant_user_id = #{userId} )
|
</if>
|
|
<if test="beginTime != null and beginTime != ''">
|
AND tco.create_time <![CDATA[ >= ]]> #{beginTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
AND tco.create_time <![CDATA[ <= ]]> #{endTime}
|
</if>
|
GROUP BY time
|
</select>
|
<select id="counsellingOrderTypeTotalData" resultType="java.util.Map">
|
SELECT type,IFNULL(SUM(number),0) number FROM
|
(
|
SELECT CASE WHEN tco.order_type =1 THEN '首次面诊' ELSE '咨询疗程' END type,
|
COUNT(tco.id) number FROM t_counselling_order tco
|
INNER JOIN t_counselling_info tci ON tci.id = tco.counselling_info_id
|
WHERE
|
tco.status_flag IN (1,2)
|
<if test="userId != null">
|
AND (tci.user_id = #{userId} OR tco.companion_user_id = #{userId} OR tco.consultant_user_id = #{userId} )
|
</if>
|
<if test="beginTime != null and beginTime != ''">
|
AND tco.create_time <![CDATA[ >= ]]> #{beginTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
AND tco.create_time <![CDATA[ <= ]]> #{endTime}
|
</if>
|
GROUP BY tco.order_type
|
) total
|
GROUP BY type
|
|
</select>
|
<select id="counsellingTypeTotalData" resultType="java.util.Map">
|
SELECT CASE WHEN tci.counselling_type =1 THEN '首席咨询师' ELSE '明星咨询师' END type,
|
COUNT(DISTINCT tco.counselling_info_id) number FROM t_counselling_order tco
|
INNER JOIN t_counselling_info tci ON tci.id = tco.counselling_info_id
|
WHERE
|
tco.status_flag IN (1,2)
|
<if test="userId != null">
|
AND (tci.user_id = #{userId} OR tco.companion_user_id = #{userId} OR tco.consultant_user_id = #{userId} )
|
</if>
|
<if test="beginTime != null and beginTime != ''">
|
AND tco.create_time <![CDATA[ >= ]]> #{beginTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
AND tco.create_time <![CDATA[ <= ]]> #{endTime}
|
</if>
|
GROUP BY tci.counselling_type
|
|
</select>
|
<select id="counsellingBuyTotal" resultType="java.lang.Long">
|
SELECT count(DISTINCT tci.user_id) number FROM t_counselling_order tco
|
INNER JOIN t_counselling_info tci ON tci.id = tco.counselling_info_id
|
WHERE
|
tco.status_flag IN (1,2)
|
<if test="userId != null">
|
AND (tci.user_id = #{userId} OR tco.companion_user_id = #{userId} OR tco.consultant_user_id = #{userId} )
|
</if>
|
|
<if test="beginTime != null and beginTime != ''">
|
AND tco.create_time <![CDATA[ >= ]]> #{beginTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
AND tco.create_time <![CDATA[ <= ]]> #{endTime}
|
</if>
|
</select>
|
<select id="courseBuyTotal" resultType="java.lang.Long">
|
SELECT count(DISTINCT tco.user_id) number FROM t_course_order tco
|
WHERE
|
tco.status_flag IN (1,2)
|
<if test="userId != null">
|
AND ( tco.course_user_id = #{userId} OR tco.tutoring_user_id = #{userId} )
|
</if>
|
<if test="beginTime != null and beginTime != ''">
|
AND tco.create_time <![CDATA[ >= ]]> #{beginTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
AND tco.create_time <![CDATA[ <= ]]> #{endTime}
|
</if>
|
|
</select>
|
<select id="courseNameTotalData" resultType="java.util.Map">
|
SELECT tc.course_name courseName,COUNT(tco.id) number FROM t_course_order tco
|
INNER JOIN t_course tc ON tc.id = tco.course_id
|
WHERE
|
tco.status_flag IN (1,2)
|
<if test="userId != null">
|
AND ( tco.course_user_id = #{userId} OR tco.tutoring_user_id = #{userId} )
|
</if>
|
<if test="beginTime != null and beginTime != ''">
|
AND tco.create_time <![CDATA[ >= ]]> #{beginTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
AND tco.create_time <![CDATA[ <= ]]> #{endTime}
|
</if>
|
GROUP BY tc.course_name
|
</select>
|
<select id="courseTagTotalData" resultType="java.util.Map">
|
SELECT tct.tag_name tagName,COUNT(tco.id) number FROM t_course_order tco
|
INNER JOIN t_course tc ON tc.id = tco.course_id
|
INNER JOIN t_course_tag tct ON FIND_IN_SET(tct.id,tc.course_tag_ids)
|
WHERE
|
tco.status_flag IN (1,2)
|
<if test="userId != null">
|
AND ( tco.course_user_id = #{userId} OR tco.tutoring_user_id = #{userId} )
|
</if>
|
<if test="beginTime != null and beginTime != ''">
|
AND tco.create_time <![CDATA[ >= ]]> #{beginTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
AND tco.create_time <![CDATA[ <= ]]> #{endTime}
|
</if>
|
GROUP BY tct.id
|
</select>
|
</mapper>
|