add
yj
2024-12-05 b9900893177c78fc559223521fe839aa21000017
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
84
85
86
87
88
89
90
91
92
93
94
95
96
<?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.iotechn.unimall.data.mapper.OrderMapper">
 
 
    <select id="selectOrderPage" resultType="com.iotechn.unimall.data.dto.order.OrderDTO">
        SELECT
            id,
            order_no AS orderNo,
            `status`,
            actual_price AS actualPrice,
            gmt_create AS gmtCreate
        FROM
            unimall_order
        WHERE
            user_id = #{userId}
            <if test="status != null and status != 0">
                AND `status` = #{status}
            </if>
        ORDER BY id DESC
            LIMIT #{offset}, #{limit}
 
    </select>
 
    <select id="countOrder" resultType="java.lang.Long">
        SELECT
            count(1)
        FROM
            unimall_order
        WHERE
            user_id = #{userId}
        <if test="status != null and status != 0">
            AND `status` = #{status}
        </if>
    </select>
 
    <select id="selectAreaStatistics" resultType="com.dobbinsoft.fw.support.model.KVModel">
        SELECT
            `province` AS `key`,
            count( 1 ) AS `value`
        FROM
            unimall_order
        WHERE
            `province` IS NOT NULL
        GROUP BY
            `province`
    </select>
 
    <select id="selectChannelStatistics" resultType="com.dobbinsoft.fw.support.model.KVModel">
        SELECT
            `channel` AS `key`,
            count( 1 ) AS `value`
        FROM
            unimall_order
        GROUP BY
            `channel`
    </select>
 
    <select id="selectOrderCountStatistics" resultType="com.dobbinsoft.fw.support.model.KVModel">
        SELECT
            DATE_FORMAT( gmt_create, '%Y-%m-%d' ) AS `key`,
            count( 1 ) AS `value`
        FROM
            unimall_order AS u
        WHERE
            gmt_create &gt; #{gmtStart}
        GROUP BY
            `key`;
    </select>
 
    <select id="selectOrderSumStatistics" resultType="com.dobbinsoft.fw.support.model.KVModel">
        SELECT
            DATE_FORMAT( gmt_create, '%Y-%m-%d' ) AS `key`,
            sum( pay_price ) AS `value`
        FROM
            unimall_order AS u
        WHERE
            pay_price IS NOT NULL
            AND gmt_create &gt; #{gmtStart}
        GROUP BY
            `key`;
    </select>
 
    <select id="selectExpireOrderNos" resultType="com.iotechn.unimall.data.domain.OrderDO">
        SELECT
           id,
           order_no as orderNo
        FROM
            unimall_order
        WHERE
            `status` = #{status}
            AND gmt_update &lt; #{time}
    </select>
 
 
</mapper>