发送邀请短信
This commit is contained in:
@@ -14,7 +14,11 @@ public enum SMSMsgEnum {
|
||||
|
||||
INTERVIEW_BEGIN_IN_DAY("面试开始前一天", "【沪上阿姨】您预约的沪上阿姨加盟资格面试将于明天 {$var}({$var})开始,为保证您能够更加顺利的通过面试,请提前通过沪上阿姨合伙人小程序仔细阅读面试准备材料并做好相应准备。点击转跳小程序:{$var}"),
|
||||
|
||||
INTERVIEW_BEGIN_IN_MINUTES("面试开始前30分钟", "【沪上阿姨】您预约的沪上阿姨加盟资格面试将在30分钟后开始。面试预计持续40分钟,请务必提前安排好您的时间。点击跳转沪上阿姨小程序,快速进入面试房间:{$var}");
|
||||
INTERVIEW_BEGIN_IN_MINUTES("面试开始前30分钟", "【沪上阿姨】您预约的沪上阿姨加盟资格面试将在30分钟后开始。面试预计持续40分钟,请务必提前安排好您的时间。点击跳转沪上阿姨小程序,快速进入面试房间:{$var}"),
|
||||
|
||||
SMS_INVATE("短信邀约", "【沪上阿姨】感谢您对沪上阿姨品牌的关注与支持,您可通过链接{$var}登记加盟申请信息,我们的客户经理将在第一时间与您联系。"),
|
||||
|
||||
;
|
||||
|
||||
private String title;
|
||||
private String content;
|
||||
|
||||
@@ -8,7 +8,9 @@ package com.cool.store.enums;
|
||||
public enum UserChannelEnum {
|
||||
|
||||
EXHIBITION("EXHIBITION","北京展会"),
|
||||
RECOMMENDED("RECOMMENDED","李德龙推荐");
|
||||
RECOMMENDED("RECOMMENDED","李德龙推荐"),
|
||||
|
||||
SMS_INVATE("","短信邀约");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.cool.store.dto.sms;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: young.yu
|
||||
* @Date: 2023-10-20 14:51
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(description = "发送邀请短信")
|
||||
public class SendInvateMsgDTO {
|
||||
@ApiModelProperty(value = "手机号", required = true)
|
||||
private String mobile;
|
||||
}
|
||||
@@ -11,4 +11,5 @@ import lombok.Data;
|
||||
@Data
|
||||
public class MiniAppUrlLinkReqDTO{
|
||||
private String path;
|
||||
private String query;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||
import com.cool.store.dto.sms.SendInvateMsgDTO;
|
||||
import com.cool.store.enums.SMSMsgEnum;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.response.SmsSendResponse;
|
||||
@@ -17,4 +18,5 @@ public interface SmsService {
|
||||
|
||||
public SmsSendResponse sendSmsVariable(String phone, SMSMsgEnum smsMsgEnum,String... objects);
|
||||
|
||||
public void sendInvateMsg(SendInvateMsgDTO sendInvateMsgDTO);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.dto.wx.MiniAppUrlLinkReqDTO;
|
||||
import com.cool.store.dto.wx.MiniProgramLoginDTO;
|
||||
import com.cool.store.request.MobileUpdateRequest;
|
||||
import com.cool.store.vo.PartnerUserInfoVO;
|
||||
@@ -21,4 +22,6 @@ public interface WechatMiniAppService {
|
||||
PartnerUserInfoVO getUserInfo(String mobile, String openId);
|
||||
|
||||
String getMiniAppUrl();
|
||||
|
||||
String getMiniAppUrlLink(MiniAppUrlLinkReqDTO miniAppUrlLinkReqDTO);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.aliyun.dysmsapi20170525.Client;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
|
||||
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import com.cool.store.context.CurrentUserHolder;
|
||||
import com.cool.store.context.LoginUserInfo;
|
||||
import com.cool.store.dto.sms.SendInvateMsgDTO;
|
||||
import com.cool.store.dto.wx.MiniAppUrlLinkReqDTO;
|
||||
import com.cool.store.enums.SMSMsgEnum;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.mq.util.HttpRestTemplateService;
|
||||
import com.cool.store.request.SmsSendRequest;
|
||||
import com.cool.store.response.SmsSendResponse;
|
||||
import com.cool.store.service.SmsService;
|
||||
import com.cool.store.utils.StringUtil;
|
||||
import com.cool.store.service.WechatMiniAppService;
|
||||
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.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
@@ -53,6 +51,14 @@ public class SmsServiceImpl implements SmsService {
|
||||
@Autowired
|
||||
private HttpRestTemplateService httpRestTemplateService;
|
||||
|
||||
@Autowired
|
||||
private WechatMiniAppService wechatMiniAppService;
|
||||
|
||||
@Value("${weixin.index.url}")
|
||||
private String miniAppIndexUrl;
|
||||
@Value("${sms.invate.channel.id}")
|
||||
private String smsInvateChannelId;
|
||||
|
||||
/**
|
||||
* 发送普通短信
|
||||
* @param phone 手机号码
|
||||
@@ -97,4 +103,17 @@ public class SmsServiceImpl implements SmsService {
|
||||
SmsSendResponse smsSingleResponse = JSON.parseObject(response, SmsSendResponse.class);
|
||||
return smsSingleResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendInvateMsg(SendInvateMsgDTO sendInvateMsgDTO) {
|
||||
LoginUserInfo operator = CurrentUserHolder.getUser();
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
MiniAppUrlLinkReqDTO miniAppUrlLinkReqDTO = new MiniAppUrlLinkReqDTO();
|
||||
miniAppUrlLinkReqDTO.setPath(miniAppIndexUrl);
|
||||
stringBuffer.append("userChannelEnum=").append(smsInvateChannelId)
|
||||
.append("&inviter=").append(operator.getUserId());
|
||||
miniAppUrlLinkReqDTO.setQuery(stringBuffer.toString());
|
||||
|
||||
sendSmsVariable(sendInvateMsgDTO.getMobile(), SMSMsgEnum.SMS_INVATE,wechatMiniAppService.getMiniAppUrlLink(miniAppUrlLinkReqDTO));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,10 +231,13 @@ public class WechatMiniAppServiceImpl implements WechatMiniAppService {
|
||||
|
||||
@Override
|
||||
public String getMiniAppUrl() {
|
||||
// 获取小程序token
|
||||
String accessToken = wechatRest.getAccessToken(wxAppId, wxAppSecret);
|
||||
MiniAppUrlLinkReqDTO miniAppUrlLinkReqDTO = new MiniAppUrlLinkReqDTO();
|
||||
// miniAppUrlLinkReqDTO.setPath(weixinIndexUrl);
|
||||
return getMiniAppUrlLink(miniAppUrlLinkReqDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMiniAppUrlLink(MiniAppUrlLinkReqDTO miniAppUrlLinkReqDTO) {
|
||||
String accessToken = wechatRest.getAccessToken(wxAppId, wxAppSecret);
|
||||
MiniAppUrlLinkDTO miniAppUrlLink = wechatRest.getMiniAppUrlLink(accessToken, miniAppUrlLinkReqDTO);
|
||||
if (miniAppUrlLink != null){
|
||||
return miniAppUrlLink.getUrlLink();
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.cool.store.controller;
|
||||
|
||||
import com.cool.store.dto.sms.SendInvateMsgDTO;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.SmsService;
|
||||
import com.cool.store.vo.role.RolePageVO;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author: young.yu
|
||||
* @Date: 2023-10-20 13:49
|
||||
* @Description:
|
||||
*/
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/sms")
|
||||
@Api(tags = "短信发送")
|
||||
public class SmsController {
|
||||
|
||||
@Autowired
|
||||
private SmsService smsService;
|
||||
|
||||
@PostMapping("/invate")
|
||||
@ApiOperation("招商邀请短信")
|
||||
public ResponseResult sendInvateMsg(@RequestBody SendInvateMsgDTO sendInvateMsgDTO){
|
||||
smsService.sendInvateMsg(sendInvateMsgDTO);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user