|  | @@ -605,4 +605,239 @@
 | 
	
		
			
				|  |  |          </foreach>
 | 
	
		
			
				|  |  |      </update>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    <select id="countUserSummary" resultType="FsUserSummaryCountVO">
 | 
	
		
			
				|  |  | +        SELECT (SELECT count(fs_user.user_id)
 | 
	
		
			
				|  |  | +                FROM fs_user
 | 
	
		
			
				|  |  | +                         LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
 | 
	
		
			
				|  |  | +                WHERE (
 | 
	
		
			
				|  |  | +                          company_user.user_id = #{userId}
 | 
	
		
			
				|  |  | +                              OR company_user.parent_id = #{userId}
 | 
	
		
			
				|  |  | +                          )) as userTotal,
 | 
	
		
			
				|  |  | +               (SELECT count(fs_user.user_id)
 | 
	
		
			
				|  |  | +                FROM fs_user
 | 
	
		
			
				|  |  | +                         LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
 | 
	
		
			
				|  |  | +                WHERE (company_user.user_id = #{userId} OR company_user.parent_id = #{userId})
 | 
	
		
			
				|  |  | +                  AND to_days(fs_user.create_time) = to_days(now())) as todayNewUser
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <select id="countTag" resultType="FsUserSummaryCountTagVO">
 | 
	
		
			
				|  |  | +        SELECT
 | 
	
		
			
				|  |  | +            company_tag.tag AS tagName,
 | 
	
		
			
				|  |  | +            count( fs_user.user_id ) AS userCount
 | 
	
		
			
				|  |  | +        FROM
 | 
	
		
			
				|  |  | +            company_tag_user
 | 
	
		
			
				|  |  | +                LEFT JOIN fs_user ON fs_user.user_id = company_tag_user.user_id
 | 
	
		
			
				|  |  | +                LEFT JOIN company_tag ON FIND_IN_SET( company_tag.tag_id, company_tag_user.tag_ids ) > 0
 | 
	
		
			
				|  |  | +                LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
 | 
	
		
			
				|  |  | +        where (company_user.user_id = #{userId} or company_user.parent_id = #{userId} ) and company_tag.tag_id is not null
 | 
	
		
			
				|  |  | +        GROUP BY
 | 
	
		
			
				|  |  | +            company_tag.tag_id
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <select id="countUserCourse" resultType="Map">
 | 
	
		
			
				|  |  | +        SELECT
 | 
	
		
			
				|  |  | +            (
 | 
	
		
			
				|  |  | +                SELECT
 | 
	
		
			
				|  |  | +                    count( fcc.user_id )
 | 
	
		
			
				|  |  | +                FROM
 | 
	
		
			
				|  |  | +                    fs_user_course_count fcc
 | 
	
		
			
				|  |  | +                        LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
 | 
	
		
			
				|  |  | +                        LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
 | 
	
		
			
				|  |  | +                        LEFT JOIN fs_user_course_video fcv ON fcv.course_id = fcc.course_id
 | 
	
		
			
				|  |  | +        WHERE
 | 
	
		
			
				|  |  | +                    ( company_user.user_id = #{userId}  OR company_user.parent_id = #{userId}  )
 | 
	
		
			
				|  |  | +                    <if test="startTime != null and startTime !='' ">
 | 
	
		
			
				|  |  | +                            and fcc.create_time >= #{startTime}
 | 
	
		
			
				|  |  | +                    </if>
 | 
	
		
			
				|  |  | +                    <if test="endTime != null and endTime != ''">
 | 
	
		
			
				|  |  | +                        and fcc.create_time <= #{endTime}
 | 
	
		
			
				|  |  | +                    </if>
 | 
	
		
			
				|  |  | +                    <if test="courseId != null and courseId != ''">
 | 
	
		
			
				|  |  | +                        AND fcc.course_id = #{courseId}
 | 
	
		
			
				|  |  | +                    </if>
 | 
	
		
			
				|  |  | +                    <if test="videoId != null and videoId != ''">
 | 
	
		
			
				|  |  | +                        AND fcv.video_id = #{videoId}
 | 
	
		
			
				|  |  | +                    </if>
 | 
	
		
			
				|  |  | +            ) as courseWatchNum,
 | 
	
		
			
				|  |  | +            (
 | 
	
		
			
				|  |  | +                SELECT
 | 
	
		
			
				|  |  | +                    count( fcc.user_id )
 | 
	
		
			
				|  |  | +                FROM
 | 
	
		
			
				|  |  | +                    fs_user_course_count fcc
 | 
	
		
			
				|  |  | +                        LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
 | 
	
		
			
				|  |  | +                        LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
 | 
	
		
			
				|  |  | +                        LEFT JOIN fs_user_course_video fcv ON fcv.course_id = fcc.course_id
 | 
	
		
			
				|  |  | +                WHERE
 | 
	
		
			
				|  |  | +                    ( company_user.user_id = #{userId}  OR company_user.parent_id = #{userId}  )
 | 
	
		
			
				|  |  | +                  AND fcc.complete_watch_count > 0
 | 
	
		
			
				|  |  | +                    <if test="startTime != null and startTime !='' ">
 | 
	
		
			
				|  |  | +                        and fcc.create_time >= #{startTime}
 | 
	
		
			
				|  |  | +                    </if>
 | 
	
		
			
				|  |  | +                    <if test="endTime != null and endTime != ''">
 | 
	
		
			
				|  |  | +                        and fcc.create_time <= #{endTime}
 | 
	
		
			
				|  |  | +                    </if>
 | 
	
		
			
				|  |  | +                    <if test="courseId != null and courseId != ''">
 | 
	
		
			
				|  |  | +                        AND fcc.course_id =  #{courseId}
 | 
	
		
			
				|  |  | +                    </if>
 | 
	
		
			
				|  |  | +                    <if test="videoId != null and videoId != ''">
 | 
	
		
			
				|  |  | +                        AND fcv.video_id = #{videoId}
 | 
	
		
			
				|  |  | +                    </if>
 | 
	
		
			
				|  |  | +            ) as courseCompleteNum
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <select id="countUserAnswer" resultType="Map">
 | 
	
		
			
				|  |  | +        SELECT
 | 
	
		
			
				|  |  | +        (
 | 
	
		
			
				|  |  | +        SELECT
 | 
	
		
			
				|  |  | +        count( fs_user.user_id )
 | 
	
		
			
				|  |  | +        FROM
 | 
	
		
			
				|  |  | +        fs_course_answer_logs
 | 
	
		
			
				|  |  | +        LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
 | 
	
		
			
				|  |  | +        LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
 | 
	
		
			
				|  |  | +        WHERE
 | 
	
		
			
				|  |  | +        ( company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
 | 
	
		
			
				|  |  | +        <if test="startTime != null and startTime !='' ">
 | 
	
		
			
				|  |  | +            AND fs_course_answer_logs.create_time >= #{startTime}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +        <if test="endTime != null and endTime != ''">
 | 
	
		
			
				|  |  | +            AND fs_course_answer_logs.create_time <= #{endTime}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +        <if test="courseId != null and courseId != ''">
 | 
	
		
			
				|  |  | +            AND fs_course_answer_logs.course_id = #{courseId}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +        <if test="videoId != null and videoId != ''">
 | 
	
		
			
				|  |  | +            AND fs_course_answer_logs.video_id = #{videoId}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +        ) AS answerNum,
 | 
	
		
			
				|  |  | +        (
 | 
	
		
			
				|  |  | +        SELECT
 | 
	
		
			
				|  |  | +        count( fs_user.user_id )
 | 
	
		
			
				|  |  | +        FROM
 | 
	
		
			
				|  |  | +        fs_course_answer_logs
 | 
	
		
			
				|  |  | +        LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
 | 
	
		
			
				|  |  | +        LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
 | 
	
		
			
				|  |  | +        WHERE
 | 
	
		
			
				|  |  | +        ( company_user.user_id = #{userId} OR company_user.parent_id = #{userId} )
 | 
	
		
			
				|  |  | +        AND fs_course_answer_logs.is_right = 1
 | 
	
		
			
				|  |  | +        <if test="startTime != null and startTime !='' ">
 | 
	
		
			
				|  |  | +            AND fs_course_answer_logs.create_time >= #{startTime}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +        <if test="endTime != null and endTime != ''">
 | 
	
		
			
				|  |  | +            AND fs_course_answer_logs.create_time <= #{endTime}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +        <if test="courseId != null and courseId != ''">
 | 
	
		
			
				|  |  | +            AND fs_course_answer_logs.course_id =  #{courseId}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +        <if test="videoId != null and videoId != ''">
 | 
	
		
			
				|  |  | +            AND fs_course_answer_logs.video_id = #{videoId}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +        ) AS answerRightNum
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <select id="countUserRedPacket" resultType="Map">
 | 
	
		
			
				|  |  | +    SELECT
 | 
	
		
			
				|  |  | +        (
 | 
	
		
			
				|  |  | +            SELECT
 | 
	
		
			
				|  |  | +                count( flog.log_id )
 | 
	
		
			
				|  |  | +            FROM
 | 
	
		
			
				|  |  | +                fs_course_red_packet_log flog
 | 
	
		
			
				|  |  | +                    LEFT JOIN fs_user ON fs_user.user_id = flog.user_id
 | 
	
		
			
				|  |  | +                    LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
 | 
	
		
			
				|  |  | +            WHERE
 | 
	
		
			
				|  |  | +                ( company_user.user_id = #{userId}  OR company_user.parent_id = #{userId}  )
 | 
	
		
			
				|  |  | +                <if test="startTime != null and startTime !='' ">
 | 
	
		
			
				|  |  | +                    AND flog.create_time >= #{startTime}
 | 
	
		
			
				|  |  | +                </if>
 | 
	
		
			
				|  |  | +                <if test="endTime != null and endTime != ''">
 | 
	
		
			
				|  |  | +                    AND flog.create_time <= #{endTime}
 | 
	
		
			
				|  |  | +                </if>
 | 
	
		
			
				|  |  | +                <if test="courseId != null and courseId != ''">
 | 
	
		
			
				|  |  | +                    AND flog.course_id =  #{courseId}
 | 
	
		
			
				|  |  | +                </if>
 | 
	
		
			
				|  |  | +                <if test="videoId != null and videoId != ''">
 | 
	
		
			
				|  |  | +                    AND flog.video_id = #{videoId}
 | 
	
		
			
				|  |  | +                </if>
 | 
	
		
			
				|  |  | +        ) AS redPacketNum,
 | 
	
		
			
				|  |  | +        (
 | 
	
		
			
				|  |  | +            SELECT
 | 
	
		
			
				|  |  | +                ifnull (sum( flog.amount ), 0)
 | 
	
		
			
				|  |  | +            FROM
 | 
	
		
			
				|  |  | +                fs_course_red_packet_log flog
 | 
	
		
			
				|  |  | +                    LEFT JOIN fs_user ON fs_user.user_id = flog.user_id
 | 
	
		
			
				|  |  | +                    LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
 | 
	
		
			
				|  |  | +            WHERE
 | 
	
		
			
				|  |  | +                ( company_user.user_id = #{userId}  OR company_user.parent_id = #{userId}  )
 | 
	
		
			
				|  |  | +                <if test="startTime != null and startTime !='' ">
 | 
	
		
			
				|  |  | +                    AND flog.create_time >= #{startTime}
 | 
	
		
			
				|  |  | +                </if>
 | 
	
		
			
				|  |  | +                <if test="endTime != null and endTime != ''">
 | 
	
		
			
				|  |  | +                    AND flog.create_time <= #{endTime}
 | 
	
		
			
				|  |  | +                </if>
 | 
	
		
			
				|  |  | +                <if test="courseId != null and courseId != ''">
 | 
	
		
			
				|  |  | +                    AND flog.course_id =  #{courseId}
 | 
	
		
			
				|  |  | +                </if>
 | 
	
		
			
				|  |  | +                <if test="videoId != null and videoId != ''">
 | 
	
		
			
				|  |  | +                    AND flog.video_id = #{videoId}
 | 
	
		
			
				|  |  | +                </if>
 | 
	
		
			
				|  |  | +        ) AS redPacketAmount
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <select id="countCourseDetails" resultType="Map">
 | 
	
		
			
				|  |  | +    select (SELECT count(fc.course_id)
 | 
	
		
			
				|  |  | +            FROM fs_user_course fc
 | 
	
		
			
				|  |  | +            WHERE fc.is_del = 0
 | 
	
		
			
				|  |  | +            <if test="courseId != null and courseId != ''">
 | 
	
		
			
				|  |  | +                AND fc.course_id =  #{courseId}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            ) as courseNum,
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +           (SELECT count(fcv.video_id)
 | 
	
		
			
				|  |  | +            FROM fs_user_course_video fcv
 | 
	
		
			
				|  |  | +                     LEFT JOIN fs_user_course fc ON fc.course_id = fcv.course_id
 | 
	
		
			
				|  |  | +            <if test="courseId != null and courseId != ''">
 | 
	
		
			
				|  |  | +                AND fcv.course_id =  #{courseId}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test="videoId != null and videoId != ''">
 | 
	
		
			
				|  |  | +                AND fcv.video_id = #{videoId}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            ) as videoNum,
 | 
	
		
			
				|  |  | +        ( SELECT count( user_id ) FROM fs_user_course_count fcc
 | 
	
		
			
				|  |  | +            LEFT JOIN fs_user_course_video fcv ON fcv.course_id = fcc.course_id
 | 
	
		
			
				|  |  | +        <if test="courseId != null and courseId != ''">
 | 
	
		
			
				|  |  | +            AND fcc.course_id =  #{courseId}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +        <if test="videoId != null and videoId != ''">
 | 
	
		
			
				|  |  | +            AND fcv.video_id = #{videoId}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +         ) as courseUserNum
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <select id="countUserRanking" resultType="Map">
 | 
	
		
			
				|  |  | +     SELECT
 | 
	
		
			
				|  |  | +                 (
 | 
	
		
			
				|  |  | +                     SELECT
 | 
	
		
			
				|  |  | +                         count( fcc.user_id )
 | 
	
		
			
				|  |  | +                     FROM
 | 
	
		
			
				|  |  | +                         fs_user_course_count fcc
 | 
	
		
			
				|  |  | +                             LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
 | 
	
		
			
				|  |  | +                             LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
 | 
	
		
			
				|  |  | +                             LEFT JOIN fs_user_course_video fcv ON fcv.course_id = fcc.course_id
 | 
	
		
			
				|  |  | +                     WHERE
 | 
	
		
			
				|  |  | +                         ( company_user.parent_id = 8563  )
 | 
	
		
			
				|  |  | +                       AND fcc.complete_watch_count > 0
 | 
	
		
			
				|  |  | +                     group by fcc.user_id  )
 | 
	
		
			
				|  |  | +                     /
 | 
	
		
			
				|  |  | +                 (SELECT
 | 
	
		
			
				|  |  | +                      count( fcc.user_id )
 | 
	
		
			
				|  |  | +                  FROM
 | 
	
		
			
				|  |  | +                      fs_user_course_count fcc
 | 
	
		
			
				|  |  | +                          LEFT JOIN fs_user ON fs_user.user_id = fcc.user_id
 | 
	
		
			
				|  |  | +                          LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
 | 
	
		
			
				|  |  | +                          LEFT JOIN fs_user_course_video fcv ON fcv.course_id = fcc.course_id
 | 
	
		
			
				|  |  | +                  WHERE
 | 
	
		
			
				|  |  | +                      ( company_user.parent_id = 8563  )
 | 
	
		
			
				|  |  | +                  group by fcc.user_id
 | 
	
		
			
				|  |  | +                 ) as
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  </mapper>
 |