fix
Helius
2021-12-15 004d9e74f66d87e8416a9b0d807b64cbfd1576f8
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?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.xzx.gc.shop.mapper.ScoreOrderMapper">
 
    <select id="queryOrderList" resultType="com.xzx.gc.shop.vo.QueryOrderListVo">
        SELECT
               a.*,
               a.CREATED_TIME createTime,
               ifnull(a.is_finish,2) isFinish,
               b.nick_name name,
               b.mobile_phone phone,
               d.express_com expressCom,
               d.address expressAddress,
               d.express_no expressNo
        FROM
        xzx_score_order a
        inner join xzx_user_info b on b.user_id = a.user_id
        left join xzx_score_express_info d on d.order_id = a.id
        WHERE 1 = 1
        <if test="orderNo != null and orderNo != ''">
            and a.order_no like concat('%',#{orderNo},'%')
        </if>
 
        <if test="name != null and name != ''">
            and (b.nick_name like concat('%',#{name},'%')
                     or b.mobile_phone like concat('%',#{accountName},'%') )
        </if>
        <if test="status.size > 0">
            and a.status in
            <foreach collection="status" item="sta" open="(" separator="," close=")">
                #{sta}
            </foreach>
        </if>
        <if test="createdTimeStart != null">
            and a.CREATED_TIME >= #{createdTimeStart}
        </if>
 
        <if test="createdTimeEnd != null">
            and a.CREATED_TIME &lt;= #{createdTimeEnd}
        </if>
        order by
            <if test="namePx != null and namePx != '' and namePx == 1">
                a.CREATED_TIME
            </if>
            <if test="namePx != null and namePx != '' and namePx == 2">
                from_base64(b.nick_name)
            </if>
 
            <if test="typePx != null and typePx != '' and typePx == 1">
                asc
            </if>
            <if test="typePx != null and typePx != '' and typePx == 2">
                desc
            </if>
 
    </select>
 
    <select id="selectXcxOrderList" resultType="com.xzx.gc.shop.vo.XcxOrderListVo">
        select
            a.*,
            b.unit_price,
            b.sku,
            b.style,
            b.thumb
        from xzx_score_order a
        inner join xzx_score_order_details b on a.id=b.order_id
        <where>
            a.user_id=#{record.userId}
            <if test="record.status == 1">
                and a.status in (1, 2, 3)
            </if>
            <if test="record.status == 2">
                and a.status = 4
            </if>
            <if test="record.status == 3">
                and a.status = 6
            </if>
        </where>
        order by a.created_time desc
    </select>
 
    <select id="selectXcxOrderDetails" resultType="com.xzx.gc.shop.vo.XcxOrderDetailsVo">
        select
            a.*
             ,b.style
             ,b.sku
             ,b.thumb
             ,b.unit_price
             ,c.address
             ,c.phone
             ,c.username
             ,c.express_com expressCompany
             ,c.express_no
        from xzx_score_order a
         inner join xzx_score_order_details b on a.id=b.order_id
         inner join xzx_score_express_info c on a.id=c.order_id
        where a.id=#{id}
    </select>
 
    <update id="updateOrderStatus">
        update xzx_score_order
        set status=#{status}
        where id=#{id} and user_id=#{userId}
    </update>
 
    <select id="selectOrderStastics" resultType="java.util.Map">
        select
            IFNULL(count(1), 0) totalBuy,
            IFNULL(sum(IFNULL(total_price,0)),0) totalPrice,
            (
                select IFNULL(count(1),0) from xzx_jhy_order where status in (3, 4)
                <if test="userId != null and userId != ''">
                    and user_id=#{userId}
                </if>
            ) totalOrder
        from xzx_score_order
        where status in (3, 4)
        <if test="userId != null and userId != ''">
            and user_id=#{userId}
        </if>
    </select>
 
    <select id="selectScoreOrderCnt" resultType="java.lang.Integer">
        select IFNULL(count(1), 0) from xzx_score_order
        where status in (3, 4)
        <if test="userId != null and userId != ''">
            and user_id=#{userId}
        </if>
    </select>
 
 
    <select id="selectGoodsQuotaTime" resultType="java.lang.Integer">
        SELECT
            IFNULL(SUM(a.cnt), 0)
        FROM
            xzx_score_order a
                LEFT JOIN xzx_score_order_details b ON b.order_id = a.id
        WHERE
            a. STATUS IN (1, 2, 3, 4, 5)
          and a.user_id = #{userId}
          AND b.goods_id = #{goodsId}
          and a.CREATED_TIME &gt;= #{qgStartTime}
          and a.CREATED_TIME &lt;= #{qgEndTime}
    </select>
 
    <select id="selectOrderByIsFinish" resultType="com.xzx.gc.entity.ScoreOrder">
        select
        a.*
        from xzx_score_order a
        where a.is_finish = 1
        and a.status = 2
        and a.is_finish_time &lt;= #{dateTime}
    </select>
 
    <update id="updateOrderStatusToDone">
        update xzx_score_order
        set status = 4
        where id = #{id}
    </update>
</mapper>