|
@@ -257,7 +257,16 @@ FROM
|
257
|
257
|
FROM
|
258
|
258
|
ta_person tp
|
259
|
259
|
LEFT JOIN
|
260
|
|
- ( SELECT *, MAX(visit_time) as max_visit_time FROM ta_person_visit_record GROUP BY person_id ) as tpvr
|
|
260
|
+ ( SELECT *, MAX(visit_time) as max_visit_time FROM ta_person_visit_record where org_id = #{org}
|
|
261
|
+
|
|
262
|
+ <if test="startDate != null">
|
|
263
|
+ and visit_time <![CDATA[ > ]]> #{startDate}
|
|
264
|
+ </if>
|
|
265
|
+ <if test="endDate == null">
|
|
266
|
+ and visit_time <![CDATA[ < ]]> #{endDate}
|
|
267
|
+ </if>
|
|
268
|
+
|
|
269
|
+ GROUP BY person_id ) as tpvr
|
261
|
270
|
ON tp.person_id = tpvr.person_id
|
262
|
271
|
where tp.org_id = #{org} AND tp.person_type IN ('customer','drift','estate agent')
|
263
|
272
|
GROUP BY DATE_FORMAT( tpvr.max_visit_time , '%Y-%m-%d' )
|