123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <?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.fdkankan.manage.mapper.IDataMapper">
- <select id="userDataGroupBy" resultType="com.fdkankan.manage.vo.response.DataGroupByCount">
- SELECT DATE_FORMAT(create_time,#{dateFormat}) AS groupKey, count(id) AS count FROM ${tb} WHERE rec_status = 'A'
- and create_time between #{startTime} and #{endTime}
- <include refid="tbWhereSql"></include>
- GROUP BY groupKey
- </select>
- <select id="userDataSumGroupBy" resultType="com.fdkankan.manage.vo.response.DataGroupBySum">
- SELECT DATE_FORMAT(create_time,#{dateFormat}) AS groupKey,
- <if test="tb == 't_order'">
- sum(total_amount) AS count
- </if>
- <if test="tb != 't_order'">
- sum(amount) AS count
- </if>
- FROM ${tb} WHERE rec_status = 'A'
- and create_time between #{startTime} and #{endTime}
- <include refid="tbWhereSql"></include>
- GROUP BY groupKey
- </select>
- <select id="userDataGroupByWeek" resultType="com.fdkankan.manage.vo.response.DataGroupByCount">
- SELECT groupKey ,count(1) as count FROM (
- select date_format(date_add(create_time,interval-(weekday(create_time ))day),'%Y-%m-%d') as groupKey
- from ${tb}
- WHERE rec_status = 'A'
- and create_time between #{startTime} and #{endTime}
- <include refid="tbWhereSql"></include>
- ) as tb GROUP BY groupKey
- </select>
- <select id="userDataSumGroupByWeek" resultType="com.fdkankan.manage.vo.response.DataGroupBySum">
- SELECT groupKey ,sum(amount) as count FROM (
- select
- <if test="tb == 't_order'">
- total_amount as amount
- </if>
- <if test="tb != 't_order'">
- amount
- </if>
- ,date_format(date_add(create_time,interval-(weekday(create_time ))day),'%Y-%m-%d') as groupKey
- from ${tb}
- WHERE rec_status = 'A'
- and create_time between #{startTime} and #{endTime}
- <include refid="tbWhereSql"></include>
- ) as tb GROUP BY groupKey
- </select>
- <sql id="typeSQL">
- <if test="type == 1">
- and is_upgrade = 0
- </if>
- <if test="type == 2">
- and pay_status = 1
- </if>
- </sql>
- <sql id="tbWhereSql">
- <if test="tb == 't_increment_order' || tb == 't_download_order'">
- and pay_status = 1
- </if>
- </sql>
- <select id="totalUserCount" resultType="java.lang.Long">
- select count(id) from ${tb} where rec_status = 'A'
- <include refid="typeSQL"></include>
- </select>
- <select id="preMonthAddCount" resultType="java.lang.Long">
- SELECT count(id) FROM ${tb}
- WHERE rec_status = 'A' and date_format(create_time, '%Y %m') = date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y %m')
- <include refid="typeSQL"></include>
- </select>
- <select id="todayAddCount" resultType="java.lang.Long">
- SELECT count(id) FROM ${tb}
- WHERE rec_status = 'A' and DATEDIFF(create_time,NOW())=0
- <include refid="typeSQL"></include>
- </select>
- <select id="todayActiveCount" resultType="java.lang.Long">
- SELECT count(distinct user_name) FROM t_login_log
- WHERE rec_status = 'A' and DATEDIFF(create_time,NOW())=0
- </select>
- <select id="sceneGroupBy" resultType="com.fdkankan.manage.vo.response.DataGroupByCount">
- SELECT DATE_FORMAT(create_time,#{dateFormat}) AS groupKey, count(id) AS count ,
- <if test="tb == 't_scene_pro' or tb == 't_scene_plus' ">
- scene_source as groupKey2
- </if>
- <if test="tb == 't_camera_detail'">
- type as groupKey2
- </if>
- FROM ${tb}
- WHERE rec_status = 'A'
- <if test="tb == 't_scene_pro'">
- AND is_upgrade = 0
- </if>
- and create_time between #{startTime} and #{endTime}
- GROUP BY groupKey ,groupKey2
- </select>
- <select id="sceneGroupByWeek" resultType="com.fdkankan.manage.vo.response.DataGroupByCount">
- SELECT groupKey ,count(1) as count,
- <if test="tb == 't_scene_pro' or tb == 't_scene_plus' ">
- scene_source as groupKey2
- </if>
- <if test="tb == 't_camera_detail'">
- type as groupKey2
- </if>
- FROM (
- select date_format(date_add(create_time,interval-(weekday(create_time ))day),'%Y-%m-%d') as groupKey,
- <if test="tb == 't_scene_pro' or tb == 't_scene_plus' ">
- scene_source
- </if>
- <if test="tb == 't_camera_detail'">
- type
- </if>
- from ${tb}
- WHERE rec_status = 'A'
- <if test="tb == 't_scene_pro'">
- AND is_upgrade = 0
- </if>
- and create_time between #{startTime} and #{endTime}
- ) as tb GROUP BY groupKey,groupKey2
- </select>
- <select id="sceneObjGroupBy" resultType="com.fdkankan.manage.vo.response.DataGroupByCount">
- SELECT DATE_FORMAT( p.create_time,#{dateFormat}) AS groupKey, count(p.id) AS count , scene_source as groupKey2
- FROM ${tb} p
- <if test="tb == 't_scene_plus'">
- LEFT JOIN t_scene_plus_ext e on p.id = e.plus_id
- </if>
- WHERE p.rec_status = 'A' and is_obj = 1
- <if test="tb == 't_scene_pro'">
- AND is_upgrade = 0
- </if>
- and p.create_time between #{startTime} and #{endTime}
- GROUP BY groupKey ,groupKey2
- </select>
- <select id="sceneObjGroupByWeek" resultType="com.fdkankan.manage.vo.response.DataGroupByCount">
- SELECT groupKey ,count(1) as count, scene_source as groupKey2
- FROM (
- select date_format(date_add(p.create_time,interval-(weekday(p.create_time ))day),'%Y-%m-%d') as groupKey,scene_source
- from ${tb} p
- <if test="tb == 't_scene_plus'">
- LEFT JOIN t_scene_plus_ext e on p.id = e.plus_id
- </if>
- WHERE p.rec_status = 'A' and is_obj = 1
- <if test="tb == 't_scene_pro'">
- AND is_upgrade = 0
- </if>
- and p.create_time between #{startTime} and #{endTime}
- ) as tb GROUP BY groupKey,groupKey2
- </select>
- <select id="sceneOutTimeGroupBy" resultType="com.fdkankan.manage.vo.response.DataGroupByCount">
- SELECT DATE_FORMAT(out_time,#{dateFormat}) AS groupKey, count(id) AS count ,
- <if test="tb == 't_scene_pro' or tb == 't_scene_plus' ">
- scene_source as groupKey2
- </if>
- <if test="tb == 't_camera_detail'">
- type as groupKey2
- </if>
- FROM ${tb}
- WHERE rec_status = 'A'
- <if test="tb == 't_scene_pro'">
- AND is_upgrade = 0
- </if>
- and out_time between #{startTime} and #{endTime}
- GROUP BY groupKey ,groupKey2
- </select>
- <select id="sceneOutTimeGroupByWeek" resultType="com.fdkankan.manage.vo.response.DataGroupByCount">
- SELECT groupKey ,count(1) as count,
- <if test="tb == 't_scene_pro' or tb == 't_scene_plus' ">
- scene_source as groupKey2
- </if>
- <if test="tb == 't_camera_detail'">
- type as groupKey2
- </if>
- FROM (
- select date_format(date_add(out_time,interval-(weekday(out_time ))day),'%Y-%m-%d') as groupKey,
- <if test="tb == 't_scene_pro' or tb == 't_scene_plus' ">
- scene_source
- </if>
- <if test="tb == 't_camera_detail'">
- type
- </if>
- from ${tb}
- WHERE rec_status = 'A'
- <if test="tb == 't_scene_pro'">
- AND is_upgrade = 0
- </if>
- and out_time between #{startTime} and #{endTime}
- ) as tb GROUP BY groupKey,groupKey2
- </select>
- </mapper>
|