替换短信发送方案为事件中心方法
This commit is contained in:
@@ -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<>();
|
||||
|
||||
@@ -67,10 +67,10 @@ public interface HyPartnerInterviewPlanService {
|
||||
/**
|
||||
* 面试前一天 20:00 提醒
|
||||
*/
|
||||
void remindInterviewStartTomorrow();
|
||||
void remindInterviewStartTomorrow() throws ApiException;
|
||||
|
||||
/**
|
||||
* 面试前 30 分钟提醒
|
||||
*/
|
||||
void remindInterviewStartMinutes();
|
||||
void remindInterviewStartMinutes() throws ApiException;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
//拒绝
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.controller;
|
||||
|
||||
import com.cool.store.dto.sms.SendInvateMsgDTO;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.SmsService;
|
||||
import com.cool.store.vo.role.RolePageVO;
|
||||
@@ -27,7 +28,7 @@ public class SmsController {
|
||||
|
||||
@PostMapping("/invate")
|
||||
@ApiOperation("招商邀请短信")
|
||||
public ResponseResult sendInvateMsg(@RequestBody SendInvateMsgDTO sendInvateMsgDTO){
|
||||
public ResponseResult sendInvateMsg(@RequestBody SendInvateMsgDTO sendInvateMsgDTO) throws ApiException {
|
||||
smsService.sendInvateMsg(sendInvateMsgDTO);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
@@ -73,15 +73,15 @@ public class EventRequestTest extends AbstractJUnit4SpringContextTests {
|
||||
//4. 面试开始前一天
|
||||
randomStr = RandomUtil.randomString(12);
|
||||
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分钟
|
||||
randomStr = RandomUtil.randomString(12);
|
||||
testWXUrl = "https://wxaurl.cn/" + randomStr;
|
||||
eventCenterHttpRequest.sendSmsVariable(testPhone, SMSMsgEnum.INTERVIEW_PASS, testWXUrl);
|
||||
eventCenterHttpRequest.sendSmsVariable(testPhone, SMSMsgEnum.INTERVIEW_BEGIN_IN_MINUTES, testWXUrl);
|
||||
//6. 短信邀约
|
||||
randomStr = RandomUtil.randomString(12);
|
||||
testWXUrl = "https://wxaurl.cn/" + randomStr;
|
||||
eventCenterHttpRequest.sendSmsVariable(testPhone, SMSMsgEnum.INTERVIEW_PASS, testWXUrl);
|
||||
eventCenterHttpRequest.sendSmsVariable(testPhone, SMSMsgEnum.SMS_INVATE, testWXUrl);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user