xuhy
2024-08-29 e0207d7029b4e90ea1e4efeab5c3c5591f0e59c3
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<?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.ruoyi.order.mapper.TChargingOrderMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.order.api.model.TChargingOrder">
        <id column="id" property="id" />
        <result column="code" property="code" />
        <result column="order_type" property="orderType" />
        <result column="order_classification" property="orderClassification" />
        <result column="app_user_id" property="appUserId" />
        <result column="app_user_car_id" property="appUserCarId" />
        <result column="site_id" property="siteId" />
        <result column="parking_lot_id" property="parkingLotId" />
        <result column="charging_pile_id" property="chargingPileId" />
        <result column="charging_gun_id" property="chargingGunId" />
        <result column="charging_capacity" property="chargingCapacity"/>
        <result column="charging_power" property="chargingPower"/>
        <result column="start_time" property="startTime" />
        <result column="end_time" property="endTime" />
        <result column="status" property="status" />
        <result column="end_mode" property="endMode"/>
        <result column="recharge_amount" property="rechargeAmount" />
        <result column="recharge_payment_type" property="rechargePaymentType" />
        <result column="recharge_payment_status" property="rechargePaymentStatus" />
        <result column="recharge_serial_number" property="rechargeSerialNumber" />
        <result column="order_amount" property="orderAmount" />
        <result column="app_coupon_id" property="appCouponId" />
        <result column="coupon_discount_amount" property="couponDiscountAmount" />
        <result column="vip_discount" property="vipDiscount" />
        <result column="vip_discount_amount" property="vipDiscountAmount" />
        <result column="payment_amount" property="paymentAmount" />
        <result column="refund_code" property="refundCode" />
        <result column="refund_amount" property="refundAmount" />
        <result column="refund_status" property="refundStatus" />
        <result column="refund_serial_number" property="refundSerialNumber" />
        <result column="refund_time" property="refundTime" />
        <result column="create_time" property="createTime" />
        <result column="del_flag" property="delFlag" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, code, order_type, order_classification, app_user_id, app_user_car_id,site_id, parking_lot_id, charging_pile_id, charging_gun_id, start_time, end_time, status, recharge_amount, recharge_payment_type, recharge_payment_status, recharge_serial_number, order_amount, app_coupon_id, coupon_discount_amount, vip_discount, vip_discount_amount, payment_amount, refund_code, refund_amount, refund_status, refund_serial_number, refund_time, create_time, del_flag
    </sql>
 
    
    <select id="getMyChargingOrderList" resultMap="BaseResultMap">
        select * from t_charging_order where del_flag = 0 and app_user_id = #{appUserId}
        <if test="1 == type">
            and id not in (select order_id from t_order_evaluate where order_type = 1 and app_user_id = #{appUserId} and del_flag = 0)
        </if>
        order by create_time desc
        <if test="null != pageCurr and null != pageSize">
            limit #{pageCurr}, #{pageSize}
        </if>
    </select>
    <select id="getNoInvoicedOrder" resultMap="BaseResultMap">
        select * from t_charging_order where del_flag = 0 and app_user_id = #{appUserId}
        <if test="null != month and '' != month">
            and DATE_FORMAT(end_time, '%Y-%m') = #{month}
        </if>
        and id not in (select order_id from t_order_invoice_detail where order_type = 1)
        order by create_time desc
        <if test="null != pageCurr and null != pageSize">
            limit #{pageCurr}, #{pageSize}
        </if>
    </select>
 
    <select id="chargingOrder" resultType="com.ruoyi.order.api.vo.ChargingOrderVO">
        select t1.*
        from t_charging_order t1
        where 1=1
        <if test="null != req.code and req.code!=''">
            and t1.code  LIKE CONCAT('%',#{req.code},'%')
        </if>
        <if test="null != req.userIds and req.userIds.size()>0" >
            and t1.app_user_id in
            <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="req.orderType != null ">
            and t1.order_type = #{req.orderType}
        </if>
        <if test="req.status != null ">
            and t1.status = #{req.status}
        </if>
        <if test="req.siteId != null ">
            and t1.site_id = #{req.siteId}
        </if>
        <if test="req.pileId != null ">
            and t1.charging_pile_id = #{req.pileId}
        </if>
        <if test="req.gunId != null ">
            and t1.charging_gun_id = #{req.gunId}
        </if>
        <if test="startTime1 != null and startTime1!=''">
            and (t1.start_time between #{startTime1} and #{startTime2}
        </if>
        <if test="endTime1 != null and endTime1!=''">
            and (t1.end_time between #{endTime1} and #{endTime2}
        </if>
    </select>
    <select id="payOrderQuery" resultType="com.ruoyi.order.dto.PayOrderDto">
        SELECT * FROM (SELECT
                           id,
                           `code`,
                           1 as type,
                           title,
                           phone,
                           `status`,
                           order_amount,
                           payment_amount ,
                           create_time,
                           end_time,
                           pay_time
                       FROM
                           charging_pile_order.t_charging_order UNION ALL
                       SELECT
                           id,
                           `code`,
                           2 as type,
                           title,
                           phone,
                           `status`,
                           order_amount,
                           payment_amount ,
                           create_time,
                           receiving_time as end_time,
                           pay_time
                       FROM
                           charging_pile_order.t_shopping_order UNION ALL
                       SELECT
                           id,
                           `code`,
                           3 as type,
                           title,
                           phone,
                           payment_status AS `status`,
                           order_amount,
                           payment_amount ,
                           create_time,
                           create_time as end_time,
                           pay_time
                       FROM
                           charging_pile_order.t_vip_order UNION ALL
                       SELECT
                           id,
                           `code`,
                           4 as type,
                           title,
                           phone,
                           `status`,
                           order_amount ,
                           order_amount as payment_amount,
                           create_time,
                           out_parking_time as end_time,
                           out_parking_time as pay_time
                       FROM
                           charging_pile_service.t_parking_record ) o
                <where>
                    <if test="data.code != null and data.code != ''">
                        AND o.code LIKE CONCAT('%',#{data.code},'%')
                    </if>
                    <if test="data.phone != null and data.phone != ''">
                        AND o.phone LIKE CONCAT('%',#{data.phone},'%')
                    </if>
                    <if test="data.type != null">
                        AND o.type = #{data.type}
                    </if>
                    <if test="data.status != null">
                        AND o.status = #{data.status}
                    </if>
                    <if test="data.createTime1 != null">
                        AND o.create_time &gt;= #{data.createTime1}
                    </if>
                    <if test="data.createTime2 != null">
                        AND o.create_time &lt;= #{data.createTime2}
                    </if>
                </where>
 
 
    </select>
    <select id="getRefundList" resultType="com.ruoyi.order.api.model.TChargingOrderRefund">
 
        select * from (SELECT id,
                              `code`,
                              refund_code,
                              refund_title,
                              refund_reason,
                              refund_amount,
                              refund_total_amount,
                              refund_time,
                              pay_type,
                              pay_amount,
                              refund_remark
                       FROM t_charging_order_refund
                       UNION ALL
                       SELECT id,
                              `code`,
                              refund_code,
                              refund_title,
                              refund_reason,
                              refund_amount,
                              refund_total_amount,
                              refund_time,
                              pay_type,
                              pay_amount,
                              refund_remark
                       FROM t_shopping_order_refund
                       UNION ALL
                       SELECT id,
                              `code`,
                              refund_code,
                              refund_title,
                              refund_reason,
                              refund_amount,
                              refund_total_amount,
                              refund_time,
                              pay_type,
                              pay_amount,
                              refund_remark
                       FROM t_vip_order_refund) o
        <where>
            <if test="data.code != null and data.code != ''">
                AND o.code LIKE CONCAT('%',#{data.code},'%')
            </if>
            <if test="data.refundCode != null and data.refundCode != ''">
                AND o.refund_code LIKE CONCAT('%',#{data.refundCode},'%')
            </if>
        </where>
 
 
    </select>
</mapper>