LogisticsSheetMapper.xml
9.06 KB
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
<?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.lframework.xingyun.sc.mappers.LogisticsSheetMapper">
    <resultMap id="LogisticsSheetFullDto" type="com.lframework.xingyun.sc.dto.logistics.LogisticsSheetFullDto">
        <id column="id" property="id"/>
        <result column="code" property="code"/>
        <result column="logistics_no" property="logisticsNo"/>
        <result column="logistics_company_id" property="logisticsCompanyId"/>
        <result column="sender_name" property="senderName"/>
        <result column="sender_telephone" property="senderTelephone"/>
        <result column="sender_province_id" property="senderProvinceId"/>
        <result column="sender_city_id" property="senderCityId"/>
        <result column="sender_district_id" property="senderDistrictId"/>
        <result column="sender_address" property="senderAddress"/>
        <result column="receiver_name" property="receiverName"/>
        <result column="receiver_telephone" property="receiverTelephone"/>
        <result column="receiver_province_id" property="receiverProvinceId"/>
        <result column="receiver_city_id" property="receiverCityId"/>
        <result column="receiver_district_id" property="receiverDistrictId"/>
        <result column="receiver_address" property="receiverAddress"/>
        <result column="status" property="status"/>
        <result column="description" property="description"/>
        <result column="total_weight" property="totalWeight"/>
        <result column="total_volume" property="totalVolume"/>
        <result column="total_amount" property="totalAmount"/>
        <result column="delivery_by" property="deliveryBy"/>
        <result column="delivery_time" property="deliveryTime"/>
        <result column="create_by" property="createBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_by" property="updateBy"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <collection property="details" javaType="java.util.ArrayList" ofType="com.lframework.xingyun.sc.dto.logistics.LogisticsSheetFullDto$DetailDto">
            <id column="detail_id" property="id"/>
            <result column="detail_sheet_id" property="sheetId"/>
            <result column="detail_biz_id" property="bizId"/>
            <result column="detail_biz_type" property="bizType"/>
        </collection>
    </resultMap>
    <sql id="LogisticsSheetDto_sql">
        SELECT
            o.*
        FROM tbl_logistics_sheet AS o
    </sql>
    <sql id="LogisticsSheetFullDto_sql">
        SELECT
            o.id,
            o.code,
            o.logistics_no,
            o.logistics_company_id,
            o.sender_name,
            o.sender_telephone,
            o.sender_province_id,
            o.sender_city_id,
            o.sender_district_id,
            o.sender_address,
            o.receiver_name,
            o.receiver_telephone,
            o.receiver_province_id,
            o.receiver_city_id,
            o.receiver_district_id,
            o.receiver_address,
            o.status,
            o.description,
            o.total_weight,
            o.total_volume,
            o.total_amount,
            o.delivery_by,
            o.delivery_time,
            o.create_by,
            o.create_time,
            o.update_by,
            o.update_time,
            d.id AS detail_id,
            d.sheet_id AS detail_sheet_id,
            d.biz_id AS detail_biz_id,
            d.biz_type AS detail_biz_type
        FROM tbl_logistics_sheet AS o
        LEFT JOIN tbl_logistics_sheet_detail AS d ON d.sheet_id = o.id
    </sql>
    <select id="query" resultType="com.lframework.xingyun.sc.entity.LogisticsSheet">
        <include refid="LogisticsSheetDto_sql"/>
        <where>
            <if test="vo != null">
                <if test="vo.code != null and vo.code != ''">
                    AND o.code = #{vo.code}
                </if>
                <if test="vo.logisticsNo != null and vo.logisticsNo != ''">
                    AND o.logistics_no = #{vo.logisticsNo}
                </if>
                <if test="vo.logisticsCompanyId != null and vo.logisticsCompanyId != ''">
                    AND o.logistics_company_id = #{vo.logisticsCompanyId}
                </if>
                <if test="vo.status != null">
                    AND o.status = #{vo.status}
                </if>
                <if test="vo.createBy != null and vo.createBy != ''">
                    AND o.create_by_id = #{vo.createBy}
                </if>
                <if test="vo.createStartTime != null">
                    AND o.create_time >= #{vo.createStartTime}
                </if>
                <if test="vo.createEndTime != null">
                    <![CDATA[
                    AND o.create_time <= #{vo.createEndTime}
                    ]]>
                </if>
                <if test="vo.deliveryBy != null and vo.deliveryBy != ''">
                    AND o.delivery_by = #{vo.deliveryBy}
                </if>
                <if test="vo.deliveryStartTime != null">
                    AND o.delivery_time >= #{vo.deliveryStartTime}
                </if>
                <if test="vo.deliveryEndTime != null">
                    <![CDATA[
                    AND o.delivery_time <= #{vo.deliveryEndTime}
                    ]]>
                </if>
            </if>
        </where>
        ORDER BY o.create_time DESC
    </select>
    <select id="getDetail" resultMap="LogisticsSheetFullDto">
        <include refid="LogisticsSheetFullDto_sql"/>
        WHERE o.id = #{id}
    </select>
    <select id="selector" resultType="com.lframework.xingyun.sc.entity.LogisticsSheet">
        <include refid="LogisticsSheetDto_sql"/>
        <where>
            <if test="vo != null">
                <if test="vo.code != null and vo.code != ''">
                    AND o.code = #{vo.code}
                </if>
                <if test="vo.logisticsNo != null and vo.logisticsNo != ''">
                    AND o.logistics_no = #{vo.logisticsNo}
                </if>
                <if test="vo.logisticsCompanyId != null and vo.logisticsCompanyId != ''">
                    AND o.logistics_company_id = #{vo.logisticsCompanyId}
                </if>
                <if test="vo.status != null">
                    AND o.status = #{vo.status}
                </if>
                <if test="vo.createBy != null and vo.createBy != ''">
                    AND o.create_by_id = #{vo.createBy}
                </if>
                <if test="vo.createStartTime != null">
                    AND o.create_time >= #{vo.createStartTime}
                </if>
                <if test="vo.createEndTime != null">
                    <![CDATA[
                    AND o.create_time <= #{vo.createEndTime}
                    ]]>
                </if>
                <if test="vo.deliveryBy != null and vo.deliveryBy != ''">
                    AND o.delivery_by = #{vo.deliveryBy}
                </if>
                <if test="vo.deliveryStartTime != null">
                    AND o.delivery_time >= #{vo.deliveryStartTime}
                </if>
                <if test="vo.deliveryEndTime != null">
                    <![CDATA[
                    AND o.delivery_time <= #{vo.deliveryEndTime}
                    ]]>
                </if>
            </if>
        </where>
        ORDER BY o.create_time DESC
    </select>
    <select id="queryBizOrder" resultType="com.lframework.xingyun.sc.dto.logistics.LogisticsSheetBizOrderDto">
        SELECT * FROM (
            SELECT
                s.id AS biz_id,
                s.code AS biz_code,
                1 AS biz_type,
                s.sc_id,
                s.customer_id AS receiver_id,
                s.create_by,
                s.create_by_id,
                s.create_time
            FROM tbl_sale_out_sheet AS s
            UNION ALL
            SELECT
                r.id AS biz_id,
                r.code AS biz_code,
                2 AS biz_type,
                r.sc_id,
                r.member_id AS receiver_id,
                r.create_by,
                r.create_by_id,
                r.create_time
            FROM tbl_retail_out_sheet AS r
        ) AS o
        LEFT JOIN tbl_logistics_sheet_detail AS d ON d.biz_id = o.biz_id
        <where>
            <if test="vo != null">
                <if test="vo.code != null and vo.code != ''">
                    AND o.biz_code = #{vo.code}
                </if>
                <if test="vo.createBy != null and vo.createBy != ''">
                   AND o.create_by_id = #{vo.createBy}
                </if>
                <if test="vo.createStartTime != null">
                   AND o.create_time >= #{vo.createStartTime}
                </if>
                <if test="vo.createEndTime != null">
                   <![CDATA[
                   AND o.create_time <= #{vo.createEndTime}
                   ]]>
                </if>
            </if>
            AND d.id IS NULL
        </where>
        ORDER BY o.create_time
    </select>
</mapper>