替换短信发送方案为事件中心方法

This commit is contained in:
feng.li
2023-10-25 16:35:42 +08:00
parent e4fd819abf
commit 59e3fa13fa
10 changed files with 41 additions and 27 deletions

View File

@@ -11,7 +11,9 @@ import com.cool.store.request.event.CreateSingleEventRequest;
import com.cool.store.request.event.SendMsgRequest;
import com.cool.store.response.event.CreateEventResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@@ -76,6 +78,7 @@ public class EventCenterHttpRequest {
* @param receiverIds 接收者 id飞书为 user_id不是 open_id
* @param objects 消息参数,飞书消息卡片为 参数名:参数
*/
@Async
public void sendFeiShuNotice(FeiShuNoticeMsgEnum msgEnum, List<String> receiverIds, Object... objects) throws ApiException {
//1. 组织消息参数SendMsgRequest 的 cardParams需要填入的参数为模板中 ${} 中的参数
HashMap<String, String> cardParams = new HashMap<>();
@@ -114,6 +117,7 @@ public class EventCenterHttpRequest {
* @param smsMsgEnum {@link com.cool.store.enums.SMSMsgEnum}
* @param objects 短信参数,短信的消息参数为 手机号: 参数1, 参数2, 参数3, 参数4, 参数5
*/
@Async
public void sendSmsVariable(String phone, SMSMsgEnum smsMsgEnum, String... objects) throws ApiException {
//1. 组织消息参数,短信的消息参数为 手机号: 参数1, 参数2, 参数3, 参数4, 参数5需要填入的参数为模板中 ${} 中的参数
HashMap<String, String> smsParams = new HashMap<>();

View File

@@ -67,10 +67,10 @@ public interface HyPartnerInterviewPlanService {
/**
* 面试前一天 20:00 提醒
*/
void remindInterviewStartTomorrow();
void remindInterviewStartTomorrow() throws ApiException;
/**
* 面试前 30 分钟提醒
*/
void remindInterviewStartMinutes();
void remindInterviewStartMinutes() throws ApiException;
}

View File

@@ -18,5 +18,5 @@ public interface SmsService {
public SmsSendResponse sendSmsVariable(String phone, SMSMsgEnum smsMsgEnum,String... objects);
public void sendInvateMsg(SendInvateMsgDTO sendInvateMsgDTO);
public void sendInvateMsg(SendInvateMsgDTO sendInvateMsgDTO) throws ApiException;
}

View File

@@ -20,6 +20,7 @@ import com.cool.store.entity.*;
import com.cool.store.enums.*;
import com.cool.store.exception.ApiException;
import com.cool.store.exception.ServiceException;
import com.cool.store.http.EventCenterHttpRequest;
import com.cool.store.http.MDMHttpRequest;
import com.cool.store.mapper.*;
import com.cool.store.oss.OSSServer;
@@ -85,8 +86,10 @@ public class FlowServiceImpl implements FlowService {
@Autowired
private HyPartnerLineInfoService hyPartnerLineInfoService;
// @Autowired
// private SmsService smsService;
@Autowired
private SmsService smsService;
private EventCenterHttpRequest eventCenterHttpRequest;
@Autowired
private HyPartnerBaseInfoDAO hyPartnerBaseInfoDAO;
@@ -246,7 +249,7 @@ public class FlowServiceImpl implements FlowService {
genPassLetterAndUpdateDB(partnerName, verifyCity, new Date(), request.getInterviewId());
//发送加盟商资质面试通过短信
HyPartnerBaseInfoDO hyPartnerBaseInfoDO = hyPartnerBaseInfoDAO.getByPartnerLineId(Long.valueOf(request.getLineId()));
smsService.sendSmsVariable(hyPartnerBaseInfoDO.getMobile(), SMSMsgEnum.INTERVIEW_PASS,wechatMiniAppService.getMiniAppUrl());
eventCenterHttpRequest.sendSmsVariable(hyPartnerBaseInfoDO.getMobile(), SMSMsgEnum.INTERVIEW_PASS,wechatMiniAppService.getMiniAppUrl());
//记录日志
CreateQualifyVerifyDTO log = CreateQualifyVerifyDTO.builder().mobile(operator.getMobile()).operateUserId(operator.getUserId()).operateUsername(operator.getName()).operateTime(DateUtil.format(new Date(), CoolDateUtils.DATE_FORMAT_SEC))
.summary(request.getSummary()).qualiVerifyContent(JSON.toJSONString(partnerCertificationInfoDO)).build();

View File

@@ -87,11 +87,11 @@ public class HyPartnerInterviewPlanServiceImpl implements HyPartnerInterviewPlan
@Value("${feishu.notice.link.url}")
private String linkUrl;
@Autowired
private ISVHttpRequest isvHttpRequest;
// @Autowired
// private ISVHttpRequest isvHttpRequest;
@Autowired
private SmsService smsService;
// @Autowired
// private SmsService smsService;
@Autowired
private WechatMiniAppService wechatMiniAppService;
@@ -363,23 +363,23 @@ public class HyPartnerInterviewPlanServiceImpl implements HyPartnerInterviewPlan
}
@Override
public void remindInterviewStartTomorrow() {
public void remindInterviewStartTomorrow() throws ApiException {
List<HyInterviewRemindDO> tomorrowInterviewInfos = hyPartnerInterviewPlanMapper.getTomorrowInterview();
SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm");
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy年MM月dd日");
Date startTime;
for (HyInterviewRemindDO tomorrowInterviewInfo : tomorrowInterviewInfos) {
startTime = tomorrowInterviewInfo.getStartTime();
smsService.sendSmsVariable(tomorrowInterviewInfo.getMobile(), SMSMsgEnum.INTERVIEW_BEGIN_IN_DAY, timeFormatter.format(startTime), dateFormatter.format(startTime), wechatMiniAppService.getMiniAppUrl());
eventCenterHttpRequest.sendSmsVariable(tomorrowInterviewInfo.getMobile(), SMSMsgEnum.INTERVIEW_BEGIN_IN_DAY, timeFormatter.format(startTime), dateFormatter.format(startTime), wechatMiniAppService.getMiniAppUrl());
}
}
//每半小时执行一次,查询有无面试时间 x 在当前时间 y < x <= y + 30m 内,有就发短信
@Override
public void remindInterviewStartMinutes() {
public void remindInterviewStartMinutes() throws ApiException {
List<HyInterviewRemindDO> minutesInterviewInfos = hyPartnerInterviewPlanMapper.remindInterviewStartMinutes();
for (HyInterviewRemindDO minutesInterviewInfo : minutesInterviewInfos) {
smsService.sendSmsVariable(minutesInterviewInfo.getMobile(), SMSMsgEnum.INTERVIEW_BEGIN_IN_MINUTES, wechatMiniAppService.getMiniAppUrl());
eventCenterHttpRequest.sendSmsVariable(minutesInterviewInfo.getMobile(), SMSMsgEnum.INTERVIEW_BEGIN_IN_MINUTES, wechatMiniAppService.getMiniAppUrl());
}
}

View File

@@ -84,15 +84,16 @@ public class HyPartnerLineInfoServiceImpl implements HyPartnerLineInfoService {
@Resource
HyPartnerUserChannelDAO hyPartnerUserChannelDAO;
@Autowired
private NoticeService noticeService;
// @Autowired
// private NoticeService noticeService;
@Autowired
private EventCenterHttpRequest eventCenterHttpRequest;
@Resource
LabelService labelService;
@Autowired
private SmsService smsService;
// @Autowired
// private SmsService smsService;
@Resource
HyFollowTaskDAO hyFollowTaskDAO;
@Resource
@@ -487,7 +488,7 @@ public class HyPartnerLineInfoServiceImpl implements HyPartnerLineInfoService {
hy.setCertifyFile(JSONObject.toJSONString(closeFollowRequest.getCertifyFile()));
}
hyPartnerBaseInfoDAO.updateByPrimaryKeySelective(hy);
smsService.sendSmsVariable(hy.getMobile(), SMSMsgEnum.INTENTION_APPLY_PASS,DateUtil.formatDateTime(hyPartnerLineInfoDO.getDeadline()),wechatMiniAppService.getMiniAppUrl());
eventCenterHttpRequest.sendSmsVariable(hy.getMobile(), SMSMsgEnum.INTENTION_APPLY_PASS,DateUtil.formatDateTime(hyPartnerLineInfoDO.getDeadline()),wechatMiniAppService.getMiniAppUrl());
}
//拒绝

View File

@@ -84,8 +84,8 @@ public class InterviewServiceImpl implements InterviewService {
@Autowired
private EnterpriseUserService enterpriseUserService;
@Autowired
private SmsService smsService;
// @Autowired
// private SmsService smsService;
@Autowired
private HyInterviewDAO interviewDAO;
@@ -582,7 +582,7 @@ public class InterviewServiceImpl implements InterviewService {
hyPartnerLineDO.setUpdateTime(new Date());
hyPartnerLineInfoMapper.updateByPrimaryKeySelective(hyPartnerLineDO);
//异步发送短信给加盟商
smsService.sendSmsVariable(partnerBaseInfo.getMobile(), SMSMsgEnum.INTERVIEW_APPOINTMENT_PASS,DateUtil.format(DateUtil.parse(interviewVO.getStartTime()), DatePattern.NORM_DATETIME_MINUTE_PATTERN),wechatMiniAppService.getMiniAppUrl());
eventCenterHttpRequest.sendSmsVariable(partnerBaseInfo.getMobile(), SMSMsgEnum.INTERVIEW_APPOINTMENT_PASS,DateUtil.format(DateUtil.parse(interviewVO.getStartTime()), DatePattern.NORM_DATETIME_MINUTE_PATTERN),wechatMiniAppService.getMiniAppUrl());
}
@Override

View File

@@ -14,7 +14,9 @@ import com.cool.store.entity.HyPartnerUserInfoDO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.LineStatusEnum;
import com.cool.store.enums.SMSMsgEnum;
import com.cool.store.exception.ApiException;
import com.cool.store.exception.ServiceException;
import com.cool.store.http.EventCenterHttpRequest;
import com.cool.store.mq.util.HttpRestTemplateService;
import com.cool.store.request.SmsSendRequest;
import com.cool.store.response.SmsSendResponse;
@@ -77,6 +79,9 @@ public class SmsServiceImpl implements SmsService {
@Autowired
private EnterpriseUserDAO enterpriseUserDAO;
@Autowired
private EventCenterHttpRequest eventCenterHttpRequest;
/**
* 发送普通短信
* @param phone 手机号码
@@ -120,7 +125,7 @@ public class SmsServiceImpl implements SmsService {
}
@Override
public void sendInvateMsg(SendInvateMsgDTO sendInvateMsgDTO) {
public void sendInvateMsg(SendInvateMsgDTO sendInvateMsgDTO) throws ApiException {
String mobile = sendInvateMsgDTO.getMobile();
//查询用户基本信息
HyPartnerUserInfoDO hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByMobile(mobile);
@@ -146,6 +151,6 @@ public class SmsServiceImpl implements SmsService {
.append("&inviter=").append(operator.getUserId());
miniAppUrlLinkReqDTO.setQuery(stringBuffer.toString());
sendSmsVariable(mobile, SMSMsgEnum.SMS_INVATE,wechatMiniAppService.getMiniAppUrlLink(miniAppUrlLinkReqDTO));
eventCenterHttpRequest.sendSmsVariable(mobile, SMSMsgEnum.SMS_INVATE,wechatMiniAppService.getMiniAppUrlLink(miniAppUrlLinkReqDTO));
}
}