短信回执接口开发完成

pull/11/head
3y 3 years ago
parent 832c476b29
commit f16864096d

@ -21,4 +21,19 @@ public enum SmsStatus {
private String description;
/**
*
* @param code
* @return
*/
public static String getDescriptionByStatus(Integer code) {
for (SmsStatus value : SmsStatus.values()) {
if (value.getCode().equals(code)) {
return value.getDescription();
}
}
return "";
}
}

@ -78,8 +78,8 @@ public class TencentSmsReceipt {
.chargingNum(0)
.status("SUCCESS".equals(pullSmsSendStatus.getReportStatus()) ? SmsStatus.RECEIVE_SUCCESS.getCode() : SmsStatus.RECEIVE_FAIL.getCode())
.reportContent(pullSmsSendStatus.getDescription())
.created(Math.toIntExact(pullSmsSendStatus.getUserReceiveTime()))
.updated(Math.toIntExact(DateUtil.currentSeconds()))
.updated(Math.toIntExact(pullSmsSendStatus.getUserReceiveTime()))
.created(Math.toIntExact(DateUtil.currentSeconds()))
.build();
smsRecordList.add(smsRecord);
}

@ -4,12 +4,21 @@ package com.java3y.austin.support.dao;
import com.java3y.austin.support.domain.SmsRecord;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
/**
* Dao
* @author 3y
*
* @author 3y
*/
public interface SmsRecordDao extends CrudRepository<SmsRecord, Long> {
/**
*
*
* @param phone
* @param sendDate
* @return
*/
List<SmsRecord> findByPhoneAndSendDate(Long phone, Integer sendDate);
}

@ -1,12 +1,12 @@
package com.java3y.austin.web.controller;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.java3y.austin.common.enums.RespStatusEnum;
import com.java3y.austin.common.vo.BasicResultVO;
import com.java3y.austin.web.service.DataService;
import com.java3y.austin.web.vo.DataParam;
import com.java3y.austin.web.vo.amis.EchartsVo;
import com.java3y.austin.web.vo.amis.SmsTimeLineVo;
import com.java3y.austin.web.vo.amis.UserTimeLineVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -49,8 +49,13 @@ public class DataController {
@PostMapping("/sms")
@ApiOperation("/获取短信下发数据")
public BasicResultVO getSmsData(@RequestBody DataParam dataParam) {
EchartsVo echartsVo = EchartsVo.builder().build();
return null;
if (dataParam == null || dataParam.getDateTime() == null || dataParam.getReceiver() == null) {
return new BasicResultVO<>(RespStatusEnum.SUCCESS, new SmsTimeLineVo());
}
SmsTimeLineVo smsTimeLineVo = dataService.getTraceSmsInfo(dataParam);
return new BasicResultVO<>(RespStatusEnum.SUCCESS, smsTimeLineVo);
}
}

@ -1,6 +1,8 @@
package com.java3y.austin.web.service;
import com.java3y.austin.web.vo.DataParam;
import com.java3y.austin.web.vo.amis.EchartsVo;
import com.java3y.austin.web.vo.amis.SmsTimeLineVo;
import com.java3y.austin.web.vo.amis.UserTimeLineVo;
/**
@ -28,4 +30,12 @@ public interface DataService {
EchartsVo getTraceMessageTemplateInfo(String businessId);
/**
*
*
* @param dataParam
* @return
*/
SmsTimeLineVo getTraceSmsInfo(DataParam dataParam);
}

@ -11,13 +11,18 @@ import com.java3y.austin.common.constant.AustinConstant;
import com.java3y.austin.common.domain.SimpleAnchorInfo;
import com.java3y.austin.common.enums.AnchorState;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.common.enums.SmsStatus;
import com.java3y.austin.support.dao.MessageTemplateDao;
import com.java3y.austin.support.dao.SmsRecordDao;
import com.java3y.austin.support.domain.MessageTemplate;
import com.java3y.austin.support.domain.SmsRecord;
import com.java3y.austin.support.utils.RedisUtils;
import com.java3y.austin.support.utils.TaskInfoUtils;
import com.java3y.austin.web.constants.AmisVoConstant;
import com.java3y.austin.web.service.DataService;
import com.java3y.austin.web.vo.DataParam;
import com.java3y.austin.web.vo.amis.EchartsVo;
import com.java3y.austin.web.vo.amis.SmsTimeLineVo;
import com.java3y.austin.web.vo.amis.UserTimeLineVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -39,6 +44,10 @@ public class DataServiceImpl implements DataService {
@Autowired
private MessageTemplateDao messageTemplateDao;
@Autowired
private SmsRecordDao smsRecordDao;
@Override
public UserTimeLineVo getTraceUserInfo(String receiver) {
List<String> userInfoList = redisUtils.lRange(receiver, 0, -1);
@ -134,6 +143,44 @@ public class DataServiceImpl implements DataService {
}
@Override
public SmsTimeLineVo getTraceSmsInfo(DataParam dataParam) {
ArrayList<SmsTimeLineVo.ItemsVO> itemsVOS = new ArrayList<>();
SmsTimeLineVo smsTimeLineVo = SmsTimeLineVo.builder().items(itemsVOS).build();
Integer sendDate = Integer.valueOf(DateUtil.format(new Date(dataParam.getDateTime() * 1000L)
, DatePattern.PURE_DATE_PATTERN));
List<SmsRecord> smsRecordList = smsRecordDao.findByPhoneAndSendDate(Long.valueOf(dataParam.getReceiver()), sendDate);
if (CollUtil.isEmpty(smsRecordList)) {
return smsTimeLineVo;
}
Map<String, List<SmsRecord>> maps = smsRecordList.stream().collect(Collectors.groupingBy((o) -> o.getPhone() + o.getSeriesId()));
for (Map.Entry<String, List<SmsRecord>> entry : maps.entrySet()) {
SmsTimeLineVo.ItemsVO itemsVO = SmsTimeLineVo.ItemsVO.builder().build();
for (SmsRecord smsRecord : entry.getValue()) {
// 发送记录 messageTemplateId >0 ,回执记录 messageTemplateId =0
if (smsRecord.getMessageTemplateId() > 0) {
itemsVO.setBusinessId(String.valueOf(smsRecord.getMessageTemplateId()));
itemsVO.setContent(smsRecord.getMsgContent());
itemsVO.setSendType(SmsStatus.getDescriptionByStatus(smsRecord.getStatus()));
itemsVO.setSendTime(DateUtil.format(new Date(Long.valueOf(smsRecord.getCreated()*1000L)), DatePattern.NORM_DATETIME_PATTERN));
} else {
itemsVO.setReceiveType(SmsStatus.getDescriptionByStatus(smsRecord.getStatus()));
itemsVO.setReceiveContent(smsRecord.getReportContent());
itemsVO.setReceiveTime(DateUtil.format(new Date(Long.valueOf(smsRecord.getUpdated()*1000L)), DatePattern.NORM_DATETIME_PATTERN));
}
}
itemsVOS.add(itemsVO);
}
return smsTimeLineVo;
}
/**
* IDbusinessId
* businessIdbusinessId
@ -150,4 +197,14 @@ public class DataServiceImpl implements DataService {
}
return businessId;
}
public static void main(String[] args) {
Long time = 1653140847 * 1000L;
String format = DateUtil.format(new Date(time), DatePattern.NORM_DATETIME_PATTERN);
System.out.println(format
);
}
}

@ -34,7 +34,8 @@ public class DataParam {
/**
* (使)
*/
private String dateTime;
private Long dateTime;

@ -0,0 +1,67 @@
package com.java3y.austin.web.vo.amis;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author 3y
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SmsTimeLineVo {
/**
* items
*/
private List<SmsTimeLineVo.ItemsVO> items;
/**
* ItemsVO
*/
@Data
@Builder
public static class ItemsVO {
/**
* ID
*/
private String businessId;
/**
* detail
*/
private String content;
/**
*
*/
private String sendType;
/**
*
*/
private String receiveType;
/**
*
*/
private String receiveContent;
/**
*
*/
private String sendTime;
/**
*
*/
private String receiveTime;
}
}
Loading…
Cancel
Save