Kaynağa Gözat

短信发送成功数量统计接口新增查询参数;

codingliang 2 yıl önce
ebeveyn
işleme
b82cd5915a

+ 3 - 2
src/main/java/com/sqx/modules/errand/controller/TbIndentSmsController.java

@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
 import com.sqx.common.exception.SqxException;
 import com.sqx.common.utils.PageUtils;
 import com.sqx.common.utils.Result;
+import com.sqx.modules.errand.dto.SmsCountQueryDTO;
 import com.sqx.modules.errand.dto.SmsLogQueryDTO;
 import com.sqx.modules.errand.dto.SmsTemplateDTO;
 import com.sqx.modules.errand.dto.SmsTemplateQueryDTO;
@@ -72,8 +73,8 @@ public class TbIndentSmsController {
 
     @ApiOperation("短信发送成功数量统计")
     @GetMapping(value = "count-of-send-success")
-    public Result countOfSendSuccess() {
-        int count = smsSendLogService.countOfSendSuccess();
+    public Result countOfSendSuccess(SmsCountQueryDTO queryDTO) {
+        int count = smsSendLogService.countOfSendSuccess(queryDTO);
         return Result.success().put("data", count);
     }
 

+ 3 - 0
src/main/java/com/sqx/modules/errand/dao/TbIndentSmsSendLogDao.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.sqx.modules.errand.IndentSmsSendLogVO;
+import com.sqx.modules.errand.dto.SmsCountQueryDTO;
 import com.sqx.modules.errand.dto.SmsLogQueryDTO;
 import com.sqx.modules.errand.entity.TbIndentSmsSendLog;
 import org.apache.ibatis.annotations.Mapper;
@@ -13,4 +14,6 @@ import org.apache.ibatis.annotations.Param;
 public interface TbIndentSmsSendLogDao extends BaseMapper<TbIndentSmsSendLog>  {
 
     IPage<IndentSmsSendLogVO> logPage(@Param("pages") Page<TbIndentSmsSendLog> pages, @Param("query") SmsLogQueryDTO query);
+
+    int countOfSendSuccess(@Param("query") SmsCountQueryDTO queryDTO);
 }

+ 27 - 0
src/main/java/com/sqx/modules/errand/dto/SmsCountQueryDTO.java

@@ -0,0 +1,27 @@
+package com.sqx.modules.errand.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 短信统计查询dto
+ */
+@Data
+@ApiModel("SmsCountQueryDTO")
+public class SmsCountQueryDTO {
+
+    @ApiModelProperty("发送人电话")
+    private String fromTo;
+
+    @ApiModelProperty("查询开始时间")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private Date startTime;
+
+    @ApiModelProperty("查询结束时间")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private Date endTime;
+}

+ 3 - 1
src/main/java/com/sqx/modules/errand/service/TbIndentSmsSendLogService.java

@@ -3,6 +3,7 @@ package com.sqx.modules.errand.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.sqx.common.sms.SmsSendResult;
 import com.sqx.common.utils.PageUtils;
+import com.sqx.modules.errand.dto.SmsCountQueryDTO;
 import com.sqx.modules.errand.dto.SmsLogQueryDTO;
 import com.sqx.modules.errand.entity.TbIndentSmsSendLog;
 
@@ -19,7 +20,8 @@ public interface TbIndentSmsSendLogService extends IService<TbIndentSmsSendLog>
 
     /**
      * 统计发送成功的短信条数
+     * @param queryDTO 查询参数
      * @return count
      */
-    int countOfSendSuccess();
+    int countOfSendSuccess(SmsCountQueryDTO queryDTO);
 }

+ 3 - 6
src/main/java/com/sqx/modules/errand/service/impl/TbIndentSmsSendLogServiceImpl.java

@@ -1,14 +1,13 @@
 package com.sqx.modules.errand.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.sqx.common.sms.SmsSendResult;
-import com.sqx.common.utils.Constant;
 import com.sqx.common.utils.PageUtils;
 import com.sqx.modules.errand.IndentSmsSendLogVO;
 import com.sqx.modules.errand.dao.TbIndentSmsSendLogDao;
+import com.sqx.modules.errand.dto.SmsCountQueryDTO;
 import com.sqx.modules.errand.dto.SmsLogQueryDTO;
 import com.sqx.modules.errand.entity.TbIndentSmsSendLog;
 import com.sqx.modules.errand.service.TbIndentSmsSendLogService;
@@ -43,9 +42,7 @@ public class TbIndentSmsSendLogServiceImpl extends ServiceImpl<TbIndentSmsSendLo
     }
 
     @Override
-    public int countOfSendSuccess() {
-        LambdaQueryWrapper<TbIndentSmsSendLog> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(TbIndentSmsSendLog::getSuccessFlag, Constant.YES);
-        return this.count(queryWrapper);
+    public int countOfSendSuccess(SmsCountQueryDTO queryDTO) {
+        return baseMapper.countOfSendSuccess(queryDTO);
     }
 }

+ 21 - 2
src/main/resources/mapper/errand/TbIndentSmsSendLogMapper.xml

@@ -21,12 +21,31 @@
                 and issl.send_to = #{query.sendTo}
             </if>
             <if test="query.startTime != null">
-                and issl.send_time >= #{query.orderId}
+                and issl.send_time >= #{query.startTime}
             </if>
             <if test="query.endTime != null">
-                and issl.send_time <![CDATA[<=]]> #{query.orderId}
+                and issl.send_time <![CDATA[<=]]> #{query.endTime}
             </if>
         </where>
         order by issl.send_time desc
     </select>
+
+    <select id="countOfSendSuccess" resultType="java.lang.Integer">
+        select
+               count(1)
+        from
+            tb_indent_sms_send_log issl
+        left join tb_user u on u.user_id = issl.send_from_id
+        where
+            issl.success_flag = '1'
+            <if test="query.fromTo != null and query.fromTo != ''">
+                and u.phone = #{query.fromTo}
+            </if>
+            <if test="query.startTime != null">
+                and issl.send_time >= #{query.startTime}
+            </if>
+            <if test="query.endTime != null">
+                and issl.send_time <![CDATA[<=]]> #{query.endTime}
+            </if>
+    </select>
 </mapper>