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

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

View File

@@ -67,10 +67,10 @@ public interface HyPartnerInterviewPlanService {
/** /**
* 面试前一天 20:00 提醒 * 面试前一天 20:00 提醒
*/ */
void remindInterviewStartTomorrow(); void remindInterviewStartTomorrow() throws ApiException;
/** /**
* 面试前 30 分钟提醒 * 面试前 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 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.enums.*;
import com.cool.store.exception.ApiException; import com.cool.store.exception.ApiException;
import com.cool.store.exception.ServiceException; import com.cool.store.exception.ServiceException;
import com.cool.store.http.EventCenterHttpRequest;
import com.cool.store.http.MDMHttpRequest; import com.cool.store.http.MDMHttpRequest;
import com.cool.store.mapper.*; import com.cool.store.mapper.*;
import com.cool.store.oss.OSSServer; import com.cool.store.oss.OSSServer;
@@ -85,8 +86,10 @@ public class FlowServiceImpl implements FlowService {
@Autowired @Autowired
private HyPartnerLineInfoService hyPartnerLineInfoService; private HyPartnerLineInfoService hyPartnerLineInfoService;
// @Autowired
// private SmsService smsService;
@Autowired @Autowired
private SmsService smsService; private EventCenterHttpRequest eventCenterHttpRequest;
@Autowired @Autowired
private HyPartnerBaseInfoDAO hyPartnerBaseInfoDAO; private HyPartnerBaseInfoDAO hyPartnerBaseInfoDAO;
@@ -246,7 +249,7 @@ public class FlowServiceImpl implements FlowService {
genPassLetterAndUpdateDB(partnerName, verifyCity, new Date(), request.getInterviewId()); genPassLetterAndUpdateDB(partnerName, verifyCity, new Date(), request.getInterviewId());
//发送加盟商资质面试通过短信 //发送加盟商资质面试通过短信
HyPartnerBaseInfoDO hyPartnerBaseInfoDO = hyPartnerBaseInfoDAO.getByPartnerLineId(Long.valueOf(request.getLineId())); 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)) 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(); .summary(request.getSummary()).qualiVerifyContent(JSON.toJSONString(partnerCertificationInfoDO)).build();

View File

@@ -87,11 +87,11 @@ public class HyPartnerInterviewPlanServiceImpl implements HyPartnerInterviewPlan
@Value("${feishu.notice.link.url}") @Value("${feishu.notice.link.url}")
private String linkUrl; private String linkUrl;
@Autowired // @Autowired
private ISVHttpRequest isvHttpRequest; // private ISVHttpRequest isvHttpRequest;
@Autowired // @Autowired
private SmsService smsService; // private SmsService smsService;
@Autowired @Autowired
private WechatMiniAppService wechatMiniAppService; private WechatMiniAppService wechatMiniAppService;
@@ -363,23 +363,23 @@ public class HyPartnerInterviewPlanServiceImpl implements HyPartnerInterviewPlan
} }
@Override @Override
public void remindInterviewStartTomorrow() { public void remindInterviewStartTomorrow() throws ApiException {
List<HyInterviewRemindDO> tomorrowInterviewInfos = hyPartnerInterviewPlanMapper.getTomorrowInterview(); List<HyInterviewRemindDO> tomorrowInterviewInfos = hyPartnerInterviewPlanMapper.getTomorrowInterview();
SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm"); SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm");
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy年MM月dd日"); SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy年MM月dd日");
Date startTime; Date startTime;
for (HyInterviewRemindDO tomorrowInterviewInfo : tomorrowInterviewInfos) { for (HyInterviewRemindDO tomorrowInterviewInfo : tomorrowInterviewInfos) {
startTime = tomorrowInterviewInfo.getStartTime(); 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 内,有就发短信 //每半小时执行一次,查询有无面试时间 x 在当前时间 y < x <= y + 30m 内,有就发短信
@Override @Override
public void remindInterviewStartMinutes() { public void remindInterviewStartMinutes() throws ApiException {
List<HyInterviewRemindDO> minutesInterviewInfos = hyPartnerInterviewPlanMapper.remindInterviewStartMinutes(); List<HyInterviewRemindDO> minutesInterviewInfos = hyPartnerInterviewPlanMapper.remindInterviewStartMinutes();
for (HyInterviewRemindDO minutesInterviewInfo : minutesInterviewInfos) { 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 @Resource
HyPartnerUserChannelDAO hyPartnerUserChannelDAO; HyPartnerUserChannelDAO hyPartnerUserChannelDAO;
@Autowired // @Autowired
private NoticeService noticeService; // private NoticeService noticeService;
@Autowired @Autowired
private EventCenterHttpRequest eventCenterHttpRequest; private EventCenterHttpRequest eventCenterHttpRequest;
@Resource @Resource
LabelService labelService; LabelService labelService;
@Autowired // @Autowired
private SmsService smsService; // private SmsService smsService;
@Resource @Resource
HyFollowTaskDAO hyFollowTaskDAO; HyFollowTaskDAO hyFollowTaskDAO;
@Resource @Resource
@@ -487,7 +488,7 @@ public class HyPartnerLineInfoServiceImpl implements HyPartnerLineInfoService {
hy.setCertifyFile(JSONObject.toJSONString(closeFollowRequest.getCertifyFile())); hy.setCertifyFile(JSONObject.toJSONString(closeFollowRequest.getCertifyFile()));
} }
hyPartnerBaseInfoDAO.updateByPrimaryKeySelective(hy); 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 @Autowired
private EnterpriseUserService enterpriseUserService; private EnterpriseUserService enterpriseUserService;
@Autowired // @Autowired
private SmsService smsService; // private SmsService smsService;
@Autowired @Autowired
private HyInterviewDAO interviewDAO; private HyInterviewDAO interviewDAO;
@@ -582,7 +582,7 @@ public class InterviewServiceImpl implements InterviewService {
hyPartnerLineDO.setUpdateTime(new Date()); hyPartnerLineDO.setUpdateTime(new Date());
hyPartnerLineInfoMapper.updateByPrimaryKeySelective(hyPartnerLineDO); 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 @Override

View File

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

View File

@@ -1,6 +1,7 @@
package com.cool.store.controller; package com.cool.store.controller;
import com.cool.store.dto.sms.SendInvateMsgDTO; import com.cool.store.dto.sms.SendInvateMsgDTO;
import com.cool.store.exception.ApiException;
import com.cool.store.response.ResponseResult; import com.cool.store.response.ResponseResult;
import com.cool.store.service.SmsService; import com.cool.store.service.SmsService;
import com.cool.store.vo.role.RolePageVO; import com.cool.store.vo.role.RolePageVO;
@@ -27,7 +28,7 @@ public class SmsController {
@PostMapping("/invate") @PostMapping("/invate")
@ApiOperation("招商邀请短信") @ApiOperation("招商邀请短信")
public ResponseResult sendInvateMsg(@RequestBody SendInvateMsgDTO sendInvateMsgDTO){ public ResponseResult sendInvateMsg(@RequestBody SendInvateMsgDTO sendInvateMsgDTO) throws ApiException {
smsService.sendInvateMsg(sendInvateMsgDTO); smsService.sendInvateMsg(sendInvateMsgDTO);
return ResponseResult.success(); return ResponseResult.success();
} }

View File

@@ -73,15 +73,15 @@ public class EventRequestTest extends AbstractJUnit4SpringContextTests {
//4. 面试开始前一天 //4. 面试开始前一天
randomStr = RandomUtil.randomString(12); randomStr = RandomUtil.randomString(12);
testWXUrl = "https://wxaurl.cn/" + randomStr; testWXUrl = "https://wxaurl.cn/" + randomStr;
eventCenterHttpRequest.sendSmsVariable(testPhone, SMSMsgEnum.INTERVIEW_PASS, "10", testDate, testWXUrl); eventCenterHttpRequest.sendSmsVariable(testPhone, SMSMsgEnum.INTERVIEW_BEGIN_IN_DAY, "10", testDate, testWXUrl);
//5. 面试开始前30分钟 //5. 面试开始前30分钟
randomStr = RandomUtil.randomString(12); randomStr = RandomUtil.randomString(12);
testWXUrl = "https://wxaurl.cn/" + randomStr; testWXUrl = "https://wxaurl.cn/" + randomStr;
eventCenterHttpRequest.sendSmsVariable(testPhone, SMSMsgEnum.INTERVIEW_PASS, testWXUrl); eventCenterHttpRequest.sendSmsVariable(testPhone, SMSMsgEnum.INTERVIEW_BEGIN_IN_MINUTES, testWXUrl);
//6. 短信邀约 //6. 短信邀约
randomStr = RandomUtil.randomString(12); randomStr = RandomUtil.randomString(12);
testWXUrl = "https://wxaurl.cn/" + randomStr; testWXUrl = "https://wxaurl.cn/" + randomStr;
eventCenterHttpRequest.sendSmsVariable(testPhone, SMSMsgEnum.INTERVIEW_PASS, testWXUrl); eventCenterHttpRequest.sendSmsVariable(testPhone, SMSMsgEnum.SMS_INVATE, testWXUrl);
} }
} }