소스 검색

用户来源 data数据列表 增加registered字段值

魏熙美 5 년 전
부모
커밋
1c8a375c64
1개의 변경된 파일33개의 추가작업 그리고 16개의 파일을 삭제
  1. 33
    16
      src/main/resources/mapper/TaPersonMapper.xml

+ 33
- 16
src/main/resources/mapper/TaPersonMapper.xml 파일 보기

@@ -366,29 +366,32 @@ FROM
366 366
     </select>
367 367
 
368 368
     <select id="selectUserSourceData" resultType="map">
369
+
369 370
         select
370 371
             temp_date.date AS date,
371 372
             temp_date.from_name as from_name,
372 373
             temp_date.from_code as from_code,
373 374
             IFNULL(user_count.count, 0) as count,
375
+            IFNULL(registered_count.count,0) as registered,
374 376
             user_count.create_date as create_date
375 377
         FROM
376 378
         (
377 379
             SELECT
378
-                DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date,
379
-                tempf.from_name as from_name,
380
-                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
381 383
             FROM
382
-                sequence a
383
-                ,
384
-                td_person_from tempf
384
+            sequence a
385
+            ,
386
+            td_person_from tempf
385 387
             WHERE
386
-            <if test="startDate == null or endDate == null">
387
-                a.rownum <![CDATA[ <= ]]> 7
388
-            </if>
389
-            <if test="startDate != null or endDate != null">
390
-                a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
391
-            </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>
392 395
 
393 396
         ) AS temp_date
394 397
 
@@ -403,13 +406,27 @@ FROM
403 406
             LEFT JOIN td_person_from tpfs
404 407
             ON tps.from_code = tpfs.from_code
405 408
             WHERE tpfs.from_code = tps.from_code
406
-            and ifnull(tps.person_type, '') != #{personType}
407
-            <if test="registeredType == 'registered' and registeredType != ''">
408
-                and tps.phone is not null
409
-            </if>
409
+            and ifnull(tps.person_type, '') != 'Realty Consultant'
410
+
410 411
             GROUP BY tpfs.from_code
411 412
         ) as user_count
412 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
413 430
         order by temp_date.date DESC
414 431
     </select>
415 432