SalesAnalysisMapper.xml 14.7 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1 2 3 4 5 6
<?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="cn.iocoder.yudao.module.delivery.mapper.SalesAnalysisMapper">
    <select id="getListPage"
            parameterType="cn.iocoder.yudao.module.delivery.entity.SalesAnalysisReq"
            resultType="cn.iocoder.yudao.module.delivery.entity.SalesAnalysisResp">
7 8 9 10 11 12 13
        select c.order_id as orderId, order_no as orderNo, tidan_no as tidanNo,
        c.status,salesman_id as salesmanid,
        (SELECT nickname from system_user where id=c.salesman_id) as salesmanidName,
        c.transport_id as transportId,c.drawee,
        if(c.transport_id=1,'海运拼柜','专线空运') as transportIdName,
        order_type as ordertype,use_weight_unit as useweightunit,
        use_volume_unit as usevolumeunit,
lanbaoming's avatar
lanbaoming committed
14
        c.marks,w.start_warehouse_name as startwarehousename,
lanbaoming's avatar
lanbaoming committed
15 16 17
        w.dst_warehouse_name as dstwarehousename,w.muDiGuo,w.muDiShi,
        c.channel_id as channelid,channel.name_zh as channelidName,
        c.create_time as createtime,sum_quantity as sumquantity,
lanbaoming's avatar
lanbaoming committed
18
        sum_volume as sumvolume,sum_weight as sumweight,
19 20 21 22 23
        if(is_cargo_control=0,'否','是') as iscargocontrol,
        ( if( c.transport_id = 1 , c.load_time, c.rucang_time) ) AS businesstime,
        cf.number as fhNumber,sh.number as shNumber,
        cf.id as cfCustomerId,sh.id as shCustomerId,
        cf.resource_type as cfresourceType,sh.resource_type as shResource_type,
lanbaoming's avatar
lanbaoming committed
24 25
        cf.is_new as cfYeJiType,sh.is_new as shYeJitype,
        (SELECT sum(ecw_order_pickup.pick_num) FROM ecw_order_pickup
lanbaoming's avatar
lanbaoming committed
26
        WHERE ( ecw_order_pickup.order_id = c.order_no)) AS picknum,
lanbaoming's avatar
lanbaoming committed
27 28
        (select in_time from ecw_order_warehouse_in where
        order_id=c.order_id ORDER BY in_time asc LIMIT 1) as firstInTime
lanbaoming's avatar
lanbaoming committed
29
        from ecw_order c
lanbaoming's avatar
lanbaoming committed
30 31
        left join (SELECT ewl.id AS line_id,
        ew_start.id AS start_warehouse_id,
lanbaoming's avatar
lanbaoming committed
32 33
        ew_dest.id AS dst_warehouse_id,ew_start.title_zh AS start_title_zh,
        ew_dest.title_zh AS dst_warehouse_name,
lanbaoming's avatar
lanbaoming committed
34 35
        r_dest.title_zh as muDiGuo, r_dest.id as muDiGuoID,
        r_sdest.title_zh as muDiShi,r_sdest.id as muDiShiID,
lanbaoming's avatar
lanbaoming committed
36
        ew_start.title_zh AS start_warehouse_name FROM ecw_warehouse_line ewl
lanbaoming's avatar
lanbaoming committed
37
        LEFT JOIN ecw_warehouse ew_start ON ewl.start_warehouse_id = ew_start.id
lanbaoming's avatar
lanbaoming committed
38
        LEFT JOIN ecw_warehouse ew_dest ON ewl.dest_warehouse_id = ew_dest.id
lanbaoming's avatar
lanbaoming committed
39 40
        left join ecw_region r_dest on ew_dest.guojia=r_dest.id
        LEFT JOIN ecw_region r_sdest on ew_dest.shi=r_sdest.id
lanbaoming's avatar
lanbaoming committed
41
        ) w ON w.line_id = c.line_id
lanbaoming's avatar
lanbaoming committed
42
        left join ecw_channel channel on channel.channel_id =c.channel_id and channel.deleted=0
43
        <!--订单发货人信息-->
lanbaoming's avatar
lanbaoming committed
44 45
        left join ecw_order_consignor nor on nor.order_id = c.order_id and nor.deleted=0
        left join ecw_customer cf on cf.id=nor.customer_id and cf.deleted=0
46
        <!--订单收货人信息-->
lanbaoming's avatar
lanbaoming committed
47 48
        left join ecw_order_consignee nee on nee.order_id = c.order_id and nee.deleted=0
        left join ecw_customer sh on sh.id=nee.customer_id and sh.deleted=0
lanbaoming's avatar
lanbaoming committed
49
        <include refid="WherePage"/>
50
        ORDER BY c.create_time asc limit #{start}, #{size}
lanbaoming's avatar
lanbaoming committed
51 52 53 54 55
    </select>

    <sql id="WherePage">
        <where>
            and c.deleted = 0
lanbaoming's avatar
lanbaoming committed
56 57
            <if test="orderNo!=null and orderNo!=''">
                <!--订单编号-->
lanbaoming's avatar
lanbaoming committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
                <if test="SearchType1!=null and SearchType1!=''">
                    <choose>
                        <when test="SearchType1 =='in'.toString()">
                            and c.order_no like concat('%',#{orderNo},'%')
                        </when>
                        <when test="SearchType1 =='notin'.toString()">
                            and c.order_no not like concat('%',#{orderNo},'%')
                        </when>
                        <when test="SearchType1 =='eq'.toString()">
                            and c.order_no= #{orderNo}
                        </when>
                        <when test="SearchType1 =='noeq'.toString()">
                            and c.order_no!= #{orderNo}
                        </when>
                        <otherwise>
                            and c.order_no= #{orderNo}
                        </otherwise>
                    </choose>
                </if>
lanbaoming's avatar
lanbaoming committed
77 78 79
            </if>
            <if test="tidanNo!=null and tidanNo!=''">
                <!--提单编号-->
lanbaoming's avatar
lanbaoming committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
                <if test="SearchType2!=null and SearchType2!=''">
                    <choose>
                        <when test="SearchType2 =='in'.toString()">
                            and c.tidan_no like concat('%',#{tidanNo},'%')
                        </when>
                        <when test="SearchType2 =='notin'.toString()">
                            and c.tidan_no not like concat('%',#{tidanNo},'%')
                        </when>
                        <when test="SearchType2 =='eq'.toString()">
                            and c.tidan_no= #{tidanNo}
                        </when>
                        <when test="SearchType2 =='noeq'.toString()">
                            and c.tidan_no!= #{tidanNo}
                        </when>
                        <otherwise>
                            and c.tidan_no= #{tidanNo}
                        </otherwise>
                    </choose>
                </if>
lanbaoming's avatar
lanbaoming committed
99 100 101
            </if>
            <if test="fhNumber!=null and fhNumber!=''">
                <!--发货人编号-->
lanbaoming's avatar
lanbaoming committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
                <if test="SearchType3!=null and SearchType3!=''">
                    <choose>
                        <when test="SearchType3 =='in'.toString()">
                            and cf.number like concat('%',#{fhNumber},'%')
                        </when>
                        <when test="SearchType3 =='notin'.toString()">
                            and cf.number not like concat('%',#{fhNumber},'%')
                        </when>
                        <when test="SearchType3 =='eq'.toString()">
                            and cf.number= #{fhNumber}
                        </when>
                        <when test="SearchType3 =='noeq'.toString()">
                            and cf.number!= #{fhNumber}
                        </when>
                        <otherwise>
                            and cf.number= #{fhNumber}
                        </otherwise>
                    </choose>
                </if>
lanbaoming's avatar
lanbaoming committed
121 122 123
            </if>
            <if test="shNumber!=null and shNumber!=''">
                <!--收货人编号-->
lanbaoming's avatar
lanbaoming committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
                <if test="SearchType4!=null and SearchType4!=''">
                    <choose>
                        <when test="SearchType4 =='in'.toString()">
                            and sh.number like concat('%',#{shNumber},'%')
                        </when>
                        <when test="SearchType4 =='notin'.toString()">
                            and sh.number not like concat('%',#{shNumber},'%')
                        </when>
                        <when test="SearchType4 =='eq'.toString()">
                            and sh.number= #{shNumber}
                        </when>
                        <when test="SearchType4 =='noeq'.toString()">
                            and sh.number!= #{shNumber}
                        </when>
                        <otherwise>
                            and sh.number= #{shNumber}
                        </otherwise>
                    </choose>
                </if>
lanbaoming's avatar
lanbaoming committed
143 144 145
            </if>
            <if test="marks!=null and marks!=''">
                <!--唛头-->
lanbaoming's avatar
lanbaoming committed
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
                <if test="SearchType5!=null and SearchType5!=''">
                    <choose>
                        <when test="SearchType5 =='in'.toString()">
                            and c.marks like concat('%',#{marks},'%')
                        </when>
                        <when test="SearchType5 =='notin'.toString()">
                            and c.marks not like concat('%',#{marks},'%')
                        </when>
                        <when test="SearchType5 =='eq'.toString()">
                            and c.marks=#{marks}
                        </when>
                        <when test="SearchType5 =='noeq'.toString()">
                            and c.marks!= #{marks}
                        </when>
                        <otherwise>
                            and c.marks= #{marks}
                        </otherwise>
                    </choose>
                </if>
lanbaoming's avatar
lanbaoming committed
165 166 167 168 169 170 171 172 173
            </if>
            <if test="salesmanId!=null and salesmanId!=''">
                <!--客户经理-->
                and c.salesman_id= #{salesmanId}
            </if>
            <if test="status!=null and status!=''">
                <!--订单状态-->
                and c.status= #{status}
            </if>
lanbaoming's avatar
lanbaoming committed
174 175 176 177
            <if test="transportId!=null and transportId!=''">
                <!--运输方式查询条件-->
                and c.transport_id= #{transportId}
            </if>
lanbaoming's avatar
lanbaoming committed
178 179 180 181 182 183 184
            <if test="startWarehouseId!=null and startWarehouseId!=''">
                <!--始发仓-->
                and w.start_warehouse_id= #{startWarehouseId}
            </if>
            <if test="muDiGuo!=null and muDiGuo!=''">
                <!--目的国-->
                and w.muDiGuoID= #{muDiGuo}
lanbaoming's avatar
lanbaoming committed
185
            </if>
lanbaoming's avatar
lanbaoming committed
186 187 188 189 190 191 192 193
            <if test="muDiShi!=null and muDiShi!=''">
                <!--目的城市-->
                and w.muDiShiID= #{muDiShi}
            </if>
            <if test="dstwarehouseid!=null and dstwarehouseid!=''">
                <!--目的仓-->
                and w.dst_warehouse_id= #{dstwarehouseid}
            </if>
lanbaoming's avatar
lanbaoming committed
194 195
            <if test="isCargoControl!=null">
                <!--是否控货 注意整型值的判断-->
196 197
                and c.is_cargo_control= #{isCargoControl}
            </if>
lanbaoming's avatar
lanbaoming committed
198 199 200
            <if test="zpType!=null and zpType!=''">
                <!--重泡货类型-->
                and c.order_type= #{zpType}
201 202 203 204 205
            </if>
            <if test="drawee!=null and drawee!=''">
                <!--付款方-->
                and c.drawee= #{drawee}
            </if>
lanbaoming's avatar
lanbaoming committed
206 207 208 209 210 211 212 213 214 215 216 217 218
            <if test="shippingChannelId!=null and shippingChannelId!=''">
                <!--渠道-->
                and c.channel_id= #{shippingChannelId}
            </if>
            <if test="ResourceType!=null and ResourceType!=''">
                <!--资源类型-->
                and c.channel_id= #{ResourceType}
            </if>
            <if test="YeJiType!=null and YeJiType!=''">
                <!--业绩类型-->
                and c.channel_id= #{YeJiType}
            </if>
            <if test="dateSearch1!=null and dateSearch1!=''
lanbaoming's avatar
lanbaoming committed
219
              and sdate1!=null and sdate1!='' and edate2!=null and edate2!=''">
lanbaoming's avatar
lanbaoming committed
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
                <!--订单创建时间-->
                and c.create_time BETWEEN #{sdate1} AND #{edate2}
            </if>
            <if test="dataSearch3!=null and dataSearch3!=''">
                <if test="dataSearch1!=null and dataSearch1!=''">
                    <if test="dataSearch2=null and dataSearch2!=''">
                        <!--数据筛选-->
                        <choose>
                            <when test="dataSearch1 =='1'.toString()">
                                <!--入仓箱数-->
                            </when>
                            <when test="dataSearch1 =='2'.toString()">
                                <!--入仓体积-->
                            </when>
                            <when test="dataSearch1 =='3'.toString()">
                                <!--入仓重量-->
                            </when>
                            <when test="dataSearch1 =='3'.toString()">
                                <!--重/泡标准-->
                            </when>
                            <when test="dataSearch1 =='3'.toString()">
                                <!--提货率-->
                            </when>
                        </choose>
                    </if>
                </if>
            </if>
lanbaoming's avatar
lanbaoming committed
247 248 249 250 251
        </where>
    </sql>


    <select id="GetCount" resultType="java.lang.Long">
lanbaoming's avatar
lanbaoming committed
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
        SELECT count(1) from ecw_order c
        left join (SELECT ewl.id AS line_id,
        ew_start.id AS start_warehouse_id,
        ew_dest.id AS dst_warehouse_id,ew_start.title_zh AS start_title_zh,
        ew_dest.title_zh AS dst_warehouse_name,
        r_dest.title_zh as muDiGuo, r_dest.id as muDiGuoID,
        r_sdest.title_zh as muDiShi,r_sdest.id as muDiShiID,
        ew_start.title_zh AS start_warehouse_name FROM ecw_warehouse_line ewl
        LEFT JOIN ecw_warehouse ew_start ON ewl.start_warehouse_id = ew_start.id
        LEFT JOIN ecw_warehouse ew_dest ON ewl.dest_warehouse_id = ew_dest.id
        left join ecw_region r_dest on ew_dest.guojia=r_dest.id
        LEFT JOIN ecw_region r_sdest on ew_dest.shi=r_sdest.id
        ) w ON w.line_id = c.line_id
        left join ecw_channel channel on channel.channel_id =c.channel_id and channel.deleted=0
        <!--订单发货人信息-->
        left join ecw_order_consignor nor on nor.order_id = c.order_id and nor.deleted=0
        left join ecw_customer cf on cf.id=nor.customer_id and cf.deleted=0
        <!--订单收货人信息-->
        left join ecw_order_consignee nee on nee.order_id = c.order_id and nee.deleted=0
        left join ecw_customer sh on sh.id=nee.customer_id and sh.deleted=0
lanbaoming's avatar
lanbaoming committed
272 273 274
        <include refid="WherePage"/>
    </select>

lanbaoming's avatar
lanbaoming committed
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
    <select id="getList"
            parameterType="cn.iocoder.yudao.module.delivery.entity.SalesAnalysisReq"
            resultType="cn.iocoder.yudao.module.delivery.entity.SalesAnalysisExcelResp">
        select order_no as orderNo, tidan_no as tidanNo,
        c.status,salesman_id as salesmanid,transport_id,marks,
        w.start_warehouse_name as startwarehousename,
        w.dst_warehouse_name as dstwarehousename,w.muDiGuo,w.muDiShi,
        c.channel_id as channelid,channel.name_zh as channelidName,
        c.create_time as createtime,sum_quantity as sumquantity,
        sum_volume as sumvolume,sum_weight as sumweight,
        is_cargo_control as iscargocontrol
        from ecw_order c
        left join (SELECT ewl.id AS line_id,
        ew_start.id AS start_warehouse_id,
        ew_dest.id AS dst_warehouse_id,ew_start.title_zh AS start_title_zh,
        ew_dest.title_zh AS dst_warehouse_name,
        r_dest.title_zh as muDiGuo,r_sdest.title_zh as muDiShi,
        ew_start.title_zh AS start_warehouse_name FROM ecw_warehouse_line ewl
        LEFT JOIN ecw_warehouse ew_start ON
        ewl.start_warehouse_id = ew_start.id
        LEFT JOIN ecw_warehouse ew_dest ON ewl.dest_warehouse_id = ew_dest.id
        left join ecw_region r_dest on ew_dest.guojia=r_dest.id
        LEFT JOIN ecw_region r_sdest on ew_dest.shi=r_sdest.id
        ) w ON w.line_id = c.line_id
        left join ecw_channel channel on channel.channel_id =c.channel_id
        <include refid="WherePage"/>

    </select>
lanbaoming's avatar
lanbaoming committed
303 304 305 306

</mapper>