|
@@ -0,0 +1,74 @@
|
|
|
|
|
+<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
|
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
+<mapper namespace="com.fs.company.mapper.ManualOutboundCallDashboardMapper">
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectCallStatisticsByUser" parameterType="com.fs.company.param.ManualOutboundCallDashboardParam"
|
|
|
|
|
+ resultType="com.fs.company.dto.ManualOutboundCallDashboardDTO">
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ ccl.company_user_id AS companyUserId,
|
|
|
|
|
+ cu.nick_name AS companyUserName,
|
|
|
|
|
+ COUNT(*) AS totalCalls,
|
|
|
|
|
+ SUM(CASE WHEN ccl.status = 2 AND ccl.call_time > 0 THEN 1 ELSE 0 END) AS connectedCalls,
|
|
|
|
|
+ SUM(CASE WHEN ccl.status = 2 AND ccl.call_time > 0 THEN ccl.call_time ELSE 0 END) AS totalDuration
|
|
|
|
|
+ FROM crm_customer_call_log ccl
|
|
|
|
|
+ LEFT JOIN company_user cu ON cu.user_id = ccl.company_user_id
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="companyId != null">
|
|
|
|
|
+ AND ccl.company_id = #{companyId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
|
+ AND DATE_FORMAT(ccl.create_time, '%Y-%m-%d') >= #{startTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
|
+ AND DATE_FORMAT(ccl.create_time, '%Y-%m-%d') <= #{endTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ GROUP BY ccl.company_user_id, cu.nick_name
|
|
|
|
|
+ ORDER BY totalCalls DESC
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectVisitStatusStatistics" parameterType="com.fs.company.param.ManualOutboundCallDashboardParam"
|
|
|
|
|
+ resultType="com.fs.company.dto.VisitStatusStatisticsDTO">
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ cc.visit_status AS visitStatus,
|
|
|
|
|
+ COUNT(DISTINCT cc.customer_id) AS customerCount
|
|
|
|
|
+ FROM crm_customer_call_log ccl
|
|
|
|
|
+ INNER JOIN crm_customer cc ON cc.customer_id = ccl.customer_id
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="companyId != null">
|
|
|
|
|
+ AND ccl.company_id = #{companyId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
|
+ AND DATE_FORMAT(ccl.create_time, '%Y-%m-%d') >= #{startTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
|
+ AND DATE_FORMAT(ccl.create_time, '%Y-%m-%d') <= #{endTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ GROUP BY cc.visit_status
|
|
|
|
|
+ ORDER BY cc.visit_status ASC
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectDailyCallTrend" parameterType="com.fs.company.param.ManualOutboundCallDashboardParam"
|
|
|
|
|
+ resultType="com.fs.company.dto.DailyCallTrendDTO">
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ DATE_FORMAT(ccl.create_time, '%Y-%m-%d') AS callDate,
|
|
|
|
|
+ COUNT(*) AS totalCalls,
|
|
|
|
|
+ SUM(CASE WHEN ccl.status = 2 AND ccl.call_time > 0 THEN 1 ELSE 0 END) AS connectedCalls
|
|
|
|
|
+ FROM crm_customer_call_log ccl
|
|
|
|
|
+ <where>
|
|
|
|
|
+ <if test="companyId != null">
|
|
|
|
|
+ AND ccl.company_id = #{companyId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
|
|
+ AND DATE_FORMAT(ccl.create_time, '%Y-%m-%d') >= #{startTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
|
|
+ AND DATE_FORMAT(ccl.create_time, '%Y-%m-%d') <= #{endTime}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ GROUP BY DATE_FORMAT(ccl.create_time, '%Y-%m-%d')
|
|
|
|
|
+ ORDER BY callDate ASC
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+</mapper>
|