OrderChartMapper.xml
3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?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.lframework.xingyun.chart.mappers.OrderChartMapper">
    <resultMap id="OrderChartSumDto" type="com.lframework.xingyun.chart.dto.OrderChartSumDto">
        <result column="total_amount" property="totalAmount"/>
        <result column="total_num" property="totalNum"/>
    </resultMap>
    <resultMap id="OrderChartSameMonthDto" type="com.lframework.xingyun.chart.dto.OrderChartSameMonthDto">
        <result column="total_amount" property="totalAmount"/>
        <result column="total_num" property="totalNum"/>
        <result column="create_date" property="createDate"/>
    </resultMap>
    <resultMap id="OrderChartTodayDto" type="com.lframework.xingyun.chart.dto.OrderChartTodayDto">
        <result column="total_amount" property="totalAmount"/>
        <result column="total_num" property="totalNum"/>
        <result column="create_hour" property="createHour"/>
    </resultMap>
    <select id="querySameMonth" resultMap="OrderChartSameMonthDto">
        SELECT
            IFNULL(SUM(c.total_amount), 0) AS total_amount,
            COUNT(1) AS total_num,
            c.create_date
        FROM tbl_order_chart AS c
        <where>
            <if test="startTime != null">
                AND c.create_time >= #{startTime}
            </if>
            <if test="endTime != null">
                <![CDATA[
                AND c.create_time <= #{endTime}
                ]]>
            </if>
            <if test="bizTypes != null and bizTypes.size() > 0">
                AND c.biz_type IN <foreach collection="bizTypes" open="(" separator="," close=")" item="item">#{item}</foreach>
            </if>
        </where>
        GROUP BY c.create_date
    </select>
    <select id="queryToday" resultMap="OrderChartTodayDto">
        SELECT
            IFNULL(SUM(c.total_amount), 0) AS total_amount,
            COUNT(1) AS total_num,
            c.create_hour
        FROM tbl_order_chart AS c
        <where>
            <if test="startTime != null">
                AND c.create_time >= #{startTime}
            </if>
            <if test="endTime != null">
                <![CDATA[
                AND c.create_time <= #{endTime}
                ]]>
            </if>
            <if test="bizTypes != null and bizTypes.size() > 0">
                AND c.biz_type IN <foreach collection="bizTypes" open="(" separator="," close=")" item="item">#{item}</foreach>
            </if>
        </where>
        GROUP BY c.create_hour
    </select>
    <select id="getChartSum" resultMap="OrderChartSumDto">
        SELECT
            IFNULL(SUM(c.total_amount), 0) AS total_amount,
            COUNT(1) AS total_num
        FROM tbl_order_chart AS c
        <where>
            <if test="startTime != null">
                AND c.create_time >= #{startTime}
            </if>
            <if test="endTime != null">
                <![CDATA[
                AND c.create_time <= #{endTime}
                ]]>
            </if>
            <if test="bizTypes != null and bizTypes.size() > 0">
                AND c.biz_type IN <foreach collection="bizTypes" open="(" separator="," close=")" item="item">#{item}</foreach>
            </if>
        </where>
    </select>
</mapper>