From 086adfdf1d5340a3503da5b5ebcae9073775450e Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期一, 30 十二月 2024 13:59:40 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master-v4' into master-v4

---
 src/main/resources/mapper/sms/SmsTaskDetailMapper.xml |   44 +++++++++++++++++++++++++++-----------------
 1 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/src/main/resources/mapper/sms/SmsTaskDetailMapper.xml b/src/main/resources/mapper/sms/SmsTaskDetailMapper.xml
index f946e3b..ef476ae 100644
--- a/src/main/resources/mapper/sms/SmsTaskDetailMapper.xml
+++ b/src/main/resources/mapper/sms/SmsTaskDetailMapper.xml
@@ -2,30 +2,40 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.mzl.flower.mapper.SmsTaskDetailMapper">
 
-    <select id="queryPage" resultType="com.mzl.flower.dto.response.sms.SmsTaskDetailVO">
+    <select id="queryPage" resultType="com.mzl.flower.dto.response.sms.SmsPhoneResultVO">
         select t.* from t_sms_task_detail t
         where t.deleted= 0
-        <if test="dto.id!=null ">
-            and t.id = #{dto.id}
+        <if test="dto.smsTaskId!=null ">
+            and t.sms_task_id = #{dto.smsTaskId}
         </if>
-        <if test="dto.result != null and dto.result != ''">
-            and t.result like concat('%', #{dto.result}, '%')
-        </if>
-        <if test="dto.phone != null and dto.phone != ''">
+        <if test="dto.phone!=null ">
             and t.phone like concat('%', #{dto.phone}, '%')
         </if>
-
-        <if test="dto.startDate!=null ">
-            <![CDATA[
-               AND t.create_time >= #{dto.startDate}
-            ]]>
+        <if test="dto.result!=null ">
+            and t.result = #{dto.result}
         </if>
-        <if test="dto.endDate!=null ">
-            <![CDATA[
-               AND t.create_time <= #{dto.endDate}
-            ]]>
+    </select>
+    <select id="getCountBySmsTaskId" resultType = "com.mzl.flower.dto.response.sms.SmsTaskDetailVO">
+        SELECT
+        t.id,
+        t.name as smsTaskName,
+        st.name as smsTemplateName,
+        COUNT(CASE WHEN std.result = 'success' THEN 1 END) AS successNum,
+        COUNT(CASE WHEN std.result = 'failure' THEN 1 END) AS failureNum,
+        COUNT(CASE WHEN std.result is null THEN 1 END) AS sendingNum,
+        COUNT(std.id) AS totalNum,
+        t.num as phoneNum
+        FROM
+            t_sms_task t
+                LEFT JOIN t_sms_template st ON t.sms_template_id = st.id
+                LEFT JOIN t_sms_task_detail std ON t.id = std.sms_task_id
+        WHERE
+            t.deleted = '0'
+        <if test="id!=null ">
+            and t.id = #{id}
         </if>
-
+        GROUP BY
+        t.id, t.name; -- 根据你需要的字段进行分组
     </select>
 
 </mapper>

--
Gitblit v1.9.3