CompanySmsLogsMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.CompanySmsLogsMapper">
  6. <resultMap type="CompanySmsLogs" id="CompanySmsLogsResult">
  7. <result property="logsId" column="logs_id" />
  8. <result property="companyId" column="company_id" />
  9. <result property="companyUserId" column="company_user_id" />
  10. <result property="customerId" column="customer_id" />
  11. <result property="tempId" column="temp_id" />
  12. <result property="tempCode" column="temp_code" />
  13. <result property="phone" column="phone" />
  14. <result property="content" column="content" />
  15. <result property="createTime" column="create_time" />
  16. <result property="sendTime" column="send_time" />
  17. <result property="status" column="status" />
  18. <result property="mid" column="mid" />
  19. <result property="stat" column="stat" />
  20. <result property="replyContent" column="reply_content" />
  21. <result property="number" column="number" />
  22. <result property="type" column="type" />
  23. <result property="apiId" column="api_id" />
  24. <result property="portId" column="port_id" />
  25. </resultMap>
  26. <sql id="selectCompanySmsLogsVo">
  27. select logs_id, company_id,type, company_user_id, customer_id, temp_id, temp_code, phone, content, create_time, send_time, status,mid,stat,reply_content,number,api_id,port_id from company_sms_logs
  28. </sql>
  29. <select id="selectCompanySmsLogsById" resultMap="CompanySmsLogsResult">
  30. <include refid="selectCompanySmsLogsVo"/>
  31. where logs_id = #{logsId}
  32. </select>
  33. <insert id="insertCompanySmsLogs" useGeneratedKeys="true" keyProperty="logsId">
  34. insert into company_sms_logs
  35. <trim prefix="(" suffix=")" suffixOverrides=",">
  36. <if test="companyId != null">company_id,</if>
  37. <if test="companyUserId != null">company_user_id,</if>
  38. <if test="customerId != null">customer_id,</if>
  39. <if test="tempId != null">temp_id,</if>
  40. <if test="tempCode != null">temp_code,</if>
  41. <if test="phone != null">phone,</if>
  42. <if test="content != null">content,</if>
  43. <if test="createTime != null">create_time,</if>
  44. <if test="sendTime != null">send_time,</if>
  45. <if test="status != null">status,</if>
  46. <if test="mid != null">mid,</if>
  47. <if test="stat != null">stat,</if>
  48. <if test="replyContent != null">reply_content,</if>
  49. <if test="number != null">number,</if>
  50. <if test="type != null">type,</if>
  51. <if test="apiId != null">api_id,</if>
  52. <if test="portId != null">port_id,</if>
  53. </trim>
  54. <trim prefix="values (" suffix=")" suffixOverrides=",">
  55. <if test="companyId != null">#{companyId},</if>
  56. <if test="companyUserId != null">#{companyUserId},</if>
  57. <if test="customerId != null">#{customerId},</if>
  58. <if test="tempId != null">#{tempId},</if>
  59. <if test="tempCode != null">#{tempCode},</if>
  60. <if test="phone != null">#{phone},</if>
  61. <if test="content != null">#{content},</if>
  62. <if test="createTime != null">#{createTime},</if>
  63. <if test="sendTime != null">#{sendTime},</if>
  64. <if test="status != null">#{status},</if>
  65. <if test="mid != null">#{mid},</if>
  66. <if test="stat != null">#{stat},</if>
  67. <if test="replyContent != null">#{replyContent},</if>
  68. <if test="number != null">#{number},</if>
  69. <if test="type != null">#{type},</if>
  70. <if test="apiId != null">#{apiId},</if>
  71. <if test="portId != null">#{portId},</if>
  72. </trim>
  73. </insert>
  74. <update id="updateCompanySmsLogs">
  75. update company_sms_logs
  76. <trim prefix="SET" suffixOverrides=",">
  77. <if test="companyId != null">company_id = #{companyId},</if>
  78. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  79. <if test="customerId != null">customer_id = #{customerId},</if>
  80. <if test="tempId != null">temp_id = #{tempId},</if>
  81. <if test="tempCode != null">temp_code = #{tempCode},</if>
  82. <if test="phone != null">phone = #{phone},</if>
  83. <if test="content != null">content = #{content},</if>
  84. <if test="createTime != null">create_time = #{createTime},</if>
  85. <if test="sendTime != null">send_time = #{sendTime},</if>
  86. <if test="status != null">status = #{status},</if>
  87. <if test="mid != null">mid = #{mid},</if>
  88. <if test="stat != null">stat = #{stat},</if>
  89. <if test="replyContent != null">reply_content = #{replyContent},</if>
  90. <if test="number != null">number = #{number},</if>
  91. <if test="type != null">type = #{type},</if>
  92. <if test="apiId != null">api_id = #{apiId},</if>
  93. <if test="portId != null">port_id = #{portId},</if>
  94. </trim>
  95. where logs_id = #{logsId}
  96. </update>
  97. <delete id="deleteCompanySmsLogsById">
  98. delete from company_sms_logs where logs_id = #{logsId}
  99. </delete>
  100. <delete id="deleteCompanySmsLogsByIds">
  101. delete from company_sms_logs where logs_id in
  102. <foreach item="logsId" collection="array" open="(" separator="," close=")">
  103. #{logsId}
  104. </foreach>
  105. </delete>
  106. <select id="selectSmsLogsCounts" resultType="com.alibaba.fastjson.JSONObject">
  107. SELECT count(t.company_user_id ) AS smsCount,count( IF ( t.status =1,1, NULL ) ) AS successCount, t.type
  108. FROM
  109. (
  110. SELECT DATE_FORMAT( s.create_time, #{sqlDateFormat} ) AS type, s.company_user_id,s.status
  111. FROM
  112. company_sms_logs AS s
  113. WHERE
  114. (DATE_FORMAT(s.create_time,#{sqlDateFormat}) between #{beginTime} and #{finalTime})
  115. AND s.company_user_id IN
  116. <foreach item="item" collection="userIds" open="(" separator="," close=")">
  117. #{item}
  118. </foreach>
  119. ) t
  120. GROUP BY t.type
  121. </select>
  122. </mapper>