CompanyVoiceLogsMapper.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.company.mapper.CompanyVoiceLogsMapper">
  6. <resultMap type="CompanyVoiceLogs" id="CompanyVoiceLogsResult">
  7. <result property="voiceId" column="voice_id" />
  8. <result property="companyId" column="company_id" />
  9. <result property="companyName" column="company_name" />
  10. <result property="voiceTitle" column="voice_title" />
  11. <result property="voiceUrl" column="voice_url" />
  12. <result property="startTime" column="start_time" />
  13. <result property="finishTime" column="finish_time" />
  14. <result property="voiceType" column="voice_type" />
  15. <result property="remark" column="remark" />
  16. <result property="callerPhone" column="caller_phone" />
  17. <result property="calleePhone" column="callee_phone" />
  18. <result property="times" column="times" />
  19. <result property="displayCallerNumber" column="display_caller_number" />
  20. <result property="displayCalleeNumber" column="display_callee_number" />
  21. <result property="sessionId" column="session_id" />
  22. <result property="companyUserId" column="company_user_id" />
  23. <result property="status" column="status" />
  24. <result property="customerId" column="customer_id" />
  25. <result property="billingTime" column="billing_time" />
  26. <result property="apiId" column="api_id" />
  27. <result property="callerNo" column="caller_no" />
  28. </resultMap>
  29. <sql id="selectCompanyVoiceLogsVo">
  30. select l.*,c.company_name from company_voice_logs l left join company c on c.company_id = l.company_id
  31. </sql>
  32. <select id="selectCompanyVoiceLogsList" parameterType="CompanyVoiceLogs" resultMap="CompanyVoiceLogsResult">
  33. <include refid="selectCompanyVoiceLogsVo"/>
  34. <where>
  35. <if test="companyId != null "> and l.company_id = #{companyId}</if>
  36. <if test="voiceTitle != null and voiceTitle != ''"> and voice_title = #{voiceTitle}</if>
  37. <if test="voiceUrl != null and voiceUrl != ''"> and voice_url = #{voiceUrl}</if>
  38. <if test="startTime != null "> and start_time = #{startTime}</if>
  39. <if test="finishTime != null "> and finish_time = #{finishTime}</if>
  40. <if test="voiceType != null "> and voice_type = #{voiceType}</if>
  41. <if test="callerPhone != null and callerPhone != ''"> and caller_phone = #{callerPhone}</if>
  42. <if test="calleePhone != null and calleePhone != ''"> and callee_phone = #{calleePhone}</if>
  43. <if test="times != null "> and times = #{times}</if>
  44. <if test="displayCallerNumber != null and displayCallerNumber != ''"> and display_caller_number = #{displayCallerNumber}</if>
  45. <if test="displayCalleeNumber != null and displayCalleeNumber != ''"> and display_callee_number = #{displayCalleeNumber}</if>
  46. <if test="sessionId != null "> and session_id = #{sessionId}</if>
  47. <if test="customerId != null "> and customer_id = #{customerId}</if>
  48. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  49. </where>
  50. order by voice_id desc
  51. </select>
  52. <select id="selectCompanyVoiceLogsById" parameterType="Long" resultMap="CompanyVoiceLogsResult">
  53. <include refid="selectCompanyVoiceLogsVo"/>
  54. where voice_id = #{voiceId}
  55. </select>
  56. <insert id="insertCompanyVoiceLogs" parameterType="CompanyVoiceLogs" useGeneratedKeys="true" keyProperty="voiceId">
  57. insert into company_voice_logs
  58. <trim prefix="(" suffix=")" suffixOverrides=",">
  59. <if test="companyId != null">company_id,</if>
  60. <if test="voiceTitle != null">voice_title,</if>
  61. <if test="voiceUrl != null">voice_url,</if>
  62. <if test="startTime != null">start_time,</if>
  63. <if test="finishTime != null">finish_time,</if>
  64. <if test="voiceType != null">voice_type,</if>
  65. <if test="remark != null">remark,</if>
  66. <if test="callerPhone != null">caller_phone,</if>
  67. <if test="calleePhone != null">callee_phone,</if>
  68. <if test="times != null">times,</if>
  69. <if test="displayCallerNumber != null">display_caller_number,</if>
  70. <if test="displayCalleeNumber != null">display_callee_number,</if>
  71. <if test="sessionId != null">session_id,</if>
  72. <if test="companyUserId != null">company_user_id,</if>
  73. <if test="status != null">status,</if>
  74. <if test="customerId != null">customer_id,</if>
  75. <if test="billingTime != null">billing_time,</if>
  76. <if test="apiId != null">api_id,</if>
  77. <if test="callerNo != null">caller_no,</if>
  78. </trim>
  79. <trim prefix="values (" suffix=")" suffixOverrides=",">
  80. <if test="companyId != null">#{companyId},</if>
  81. <if test="voiceTitle != null">#{voiceTitle},</if>
  82. <if test="voiceUrl != null">#{voiceUrl},</if>
  83. <if test="startTime != null">#{startTime},</if>
  84. <if test="finishTime != null">#{finishTime},</if>
  85. <if test="voiceType != null">#{voiceType},</if>
  86. <if test="remark != null">#{remark},</if>
  87. <if test="callerPhone != null">#{callerPhone},</if>
  88. <if test="calleePhone != null">#{calleePhone},</if>
  89. <if test="times != null">#{times},</if>
  90. <if test="displayCallerNumber != null">#{displayCallerNumber},</if>
  91. <if test="displayCalleeNumber != null">#{displayCalleeNumber},</if>
  92. <if test="sessionId != null">#{sessionId},</if>
  93. <if test="companyUserId != null">#{companyUserId},</if>
  94. <if test="status != null">#{status},</if>
  95. <if test="customerId != null">#{customerId},</if>
  96. <if test="billingTime != null">#{billingTime},</if>
  97. <if test="apiId != null">#{apiId},</if>
  98. <if test="callerNo != null">#{callerNo},</if>
  99. </trim>
  100. </insert>
  101. <update id="updateCompanyVoiceLogs" parameterType="CompanyVoiceLogs">
  102. update company_voice_logs
  103. <trim prefix="SET" suffixOverrides=",">
  104. <if test="companyId != null">company_id = #{companyId},</if>
  105. <if test="voiceTitle != null">voice_title = #{voiceTitle},</if>
  106. <if test="voiceUrl != null">voice_url = #{voiceUrl},</if>
  107. <if test="startTime != null">start_time = #{startTime},</if>
  108. <if test="finishTime != null">finish_time = #{finishTime},</if>
  109. <if test="voiceType != null">voice_type = #{voiceType},</if>
  110. <if test="remark != null">remark = #{remark},</if>
  111. <if test="callerPhone != null">caller_phone = #{callerPhone},</if>
  112. <if test="calleePhone != null">callee_phone = #{calleePhone},</if>
  113. <if test="times != null">times = #{times},</if>
  114. <if test="displayCallerNumber != null">display_caller_number = #{displayCallerNumber},</if>
  115. <if test="displayCalleeNumber != null">display_callee_number = #{displayCalleeNumber},</if>
  116. <if test="sessionId != null">session_id = #{sessionId},</if>
  117. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  118. <if test="status != null">status = #{status},</if>
  119. <if test="customerId != null">customer_id = #{customerId},</if>
  120. <if test="billingTime != null">billing_time = #{billingTime},</if>
  121. <if test="apiId != null">api_id = #{apiId},</if>
  122. <if test="callerNo != null">caller_no = #{callerNo},</if>
  123. </trim>
  124. where voice_id = #{voiceId}
  125. </update>
  126. <delete id="deleteCompanyVoiceLogsById" parameterType="Long">
  127. delete from company_voice_logs where voice_id = #{voiceId}
  128. </delete>
  129. <delete id="deleteCompanyVoiceLogsByIds" parameterType="String">
  130. delete from company_voice_logs where voice_id in
  131. <foreach item="voiceId" collection="array" open="(" separator="," close=")">
  132. #{voiceId}
  133. </foreach>
  134. </delete>
  135. <select id="selectVoiceLogsTotalCount" resultType="com.alibaba.fastjson.JSONObject">
  136. SELECT count(t.company_user_id ) AS callCount,count( IF ( t.times > 0,1, NULL ) ) AS callSuccessCount, t.type, sum(IFNULL(t.times,0)) as times,sum(IFNULL(t.billing_time,0)) as billingTime
  137. FROM
  138. (
  139. SELECT DATE_FORMAT( l.start_time, #{sqlDateFormat} ) AS type, l.company_user_id,l.times,l.billing_time
  140. FROM
  141. company_voice_logs AS l
  142. WHERE
  143. (DATE_FORMAT(l.start_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
  144. AND l.company_user_id IN
  145. <foreach item="item" collection="userIds" open="(" separator="," close=")">
  146. #{item}
  147. </foreach>
  148. ) t
  149. GROUP BY t.type
  150. </select>
  151. </mapper>