|
@@ -31,8 +31,9 @@
|
|
|
</resultMap>
|
|
|
|
|
|
<resultMap id="chartBean" type="com.shawn.model.Bean.ChartBean">
|
|
|
- <result column="categories" jdbcType="VARCHAR" property="categories" />
|
|
|
- <result column="seriesData" jdbcType="INTEGER" property="seriesData" />
|
|
|
+ <result column="categorie" jdbcType="VARCHAR" property="categorie" />
|
|
|
+ <result column="saleNum" jdbcType="INTEGER" property="saleNum" />
|
|
|
+ <result column="salePrice" jdbcType="DECIMAL" property="salePrice" />
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
@@ -654,12 +655,128 @@
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</update>
|
|
|
- <select id="getProductSaleMonth" resultMap="chartBean" parameterType="java.lang.String">
|
|
|
- select a.product_name as categories,count(1) as seriesData from t_order a where 1=1
|
|
|
- and DATE_FORMAT( a.create_date,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
|
|
|
- and a.admin_id='56'
|
|
|
- <!-- and a.admin_id=#{userId} -->
|
|
|
- group by a.product_name
|
|
|
- order by seriesData desc
|
|
|
+ <!-- 日统计 -->
|
|
|
+ <select id="getDayStatistics" resultMap="chartBean" parameterType="com.shawn.model.param.StatisticsParam">
|
|
|
+ select concat(DATE_FORMAT( a.create_date,'%H'),'点') as categorie,count(1) as saleNum,sum(a.price) as salePrice from t_order a
|
|
|
+ where a.status='1' -- 支付成功
|
|
|
+ <if test="adminId != null and adminId !=''">
|
|
|
+ and a.admin_id= #{adminId} -- 所属商家id
|
|
|
+ </if>
|
|
|
+ <if test="equipmentId != null and equipmentId !=''">
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+ and DATE_FORMAT( a.create_date,'%Y/%m/%d') = #{startDate}
|
|
|
+ group by DATE_FORMAT( a.create_date,'%H')
|
|
|
+ order by categorie
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 周统计 -->
|
|
|
+ <select id="getWeekStatistics" resultMap="chartBean" parameterType="com.shawn.model.param.StatisticsParam">
|
|
|
+ SELECT tab1.categorie,ifnull(tab2.saleNum,0) as saleNum,ifnull(tab2.salePrice,0) as salePrice from (
|
|
|
+ select '周1' as categorie from dual UNION all
|
|
|
+ select '周2' as categorie from dual UNION all
|
|
|
+ select '周3' as categorie from dual UNION all
|
|
|
+ select '周4' as categorie from dual UNION all
|
|
|
+ select '周5' as categorie from dual UNION all
|
|
|
+ select '周6' as categorie from dual UNION all
|
|
|
+ select '周日' as categorie from dual) tab1
|
|
|
+ left join (
|
|
|
+ select case DATE_FORMAT( a.create_date,'%w') when 0 then '周日' else CONCAT('周',DATE_FORMAT( a.create_date,'%w')) end as categorie,
|
|
|
+ count(1) as saleNum,sum(a.price) as salePrice from t_order a
|
|
|
+ where a.status='1' -- 支付成功
|
|
|
+ <if test="adminId != null and adminId !=''">
|
|
|
+ and a.admin_id= #{adminId} -- 所属商家id
|
|
|
+ </if>
|
|
|
+ <if test="equipmentId != null and equipmentId !=''">
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+ AND a.create_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
|
|
|
+ <![CDATA[ AND a.create_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
|
|
|
+ group by DATE_FORMAT( a.create_date,'%w')
|
|
|
+ ) tab2 on tab1.categorie = tab2.categorie
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 月统计 -->
|
|
|
+ <select id="getMonthStatistics" resultMap="chartBean" parameterType="com.shawn.model.param.StatisticsParam">
|
|
|
+ select DATE_FORMAT( a.create_date,'%m月%d') as categorie,count(1) as saleNum,sum(a.price) as salePrice from t_order a
|
|
|
+ where a.status='1' -- 支付成功
|
|
|
+ <if test="adminId != null and adminId !=''">
|
|
|
+ and a.admin_id= #{adminId} -- 所属商家id
|
|
|
+ </if>
|
|
|
+ <if test="equipmentId != null and equipmentId !=''">
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+ AND a.create_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
|
|
|
+ <![CDATA[ AND a.create_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
|
|
|
+ group by DATE_FORMAT( a.create_date,'%m月%d')
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 年统计 -->
|
|
|
+ <select id="getYearStatistics" resultMap="chartBean" parameterType="com.shawn.model.param.StatisticsParam">
|
|
|
+ SELECT tab1.categorie,ifnull(tab2.saleNum,0) as saleNum,ifnull(tab2.salePrice,0) as salePrice from (
|
|
|
+ select '01月' as categorie from dual UNION all
|
|
|
+ select '02月' as categorie from dual UNION all
|
|
|
+ select '03月' as categorie from dual UNION all
|
|
|
+ select '04月' as categorie from dual UNION all
|
|
|
+ select '05月' as categorie from dual UNION all
|
|
|
+ select '06月' as categorie from dual UNION all
|
|
|
+ select '07月' as categorie from dual UNION all
|
|
|
+ select '08月' as categorie from dual UNION all
|
|
|
+ select '09月' as categorie from dual UNION all
|
|
|
+ select '10月' as categorie from dual UNION all
|
|
|
+ select '11月' as categorie from dual UNION all
|
|
|
+ select '12月' as categorie from dual) tab1
|
|
|
+ left join (
|
|
|
+ select concat(DATE_FORMAT( a.create_date,'%m'),'月') as categorie,count(1) as saleNum,sum(a.price) as salePrice from t_order a
|
|
|
+ where a.status='1' -- 支付成功
|
|
|
+ <if test="adminId != null and adminId !=''">
|
|
|
+ and a.admin_id= #{adminId} -- 所属商家id
|
|
|
+ </if>
|
|
|
+ <if test="equipmentId != null and equipmentId !=''">
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+ AND a.create_date >= STR_TO_DATE(CONCAT(#{startDate},' 00:00:00'),'%Y/%m/%d %H:%i:%s')
|
|
|
+ <![CDATA[ AND a.create_date <= STR_TO_DATE(CONCAT(#{endDate},' 23:59:59'),'%Y/%m/%d %H:%i:%s') ]]>
|
|
|
+ group by DATE_FORMAT( a.create_date,'%m')
|
|
|
+ ) tab2 on tab1.categorie = tab2.categorie
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 汇总统计-->
|
|
|
+ <select id="getMainStatistics" resultMap="chartBean">
|
|
|
+ select 'day' as categorie, count(1) as saleNum,ifnull(sum(a.price),0) as salePrice from t_order a
|
|
|
+where date_format(a.create_date,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
|
|
|
+ <if test="adminId != null and adminId !=''">
|
|
|
+ and a.admin_id= #{adminId} -- 所属商家id
|
|
|
+ </if>
|
|
|
+ <if test="equipmentId != null and equipmentId !=''">
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+UNION all
|
|
|
+select 'week' as categorie, count(1) as saleNum,ifnull(sum(a.price),0) as salePrice from t_order a
|
|
|
+where YEARWEEK(date_format(a.create_date,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
|
|
|
+ <if test="adminId != null and adminId !=''">
|
|
|
+ and a.admin_id= #{adminId} -- 所属商家id
|
|
|
+ </if>
|
|
|
+ <if test="equipmentId != null and equipmentId !=''">
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+UNION all
|
|
|
+select 'month' as categorie, count(1) as saleNum,ifnull(sum(a.price),0) as salePrice from t_order a
|
|
|
+where date_format(a.create_date,'%Y-%m') = date_format(now(),'%Y-%m')
|
|
|
+ <if test="adminId != null and adminId !=''">
|
|
|
+ and a.admin_id= #{adminId} -- 所属商家id
|
|
|
+ </if>
|
|
|
+ <if test="equipmentId != null and equipmentId !=''">
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
+UNION all
|
|
|
+select 'year' as categorie, count(1) as saleNum,ifnull(sum(a.price),0) as salePrice from t_order a
|
|
|
+where date_format(a.create_date,'%Y') = date_format(now(),'%Y')
|
|
|
+ <if test="adminId != null and adminId !=''">
|
|
|
+ and a.admin_id= #{adminId} -- 所属商家id
|
|
|
+ </if>
|
|
|
+ <if test="equipmentId != null and equipmentId !=''">
|
|
|
+ and a.equipment_id= #{equipmentId} -- 设备id
|
|
|
+ </if>
|
|
|
</select>
|
|
|
</mapper>
|