|
@@ -246,64 +246,72 @@ FROM
|
246
|
246
|
SELECT
|
247
|
247
|
authorization_count_table.date as date,
|
248
|
248
|
ifnull(authorization_count_table.authorization_count, 0) as authorization_count,
|
249
|
|
- user_count_table.user_count as user_count
|
|
249
|
+ ifnull(user_count_table.user_count, 0) as user_count
|
250
|
250
|
FROM
|
251
|
251
|
(
|
252
|
252
|
SELECT
|
253
|
|
- *
|
|
253
|
+ *
|
254
|
254
|
FROM
|
255
|
255
|
(
|
256
|
|
- SELECT
|
257
|
|
- DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
|
258
|
|
- FROM
|
259
|
|
- sequence a
|
260
|
|
- WHERE
|
|
256
|
+ SELECT
|
|
257
|
+ DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
|
|
258
|
+ FROM
|
|
259
|
+ sequence a
|
|
260
|
+ WHERE
|
|
261
|
+
|
261
|
262
|
<if test="startDate == null or endDate == null">
|
262
|
263
|
a.rownum <![CDATA[ <= ]]> 7
|
263
|
264
|
</if>
|
264
|
265
|
<if test="startDate != null or endDate != null">
|
265
|
266
|
a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
|
266
|
267
|
</if>
|
|
268
|
+
|
267
|
269
|
) AS temp_date
|
268
|
270
|
LEFT JOIN (
|
269
|
271
|
SELECT
|
270
|
|
- COUNT(1) as authorization_count,
|
271
|
|
- tpvr.visit_time AS visit_time
|
|
272
|
+ COUNT(1) as authorization_count,
|
|
273
|
+ tp.create_date AS create_date
|
272
|
274
|
FROM
|
273
|
|
- ta_person tp
|
274
|
|
- INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
|
|
275
|
+ ta_person tp
|
275
|
276
|
where ifnull(tp.person_type, '') != #{personType}
|
276
|
|
- and tp.phone is NOT NULL
|
277
|
|
- ) AS temp ON temp_date.date = DATE_FORMAT( temp.visit_time , '%Y-%m-%d' )
|
|
277
|
+ and tp.phone is NOT NULL
|
|
278
|
+ GROUP BY tp.create_date
|
|
279
|
+ ) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date , '%Y-%m-%d' )
|
|
280
|
+
|
278
|
281
|
) as authorization_count_table
|
279
|
282
|
,
|
280
|
|
- (SELECT
|
281
|
|
- *
|
282
|
|
- FROM
|
283
|
283
|
(
|
|
284
|
+ SELECT
|
|
285
|
+ *
|
|
286
|
+ FROM
|
|
287
|
+ (
|
284
|
288
|
SELECT
|
285
|
|
- DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
|
|
289
|
+ DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
|
286
|
290
|
FROM
|
287
|
|
- sequence a
|
|
291
|
+ sequence a
|
288
|
292
|
WHERE
|
289
|
|
- <if test="startDate == null or endDate == null">
|
290
|
|
- a.rownum <![CDATA[ <= ]]> 7
|
291
|
|
- </if>
|
292
|
|
- <if test="startDate != null or endDate != null">
|
293
|
|
- a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
|
294
|
|
- </if>
|
|
293
|
+
|
|
294
|
+ <if test="startDate == null or endDate == null">
|
|
295
|
+ a.rownum <![CDATA[ <= ]]> 7
|
|
296
|
+ </if>
|
|
297
|
+ <if test="startDate != null or endDate != null">
|
|
298
|
+ a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
|
|
299
|
+ </if>
|
|
300
|
+
|
295
|
301
|
) AS temp_date
|
296
|
302
|
LEFT JOIN (
|
297
|
303
|
SELECT
|
298
|
|
- COUNT(1) as user_count,
|
299
|
|
- tpvr.visit_time AS visit_time
|
|
304
|
+ COUNT(1) as user_count,
|
|
305
|
+ tp.create_date AS create_date
|
300
|
306
|
FROM
|
301
|
|
- ta_person tp
|
302
|
|
- INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
|
|
307
|
+ ta_person tp
|
303
|
308
|
where ifnull(tp.person_type, '') != #{personType}
|
304
|
|
- ) AS temp ON temp_date.date = DATE_FORMAT( temp.visit_time , '%Y-%m-%d' )
|
|
309
|
+ GROUP BY tp.create_date
|
|
310
|
+ ) AS temp ON temp_date.date = DATE_FORMAT( temp.create_date , '%Y-%m-%d' )
|
305
|
311
|
|
306
|
312
|
) as user_count_table
|
|
313
|
+ where
|
|
314
|
+ user_count_table.date = authorization_count_table.date
|
307
|
315
|
GROUP BY date
|
308
|
316
|
</select>
|
309
|
317
|
|
|
@@ -358,29 +366,32 @@ FROM
|
358
|
366
|
</select>
|
359
|
367
|
|
360
|
368
|
<select id="selectUserSourceData" resultType="map">
|
|
369
|
+
|
361
|
370
|
select
|
362
|
371
|
temp_date.date AS date,
|
363
|
372
|
temp_date.from_name as from_name,
|
364
|
373
|
temp_date.from_code as from_code,
|
365
|
374
|
IFNULL(user_count.count, 0) as count,
|
|
375
|
+ IFNULL(registered_count.count,0) as registered,
|
366
|
376
|
user_count.create_date as create_date
|
367
|
377
|
FROM
|
368
|
378
|
(
|
369
|
379
|
SELECT
|
370
|
|
- DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date,
|
371
|
|
- tempf.from_name as from_name,
|
372
|
|
- tempf.from_code as from_code
|
|
380
|
+ DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date,
|
|
381
|
+ tempf.from_name as from_name,
|
|
382
|
+ tempf.from_code as from_code
|
373
|
383
|
FROM
|
374
|
|
- sequence a
|
375
|
|
- ,
|
376
|
|
- td_person_from tempf
|
|
384
|
+ sequence a
|
|
385
|
+ ,
|
|
386
|
+ td_person_from tempf
|
377
|
387
|
WHERE
|
378
|
|
- <if test="startDate == null or endDate == null">
|
379
|
|
- a.rownum <![CDATA[ <= ]]> 7
|
380
|
|
- </if>
|
381
|
|
- <if test="startDate != null or endDate != null">
|
382
|
|
- a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
|
383
|
|
- </if>
|
|
388
|
+
|
|
389
|
+ <if test="startDate == null or endDate == null">
|
|
390
|
+ a.rownum <![CDATA[ <= ]]> 7
|
|
391
|
+ </if>
|
|
392
|
+ <if test="startDate != null or endDate != null">
|
|
393
|
+ a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
|
|
394
|
+ </if>
|
384
|
395
|
|
385
|
396
|
) AS temp_date
|
386
|
397
|
|
|
@@ -395,13 +406,28 @@ FROM
|
395
|
406
|
LEFT JOIN td_person_from tpfs
|
396
|
407
|
ON tps.from_code = tpfs.from_code
|
397
|
408
|
WHERE tpfs.from_code = tps.from_code
|
398
|
|
- and ifnull(tps.person_type, '') != #{personType}
|
399
|
|
- <if test="registeredType == 'registered' and registeredType != ''">
|
400
|
|
- and tps.phone is not null
|
401
|
|
- </if>
|
|
409
|
+ and ifnull(tps.person_type, '') != 'Realty Consultant'
|
|
410
|
+
|
402
|
411
|
GROUP BY tpfs.from_code
|
403
|
412
|
) as user_count
|
404
|
413
|
ON DATE_FORMAT(user_count.create_date,'%Y-%m-%d') = temp_date.date and temp_date.from_code = user_count.from_code
|
|
414
|
+ LEFT JOIN
|
|
415
|
+ (
|
|
416
|
+ SELECT
|
|
417
|
+ ifnull(COUNT(1), 0) as count,
|
|
418
|
+ tps.create_date as create_date,
|
|
419
|
+ tpfs.from_code as from_code,
|
|
420
|
+ tpfs.from_name as from_name
|
|
421
|
+ FROM ta_person tps
|
|
422
|
+ LEFT JOIN td_person_from tpfs
|
|
423
|
+ ON tps.from_code = tpfs.from_code
|
|
424
|
+ WHERE tpfs.from_code = tps.from_code
|
|
425
|
+ and ifnull(tps.person_type, '') != 'Realty Consultant'
|
|
426
|
+ and tps.phone is not null
|
|
427
|
+ GROUP BY tpfs.from_code
|
|
428
|
+ ) as registered_count
|
|
429
|
+ ON DATE_FORMAT(user_count.create_date,'%Y-%m-%d') = temp_date.date and temp_date.from_code = registered_count.from_code
|
|
430
|
+ order by temp_date.date DESC
|
405
|
431
|
</select>
|
406
|
432
|
|
407
|
433
|
</mapper>
|