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
<?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.CustomerReportMapper">
<select id="getListPage"
parameterType="cn.iocoder.yudao.module.delivery.entity.CustomerReportReq"
resultType="cn.iocoder.yudao.module.delivery.entity.CustomerReportResp">
SELECT number,name,(
SELECT nickname from system_user where id=c.customer_service
) as salesman,c.customer_service as salesmanid,
source,create_time as createtime,
(u_d.dept_id) as deptid,(u_d.deptName) as deptname,
<!--总V值 2024-04-22-->
(SELECT round(sum(vz),2) FROM view_order_businesstime WHERE customer_id = c.id AND business_time BETWEEN '${sDate}' AND '${eDate}') AS allsumvolume,
(SELECT round(sum(vz),2) FROM view_order_businesstime WHERE customer_id = c.id AND business_time BETWEEN '${sDuiBiDate}' AND '${eDuiBiDate}') as allsumvolumeTb,
<!--海运-->
(SELECT round(sum(charge_volume)/(SELECT vz FROM ecw_vz WHERE fuhao ='M3' LIMIT 1),2) FROM view_order_businesstime WHERE customer_id = c.id AND transport_id = 1 AND business_time BETWEEN '${sDate}' AND '${eDate}') AS sumvolume1,
(SELECT round(sum(charge_volume)/(SELECT vz FROM ecw_vz WHERE fuhao ='M3' LIMIT 1),2) FROM view_order_businesstime WHERE customer_id = c.id AND transport_id = 1 AND business_time BETWEEN '${sDuiBiDate}' AND '${eDuiBiDate}') as sumvolumeTb1,
<!--空运-->
(SELECT round(sum(charge_weight),2)/(SELECT vz FROM ecw_vz WHERE fuhao ='KG' LIMIT 1 ) FROM view_order_businesstime WHERE customer_id = c.id AND transport_id = 3 AND business_time BETWEEN '${sDate}' AND '${eDate}') AS sumweight3,
(SELECT round(sum(charge_weight),2)/(SELECT vz FROM ecw_vz WHERE fuhao ='KG' LIMIT 1 ) FROM view_order_businesstime WHERE customer_id = c.id AND transport_id = 3 AND business_time BETWEEN '${sDuiBiDate}' AND '${eDuiBiDate}') as sumweightTb3
from ecw_customer c left join (SELECT d.NAME as deptName,u.dept_id,u.id as userid FROM
system_user u LEFT JOIN system_dept d ON u.dept_id = d.id) AS u_d ON c.customer_service = u_d.userid
<include refid="WherePage"/>
ORDER BY allsumvolume desc
limit 0,10
</select>
<sql id="WherePage">
<where>
and c.deleted = 0
<if test="salesmanid!=null and salesmanid!=''">
and c.customer_service= #{salesmanid}
</if>
<if test="deptid!=null and deptid!=''">
and u_d.dept_id= #{deptid}
</if>
</where>
</sql>
<select id="GetCount" resultType="java.lang.Long">
SELECT count(1)
from ecw_customer c left join
(SELECT d.NAME as deptName,u.dept_id,u.id as userid FROM
system_user u LEFT JOIN system_dept d ON u.dept_id = d.id
) AS u_d ON c.customer_service = u_d.userid
<include refid="WherePage"/>
</select>
</mapper>