Преглед на файлове

短信改腾讯云短信

LiFei преди 2 години
родител
ревизия
014c17b9cb

+ 43 - 0
happy-job-base-common/src/main/java/com/jeeplus/common/captcha/CaptchaProperties.java

@@ -0,0 +1,43 @@
+package com.jeeplus.common.captcha;
+
+
+import org.springframework.beans.factory.annotation.Value;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * @Author: zwq
+ * @Date: Create in 2022/10/24 17:12
+ * @Description: 电签配置参数
+ */
+@Component
+public class CaptchaProperties {
+
+    /**
+     * 应用id
+     */
+    @Value("${captcha.captchaAppId}")
+    private Long captchaAppId;
+    /**
+     * 应用秘钥
+     */
+    @Value("${captcha.captchaAppSecret}")
+    private String captchaAppSecret;
+
+
+    public Long getCaptchaAppId() {
+        return captchaAppId;
+    }
+
+    public void setCaptchaAppId(Long captchaAppId) {
+        this.captchaAppId = captchaAppId;
+    }
+
+    public String getCaptchaAppSecret() {
+        return captchaAppSecret;
+    }
+
+    public void setCaptchaAppSecret(String captchaAppSecret) {
+        this.captchaAppSecret = captchaAppSecret;
+    }
+}

+ 44 - 0
happy-job-base-common/src/main/java/com/jeeplus/common/captcha/Constants.java

@@ -0,0 +1,44 @@
+package com.jeeplus.common.captcha;
+
+/**
+ * @Author: zwq
+ * @Date: Create in 2022/10/24 14:42
+ * @Description:
+ */
+public interface Constants {
+    /********************腾讯云验证码接口请求域名************************/
+    public static final String CAPTCHA_URL = "captcha.tencentcloudapi.com";
+
+    /********************腾讯云电签请求域名************************/
+    public static final String ESS_URL = "ess.tencentcloudapi.com";
+
+    /********************腾讯云电签(渠道版)请求域名************************/
+    public static final String ESS_BASIC_URL = "essbasic.tencentcloudapi.com";
+
+    /********************腾讯云短信请求域名************************/
+    public static final String SMS_URL = "sms.tencentcloudapi.com";
+
+    /********************腾讯云身份认证请求域名************************/
+    public static final String FACEID_URL = "faceid.tencentcloudapi.com";
+
+    /********************腾讯云营业执照识别请求域名************************/
+    public static final String OCR_URL = "ocr.tencentcloudapi.com";
+
+    /********************腾讯云电签地域参数(无需)************************/
+    public static final String ESS_REGION = "";
+
+    /********************腾讯云营业执照识别地域参数************************/
+    public static final String OCR_REGION = "ap-shanghai";
+
+    /********************腾讯云短信地域参数************************/
+    public static final String SMS_REGION = "ap-nanjing";
+
+    /********************认证通过************************/
+    public static final String AUTH_CODE_OK = "0";
+
+    /********************腾讯云验证码接口返回状态************************/
+    /**
+     * OK 验证通过
+     */
+    public static final Long CAPTCHA_CODE_OK = 1L;
+}

+ 56 - 0
happy-job-base-common/src/main/java/com/jeeplus/common/captcha/TxCaptchaUtils.java

@@ -0,0 +1,56 @@
+package com.jeeplus.common.captcha;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tencentcloudapi.captcha.v20190722.CaptchaClient;
+import com.tencentcloudapi.captcha.v20190722.models.DescribeCaptchaResultRequest;
+import com.tencentcloudapi.captcha.v20190722.models.DescribeCaptchaResultResponse;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author: zwq
+ * @Date: Create in 2022/10/25 10:01
+ * @Description: 腾讯云ocr识别工具类
+ */
+@Component
+@Service
+public class TxCaptchaUtils {
+    private Logger log = LoggerFactory.getLogger(getClass());
+    @Autowired
+    private CaptchaClient captchaClient;
+    @Autowired
+    private CaptchaProperties captchaProperties;
+
+    /**
+     * 服务器端
+     * 腾讯云验证码票据验证
+     */
+    public boolean checkTicket(JSONObject json) {
+        boolean ok = false;
+        try {
+            // 实例化一个请求对象
+            DescribeCaptchaResultRequest req = new DescribeCaptchaResultRequest();
+            req.setCaptchaType(json.getLong("CaptchaType"));
+            req.setTicket(json.getString("Ticket"));
+            req.setUserIp(json.getString("UserIp"));
+            req.setRandstr(json.getString("Randstr"));
+            req.setCaptchaAppId(captchaProperties.getCaptchaAppId());
+            req.setAppSecretKey(captchaProperties.getCaptchaAppSecret());
+            // 通过 client 对象调用想要访问的接口,需要传入请求对象
+            DescribeCaptchaResultResponse resp = captchaClient.DescribeCaptchaResult(req);
+            String result = DescribeCaptchaResultResponse.toJsonString(resp);
+            log.info("腾讯云验证码票据验证成功==={}", result);
+            if (Constants.CAPTCHA_CODE_OK.equals(resp.getCaptchaCode())) {
+                ok = true;
+            }
+        } catch (TencentCloudSDKException e) {
+            e.printStackTrace();
+            log.info("腾讯云验证码票据失败==={}", e.getMessage());
+        }
+        return ok;
+    }
+}

+ 43 - 0
happy-job-base-common/src/main/java/com/jeeplus/common/smstx/SmsProperties.java

@@ -0,0 +1,43 @@
+package com.jeeplus.common.smstx;
+
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Author: zwq
+ * @Date: Create in 2022/10/24 17:12
+ * @Description: 电签配置参数
+ */
+@Component
+public class SmsProperties {
+
+    /**
+     * 短信应用id
+     */
+    @Value("${smstx.appId}")
+    private String appId;
+
+    /**
+     * 短信应用签名
+     */
+    @Value("${smstx.signName}")
+    private String signName;
+
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+    public String getSignName() {
+        return signName;
+    }
+
+    public void setSignName(String signName) {
+        this.signName = signName;
+    }
+}

+ 166 - 0
happy-job-base-common/src/main/java/com/jeeplus/common/smstx/TencentConfig.java

@@ -0,0 +1,166 @@
+package com.jeeplus.common.smstx;
+
+import com.jeeplus.common.captcha.Constants;
+import com.tencentcloudapi.captcha.v20190722.CaptchaClient;
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import com.tencentcloudapi.ess.v20201111.EssClient;
+import com.tencentcloudapi.essbasic.v20210526.EssbasicClient;
+import com.tencentcloudapi.faceid.v20180301.FaceidClient;
+import com.tencentcloudapi.ocr.v20181119.OcrClient;
+import com.tencentcloudapi.sms.v20210111.SmsClient;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author: zwq
+ * @date: 2022年10月24日 14:36
+ * @Description: 腾讯云配置类
+ */
+@Configuration
+public class TencentConfig {
+    @Value("${tencent.secretId}")
+    private String secretId;
+    @Value("${tencent.secretKey}")
+    private String secretKey;
+
+    /**
+     * 电签客户端对象
+     * 将EssClient对象装配到Spring容器
+     *
+     * @return
+     */
+    @Bean
+    public EssClient essClient() {
+        //实例化一个认证对象,入参需要传入腾讯云账户密钥secretId,secretKey
+        Credential cred = new Credential(secretId, secretKey);
+        //实例化一个http选项
+        HttpProfile httpProfile = new HttpProfile();
+        httpProfile.setEndpoint(Constants.ESS_URL);
+
+        //实例化一个client选项
+        ClientProfile clientProfile = new ClientProfile();
+        clientProfile.setHttpProfile(httpProfile);
+
+        // 实例化要请求产品(ESS)的 client 对象
+        EssClient essClient = new EssClient(cred, Constants.ESS_REGION, clientProfile);
+
+        return essClient;
+    }
+
+    /**
+     * 电签客户端对象(渠道版)
+     * 将EssbasicClient对象装配到Spring容器
+     *
+     * @return
+     */
+    @Bean
+    public EssbasicClient essbasicClient() {
+        //实例化一个认证对象,入参需要传入腾讯云账户密钥secretId,secretKey
+        Credential cred = new Credential(secretId, secretKey);
+        //实例化一个http选项
+        HttpProfile httpProfile = new HttpProfile();
+        httpProfile.setEndpoint(Constants.ESS_BASIC_URL);
+
+        //实例化一个client选项
+        ClientProfile clientProfile = new ClientProfile();
+        clientProfile.setHttpProfile(httpProfile);
+
+        // 实例化要请求产品(ESS)的 client 对象
+        EssbasicClient essbasicClient = new EssbasicClient(cred, Constants.ESS_REGION, clientProfile);
+
+        return essbasicClient;
+    }
+
+    /**
+     * 验证码客户端对象
+     * 将CaptchaClient对象装配到Spring容器
+     *
+     * @return
+     */
+    @Bean
+    public CaptchaClient captchaClient() {
+        //实例化一个认证对象,入参需要传入腾讯云账户密钥secretId,secretKey
+        Credential cred = new Credential(secretId, secretKey);
+
+        HttpProfile httpProfile = new HttpProfile();
+        httpProfile.setEndpoint(Constants.CAPTCHA_URL);
+
+        ClientProfile clientProfile = new ClientProfile();
+        clientProfile.setHttpProfile(httpProfile);
+
+        // 实例化要请求产品(captcha)的 client 对象
+        CaptchaClient client = new CaptchaClient(cred, "", clientProfile);
+
+        return client;
+    }
+
+    /**
+     * 短信客户端对象
+     * 将SmsClient对象装配到Spring容器
+     *
+     * @return
+     */
+    @Bean
+    public SmsClient smsClient() {
+        //实例化一个认证对象,入参需要传入腾讯云账户密钥secretId,secretKey
+        Credential cred = new Credential(secretId, secretKey);
+
+        HttpProfile httpProfile = new HttpProfile();
+        httpProfile.setEndpoint(Constants.SMS_URL);
+
+        ClientProfile clientProfile = new ClientProfile();
+        clientProfile.setHttpProfile(httpProfile);
+
+        // 实例化要请求产品(SMS)的 client 对象
+        SmsClient client = new SmsClient(cred, Constants.SMS_REGION, clientProfile);
+
+        return client;
+    }
+
+    /**
+     * 身份认证客户端对象
+     *
+     * @return
+     */
+    @Bean
+    public FaceidClient faceidClient() {
+        //实例化一个认证对象,入参需要传入腾讯云账户密钥secretId,secretKey
+        Credential cred = new Credential(secretId, secretKey);
+
+        HttpProfile httpProfile = new HttpProfile();
+        httpProfile.setEndpoint(Constants.FACEID_URL);
+
+        ClientProfile clientProfile = new ClientProfile();
+        clientProfile.setHttpProfile(httpProfile);
+
+        // 实例化要请求产品(faceId)的 client 对象
+        FaceidClient client = new FaceidClient(cred, "", clientProfile);
+
+        return client;
+    }
+
+    /**
+     * ocr客户端对象
+     *
+     * @return
+     */
+    @Bean
+    public OcrClient ocrClient() {
+        //实例化一个认证对象,入参需要传入腾讯云账户密钥secretId,secretKey
+        Credential cred = new Credential(secretId, secretKey);
+
+        HttpProfile httpProfile = new HttpProfile();
+        httpProfile.setEndpoint(Constants.OCR_URL);
+
+        ClientProfile clientProfile = new ClientProfile();
+        clientProfile.setHttpProfile(httpProfile);
+
+        // 实例化要请求产品(ocr)的 client 对象
+        OcrClient client = new OcrClient(cred, Constants.OCR_REGION, clientProfile);
+
+        return client;
+    }
+}

+ 47 - 0
happy-job-base-common/src/main/java/com/jeeplus/common/smstx/TxSmsEnum.java

@@ -0,0 +1,47 @@
+package com.jeeplus.common.smstx;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * @author: zwq
+ * @date: 2022年11月4日 09:36
+ * @Description: 腾讯云短信枚举
+ */
+public enum TxSmsEnum {
+    /**
+     * 模板code
+     */
+    LOGIN_TEMPLATE_CODE("1608236"),
+    PASSWORD_TEMPLATE_CODE("1608270"),
+    PAYMENT_TEMPLATE_CODE("1608249");
+
+    /**
+     * 短信模板id
+     */
+    private String templateId;
+
+    private TxSmsEnum(String templateId) {
+        this.templateId = templateId;
+    }
+
+    public String getTemplateId() {
+        return templateId;
+    }
+
+    public void setTemplateId(String templateId) {
+        this.templateId = templateId;
+    }
+
+    public static TxSmsEnum toEnum(String templateId) {
+        if (StringUtils.isEmpty(templateId)) {
+            return null;
+        }
+        for (TxSmsEnum item : TxSmsEnum.values()) {
+            if (item.getTemplateId().equals(templateId)) {
+                return item;
+            }
+        }
+        return null;
+    }
+}
+

+ 111 - 0
happy-job-base-common/src/main/java/com/jeeplus/common/smstx/TxSmsUtils.java

@@ -0,0 +1,111 @@
+package com.jeeplus.common.smstx;
+
+import com.tencentcloudapi.sms.v20210111.SmsClient;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
+import com.tencentcloudapi.sms.v20210111.models.SendStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @author: zwq
+ * @date: 2022年11月4日 09:36
+ * @Description: 腾讯云短信工具类
+ */
+@Component
+@Service
+public class TxSmsUtils {
+
+    private final static Logger logger = LoggerFactory.getLogger(TxSmsUtils.class);
+    @Resource
+    private SmsClient smsClient;
+    @Autowired
+    private SmsProperties smsProperties;
+
+    /**
+     * 发送短信
+     *
+     * @param phoneNumbers
+     * @param templateParams
+     * @param txSmsEnum
+     * @return
+     */
+    public boolean sendSms(List<String> phoneNumbers, List<String> templateParams, TxSmsEnum txSmsEnum) {
+        boolean result = false;
+        try {
+            /* 实例化一个请求对象,根据调用的接口和实际情况,可以进一步设置请求参数 */
+            SendSmsRequest req = new SendSmsRequest();
+
+            /* 填充请求参数,这里request对象的成员变量即对应接口的入参
+             * 你可以通过官网接口文档或跳转到request对象的定义处查看请求参数的定义
+             * 基本类型的设置:
+             * 帮助链接:
+             * 短信控制台: https://console.cloud.tencent.com/smsv2
+             * 腾讯云短信小助手: https://cloud.tencent.com/document/product/382/3773#.E6.8A.80.E6.9C.AF.E4.BA.A4.E6.B5.81 */
+
+            /* 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId,示例如1400006666 */
+            // 应用 ID 可前往 [短信控制台](https://console.cloud.tencent.com/smsv2/app-manage) 查看
+            String sdkAppId = smsProperties.getAppId();
+            req.setSmsSdkAppId(sdkAppId);
+
+            /* 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名 发送国内短信该参数必填。*/
+            // 签名信息可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-sign) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-sign) 的签名管理查看
+            String signName = smsProperties.getSignName();
+            req.setSignName(signName);
+
+            /* 模板 ID: 必须填写已审核通过的模板 ID */
+            // 模板 ID 可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-template) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-template) 的正文模板管理查看
+            String templateId = txSmsEnum.getTemplateId();
+            req.setTemplateId(templateId);
+
+            /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */
+            String[] templateParamSet = templateParams.toArray(new String[]{});
+            req.setTemplateParamSet(templateParamSet);
+
+            /* 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号]
+             * 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号 */
+            String[] phoneNumberSet = phoneNumbers.toArray(new String[]{});
+            req.setPhoneNumberSet(phoneNumberSet);
+
+            /* 用户的 session 内容(无需要可忽略): 可以携带用户侧 ID 等上下文信息,server 会原样返回 */
+            String sessionContext = "";
+            req.setSessionContext(sessionContext);
+
+            /* 短信码号扩展号(无需要可忽略): 默认未开通,如需开通请联系 [腾讯云短信小助手] */
+            String extendCode = "";
+            req.setExtendCode(extendCode);
+
+            /* 国际/港澳台短信 SenderId(无需要可忽略): 国内短信填空,默认未开通,如需开通请联系 [腾讯云短信小助手] */
+            String senderid = "";
+            req.setSenderId(senderid);
+
+            /* 通过 client 对象调用 SendSms 方法发起请求。注意请求方法名与请求对象是对应的
+             * 返回的 res 是一个 SendSmsResponse 类的实例,与请求对象对应 */
+            SendSmsResponse res = smsClient.SendSms(req);
+
+            // 输出json格式的字符串回包
+            logger.info("短信接口返回的数据----------------");
+            logger.info(SendSmsResponse.toJsonString(res));
+
+            SendStatus[] sendStatuses = res.getSendStatusSet();
+            for (SendStatus sendStatus : sendStatuses) {
+                logger.info("{Code:" + sendStatus.getCode() + ",Message:" + sendStatus.getMessage() + ",phone:" + sendStatus.getPhoneNumber() + ",RequestId:" + res.getRequestId() + "}");
+                if ("Ok".equals(sendStatus.getCode())) {
+                    logger.info("发送成功{}", sendStatus.getCode());
+                    result = true;
+                    break;
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            logger.info("发送失败{}", e.getMessage());
+        }
+        return result;
+    }
+}

+ 1 - 1
happy-job-base-system/src/main/resources/j2cache/j2cache.properties

@@ -89,7 +89,7 @@ redis.namespace =
 
 ## connection\u672C\u5730
 redis.hosts = 127.0.0.1:6379
-redis.password =123456
+redis.password =
 #\u6D4B\u8BD5\u670D
 #redis.hosts = 127.0.0.1:18369
 #redis.password =zX$l5c8QNAQH$l25HK

+ 11 - 0
happy-job-base-system/src/main/resources/properties/jeeplus.properties

@@ -141,6 +141,17 @@ sms.password=O04MCJiBLc6b64
 sms.smsUrl=http://smssh1.253.com/msg/send/json
 #253\u4E91\u901A\u8BAF\u5E73\u53F0\u4E0A\u914D\u7F6E\u7B7E\u540D
 sms.smsSign=%e3%80%90%e5%bc%80%e5%bf%83%e5%b7%a5%e4%bd%9c%e3%80%91
+#tx\u77ED\u4FE1\u79D8\u94A5
+#\u77ED\u4FE1\u5E94\u7528id
+smstx.appId=1400766289
+#\u77ED\u4FE1\u5E94\u7528\u7B7E\u540D
+smstx.signName=\u6C5F\u82CF\u5F00\u5FC3\u5DE5\u4F5C\u79D1\u6280
+#\u4EA7\u54C11\u2014\u2014\u9A8C\u8BC1\u7801
+captcha.captchaAppId=2072736870
+captcha.captchaAppSecret=02HfKJprDUkFdgAcErXdfog**
+#\u4EA7\u54C1\u79D8\u94A5
+tencent.secretId=AKIDIH5dojPtDG2btwvfKiodAPxDfRvwR7FD
+tencent.secretKey=ulOiodBRYO2SaT52h8HDrDeXYJm0xlQN
 
 ############################ oss\u5BF9\u8C61\u5B58\u50A8###############################
 #\u6D4B\u8BD5\u670D

+ 1 - 1
happy-job-base-system/src/main/resources/properties/license.properties

@@ -1,3 +1,3 @@
 #\u8F93\u5165\u60A8\u7684\u7528\u6237\u540D\uFF0C\u4EE5\u53CAlicense\uFF0C\u4E00\u4E2Alicense\u6388\u6743\u4E00\u4E2A\u9879\u76EE\u3002
 productID=Y2019012590
-license=6CABFF1C20DE2EDCDA2C69CCBC4F12FD867D4600C0D942D3EB69C69529B8689CE7C215E172B70621DB94F07A473A13043F3C89F48B73C6FCBA1754A292198EA6
+license=5BE8D71C7AFBA83B6CF26B8F83BFE97F4E7B8CB6CC323F379367D175043E4B8A870F4F3B4520BC1D52C4FA1E0CC17E7EC0A9A920A2694A24EF854A30B3D18C09

+ 39 - 22
happy-job-module-hpjob/src/main/java/com/jeeplus/modules/sys/service/HpUserService.java

@@ -6,11 +6,14 @@ package com.jeeplus.modules.sys.service;
 import com.google.common.collect.Lists;
 import com.jeeplus.common.annotation.LoginAppIntercept;
 import com.jeeplus.common.annotation.LoginWxAppletsIntercept;
+import com.jeeplus.common.captcha.TxCaptchaUtils;
 import com.jeeplus.common.config.Global;
 import com.jeeplus.common.json.AjaxJson;
 import com.jeeplus.common.oss.OSSClientUtil;
 import com.jeeplus.common.sms.SMS253Utils;
 import com.jeeplus.common.sms.SMSConst;
+import com.jeeplus.common.smstx.TxSmsEnum;
+import com.jeeplus.common.smstx.TxSmsUtils;
 import com.jeeplus.common.utils.CacheUtils;
 import com.jeeplus.common.utils.StringUtils;
 import com.jeeplus.common.utils.api.IPUtil;
@@ -45,6 +48,8 @@ import com.jeeplus.modules.tools.utils.TwoDimensionCode;
 import com.jeeplus.modules.utils.AppLoginsEnum;
 import com.jeeplus.modules.vipmanager.entity.MpMemberAccountF;
 import net.sf.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -75,7 +80,7 @@ import java.util.*;
 @Service
 @Transactional(readOnly = true)
 public class HpUserService extends CrudService<HpUserMapper, HpUser> {
-
+    private Logger log = LoggerFactory.getLogger(getClass());
     @Autowired
     private HpResumeWorkExperienceService hpResumeWorkExperienceService;
     @Autowired
@@ -96,6 +101,10 @@ public class HpUserService extends CrudService<HpUserMapper, HpUser> {
     private HpResumeBankMapper hpResumeBankMapper;
     @Autowired
     private MpMemberTaskServiceF mpMemberTaskServiceF;
+    @Autowired
+    private TxCaptchaUtils txCaptchaUtils;
+    @Autowired
+    private TxSmsUtils txSmsUtils;
 
     private static final String APP_USER = "appUser";
     private static final String APP_USERMSG = "appUserMsg";
@@ -166,29 +175,37 @@ public class HpUserService extends CrudService<HpUserMapper, HpUser> {
                 if (StringUtils.isBlank(ticket) || StringUtils.isBlank(randstr)) {
                     throw new OtherException("10000", "系统内部错误!");
                 }
-                //验证码票据验证
-                JSONObject json = getTicketData(hashMap, request);
-                JSONObject jsonObject = TokenUtil.checkTicket(json);
-                logger.info("验证码票据验证========={}", jsonObject.toString());
-                long captchaCode = jsonObject.getLong("CaptchaCode");
-                if (captchaCode != Constants.CAPTCHA_CODE_OK) {
-                    throw new OtherException("10000", "系统内部错误!");
+                // 验证码票据验证
+                com.alibaba.fastjson.JSONObject json = getTicketData(hashMap, request);
+                log.info("验证码票据验证========={}", json.toString());
+                boolean isCheck = txCaptchaUtils.checkTicket(json);
+                if (!isCheck) {
+                    throw new OtherException("10000", "获取验证码失败,请稍后重试!");
                 }
+
+                // 手机号
+                List<String> phoneList = new ArrayList<>();
+                phoneList.add(mobile);
+
                 Random random = new Random();
-                String code = "";
+                // 随机数
+                String captcha = "";
                 for (int i = 0; i < 6; i++) {
-                    code += random.nextInt(10);
-                }
-                HashMap<String, String> hashMaps = new HashMap<String, String>();
-                // 手机号码
-                hashMaps.put("phone", mobile);
-                hashMaps.put("msg", "亲爱的用户,您的验证码是" + code + ",如非本人操作请忽略!");
-                returnMap = SMS253Utils.sendSms(hashMaps);
-                if (SMSConst.OKCode.equals(returnMap.get("success"))) {
-                    returnMap.put("code", code);
-                    //将获取到的验证码存到redis中
-                    CacheUtils.put(APP_USER, mobile, code);
+                    captcha += random.nextInt(10);
                 }
+                List<String> templateParams = new ArrayList<>();
+                templateParams.add(captcha);
+                templateParams.add("10");
+                boolean b = txSmsUtils.sendSms(phoneList, templateParams, TxSmsEnum.LOGIN_TEMPLATE_CODE);
+                if (b == false) {
+                    throw new OtherException("10000", "短信验证码发送失败,请稍后重试");
+                }
+                //将获取到的验证码存到redis中
+                CacheUtils.put(APP_USER, mobile, captcha);
+                returnMap.put("success", 200);
+                returnMap.put("msg", "获取短信验证码成功!");
+                returnMap.put("code", captcha);
+
             } catch (Exception e) {
                 throw new OtherException("10000", "系统内部错误!");
             }
@@ -202,8 +219,8 @@ public class HpUserService extends CrudService<HpUserMapper, HpUser> {
      * @param requestMap
      * @return
      */
-    public JSONObject getTicketData(HashMap<String, String> requestMap, HttpServletRequest request) {
-        JSONObject json = new JSONObject();
+    public com.alibaba.fastjson.JSONObject getTicketData(HashMap<String, String> requestMap, HttpServletRequest request) {
+        com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
         //固定填值:9。可在控制台配置不同验证码类型。
         json.put("CaptchaType", 9);
         //前端回调函数返回的用户验证票据

+ 9 - 0
pom.xml

@@ -62,6 +62,7 @@
         <webserver.port>8081</webserver.port>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <downloadSources>true</downloadSources>
+        <tencent.cloud.version>3.1.613</tencent.cloud.version>
 
     </properties>
 
@@ -798,6 +799,14 @@
             <version>1.8.1</version>
         </dependency>
         <!-- UTILS end -->
+
+        <!--腾讯云sdk-->
+        <dependency>
+            <groupId>com.tencentcloudapi</groupId>
+            <artifactId>tencentcloud-sdk-java</artifactId>
+            <version>${tencent.cloud.version}</version>
+        </dependency>
+
     </dependencies>
 
 </project>