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
<?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.SalesReportMapper">
<!--总值统计-->
<select id="SalesReportCountAll" resultType="cn.iocoder.yudao.module.delivery.entity.SalesReportRespAll">
SELECT (
SELECT sum(if(transport_id = 1, sum_volume, sum_weight))
FROM ecw_order c
WHERE is_del = 0
AND (transport_id = 1 OR transport_id = 3)
AND rucang_time BETWEEN #{sDate} AND #{eDate}
<include refid="WherePage"/>
) AS curValue,
(SELECT sum(if(transport_id = 1, sum_volume, sum_weight))
FROM ecw_order c
WHERE is_del = 0
AND (transport_id = 1 OR transport_id = 3)
AND rucang_time BETWEEN #{sDuiBiDate} AND #{eDuiBiDate}
<include refid="WherePage"/>
) AS tbValue,
(SELECT sum(if(transport_id = 1, sum_volume, sum_weight))
FROM ecw_order c
WHERE is_del = 0
AND (transport_id = 1 OR transport_id = 3)
AND rucang_time BETWEEN #{sHuanBiDate} AND #{eHuanBiDate}
<include refid="WherePage"/>
) AS hbValue,
(
SELECT sum(sum_volume)
FROM ecw_order c
WHERE is_del = 0
AND transport_id = 1
AND rucang_time BETWEEN #{sDate} AND #{eDate}
<include refid="WherePage"/>
) AS curValue1,
(SELECT sum(sum_volume)
FROM ecw_order c
WHERE is_del = 0
AND transport_id = 1
AND rucang_time BETWEEN #{sDuiBiDate} AND #{eDuiBiDate}
<include refid="WherePage"/>
) AS tbValue1,
(SELECT round(sum(sum_volume) / (SELECT vz FROM ecw_vz WHERE fuhao = 'M3' LIMIT 1), 2)
FROM ecw_order c
WHERE is_del = 0
AND transport_id = 1
AND rucang_time BETWEEN #{sHuanBiDate} AND #{eHuanBiDate}
<include refid="WherePage"/>
) AS hbValue1,
(SELECT round(sum(sum_weight) / (SELECT vz FROM ecw_vz WHERE fuhao = 'KG' LIMIT 1), 2)
FROM ecw_order c
WHERE is_del = 0
AND transport_id = 3
AND rucang_time BETWEEN #{sDate} AND #{eDate}
<include refid="WherePage"/>
) AS curValue3,
(SELECT sum(sum_weight)
FROM ecw_order c
WHERE is_del = 0
AND transport_id = 3
AND rucang_time BETWEEN #{sDuiBiDate} AND #{eDuiBiDate}
<include refid="WherePage"/>
) AS tbValue3,
(SELECT sum(sum_weight)
FROM ecw_order c
WHERE is_del = 0
AND transport_id = 3
AND rucang_time BETWEEN #{sHuanBiDate} AND #{eHuanBiDate}
<include refid="WherePage"/>
) AS hbValue3
FROM DUAL
</select>
<select id="SalesReportCount" resultType="cn.iocoder.yudao.module.delivery.entity.SalesReportResp">
SELECT (
SELECT sum(if(transport_id = 1, sum_volume, sum_weight))
FROM ecw_order c
WHERE is_del = 0
AND (transport_id = 1 OR transport_id = 3)
AND rucang_time BETWEEN #{sDate} AND #{eDate}
<include refid="WherePage"/>
) AS curValue,
(SELECT sum(if(transport_id = 1, sum_volume, sum_weight))
FROM ecw_order c
WHERE is_del = 0
AND (transport_id = 1 OR transport_id = 3)
AND rucang_time BETWEEN #{sDuiBiDate} AND #{eDuiBiDate}
<include refid="WherePage"/>
) AS tbValue,
(SELECT sum(if(transport_id = 1, sum_volume, sum_weight))
FROM ecw_order c
WHERE is_del = 0
AND (transport_id = 1 OR transport_id = 3)
AND rucang_time BETWEEN #{sHuanBiDate} AND #{eHuanBiDate}
<include refid="WherePage"/>
) AS hbValue
FROM DUAL
</select>
<!--海运统计-->
<select id="SalesReportCountSea" resultType="cn.iocoder.yudao.module.delivery.entity.SalesReportResp">
SELECT (
SELECT sum(sum_volume)
FROM ecw_order c
WHERE is_del = 0
AND transport_id = 1
AND rucang_time BETWEEN #{sDate} AND #{eDate}
<include refid="WherePage"/>
) AS curValue,
(SELECT sum(sum_volume)
FROM ecw_order c
WHERE is_del = 0
AND transport_id = 1
AND rucang_time BETWEEN #{sDuiBiDate} AND #{eDuiBiDate}
<include refid="WherePage"/>
) AS tbValue,
(SELECT sum(sum_volume)
FROM ecw_order c
WHERE is_del = 0
AND transport_id = 1
AND rucang_time BETWEEN #{sHuanBiDate} AND #{eHuanBiDate}
<include refid="WherePage"/>
) AS hbValue
FROM DUAL
</select>
<!--空运统计-->
<select id="SalesReportCountAir" resultType="cn.iocoder.yudao.module.delivery.entity.SalesReportResp">
SELECT (
SELECT sum(sum_weight)
FROM ecw_order c
WHERE is_del = 0
AND transport_id = 3
AND rucang_time BETWEEN #{sDate} AND #{eDate}
<include refid="WherePage"/>
) AS curValue,
(SELECT sum(sum_weight)
FROM ecw_order c
WHERE is_del = 0
AND transport_id = 3
AND rucang_time BETWEEN #{sDuiBiDate} AND #{eDuiBiDate}
<include refid="WherePage"/>
) AS tbValue,
(SELECT sum(sum_weight)
FROM ecw_order c
WHERE is_del = 0
AND transport_id = 3
AND rucang_time BETWEEN #{sHuanBiDate} AND #{eHuanBiDate}
<include refid="WherePage"/>
) AS hbValue
FROM DUAL
</select>
<!--2024-04-22-->
<select id="FirstCustomerCount" resultType="int">
SELECT count(c.customer_id) as s_customer_id
from ecw_order a
left join ecw_order_consignee c on a.order_id = c.order_id
left join ecw_customer cc on cc.id = c.customer_id
where cc.is_new = 0
and a.is_del = 0
and a.status > 0
and a.rucang_time BETWEEN #{sDate} AND #{eDate}
and a.drawee = 2
</select>
<select id="CustomerTargetCount" resultType="int">
<!--根据业绩达成日志来统计-->
SELECT COUNT( DISTINCT customer_id) as countTargrt from ecw_target_log
<where>
deleted=0
<if test="sDate!=null and sDate!='' and
eDate!=null and eDate!=''">
and achievement_time BETWEEN #{sDate} and #{eDate}
</if>
<if test="salesmanid!=null and salesmanid!=''">
<!--客户经理查询条件-->
and user_id= #{salesmanid}
</if>
<if test="deptid!=null and deptid!=''">
<!--部门查询条件-->
and user_id= #{salesmanid}
</if>
</where>
</select>
<sql id="WherePage">
<if test="salesmanid!=null and salesmanid!=''">
and c.salesman_id= #{salesmanid}
</if>
<if test="deptid!=null and deptid!=''">
and c.salesman_id in
(SELECT id from system_user where dept_id =#{deptid} )
</if>
</sql>
</mapper>