job sendsms
This commit is contained in:
@@ -84,4 +84,8 @@ public class PositionRegistrationOperatorDTO implements Serializable {
|
|||||||
* 标签
|
* 标签
|
||||||
*/
|
*/
|
||||||
private String tag;
|
private String tag;
|
||||||
}
|
|
||||||
|
@ApiModelProperty("是否发送短信")
|
||||||
|
@Builder.Default
|
||||||
|
private Boolean sendSms = false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.newyetai.common.AlitaResult;
|
||||||
|
import com.newyetai.common.validation.util.ValidateUtils;
|
||||||
|
import com.newyetai.sdk.sms.util.SmsUtils;
|
||||||
|
import com.newyetai.usercenter.enums.SmsTemplateCodeEnum;
|
||||||
import com.newyetai.usercenter.notice.constant.NoticeChannelTypeEnum;
|
import com.newyetai.usercenter.notice.constant.NoticeChannelTypeEnum;
|
||||||
import com.newyetai.usercenter.notice.constant.NoticeTemplateCodeEnum;
|
import com.newyetai.usercenter.notice.constant.NoticeTemplateCodeEnum;
|
||||||
import com.newyetai.usercenter.notice.dto.NoticeSendRecordOperateDTO;
|
import com.newyetai.usercenter.notice.dto.NoticeSendRecordOperateDTO;
|
||||||
@@ -335,7 +339,7 @@ public class PositionRegistrationServiceImpl implements PositionRegistrationServ
|
|||||||
// 发送通知
|
// 发送通知
|
||||||
sendNotice(NoticeTemplateCodeEnum.POSITION_INVITE, positionRegistrationDTO.getUserId(),
|
sendNotice(NoticeTemplateCodeEnum.POSITION_INVITE, positionRegistrationDTO.getUserId(),
|
||||||
positionRegistrationMapper.noticeInvite(operatorDTO.getId(),
|
positionRegistrationMapper.noticeInvite(operatorDTO.getId(),
|
||||||
UserContextHolder.getLoginUserId()));
|
UserContextHolder.getLoginUserId()), operatorDTO.getSendSms());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -392,19 +396,20 @@ public class PositionRegistrationServiceImpl implements PositionRegistrationServ
|
|||||||
if (PositionRegistrationStatusEnum.FAIL_THE_INTERVIEW.getStatus().equals(operatorDTO.getStatus())){
|
if (PositionRegistrationStatusEnum.FAIL_THE_INTERVIEW.getStatus().equals(operatorDTO.getStatus())){
|
||||||
sendNotice(NoticeTemplateCodeEnum.POSITION_INTERVIEW_FAIL, positionRegistrationDTO.getUserId(),
|
sendNotice(NoticeTemplateCodeEnum.POSITION_INTERVIEW_FAIL, positionRegistrationDTO.getUserId(),
|
||||||
positionRegistrationMapper.noticeInterview(operatorDTO.getId(),
|
positionRegistrationMapper.noticeInterview(operatorDTO.getId(),
|
||||||
UserContextHolder.getLoginUserId()));
|
UserContextHolder.getLoginUserId()), operatorDTO.getSendSms());
|
||||||
} else {
|
} else {
|
||||||
sendNotice(NoticeTemplateCodeEnum.POSITION_INTERVIEW_PASS,
|
sendNotice(NoticeTemplateCodeEnum.POSITION_INTERVIEW_PASS,
|
||||||
positionRegistrationDTO.getUserId(),
|
positionRegistrationDTO.getUserId(),
|
||||||
positionRegistrationMapper.noticeInterview(operatorDTO.getId(),
|
positionRegistrationMapper.noticeInterview(operatorDTO.getId(),
|
||||||
UserContextHolder.getLoginUserId()));
|
UserContextHolder.getLoginUserId()), operatorDTO.getSendSms());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送站内信
|
//发送站内信
|
||||||
private void sendNotice(NoticeTemplateCodeEnum templateCodeEnum, Long receiverUserId, Map<String, Object> contentParamDataMap) {
|
private void sendNotice(NoticeTemplateCodeEnum templateCodeEnum, Long receiverUserId, Map<String, Object> contentParamDataMap, Boolean sendSms) {
|
||||||
String templateCode = templateCodeEnum.getType();
|
String templateCode = templateCodeEnum.getType();
|
||||||
try {
|
try {
|
||||||
|
// 发送站内信
|
||||||
NoticeSendRecordOperateDTO sendRecordOperateDTO = NoticeSendRecordOperateDTO.builder()
|
NoticeSendRecordOperateDTO sendRecordOperateDTO = NoticeSendRecordOperateDTO.builder()
|
||||||
.templateCode(templateCode)
|
.templateCode(templateCode)
|
||||||
.channelType(NoticeChannelTypeEnum.SITE.getType())
|
.channelType(NoticeChannelTypeEnum.SITE.getType())
|
||||||
@@ -413,7 +418,23 @@ public class PositionRegistrationServiceImpl implements PositionRegistrationServ
|
|||||||
.build();
|
.build();
|
||||||
noticeSendRecordService.create(sendRecordOperateDTO);
|
noticeSendRecordService.create(sendRecordOperateDTO);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info("发送[{}]站内信失败:{}", templateCode, e.getMessage());
|
log.info("发送站内信[{}]失败:{}", templateCode, e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送短信
|
||||||
|
try {
|
||||||
|
UserDTO userDTO = userService.get(receiverUserId);
|
||||||
|
if (StringUtils.isNotBlank(userDTO.getPhone()) && Boolean.TRUE.equals(sendSms)) {
|
||||||
|
SmsTemplateCodeEnum smsTemplate = SmsTemplateCodeEnum.getByTemplateCodeKey(templateCode);
|
||||||
|
if (smsTemplate != null) {
|
||||||
|
AlitaResult<Boolean> result = SmsUtils.getService().sendSimple(smsTemplate.getTemplateCodeKey(), userDTO.getPhone(), contentParamDataMap);
|
||||||
|
if (!Boolean.TRUE.equals(result.getSuccess()) || !Boolean.TRUE.equals(result.getData())) {
|
||||||
|
log.info("发送短信失败,用户:{},模板:{},原因:{}", receiverUserId, templateCode, result.getMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("发送短信[{}]失败:{}", templateCode, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ public enum SmsScenesEnum {
|
|||||||
UPDATE_PAY_PASSWORD("3", "更新支付密码"),
|
UPDATE_PAY_PASSWORD("3", "更新支付密码"),
|
||||||
CREATE_SAVE_CODE("4", "设置安全码"),
|
CREATE_SAVE_CODE("4", "设置安全码"),
|
||||||
UPDATE_PASSWORD("5", "更新密码"),
|
UPDATE_PASSWORD("5", "更新密码"),
|
||||||
SAVE_ALIPAY_USER_INFO("6", "保存支付宝用户信息", "纽业态", SmsTemplateCodeEnum.CYB_COLLECT_INFO_SMS),
|
|
||||||
WECHAT_USER_INFO("7", "微信端用户信息绑定");
|
WECHAT_USER_INFO("7", "微信端用户信息绑定");
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.newyetai.usercenter.enums;
|
package com.newyetai.usercenter.enums;
|
||||||
|
|
||||||
import com.newyetai.sdk.sms.dto.ITemplateCode;
|
import com.newyetai.sdk.sms.dto.ITemplateCode;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 短信模版
|
* 短信模版
|
||||||
@@ -9,54 +12,39 @@ import com.newyetai.sdk.sms.dto.ITemplateCode;
|
|||||||
*/
|
*/
|
||||||
public enum SmsTemplateCodeEnum implements ITemplateCode {
|
public enum SmsTemplateCodeEnum implements ITemplateCode {
|
||||||
|
|
||||||
/**
|
|
||||||
* 个人签约认证短信模版
|
|
||||||
**/
|
|
||||||
PERSON_VERIFY("templatePersonVerify"),
|
|
||||||
/**
|
|
||||||
* 结算提醒通知模版
|
|
||||||
**/
|
|
||||||
SETTLEMENT_NOTIFY("templateSettlementNotify"),
|
|
||||||
/**
|
|
||||||
* 结算支付验证
|
|
||||||
**/
|
|
||||||
SETTLE_CAPTCHA("templateSettleCaptcha"),
|
|
||||||
/**
|
|
||||||
* 机构开通通知模版
|
|
||||||
**/
|
|
||||||
ORG_CREATE("templateOrgCreate"),
|
|
||||||
/**
|
|
||||||
* 代发开通通知模板
|
|
||||||
**/
|
|
||||||
AGENT_SEND_SMS("agentSendSms"),
|
|
||||||
/**
|
|
||||||
* 三要素认证开通通知模板
|
|
||||||
**/
|
|
||||||
THREE_ELEMENT_SMS("threeElementSms"),
|
|
||||||
/**
|
/**
|
||||||
* 手机短信模拟
|
* 手机短信模拟
|
||||||
**/
|
**/
|
||||||
PHONE_SMS("phoneSms"),
|
PHONE_SMS("phoneSms"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采源宝信息收集Sms
|
* 岗位报名-邀请面试
|
||||||
**/
|
**/
|
||||||
CYB_COLLECT_INFO_SMS("cybCollectInfoSms"),
|
POSITION_INVITE("position_invite"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 无卡发薪支付成功通知
|
* 岗位报名-面试通过
|
||||||
*/
|
**/
|
||||||
UPAY_PAY_SUCCESS("upayPaySuccess"),
|
POSITION_INTERVIEW_PASS("position_interview_pass"),
|
||||||
|
|
||||||
/** 合同续期(人事) **/
|
/**
|
||||||
CONTRACT_CONTINUED("contractContinued"),
|
* 岗位报名-面试不通过
|
||||||
|
**/
|
||||||
|
POSITION_INTERVIEW_FAIL("position_interview_fail"),
|
||||||
|
|
||||||
|
|
||||||
/** 机构审批通过 **/
|
|
||||||
ORG_APPLY_SUCCESS("orgApplySuccess"),
|
|
||||||
/** 机构审批不通过 **/
|
|
||||||
ORG_APPLY_REJECT("orgApplyReject"),
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
private static final Map<String, SmsTemplateCodeEnum> templateCodeMap;
|
||||||
|
|
||||||
|
static {
|
||||||
|
SmsTemplateCodeEnum[] smsTemplateCodeEnums = SmsTemplateCodeEnum.values();
|
||||||
|
templateCodeMap = Maps.newHashMapWithExpectedSize(smsTemplateCodeEnums.length);
|
||||||
|
for (SmsTemplateCodeEnum smsTemplateCodeEnum : smsTemplateCodeEnums) {
|
||||||
|
templateCodeMap.put(smsTemplateCodeEnum.getTemplateCodeKey(), smsTemplateCodeEnum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模版配置键
|
* 模版配置键
|
||||||
**/
|
**/
|
||||||
@@ -71,4 +59,8 @@ public enum SmsTemplateCodeEnum implements ITemplateCode {
|
|||||||
return this.templateCodeKey;
|
return this.templateCodeKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SmsTemplateCodeEnum getByTemplateCodeKey(String templateCodeKey) {
|
||||||
|
return templateCodeMap.get(templateCodeKey);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,9 @@ sms.signName=\u65b0\u7586\u4eba\u624d\u521b\u65b0\u79d1\u6280
|
|||||||
sms.numLimit=300000
|
sms.numLimit=300000
|
||||||
#短信验证码模板配置
|
#短信验证码模板配置
|
||||||
sms.phoneSms=SMS_320262429
|
sms.phoneSms=SMS_320262429
|
||||||
|
sms.position_invite=SMS_493260244
|
||||||
|
sms.position_interview_pass=SMS_493400245
|
||||||
|
sms.position_interview_fail=SMS_493245262
|
||||||
|
|
||||||
#默认认证源:1fxq,2cl,4ali
|
#默认认证源:1fxq,2cl,4ali
|
||||||
alita.authenticationSource=4
|
alita.authenticationSource=4
|
||||||
|
|||||||
@@ -132,6 +132,9 @@ sms.signName=\u65b0\u7586\u4eba\u624d\u521b\u65b0\u79d1\u6280
|
|||||||
sms.numLimit=300000
|
sms.numLimit=300000
|
||||||
#短信验证码模板配置
|
#短信验证码模板配置
|
||||||
sms.phoneSms=SMS_320262429
|
sms.phoneSms=SMS_320262429
|
||||||
|
sms.position_invite=SMS_320262430
|
||||||
|
sms.position_interview_pass=SMS_320262431
|
||||||
|
sms.position_interview_fail=SMS_320262432
|
||||||
|
|
||||||
#默认认证源:1fxq,2cl,4ali
|
#默认认证源:1fxq,2cl,4ali
|
||||||
alita.authenticationSource=4
|
alita.authenticationSource=4
|
||||||
|
|||||||
Reference in New Issue
Block a user