CommonMapper.xml
4.03 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
<?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.runsa.crmapp.common.mapper.CommonMapper">
<select id="selectChannelId" resultType="java.util.HashMap">
select
b.CHL_ID
from crm_account_set_wxgzh a,crm_account_set_channel b
where a.ACT_ID=b.ACT_ID
and b.SCENE=#{SCENE,jdbcType=VARCHAR}
and a.GZH_ID=#{GZH_ID,jdbcType=VARCHAR}
</select>
<select id="selectChannelIdByActId" resultType="java.lang.Integer">
select CHL_ID
from crm_account_set_channel
where ACT_ID=#{ACT_ID} limit 0,1
</select>
<select id="selectProvince" resultType="java.util.HashMap">
select prId as id,prName as name,prSort as sort
from mtProvince
where
coId=#{pid,jdbcType=VARCHAR}
</select>
<select id="selectCity" resultType="java.util.HashMap">
select ciId as id,ciName as name,ciSort as sort
from mtCity
where
prId=#{pid,jdbcType=VARCHAR}
</select>
<select id="selectCityByName" resultType="java.util.HashMap">
select ciId as id,ciName as name,ciSort as sort
from mtCity
where
ciName
like CONCAT('%','#{name,jdbcType=VARCHAR}','%')
</select>
<select id="selectTown" resultType="java.util.HashMap">
select diId as id,diName as name,diSort as sort
from mtDistrict
where
ciId=#{pid,jdbcType=VARCHAR}
</select>
<select id="selectArea" resultType="java.util.HashMap">
select CBD_ID as id,CBD_NAME as name
from crm_district
<where>
<if test="province !=null and province != '' ">
PROVINCE = #{province, jdbcType=INTEGER}
</if>
<if test="province !=null and province != '' ">
CITY = #{city, jdbcType=INTEGER}
</if>
<if test="province !=null and province != '' ">
COUNTY = #{county, jdbcType=INTEGER}
</if>
</where>
</select>
<select id="selectGzhBrand" resultType="java.util.HashMap">
select a.brId,a.brName from mtbrand a
INNER JOIN crm_account_set_brand b
on a.brId=b.BND_ID
INNER JOIN crm_site_group c on b.ACT_ID=c.ACT_ID
INNER JOIN crm_site_group_wxgzh d on
c.GRP_ID=d.GRP_ID
where d.GZH_ID=#{gzhId,jdbcType=VARCHAR}
</select>
<select id="getNearbyStores" resultType="map">
SELECT distinct
a.siId,a.siCode,a.siName,a.ptAddr,a.ptTphone,st_distance(point(IFNULL(a.siNavLat,0),IFNULL(a.siNavLng,0)),point(#{latitude},#{longitude}))*111195
AS distance,a.siNavLat,a.siNavLng
FROM
mtSite a LEFT JOIN vdistrict b on a.diId = b.diId
LEFT JOIN
crm_account_set_site c on
a.siId=c.SIT_ID
WHERE a.siId in
(select SIT_ID from crm_account_set_site where GRP_ID in
(select GRP_ID from crm_site_group_wxgzh where GZH_ID = #{gzhId,jdbcType=VARCHAR}))
<if test="city=null">
AND a.siNavLat is not null
AND a.siNavLng is not null
AND a.siNavLat > #{ringRegion.minLat}
AND a.siNavLat < #{ringRegion.maxLat}
AND a.siNavLng > #{ringRegion.minLng}
AND a.siNavLng < #{ringRegion.maxLng}
</if>
<if test="city!=null">
AND b.`ciId` in
<foreach collection="city" open="(" close=")" separator="," item="it">
#{it}
</foreach>
</if>
<if test="brand!=null">
AND c.`BND_ID` in
<foreach collection="brand" open="(" close=")" separator="," item="it">
#{it}
</foreach>
</if>
<if test="siteName!=null">
AND a.`siName` like CONCAT('%',#{siteName,jdbcType=VARCHAR},'%')
</if>
AND a.`ptValid` = 1
ORDER BY distance ASC
LIMIT
#{start} ,#{size}
</select>
<select id="selectAll" resultType="java.util.HashMap">
select distinct ciId,ciName,prId,prName
from vdistrict
order by convert(prName using gbk) asc
</select>
<select id="nearlySiteAndCity" resultType="map">
SELECT t1.siId,t1.siName,t3.prName,t3.ciName,t3.diName,
st_distance(point(t1.siNavLat,t1.siNavLng),point(#{latitude},#{longitude}))*111195 as distance
FROM `mtsite` t1
LEFT JOIN vdistrict t3 ON t1.diId = t3.diId
WHERE t1.`ptValid` = 1
AND t1.siId in
(select SIT_ID from crm_account_set_site where GRP_ID in
(select GRP_ID from crm_site_group_wxgzh where GZH_ID = #{gzhId,jdbcType=VARCHAR}))
ORDER BY distance ASC LIMIT 0,1
</select>
</mapper>