Helius
2021-06-16 4e51778362c2130598a4c73ec4cebe6629dbc53f
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
<?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.system.mapper.OrderStorageInfoMapper">
 
    <select id="queryDayDiff" resultType="java.lang.Integer">
        select IFNULL(timestampdiff(day,
        (select substring_index(storage_time,"
        ",1)
        from xzx_order_storage_info
        where storage_status=0
        <if test="sysStorageId != null and sysStorageId != ''">
            AND sys_storage_id <![CDATA[>= ]]>#{sysStorageId}
        </if>
        <if test="startTime != null and startTime != ''">
            AND storage_time <![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND storage_time<![CDATA[<= ]]>#{endTime}
        </if>
        order by storage_time
        asc limit 1),
        (select substring_index(storage_time," ",1)
        from xzx_order_storage_info
        where storage_status=0
        <if test="sysStorageId != null and sysStorageId != ''">
            AND sys_storage_id <![CDATA[>= ]]>#{sysStorageId}
        </if>
        <if test="startTime != null and startTime != ''">
            AND storage_time <![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND storage_time<![CDATA[<= ]]>#{endTime}
        </if>
        order by storage_time
        desc limit 1)),0) from dual
    </select>
 
    <select id="querySysStorageAll" resultType="java.util.HashMap">
        select
        IFNULL(sum(a.storage_weight),0) as storageWeight,
        IFNULL(sum(a.storage_money),0) as storageMoney,
        IFNULL(sum(a.recycle_weight),0) as recycleWeight,
        IFNULL(sum(a.recycle_money),0) as recycleMoney
        from xzx_order_storage_info a
        left join xzx_user_other_info b on a.receiver = b.user_id
        where a.storage_status=0
        <if test=" sysStorageId != null and sysStorageId != ''">
            AND a.sys_storage_id =#{sysStorageId}
        </if>
        <if test="startTime != null and startTime != ''">
            AND a.storage_time <![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND a.storage_time<![CDATA[<= ]]>#{endTime}
        </if>
        <if test=" partnerIds != null and partnerIds.size() != 0">
            AND b.partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
 
    <select id="sysStorageOrderNum" resultType="java.lang.String">
        select a.order_id
        from xzx_order_storage_info a
        left join xzx_user_other_info b on a.receiver = b.user_id
        where a.storage_status=0
        <if test="sysStorageId != null  and sysStorageId != ''">
            AND a.sys_storage_id =#{sysStorageId}
        </if>
        <if test="startTime != null and startTime != ''">
            AND a.storage_time <![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND a.storage_time<![CDATA[<= ]]>#{endTime}
        </if>
        <if test=" partnerIds != null and partnerIds.size() != 0">
            AND b.partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
</mapper>