Pu Zhibing
2025-02-27 f0a9a41697a8568e8b3bd3436c450e68b3298916
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<?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.panzhihua.service_community.dao.ComShopFlowerOrderDAO">
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComShopFlowerOrderDO">
        <!--@mbg.generated-->
        <!--@Table com_shop_flower_order-->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="store_id" jdbcType="BIGINT" property="storeId"/>
        <result column="user_id" jdbcType="BIGINT" property="userId"/>
        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
        <result column="pay_no" jdbcType="VARCHAR" property="payNo"/>
        <result column="wx_tarde_no" jdbcType="VARCHAR" property="wxTardeNo"/>
        <result column="status" jdbcType="TINYINT" property="status"/>
        <result column="pay_status" jdbcType="TINYINT" property="payStatus"/>
        <result column="receiver_id" jdbcType="BIGINT" property="receiverId"/>
        <result column="delete_status" jdbcType="TINYINT" property="deleteStatus"/>
        <result column="total_amount" jdbcType="DECIMAL" property="totalAmount"/>
        <result column="discount_amount" jdbcType="DECIMAL" property="discountAmount"/>
        <result column="pay_amount" jdbcType="DECIMAL" property="payAmount"/>
        <result column="pay_type" jdbcType="TINYINT" property="payType"/>
        <result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
        <result column="delivery_type" jdbcType="TINYINT" property="deliveryType"/>
        <result column="delivery_status" jdbcType="TINYINT" property="deliveryStatus"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="logistics_company" jdbcType="VARCHAR" property="logisticsCompany"/>
        <result column="logistics_no" jdbcType="VARCHAR" property="logisticsNo"/>
        <result column="create_at" jdbcType="TIMESTAMP" property="createAt"/>
        <result column="update_at" jdbcType="TIMESTAMP" property="updateAt"/>
        <result column="delivery_time" jdbcType="TIMESTAMP" property="deliveryTime"/>
        <result column="service_time" jdbcType="TIMESTAMP" property="serviceTime"/>
        <result column="receiving_time" jdbcType="TIMESTAMP" property="receivingTime"/>
        <result column="refund_time" jdbcType="TIMESTAMP" property="refundTime"/>
        <result column="delivery_id" jdbcType="TIMESTAMP" property="deliveryId"/>
        <result column="delivery_no" jdbcType="TIMESTAMP" property="deliveryNo"/>
 
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, store_id, user_id, order_no, pay_no, wx_tarde_no, `status`, pay_status, receiver_id,
        delete_status, total_amount, discount_amount, pay_amount, pay_type, pay_time, delivery_type,
        delivery_status, remark, logistics_company, logistics_no, create_at, update_at, delivery_time,
        service_time, receiving_time, refund_time,point_id,delivery_id,delivery_no
    </sql>
 
    <select id="pageOrderList" resultType="com.panzhihua.common.model.vos.shop.ComShopFlowerOrderPageVO">
        select id as orderId,order_no,store_id,`status`,pay_status,receiver_id,total_amount as
        orderTotal,pay_amount,delivery_type,remark,create_at, logistics_company, logistics_no,receiving_time from com_shop_flower_order as cso
        where  cso.delete_status = 1  and cso.`status` != 0
        <if test="comOrderListDTO.userId != null">
            and cso.user_id = #{comOrderListDTO.userId}
        </if>
        <if test='comOrderListDTO.status != null'>
            AND cso.status =  #{comOrderListDTO.status}
         </if>
        order by create_at desc
    </select>
 
    <select id="pageOrderListNoDelivery" resultType="com.panzhihua.common.model.vos.shop.ComShopFlowerOrderPageVO">
        select cso.id as orderId,cso.order_no,cso.store_id,cso.`status`,cso.pay_status,cso.receiver_id,cso.total_amount as
        orderTotal,cso.pay_amount,cso.delivery_type,cso.remark,cso.create_at , g.goods_name,g.goods_attr_name,g.amount,g.goods_attr_price,
        g.goods_attr_pic
        from com_shop_flower_order as cso LEFT JOIN com_shop_flower_order_goods g ON cso.id = g.order_id
        where 1=1 and
        cso.delete_status = 1 and cso.status = 1 and cso.delivery_type = 1
        <if test='comOrderListDTO.pointId != null'>
            AND cso.point_id = #{comOrderListDTO.pointId}
        </if>
        order by create_at desc
    </select>
 
    <select id="pageOrderBy" resultType="com.panzhihua.common.model.vos.shop.ComShopOrderSearchVO">
        SELECT  sr.id, sr.store_id, sr.user_id, su.phone AS userName , sr.order_no, sr.pay_no,
        sr.wx_tarde_no, sr.status, sr.pay_status, sr.receiver_id,
        sr.total_amount, sr.discount_amount, sr.pay_amount, sr.pay_type,
        sr.pay_time, sr.delivery_type, sr.delivery_status, sr.logistics_company,
        sr.logistics_no, sr.create_at, uad.name as receiver_name, uad.phone as receiver_phone,
        group_concat(og.goods_name)
        as goodsName, ss.name as store_name ,ccep.address,ccep.`name` point_name
        FROM com_shop_flower_order sr LEFT JOIN com_shop_flower_order_goods og ON sr.id = og.order_id
        LEFT JOIN com_shop_flower_goods_attr ga ON og.goods_attr_id = ga.id
        LEFT JOIN sys_user su ON sr.user_id = su.user_id
        LEFT JOIN com_shop_flower_user_address uad ON sr.receiver_id = uad.id
        LEFT JOIN com_convenient_merchants ss ON sr.store_id = ss.id
        LEFT JOIN  com_convenient_elevating_point ccep on ccep.id = sr.point_id
        WHERE sr.delete_status = 1  and sr.`status` != 0
        <if test='pageComShopOrderSearchDTO.userId != null'>
            AND sr.user_id = #{pageComShopOrderSearchDTO.userId}
        </if>
        <if test='pageComShopOrderSearchDTO.createAtStart != null'>
            AND #{pageComShopOrderSearchDTO.createAtStart} <![CDATA[<=]]>  sr.create_at
        </if>
        <if test='pageComShopOrderSearchDTO.createAtEnd != null'>
            AND sr.create_at <![CDATA[<=]]> #{pageComShopOrderSearchDTO.createAtEnd}
        </if>
        <if test='pageComShopOrderSearchDTO.orderNo != null  '>
            AND sr.order_no like concat('%',#{pageComShopOrderSearchDTO.orderNo}, '%')
        </if>
        <if test='pageComShopOrderSearchDTO.userAccount != null  '>
            AND su.phone like concat('%',#{pageComShopOrderSearchDTO.userAccount}, '%')
        </if>
        <if test='pageComShopOrderSearchDTO.receiverAccount != null  '>
            AND uad.name like concat('%',#{pageComShopOrderSearchDTO.receiverAccount}, '%')
        </if>
        <if test='pageComShopOrderSearchDTO.receiverPhone != null '>
            AND uad.phone like concat('%',#{pageComShopOrderSearchDTO.receiverPhone}, '%')
        </if>
        <if test='pageComShopOrderSearchDTO.goodsName != null'>
            AND og.goods_name like concat('%',#{pageComShopOrderSearchDTO.goodsName}, '%')
        </if>
        <if test='pageComShopOrderSearchDTO.status != null '>
            AND sr.status = #{pageComShopOrderSearchDTO.status}
        </if>
        <if test='pageComShopOrderSearchDTO.storeName != null '>
            AND ss.name like concat('%',#{pageComShopOrderSearchDTO.storeName}, '%')
        </if>
        <if test='pageComShopOrderSearchDTO.storeId != null '>
            AND ss.id = #{pageComShopOrderSearchDTO.storeId}
        </if>
        <if test='pageComShopOrderSearchDTO.storeUserId != null '>
            AND ss.user_id = #{pageComShopOrderSearchDTO.storeUserId}
        </if>
        <if test='pageComShopOrderSearchDTO.deliveryType != null '>
            AND sr.delivery_type = #{pageComShopOrderSearchDTO.deliveryType}
        </if>
        <if test="pageComShopOrderSearchDTO.keyWord != null and pageComShopOrderSearchDTO.keyWord != ''">
            AND (ss.name like concat('%',#{pageComShopOrderSearchDTO.keyWord}, '%')
                OR sr.order_no like concat('%',#{pageComShopOrderSearchDTO.keyWord}, '%')
                OR og.goods_name like concat('%',#{pageComShopOrderSearchDTO.keyWord}, '%')
            )
        </if>
        GROUP BY sr.id ORDER BY sr.create_at DESC
    </select>
    <update id="updateOrder">
        update com_shop_flower_order set delivery_time = #{deliveryTime},status = #{status},delivery_id =
        #{deliveryId},delivery_no = #{deliveryNo}
        where id in
        <foreach item='id' index='index' collection='orderIds' open='(' separator=',' close=')'>
            #{id}
        </foreach>
    </update>
    <update id="updateOrderStatus">
         update com_shop_flower_order set service_time = #{serviceTime},status = #{status} where delivery_id =#{deliveryId}
    </update>
    <select id="pageOrderByStoreId" resultType="com.panzhihua.common.model.vos.shop.ComShopFlowerOrderStoreListVO">
        SELECT
            o.id order_id,
            o.order_no,
            o.delivery_type,
            o.`status`,
            g.goods_name,
            g.goods_attr_name,
            g.amount,
            g.goods_attr_price,
            g.goods_attr_pic,
            o.total_amount,
            a.`name`,
            a.phone,
            a.province_name,
            a.city_name,
            a.district_name,
            a.detail_address,
            o.point_id,
            o.logistics_company,
            o.logistics_no
            FROM
                com_shop_flower_order o
                LEFT JOIN com_shop_flower_order_goods g ON o.id = g.order_id
                LEFT JOIN com_shop_flower_user_address a ON a.id = o.receiver_id
            WHERE 1=1  and o.`status` != 0
        <if test="comOrderListDTO.deliveryType != null">
            and o.delivery_type = #{comOrderListDTO.deliveryType}
        </if>
        <if test="comOrderListDTO.storeId != null">
            and o.store_id = #{comOrderListDTO.storeId}
        </if>
        <if test="comOrderListDTO.deliveryId != null">
            and o.delivery_id = #{comOrderListDTO.deliveryId}
        </if>
        <if test="comOrderListDTO.status != null">
            and o.status = #{comOrderListDTO.status}
        </if>
        order by  o.create_at desc
 
    </select>
    <select id="pageOrderByDeliveryNo" resultType="com.panzhihua.common.model.vos.shop.ComShopFlowerOrderStoreListVO">
        SELECT
        o.id order_id,
        o.order_no,
        o.delivery_type,
        o.`status`,
        g.goods_name,
        g.goods_attr_name,
        g.amount,
        g.goods_attr_price,
        g.goods_attr_pic,
        o.total_amount,
        a.`name`,
        a.phone,
        a.province_name,
        a.city_name,
        a.district_name,
        a.detail_address,
        o.point_id
        FROM
        com_shop_flower_order o
        LEFT JOIN com_shop_flower_order_goods g ON o.id = g.order_id
        LEFT JOIN com_shop_flower_user_address a ON a.id = o.receiver_id
        WHERE 1=1 and o.delivery_type = 1  and o.`status` != 0
        <if test="comOrderListDTO.storeId != null">
            and o.store_id = #{comOrderListDTO.storeId}
        </if>
        <if test="comOrderListDTO.deliveryId != null">
            and o.delivery_id = #{comOrderListDTO.deliveryId}
        </if>
        order by  o.create_at desc
    </select>
    <select id="selectCountByDeliveryType"
            resultType="com.panzhihua.common.model.vos.shop.ComShopOrderCountVO">
        SELECT count(1) amount , `status` FROM com_shop_flower_order WHERE delivery_type = #{deliveryType} and store_id = #{storeId} and `status` != 0  GROUP BY `status`
    </select>
    <select id="selectCountByStoreId"
            resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdCountVO">
 
        SELECT count(1) as count_num,'dayCount' as count_name FROM com_shop_flower_order WHERE TO_DAYS(create_at)=TO_DAYS(NOW()) and `status` != 0
            <if test="storeId != null">
                and store_id = #{storeId}
            </if>
            <if test="deliveryType != null">
                and delivery_type = #{deliveryType}
            </if>
        union all
        SELECT count(1) as count_num,'monthCount' as count_name FROM com_shop_flower_order WHERE  DATE_FORMAT(create_at,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') and `status` != 0
            <if test="storeId != null">
                and store_id = #{storeId}
            </if>
            <if test="deliveryType != null">
                and delivery_type = #{deliveryType}
            </if>
        union all
        SELECT count(1) as count_num,'yearCount' as count_name FROM com_shop_flower_order  where  YEAR(create_at) =YEAR(NOW()) and `status` != 0
            <if test="storeId != null">
                and store_id = #{storeId}
            </if>
            <if test="deliveryType != null">
                and delivery_type = #{deliveryType}
            </if>
        union all
        SELECT count(1) as count_num,'allCount' as count_name FROM com_shop_flower_order  WHERE `status` != 0
        <if test="storeId != null">
                and store_id = #{storeId}
            </if>
            <if test="deliveryType != null">
                and delivery_type = #{deliveryType}
            </if>
    </select>
    <select id="selectSumAmountByStoreId"
            resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdNumVO">
        SELECT IFNULL(sum(pay_amount),0) as count_num,'dayAmount' as count_name FROM com_shop_flower_order WHERE  TO_DAYS(create_at)=TO_DAYS(NOW())  and `status` not in (6,7)  and `status` != 0
        <if test="storeId != null">
                and store_id = #{storeId}
            </if>
        union all
        SELECT IFNULL(sum(pay_amount),0) as count_num,'monthAmount' as count_name FROM com_shop_flower_order WHERE  DATE_FORMAT(create_at,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m')  and `status` not in (6,7)  and `status` != 0
        <if test="storeId != null">
                and store_id = #{storeId}
            </if>
        union all
        SELECT IFNULL(sum(pay_amount),0) as count_num,'yearAmount' as count_name FROM com_shop_flower_order  where  YEAR(create_at) =YEAR(NOW())  and `status` not in (6,7)  and `status` != 0
        <if test="storeId != null">
                and store_id = #{storeId}
            </if>
        union all
        SELECT IFNULL(sum(pay_amount),0) as count_num,'allAmount' as count_name FROM com_shop_flower_order  WHERE   `status` not in (6,7)  and `status` != 0
        <if test="storeId != null">
                and store_id = #{storeId}
            </if>
    </select>
    <select id="selectTurnover" resultType="java.math.BigDecimal">
         SELECT IFNULL(sum(pay_amount),0) as count_num FROM com_shop_flower_order  WHERE   `status` not in (6,7) and store_id = #{storeId}
    </select>
    <select id="selectSettlement" resultType="java.math.BigDecimal">
        SELECT IFNULL(sum(pay_amount),0) as count_num FROM com_shop_flower_order  WHERE   `status` in (4,5) and create_at &lt;= date_sub(now(), INTERVAL 15 DAY)
    </select>
    <select id="selectSumOrderAndAmountByStoreId"
            resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdNumVO">
        SELECT count(1)  count_num ,'pddd' as  count_name FROM `com_shop_flower_order` WHERE delivery_type =1 and delete_status = 1 and pay_status = 2 and store_id = #{storeId}  and `status` != 0
        union all
        SELECT count(1)  count_num ,'kddd' as  count_name FROM `com_shop_flower_order` WHERE delivery_type =2 and delete_status = 1 and pay_status = 2 and store_id = #{storeId}  and `status` != 0
        union all
        SELECT count(1)  count_num ,'tkdd' as  count_name FROM `com_shop_flower_order` WHERE  delete_status = 1 and pay_status = 2 and `status` = 7  and store_id = #{storeId}  and `status` != 0
        union all
        SELECT IFNULL(sum(pay_amount),0) count_num ,'yysr' as  count_name  FROM `com_shop_flower_order` WHERE `status` not in (6,7) and store_id = #{storeId}  and `status` != 0
        union all
        SELECT IFNULL(sum(pay_amount),0) count_num ,'tkje' as  count_name  FROM `com_shop_flower_order` WHERE `status`  =7 and store_id = #{storeId}  and `status` != 0
        union all
        SELECT IFNULL(sum(pay_amount),0) count_num ,'ktxje' as  count_name  FROM `com_shop_flower_order` WHERE `status` in (4,5) and create_at &lt;= date_sub(now(), INTERVAL 15 DAY) and store_id = #{storeId}  and `status` != 0
 
 
    </select>
    <select id="selectCountOrderDayByStoreId"
            resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdCountVO">
        SELECT count(1) count_num, date_format(create_at,'%Y-%m-%d') as count_name FROM com_shop_flower_order
        WHERE  date_format(create_at,'%Y-%m-%d') &gt;= date_format(date_sub(now(), INTERVAL #{days} DAY),'%Y-%m-%d')
        and store_id = #{storeId} and `status` != 0
        GROUP BY  count_name
    </select>
    <select id="selectCountOrderMonthByStoreId"
            resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdCountVO">
        SELECT count(1) count_num, date_format(create_at,'%Y-%m') as count_name FROM com_shop_flower_order
        WHERE  date_format(create_at,'%Y-%m') &gt;= date_format(now(),'%Y-01')  and store_id = #{storeId} and `status` != 0  GROUP BY  count_name
    </select>
    <select id="selectOrderSumPayDayByStoreId"
            resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdNumVO">
        SELECT IFNULL(sum(pay_amount),0) count_num, date_format(create_at,'%Y-%m-%d') as count_name FROM com_shop_flower_order
        WHERE  date_format(create_at,'%Y-%m-%d') &gt;= date_format(date_sub(now(), INTERVAL #{days} DAY),'%Y-%m-%d')
        and store_id = #{storeId} and `status` not in (6,7) and `status` != 0
        GROUP BY  count_name
    </select>
    <select id="selectOrderSumMonthByStoreId"
            resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdNumVO">
        SELECT IFNULL(sum(pay_amount),0) count_num, date_format(create_at,'%Y-%m') as count_name FROM com_shop_flower_order
        WHERE  date_format(create_at,'%Y-%m') &gt;= date_format(now(),'%Y-01')  and store_id = #{storeId}  and `status` not in (6,7)  and `status` != 0  GROUP BY  count_name
    </select>
 
 
</mapper>