张延森 5 years ago
parent
commit
bc3cd3a1f9
1 changed files with 10 additions and 9 deletions
  1. 10
    9
      src/main/resources/mapper/TaRecommendCustomerMapper.xml

+ 10
- 9
src/main/resources/mapper/TaRecommendCustomerMapper.xml View File

111
         SELECT
111
         SELECT
112
         a.*,
112
         a.*,
113
         a.customer_id AS customerId,
113
         a.customer_id AS customerId,
114
-        if(b.NAME  = null, d.name, b.name) as consultantName,
115
-        if(b.tel  = null, d.tel, b.tel) AS consultTel,
114
+        IFNULL(d.user_name, b.name) as consultantName,
115
+        IFNULL(d.phone, b.tel) as consultTel,
116
         c.building_name as intentionName
116
         c.building_name as intentionName
117
         FROM
117
         FROM
118
         ta_recommend_customer a
118
         ta_recommend_customer a
119
         LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
119
         LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
120
-        LEFT JOIN ta_person d on a.realty_consultant = d.user_id
120
+        LEFT JOIN ta_user d on a.realty_consultant = d.user_id
121
         LEFT JOIN ta_building c ON a.building_id = c.building_id
121
         LEFT JOIN ta_building c ON a.building_id = c.building_id
122
         <where>
122
         <where>
123
             a.status > 0
123
             a.status > 0
135
                 and a.phone like concat(concat("%",#{tel}),"%")
135
                 and a.phone like concat(concat("%",#{tel}),"%")
136
             </if>
136
             </if>
137
             <if test="consultName != null and consultName !=''">
137
             <if test="consultName != null and consultName !=''">
138
-                and b.name like CONCAT('%',#{consultName}, '%')
138
+                and IFNULL(d.user_name, b.name) like CONCAT('%',#{consultName}, '%')
139
             </if>
139
             </if>
140
             <if test="consultTel != null and consultTel !=''">
140
             <if test="consultTel != null and consultTel !=''">
141
-                and b.tel = #{consultTel}
141
+                and IFNULL(d.phone, b.tel) = #{consultTel}
142
             </if>
142
             </if>
143
             <if test="entryType != null and entryType !=''">
143
             <if test="entryType != null and entryType !=''">
144
                 and a.entry_type = #{entryType}
144
                 and a.entry_type = #{entryType}
377
         a.phone as phone,
377
         a.phone as phone,
378
         c.building_name as intentionName,
378
         c.building_name as intentionName,
379
         if(a.sex = 1, '男',if(a.sex = 2, '女', '未知')) as sex,
379
         if(a.sex = 1, '男',if(a.sex = 2, '女', '未知')) as sex,
380
-        b.NAME AS consultantName,
381
-        b.tel AS consultTel
380
+        IFNULL(d.user_name, b.name) as consultantName,
381
+        IFNULL(d.phone, b.tel) as consultTel
382
         FROM
382
         FROM
383
         ta_recommend_customer a
383
         ta_recommend_customer a
384
         LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
384
         LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
385
+        LEFT JOIN ta_user d on a.realty_consultant = d.user_id
385
         LEFT JOIN ta_building c ON a.building_id = c.building_id
386
         LEFT JOIN ta_building c ON a.building_id = c.building_id
386
         <where>
387
         <where>
387
             a.status > 0
388
             a.status > 0
399
                 and a.phone like concat(concat("%",#{tel}),"%")
400
                 and a.phone like concat(concat("%",#{tel}),"%")
400
             </if>
401
             </if>
401
             <if test="consultName != null and consultName !=''">
402
             <if test="consultName != null and consultName !=''">
402
-                and b.name like CONCAT('%',#{consultName}, '%')
403
+                and IFNULL(d.user_name, b.name) like CONCAT('%',#{consultName}, '%')
403
             </if>
404
             </if>
404
             <if test="consultTel != null and consultTel !=''">
405
             <if test="consultTel != null and consultTel !=''">
405
-                and b.tel = #{consultTel}
406
+                and IFNULL(d.phone, b.tel) = #{consultTel}
406
             </if>
407
             </if>
407
             <if test="entryType != null and entryType !=''">
408
             <if test="entryType != null and entryType !=''">
408
                 and a.entry_type = #{entryType}
409
                 and a.entry_type = #{entryType}