| @@ -32,7 +32,6 @@ public class WxProjectConfigController extends BaseController { | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | return new ResultData(ErrorCode.SYS_SERVER_ERROR); | ||||
| } | } | ||||
| } | } | ||||
| @@ -4,6 +4,7 @@ spring: | |||||
| #include: rabbitMQ | #include: rabbitMQ | ||||
| # JDBC | # JDBC | ||||
| datasource: | datasource: | ||||
| #url: jdbc:mysql://rm-2zel9i9t555zy7lftmo.mysql.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true&allowMultiQueries=true | |||||
| url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true&allowMultiQueries=true | url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true&allowMultiQueries=true | ||||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | ||||
| password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | ||||
| @@ -40,6 +41,18 @@ spring: | |||||
| max-idle: 500 | max-idle: 500 | ||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 10 | min-idle: 10 | ||||
| # SMS | |||||
| aliyun: | |||||
| sms: | |||||
| accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V | |||||
| accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||||
| product: Dysmsapi | |||||
| domain: dysmsapi.aliyuncs.com | |||||
| regionId: cn-hangzhou | |||||
| dateFormat: yyyyMMdd | |||||
| endpointName: cn-hangzhou | |||||
| mail: | mail: | ||||
| host: smtp.exmail.qq.com | host: smtp.exmail.qq.com | ||||
| @@ -4,6 +4,7 @@ spring: | |||||
| #include: rabbitMQ | #include: rabbitMQ | ||||
| # JDBC | # JDBC | ||||
| datasource: | datasource: | ||||
| #url: jdbc:mysql://rm-2zel9i9t555zy7lftmo.mysql.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | |||||
| url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | ||||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | ||||
| password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | ||||
| @@ -39,6 +40,18 @@ spring: | |||||
| max-idle: 30 | max-idle: 30 | ||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| # SMS | |||||
| aliyun: | |||||
| sms: | |||||
| accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V | |||||
| accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||||
| product: Dysmsapi | |||||
| domain: dysmsapi.aliyuncs.com | |||||
| regionId: cn-hangzhou | |||||
| dateFormat: yyyyMMdd | |||||
| endpointName: cn-hangzhou | |||||
| mail: | mail: | ||||
| host: smtp.exmail.qq.com | host: smtp.exmail.qq.com | ||||
| @@ -4,6 +4,7 @@ spring: | |||||
| #include: rabbitMQ | #include: rabbitMQ | ||||
| # JDBC | # JDBC | ||||
| datasource: | datasource: | ||||
| #url: jdbc:mysql://rm-2zel9i9t555zy7lftmo.mysql.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | |||||
| url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | ||||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | ||||
| password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | ||||
| @@ -39,6 +40,18 @@ spring: | |||||
| max-idle: 100 | max-idle: 100 | ||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| # SMS | |||||
| aliyun: | |||||
| sms: | |||||
| accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V | |||||
| accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||||
| product: Dysmsapi | |||||
| domain: dysmsapi.aliyuncs.com | |||||
| regionId: cn-hangzhou | |||||
| dateFormat: yyyyMMdd | |||||
| endpointName: cn-hangzhou | |||||
| mail: | mail: | ||||
| host: smtp.exmail.qq.com | host: smtp.exmail.qq.com | ||||
| @@ -4,6 +4,7 @@ spring: | |||||
| #include: rabbitMQ | #include: rabbitMQ | ||||
| # JDBC | # JDBC | ||||
| datasource: | datasource: | ||||
| #url: jdbc:mysql://rm-2zel9i9t555zy7lftmo.mysql.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | |||||
| url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | ||||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | ||||
| password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | ||||
| @@ -40,6 +41,18 @@ spring: | |||||
| max-idle: 500 | max-idle: 500 | ||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 10 | min-idle: 10 | ||||
| # SMS | |||||
| aliyun: | |||||
| sms: | |||||
| accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V | |||||
| accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||||
| product: Dysmsapi | |||||
| domain: dysmsapi.aliyuncs.com | |||||
| regionId: cn-hangzhou | |||||
| dateFormat: yyyyMMdd | |||||
| endpointName: cn-hangzhou | |||||
| mail: | mail: | ||||
| host: smtp.exmail.qq.com | host: smtp.exmail.qq.com | ||||
| @@ -4,6 +4,7 @@ spring: | |||||
| #include: rabbitMQ | #include: rabbitMQ | ||||
| # JDBC | # JDBC | ||||
| datasource: | datasource: | ||||
| #url: jdbc:mysql://rm-2zel9i9t555zy7lftmo.mysql.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | |||||
| url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | ||||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | ||||
| password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | ||||
| @@ -41,6 +42,18 @@ spring: | |||||
| max-idle: 50 | max-idle: 50 | ||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 10 | min-idle: 10 | ||||
| # SMS | |||||
| aliyun: | |||||
| sms: | |||||
| accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V | |||||
| accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||||
| product: Dysmsapi | |||||
| domain: dysmsapi.aliyuncs.com | |||||
| regionId: cn-hangzhou | |||||
| dateFormat: yyyyMMdd | |||||
| endpointName: cn-hangzhou | |||||
| mail: | mail: | ||||
| host: smtp.exmail.qq.com | host: smtp.exmail.qq.com | ||||
| @@ -4,6 +4,7 @@ spring: | |||||
| #include: rabbitMQ | #include: rabbitMQ | ||||
| # JDBC | # JDBC | ||||
| datasource: | datasource: | ||||
| #url: jdbc:mysql://rm-2zel9i9t555zy7lftmo.mysql.rds.aliyuncs.com:3306/mallinkDevGroup1?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | |||||
| url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallinkDevGroup1?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallinkDevGroup1?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | ||||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | ||||
| password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | ||||
| @@ -39,6 +40,18 @@ spring: | |||||
| max-idle: 30 | max-idle: 30 | ||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| # SMS | |||||
| aliyun: | |||||
| sms: | |||||
| accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V | |||||
| accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||||
| product: Dysmsapi | |||||
| domain: dysmsapi.aliyuncs.com | |||||
| regionId: cn-hangzhou | |||||
| dateFormat: yyyyMMdd | |||||
| endpointName: cn-hangzhou | |||||
| mail: | mail: | ||||
| host: smtp.exmail.qq.com | host: smtp.exmail.qq.com | ||||
| @@ -4,6 +4,7 @@ spring: | |||||
| #include: rabbitMQ | #include: rabbitMQ | ||||
| # JDBC | # JDBC | ||||
| datasource: | datasource: | ||||
| #url: jdbc:mysql://rm-2zel9i9t555zy7lftmo.mysql.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | |||||
| url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | ||||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | ||||
| password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | ||||
| @@ -41,6 +42,18 @@ spring: | |||||
| max-idle: 50 | max-idle: 50 | ||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 10 | min-idle: 10 | ||||
| # SMS | |||||
| aliyun: | |||||
| sms: | |||||
| accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V | |||||
| accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||||
| product: Dysmsapi | |||||
| domain: dysmsapi.aliyuncs.com | |||||
| regionId: cn-hangzhou | |||||
| dateFormat: yyyyMMdd | |||||
| endpointName: cn-hangzhou | |||||
| mail: | mail: | ||||
| host: smtp.exmail.qq.com | host: smtp.exmail.qq.com | ||||
| @@ -0,0 +1,109 @@ | |||||
| package com.iformall.aliyunSMS; | |||||
| import com.aliyuncs.DefaultAcsClient; | |||||
| import com.aliyuncs.IAcsClient; | |||||
| import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsRequest; | |||||
| import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsResponse; | |||||
| import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; | |||||
| import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; | |||||
| import com.aliyuncs.exceptions.ClientException; | |||||
| import com.aliyuncs.profile.DefaultProfile; | |||||
| import com.aliyuncs.profile.IClientProfile; | |||||
| import com.iformall.aliyunSMS.bean.AliyunSMSConfig; | |||||
| import com.iformall.aliyunSMS.bean.Query; | |||||
| import com.iformall.aliyunSMS.bean.Result; | |||||
| import com.iformall.aliyunSMS.bean.SMS; | |||||
| import lombok.extern.slf4j.Slf4j; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Component; | |||||
| import java.text.SimpleDateFormat; | |||||
| @Component | |||||
| @Slf4j | |||||
| public class SimpleSMSSender { | |||||
| @Autowired | |||||
| private AliyunSMSConfig smsConfig; | |||||
| /** | |||||
| * 发送短信 | |||||
| * @param sms | |||||
| * @return | |||||
| */ | |||||
| public Result sendSms(SMS sms) { | |||||
| IAcsClient acsClient = getClient(); | |||||
| SendSmsRequest request = getRequest(sms); | |||||
| SendSmsResponse sendSmsResponse = null; | |||||
| try { | |||||
| sendSmsResponse = acsClient.getAcsResponse(request); | |||||
| } catch (ClientException e) { | |||||
| log.error("发送短信发生错误。错误代码是 [{}],错误消息是 [{}],错误请求ID是 [{}],错误Msg是 [{}],错误类型是 [{}]", | |||||
| e.getErrCode(), e.getMessage(), e.getRequestId(), e.getErrMsg(), e.getErrorType()); | |||||
| } | |||||
| if(sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")){ | |||||
| log.info(sendSmsResponse.getCode() + "----" + sendSmsResponse.getMessage()); | |||||
| Result result = new Result(); | |||||
| result.setSendSmsResponse(sendSmsResponse); | |||||
| result.setSms(sms); | |||||
| return result; | |||||
| }else{ | |||||
| log.error(sendSmsResponse.getCode() + "----" + sendSmsResponse.getMessage()); | |||||
| return null; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 查询短信发送结果 | |||||
| * @param query | |||||
| * @return | |||||
| */ | |||||
| public QuerySendDetailsResponse querySendDetails(Query query) { | |||||
| IAcsClient acsClient = getClient(); | |||||
| QuerySendDetailsRequest request = new QuerySendDetailsRequest(); | |||||
| request.setPhoneNumber(query.getPhoneNumber()); | |||||
| request.setBizId(query.getBizId()); | |||||
| SimpleDateFormat ft = new SimpleDateFormat(smsConfig.getDateFormat()); | |||||
| request.setSendDate(ft.format(query.getSendDate())); | |||||
| request.setPageSize(query.getPageSize()); | |||||
| request.setCurrentPage(query.getCurrentPage()); | |||||
| QuerySendDetailsResponse querySendDetailsResponse = null; | |||||
| try { | |||||
| querySendDetailsResponse = acsClient.getAcsResponse(request); | |||||
| } catch (ClientException e) { | |||||
| log.error("AliyunSMS查询短信发送结果异常" + e); | |||||
| } | |||||
| return querySendDetailsResponse; | |||||
| } | |||||
| /** | |||||
| * 获取短信请求 | |||||
| * @param sms | |||||
| * @return | |||||
| */ | |||||
| private SendSmsRequest getRequest(SMS sms) { | |||||
| SendSmsRequest request = new SendSmsRequest(); | |||||
| request.setPhoneNumbers(sms.getPhoneNumbers()); | |||||
| request.setSignName(sms.getSignName()); | |||||
| request.setTemplateCode(sms.getTemplateCode()); | |||||
| request.setTemplateParam(sms.getTemplateParam()); | |||||
| request.setOutId(sms.getOutId()); | |||||
| return request; | |||||
| } | |||||
| /** | |||||
| * 获取短信发送服务机 | |||||
| * @return | |||||
| */ | |||||
| private IAcsClient getClient() { | |||||
| IClientProfile profile = DefaultProfile.getProfile(smsConfig.getRegionId(), smsConfig.getAccessKeyId(), smsConfig.getAccessKeySecret()); | |||||
| try { | |||||
| DefaultProfile.addEndpoint(smsConfig.getEndpointName(), smsConfig.getRegionId(), smsConfig.getProduct(), smsConfig.getDomain()); | |||||
| } catch (ClientException e) { | |||||
| log.error("AliyunSMS获取短信发送服务机异常" + e); | |||||
| } | |||||
| return new DefaultAcsClient(profile); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,30 @@ | |||||
| package com.iformall.aliyunSMS.bean; | |||||
| import lombok.Data; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import org.springframework.stereotype.Component; | |||||
| /** | |||||
| * aliyun 配置 | |||||
| */ | |||||
| @Component | |||||
| @Data | |||||
| @ConfigurationProperties(prefix = "spring.aliyun.sms") | |||||
| public class AliyunSMSConfig { | |||||
| //用户标识 | |||||
| private String accessKeyId; | |||||
| //密钥 | |||||
| private String accessKeySecret; | |||||
| // 短信API产品名称(短信产品名固定,无需修改) product = "Dysmsapi" | |||||
| private String product; | |||||
| //短信API产品域名,接口地址固定,无需修改 domain = "dysmsapi.aliyuncs.com" | |||||
| private String domain; | |||||
| //API支持的RegionID,如短信API的值为: cn-hangzhou。 | |||||
| private String regionId; | |||||
| //#发送日期 支持30天内记录查询,格式: yyyyMMdd | |||||
| private String dateFormat; | |||||
| //服务结点: cn-hangzhou | |||||
| private String endpointName; | |||||
| } | |||||
| @@ -0,0 +1,24 @@ | |||||
| package com.iformall.aliyunSMS.bean; | |||||
| import lombok.Data; | |||||
| import java.util.Date; | |||||
| /** | |||||
| * aliyun 查询对象 | |||||
| */ | |||||
| @Data | |||||
| public class Query { | |||||
| //阿里云返回的回执ID | |||||
| private String bizId; | |||||
| //接收短信的手机号码。 | |||||
| private String phoneNumber; | |||||
| //短信发送日期,支持查询最近30天的记录。 | |||||
| private Date sendDate; | |||||
| //分页查看发送记录,指定每页显示的短信记录数量。 | |||||
| private Long pageSize; | |||||
| //分页查看发送记录,指定发送记录的的当前页码。 | |||||
| private Long currentPage; | |||||
| } | |||||
| @@ -0,0 +1,20 @@ | |||||
| package com.iformall.aliyunSMS.bean; | |||||
| import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class Result { | |||||
| /** | |||||
| * 发送短信的返回结果对象 | |||||
| * Code:请求状态码。返回OK代表请求成功。 | |||||
| * Message:状态码的描述。 | |||||
| * bizId:回执ID | |||||
| */ | |||||
| private SendSmsResponse sendSmsResponse; | |||||
| private SMS sms; | |||||
| } | |||||
| @@ -0,0 +1,20 @@ | |||||
| package com.iformall.aliyunSMS.bean; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class SMS { | |||||
| //接收短信的手机号码。 | |||||
| private String phoneNumbers; | |||||
| //短信模板变量对应的实际值,JSON格式。 | |||||
| private String templateParam; | |||||
| //外部流水扩展字段。 | |||||
| private String outId; | |||||
| //短信模板ID。请在控制台模板管理页面模板CODE一列查看。 | |||||
| private String templateCode; | |||||
| //短信签名名称。请在控制台签名管理页面签名名称一列查看。 | |||||
| private String signName; | |||||
| } | |||||
| @@ -28,6 +28,8 @@ public class WxMsgValidationcodeModel extends TenantEntity { | |||||
| private Integer minutes; | private Integer minutes; | ||||
| @io.swagger.annotations.ApiModelProperty(value="",name="modelId") | @io.swagger.annotations.ApiModelProperty(value="",name="modelId") | ||||
| private Integer modelId; | private Integer modelId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="阿里云模板code",name="modelCode") | |||||
| private String modelCode; | |||||
| @io.swagger.annotations.ApiModelProperty(value="场景",name="type") | @io.swagger.annotations.ApiModelProperty(value="场景",name="type") | ||||
| private Integer type; | private Integer type; | ||||
| @@ -37,7 +39,7 @@ public class WxMsgValidationcodeModel extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="发送开关 0开1关",name="open") | @io.swagger.annotations.ApiModelProperty(value="发送开关 0开1关",name="open") | ||||
| private Integer open; | private Integer open; | ||||
| @io.swagger.annotations.ApiModelProperty(value="消息类型 0全部 1短信 2邮箱",name="msgType") | |||||
| @io.swagger.annotations.ApiModelProperty(value="消息类型 0全部 1短信 2邮箱 11阿里云短信(暂未启用)",name="msgType") | |||||
| private Integer msgType; | private Integer msgType; | ||||
| @io.swagger.annotations.ApiModelProperty(value="0通用1管理员2商户端3消费者",name="roleType") | @io.swagger.annotations.ApiModelProperty(value="0通用1管理员2商户端3消费者",name="roleType") | ||||
| @@ -1,6 +1,12 @@ | |||||
| package com.iformall.service.msg.impl; | package com.iformall.service.msg.impl; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.iformall.aliyunSMS.SimpleSMSSender; | |||||
| import com.iformall.aliyunSMS.bean.AliyunSMSConfig; | |||||
| import com.iformall.aliyunSMS.bean.Result; | |||||
| import com.iformall.aliyunSMS.bean.SMS; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| @@ -32,6 +38,10 @@ import java.util.Map; | |||||
| @Service | @Service | ||||
| public class SendSmsServiceImpl implements MsgSendService { | public class SendSmsServiceImpl implements MsgSendService { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private SimpleSMSSender simpleSMSSender; | |||||
| @Autowired | @Autowired | ||||
| private WxMsgConfigMapper wxMsgConfigMapper; | private WxMsgConfigMapper wxMsgConfigMapper; | ||||
| @Autowired | @Autowired | ||||
| @@ -50,18 +60,6 @@ public class SendSmsServiceImpl implements MsgSendService { | |||||
| wxMsgValidationcode.updateTenantInfo(tenantEntity); | wxMsgValidationcode.updateTenantInfo(tenantEntity); | ||||
| wxMsgValidationcode.setType(record.getModelType()); | wxMsgValidationcode.setType(record.getModelType()); | ||||
| //3、从短信配置中查询密钥 bid 等信息 | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.updateTenantInfo(wxMsgValidationcode); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if(CollectionUtils.isEmpty(wxMsgConfigs)){ | |||||
| throw new MallinkException(ErrorCode.MSG_CONFIG_NOT_FOUND); | |||||
| } | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| if (wxMsgConfig.getRemains() <= 0L) { | |||||
| throw new MallinkException(ErrorCode.MSG_CONFIG_ACCOUNT); | |||||
| } | |||||
| WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | ||||
| wxMsgValidationcodeModel.updateTenantInfo(wxMsgValidationcode); | wxMsgValidationcodeModel.updateTenantInfo(wxMsgValidationcode); | ||||
| wxMsgValidationcodeModel.setType(record.getModelType()); | wxMsgValidationcodeModel.setType(record.getModelType()); | ||||
| @@ -73,28 +71,62 @@ public class SendSmsServiceImpl implements MsgSendService { | |||||
| wxMsgValidationcodeModel = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel).get(0); | wxMsgValidationcodeModel = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel).get(0); | ||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| String phone = record.getReceiver(); | |||||
| String signature = wxMsgValidationcodeModel.getSignature(); | |||||
| wxMsgValidationcode.setSignature(signature); | |||||
| //替换内容 | |||||
| wxMsgValidationcode.setSignature(wxMsgValidationcodeModel.getSignature()); | |||||
| //替换短信内容 | |||||
| String msg = wxMsgValidationcodeModel.getContent(); | String msg = wxMsgValidationcodeModel.getContent(); | ||||
| for (Map.Entry<String, String> entry : record.getDynamicContentMap().entrySet()) { | for (Map.Entry<String, String> entry : record.getDynamicContentMap().entrySet()) { | ||||
| msg = msg.replace("{"+entry.getKey()+"}", entry.getValue()); | msg = msg.replace("{"+entry.getKey()+"}", entry.getValue()); | ||||
| } | } | ||||
| wxMsgValidationcode.setMsg(msg); | wxMsgValidationcode.setMsg(msg); | ||||
| if(record.getDynamicContentMap() !=null) { | if(record.getDynamicContentMap() !=null) { | ||||
| wxMsgValidationcode.setCode(record.getDynamicContentMap().get("s6")); | wxMsgValidationcode.setCode(record.getDynamicContentMap().get("s6")); | ||||
| } | } | ||||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| Integer modelId = wxMsgValidationcodeModel.getModelId(); | |||||
| String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.YES.getCode().toString(), modelId); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret = jsonObjectResult.get("ret").toString(); | |||||
| String batchNo = jsonObjectResult.get("data").toString(); | |||||
| //3、从短信配置中查询密钥 bid 等信息 | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.updateTenantInfo(wxMsgValidationcode); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if(CollectionUtils.isEmpty(wxMsgConfigs)){ | |||||
| throw new MallinkException(ErrorCode.MSG_CONFIG_NOT_FOUND); | |||||
| } | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| if (wxMsgConfig.getRemains() <= 0L) { | |||||
| throw new MallinkException(ErrorCode.MSG_CONFIG_ACCOUNT); | |||||
| } | |||||
| String ret = "",batchNo = ""; | |||||
| if(wxMsgValidationcodeModel.getMsgType().equals(11)){ | |||||
| //阿里云发短信 | |||||
| SMS sms = new SMS(); | |||||
| sms.setPhoneNumbers(record.getReceiver()); | |||||
| sms.setTemplateParam(JSON.toJSONString(record.getDynamicContentMap())); | |||||
| sms.setTemplateCode(wxMsgValidationcodeModel.getModelCode()); | |||||
| sms.setOutId(wxMsgValidationcodeModel.getId().toString()); | |||||
| sms.setSignName(wxMsgValidationcodeModel.getSignature()); | |||||
| Result result = simpleSMSSender.sendSms(sms); | |||||
| if(result != null){ | |||||
| ret = "1"; | |||||
| batchNo = result.getSendSmsResponse().getBizId(); | |||||
| } | |||||
| }else{ | |||||
| //迈外迪发短信 | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| String phone = record.getReceiver(); | |||||
| String signature = wxMsgValidationcodeModel.getSignature(); | |||||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| Integer modelId = wxMsgValidationcodeModel.getModelId(); | |||||
| String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.YES.getCode().toString(), modelId); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| ret = jsonObjectResult.get("ret").toString(); | |||||
| batchNo = jsonObjectResult.get("data").toString(); | |||||
| } | |||||
| if (ret.equals("1")) { | if (ret.equals("1")) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxMsgValidationcode.setId(idWorker.nextId()); | wxMsgValidationcode.setId(idWorker.nextId()); | ||||
| @@ -114,7 +146,7 @@ public class SendSmsServiceImpl implements MsgSendService { | |||||
| wxMsgConfig.setRemains(1L); | wxMsgConfig.setRemains(1L); | ||||
| wxMsgConfigMapper.updateRemains(wxMsgConfig); | wxMsgConfigMapper.updateRemains(wxMsgConfig); | ||||
| }else{ | }else{ | ||||
| throw new MallinkException(1001,"运营商返回失败:"+result); | |||||
| throw new MallinkException(1001,"运营商返回失败:"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -10,6 +10,7 @@ | |||||
| <result column="status" jdbcType="INTEGER" property="status" /> | <result column="status" jdbcType="INTEGER" property="status" /> | ||||
| <result column="minutes" jdbcType="INTEGER" property="minutes" /> | <result column="minutes" jdbcType="INTEGER" property="minutes" /> | ||||
| <result column="model_id" jdbcType="INTEGER" property="modelId" /> | <result column="model_id" jdbcType="INTEGER" property="modelId" /> | ||||
| <result column="model_code" jdbcType="VARCHAR" property="modelCode" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | <result column="type" jdbcType="INTEGER" property="type" /> | ||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | ||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | ||||
| @@ -21,7 +22,7 @@ | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`name`,`signature`,`content`,`createtime`,`status`,`minutes`,`model_id`,`type`,`tenant_id`,`parent_tenant_id`,email_bg_img,`open`,msg_type,role_type | |||||
| `id`,`name`,`signature`,`content`,`createtime`,`status`,`minutes`,`model_id`,`model_code`,`type`,`tenant_id`,`parent_tenant_id`,email_bg_img,`open`,msg_type,role_type | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -34,6 +35,7 @@ | |||||
| <if test=" null != status "> and `status` = #{status} </if> | <if test=" null != status "> and `status` = #{status} </if> | ||||
| <if test=" null != minutes "> and `minutes` = #{minutes} </if> | <if test=" null != minutes "> and `minutes` = #{minutes} </if> | ||||
| <if test=" null != modelId "> and `model_id` = #{modelId} </if> | <if test=" null != modelId "> and `model_id` = #{modelId} </if> | ||||
| <if test=" null != modelCode "> and `model_code` = #{modelCode} </if> | |||||
| <if test=" null != type "> and `type` = #{type} </if> | <if test=" null != type "> and `type` = #{type} </if> | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and `tenant_id` = #{tenantId} | and `tenant_id` = #{tenantId} | ||||
| @@ -3,6 +3,7 @@ spring: | |||||
| include: rabbitMQ | include: rabbitMQ | ||||
| # JDBC | # JDBC | ||||
| datasource: | datasource: | ||||
| #url: jdbc:mysql://rm-2zel9i9t555zy7lftmo.mysql.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | |||||
| url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | ||||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | ||||
| password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | ||||
| @@ -39,6 +40,18 @@ spring: | |||||
| max-idle: 500 | max-idle: 500 | ||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 10 | min-idle: 10 | ||||
| # SMS | |||||
| aliyun: | |||||
| sms: | |||||
| accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V | |||||
| accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||||
| product: Dysmsapi | |||||
| domain: dysmsapi.aliyuncs.com | |||||
| regionId: cn-hangzhou | |||||
| dateFormat: yyyyMMdd | |||||
| endpointName: cn-hangzhou | |||||
| mail: | mail: | ||||
| host: smtp.exmail.qq.com | host: smtp.exmail.qq.com | ||||
| @@ -4,6 +4,7 @@ spring: | |||||
| #include: rabbitMQ | #include: rabbitMQ | ||||
| # JDBC | # JDBC | ||||
| datasource: | datasource: | ||||
| #url: jdbc:mysql://rm-2zel9i9t555zy7lftmo.mysql.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | |||||
| url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | ||||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | ||||
| password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | password: ENC(IKH7HxMZwIqMttMc9+QsqWa1KMsJvTs4) | ||||
| @@ -41,6 +42,18 @@ spring: | |||||
| max-idle: 50 | max-idle: 50 | ||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 10 | min-idle: 10 | ||||
| # SMS | |||||
| aliyun: | |||||
| sms: | |||||
| accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V | |||||
| accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||||
| product: Dysmsapi | |||||
| domain: dysmsapi.aliyuncs.com | |||||
| regionId: cn-hangzhou | |||||
| dateFormat: yyyyMMdd | |||||
| endpointName: cn-hangzhou | |||||
| mail: | mail: | ||||
| host: smtp.exmail.qq.com | host: smtp.exmail.qq.com | ||||
| @@ -375,6 +375,18 @@ | |||||
| <version>2.5.0</version> | <version>2.5.0</version> | ||||
| </dependency> | </dependency> | ||||
| <!--阿里云的短信服务SDK--> | |||||
| <dependency> | |||||
| <groupId>com.aliyun</groupId> | |||||
| <artifactId>aliyun-java-sdk-core</artifactId> | |||||
| <version>3.7.1</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.aliyun</groupId> | |||||
| <artifactId>aliyun-java-sdk-dysmsapi</artifactId> | |||||
| <version>1.1.0</version> | |||||
| </dependency> | |||||
| </dependencies> | </dependencies> | ||||
| <!-- | <!-- | ||||