From 59e3fa13fa6a97f0d9023ea914ddaf97a8e99598 Mon Sep 17 00:00:00 2001 From: "feng.li" Date: Wed, 25 Oct 2023 16:35:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E7=9F=AD=E4=BF=A1=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=96=B9=E6=A1=88=E4=B8=BA=E4=BA=8B=E4=BB=B6=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cool/store/http/EventCenterHttpRequest.java | 4 ++++ .../service/HyPartnerInterviewPlanService.java | 4 ++-- .../java/com/cool/store/service/SmsService.java | 2 +- .../cool/store/service/impl/FlowServiceImpl.java | 7 +++++-- .../impl/HyPartnerInterviewPlanServiceImpl.java | 16 ++++++++-------- .../impl/HyPartnerLineInfoServiceImpl.java | 11 ++++++----- .../store/service/impl/InterviewServiceImpl.java | 6 +++--- .../cool/store/service/impl/SmsServiceImpl.java | 9 +++++++-- .../com/cool/store/controller/SmsController.java | 3 ++- .../com/cool/store/service/EventRequestTest.java | 6 +++--- 10 files changed, 41 insertions(+), 27 deletions(-) diff --git a/coolstore-partner-service/src/main/java/com/cool/store/http/EventCenterHttpRequest.java b/coolstore-partner-service/src/main/java/com/cool/store/http/EventCenterHttpRequest.java index 0dbb8c2b8..90b356cc5 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/http/EventCenterHttpRequest.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/http/EventCenterHttpRequest.java @@ -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 receiverIds, Object... objects) throws ApiException { //1. 组织消息参数,SendMsgRequest 的 cardParams,需要填入的参数为模板中 ${} 中的参数 HashMap 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 smsParams = new HashMap<>(); diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/HyPartnerInterviewPlanService.java b/coolstore-partner-service/src/main/java/com/cool/store/service/HyPartnerInterviewPlanService.java index 4dfd37215..5f05fd50a 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/HyPartnerInterviewPlanService.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/HyPartnerInterviewPlanService.java @@ -67,10 +67,10 @@ public interface HyPartnerInterviewPlanService { /** * 面试前一天 20:00 提醒 */ - void remindInterviewStartTomorrow(); + void remindInterviewStartTomorrow() throws ApiException; /** * 面试前 30 分钟提醒 */ - void remindInterviewStartMinutes(); + void remindInterviewStartMinutes() throws ApiException; } diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/SmsService.java b/coolstore-partner-service/src/main/java/com/cool/store/service/SmsService.java index e830e3637..ee3da8298 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/SmsService.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/SmsService.java @@ -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; } diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/FlowServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/FlowServiceImpl.java index 7d160cd34..314dde535 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/FlowServiceImpl.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/FlowServiceImpl.java @@ -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(); diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/HyPartnerInterviewPlanServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/HyPartnerInterviewPlanServiceImpl.java index 888e89f84..4cd5bc119 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/HyPartnerInterviewPlanServiceImpl.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/HyPartnerInterviewPlanServiceImpl.java @@ -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 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 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()); } } diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/HyPartnerLineInfoServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/HyPartnerLineInfoServiceImpl.java index a894efdf3..fc2781e21 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/HyPartnerLineInfoServiceImpl.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/HyPartnerLineInfoServiceImpl.java @@ -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()); } //拒绝 diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/InterviewServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/InterviewServiceImpl.java index f35ea8687..27c1e4a93 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/InterviewServiceImpl.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/InterviewServiceImpl.java @@ -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 diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/SmsServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/SmsServiceImpl.java index efb1d49ef..1c4905f4c 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/SmsServiceImpl.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/SmsServiceImpl.java @@ -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)); } } diff --git a/coolstore-partner-webb/src/main/java/com/cool/store/controller/SmsController.java b/coolstore-partner-webb/src/main/java/com/cool/store/controller/SmsController.java index e7631a087..27a92ed06 100644 --- a/coolstore-partner-webb/src/main/java/com/cool/store/controller/SmsController.java +++ b/coolstore-partner-webb/src/main/java/com/cool/store/controller/SmsController.java @@ -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(); } diff --git a/coolstore-partner-webb/src/test/java/com/cool/store/service/EventRequestTest.java b/coolstore-partner-webb/src/test/java/com/cool/store/service/EventRequestTest.java index 11a9ea724..05eedb8f1 100644 --- a/coolstore-partner-webb/src/test/java/com/cool/store/service/EventRequestTest.java +++ b/coolstore-partner-webb/src/test/java/com/cool/store/service/EventRequestTest.java @@ -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); } }