SalesDao.xml
2.4 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
<?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.w1hd.zzhnc.dao.SalesDao">
<select id="getSalesList" resultType="com.w1hd.zzhnc.vo.Sales_Vo">
select a.*,b.name as projectname from sales a
LEFT JOIN projects b on
a.projectId=b.id
where a.deleted=0
<if test="projectid != null and projectid>0">
and a.projectid=#{projectid}
</if>
<if test="isvanker != null">
and a.isvanker=#{isvanker}
</if>
<if test="keyword !=null and keyword!='' ">
and (a.name like CONCAT(CONCAT('%',#{keyword}),'%')
or
a.phone like CONCAT(CONCAT('%',#{keyword}),'%')
or b.name like
CONCAT(CONCAT('%',#{keyword}),'%'))
</if>
order by a.updatedtime desc
limit #{0},#{1}
</select>
<select id="getSalesCount" resultType="java.lang.Integer">
select count(a.id) from sales a
LEFT JOIN projects b on
a.projectId=b.id
where a.deleted=0
<if test="projectid != null and projectid>0">
and a.projectid=#{projectid}
</if>
<if test="isvanker != null">
and a.isvanker=#{isvanker}
</if>
<if test="keyword !=null and keyword!='' ">
and (a.name like CONCAT(CONCAT('%',#{keyword}),'%')
or
a.phone like CONCAT(CONCAT('%',#{keyword}),'%')
or b.name like
CONCAT(CONCAT('%',#{keyword}),'%'))
</if>
</select>
<select id="getSalesReportList" resultType="com.w1hd.zzhnc.vo.SalesReport_Vo">
select a.id,a.name,e.name as projectname,
IFNULL(b.fanscount,0) as fanscount,
IFNULL(c.callcount,0)as callcount,
IFNULL(d.chatcount,0)as chatcount
from sales a
left join(
select count(id) as fanscount,salesid from fans group by salesId
) as b on a.id=b.salesid
left JOIN(
select count(id) callcount,salesid from calllog GROUP BY salesid
)as c on a.id=c.salesid
left join(
select count(id) chatcount,salesid from chatlog GROUP BY salesid
)as d on a.id=d.salesid
left join projects as e on a.projectId=e.id
where a.deleted=0
<if test="keyword !=null and keyword!='' ">
and (a.name like CONCAT(CONCAT('%',#{keyword}),'%'))
</if>
ORDER BY d.chatcount desc,b.fanscount desc
limit #{0},#{1}
</select>
<select id="getSalesReportCount" resultType="java.lang.Integer">
select count(a.id) from sales a
where a.deleted=0
<if test="keyword !=null and keyword!='' ">
and (a.name like CONCAT(CONCAT('%',#{keyword}),'%'))
</if>
</select>
</mapper>